Tools

This page contains various tools that I've written to better assist others and / or myself.  As I am not a developer by nature, the contained code is likely not pretty and could possibly be more efficient, though it meets my needs.  Feel free to use the tools below if they can be of use to you, noting that you are solely liable for their usage and they are provided as is.  I am the sole author of all listed tools which are released under the CDDL unless otherwise noted.  Should you have suggestions or comments for a particular tool, let me know by posting a comment or via email at 'troysunix <at> gmail <dot> com'.

- troy


Tools
basecon.pl -- converts base inputs to selected base output
create_diskmap.ksh - from opensolaris.org, lists grub device to correlating ctd and dev path
getldp.pl -- determine device information for what a network interface is connected to by way of reading CDP or LLDP packets
ioDev -- translates logical IO device names to physically identifiable locations on the host (Solaris Hosts)
ipcalc.pl -- utility for IPv4 range calculations based on CIDRs or netmasks
lprtdiag.pl -- Linux 'prtdiag' like utiltiy
op82dec.pl -- DHCP option 82 suboption 2 decoder / encoder
showdisk.pl --  displays how recognized disks are currently used on the system
timetrans.pl --  translates between UNIX epoch time and normal date/time formats

basecon.pl (download)
user@host [0] basecon.pl -h

basecon.pl converts base inputs to selected base output

Usage:  basecon.pl [ -h ]
        basecon.pl [ -V ]
        basecon.pl < -i IBASE > < -o OBASE > [ -v | -c [ -s CSEP ]]
                        [ -d ISEP ] val0 (val1 val2 ... valN)

    -h          This help output
    -V          Display basecon.pl version and exit
    -i IBASE    Base value of input
    -o OBASE    Base value to set for output
        Base Values:
                  a     ascii
                  b     binary
                  d     decimal
                  h     hexadecimal
                  o     octal
    -v          Verbose output (mutually exclusive to '-c')
    -c          CSV output (mutually exclusive to '-v')
    -s CSEP     CSV output delimiter (default is a pipe, '|')
    -d ISEP     Delimiter within an input string value

Note:   If output is set to ascii, unprintable ascii characters are
        replaced with '[Dval]', thus BS (backspace) would output as [D8]

Sample: convert from octal to ascii, verbose output, with '-' as 
    internal value delimiter:

        host [0] basecon.pl -v -io -oa -d - 150 105-146-147 154 141
        octal   =>      ascii
        150     =>      h
        105-146-147     =>      E-f-g
        154     =>      l
        141     =>      a

# input file:
  user@host [0] tail -5 infile0
  10.132.41.251
  10.132.41.252
  10.132.41.253
  10.132.41.254
  10.132.41.255
# decimal conversion to hexadecimal
  user@host [0] basecon.pl -id -oh -d . `tail -5 infile0`
  0a.84.29.fb
  0a.84.29.fc
  0a.84.29.fd
  0a.84.29.fe
  0a.84.29.ff
# ascii conversion to decimal (csv output)
  user@host [0] basecon.pl -c -ia -od -d " " "TiMOS CLI"
  ascii|decimal
  TiMOS CLI|84 105 77 79 83 67 76 73
# binary conversion to ascii
  user@host [0] basecon.pl -ib -oa -d " " "01000011 01001100 01001001"
  C L I
# octal conversion to hexadecimal (verbose)
  user@host [0] basecon.pl -v -io -oh -d . 012.204.051.375 117.123.114.111    
  octal   =>      hexadecimal
  012.204.051.375 =>      0a.84.29.fd
  117.123.114.111 =>      4f.53.4c.49
# hexadecimal conversion to ascii (verbose)
  user@host [0] basecon.pl -v -ih -oa -d " " "54 69 4d 4f 53 43 4c 49"
  hexadecimal     =>      ascii
  54 69 4d 4f 53 43 4c 49 =>      T i M O S C L I
(back to top)
getldp.pl (download)
     determine device information for what a network interface is connected to by way of reading CDP or LLDP packets
Usage:  getldp.pl -h

        getldp.pl looks for LDP (Link Discovery Protocol) packets to determine
            the device connected to, device type, and interface port; assumes the
            availability of snoop on Solaris or tcpdump on Linux / FreeBSD
                (getldp.pl can run on other OSes if '-b' is used
                 to specify the path to either snoop or tcpdump.)

        Usage:  getldp.pl [ -h ]
                getldp.pl [ -v ]
                getldp.pl < -i interface > [ -t TIMEOUT ] [ -c | -l ] [ -d ]
                             [ -x [ -s ]] [ -b BINARY ]

            -h              This help output.
            -v              Display getldp.pl version and exit
            -x              verbose output
            -s              extra verbose (useful for LLDP); requires -x
            -i interface    Specify network interface to listen on or the packet
                                capture file to read from (required)
            -t TIMEOUT      Set the timeout to listen for LDP packets (default 60 sec)
            -c              Look for CDP packets; mutually exclusive to -l (default)
            -l              Look for LLDP packets; mutually exclusive to -c (optional)
            -d              Display the command that would be run but without
                                actually doing so
            -b BINARY       /path/to/BINARY/executable to run to capture LDP packets;
                                getldp.pl only knows how to handle output from
                                snoop and tcpdump

Sample version: getldp.pl -v
        getldp.pl version:  v0.1.7

Sample CDP minimal: getldp.pl -i e1000g4 -c
        Watching for CDP packet on e1000g4 for 60 seconds...
        device-id:      ourSwitch
        port-id:        FastEthernet2/2

Sample CDP verbose with 120 second timeout: getldp.pl -i bge0 -x -t 120
        Watching for CDP packet on bge0 for 120 seconds...
        device-id:      my.6509
        platform:       cisco WS-C6509
        port-id:        GigabitEthernet8/46
        vtp-mgmt-dom:   Services
        native-vlan:    18
        CDPversion:     2

Sample CDP verbose reading a VLAN tagged packet capture from file: getldp.pl -i packet-captures/new.cap -x
        Watching for CDP packet on pack-cap/1.pcap for 60 seconds...
        device-id:    svcs.4948
        platform:     cisco WS-C4948
        sw-version:   Cisco IOS Software, Catalyst 4500 L3 Switch Software (cat4500-ENTSERVICESK9-M), Version 12.2(52)SG, RELEASE SOFTWARE (fc1)
        capabilities: L3R(router) L2SW(switch) IGMP(snooping)
        port-id:      GigabitEthernet1/8
        duplex:       Full
        mgmt-address: 10.19.70.42
        native-vlan:  15
        CDPversion:   2
        priority:     7
        vlanID:       77

Sample LLDP minimal: getldp.pl -i eth0 -l
        Watching for LLDP packet on eth0 for 60 seconds...
          device-id:    00:01:30:f9:ad:a0
          port-id:      1/1

Sample LLDP verbose: getldp.pl -i eth0 -l -x 
        Watching for LLDP packet on eth0 for 60 seconds...
          device-id:    00:01:30:f9:ad:a0
          platform:     Summit300-48 - Version 7.4e.1 (Build 5) by Release_Master 05/27/05 04:53:11
          capabilities: L2(bridge) L3R(router)
          port-id:      1/1
          portDesc:     Summit300-48-Port 1001
          sysName:      Summit300-48
          mgmt-address: 00:01:30:f9:ad:a0
          vlanName:     v2-0488-03-0505
          native-vlan:  488

Sample LLDP extra verbose: getldp.pl -i eth0 -l -xs
        Watching for LLDP packet on eth0 for 60 seconds...
          device-id:             hwaddr:  00:01:30:f9:ad:a0
           platform:                val:  Summit300-48 - Version 7.4e.1 (Build 5) by Release_Master 05/27/05 04:53:11
       capabilities:                val:  L2(bridge)    L3R(router)
            port-id:             ifName:  1/1
           portDesc:                val:  Summit300-48-Port 1001
            sysName:                val:  Summit300-48
       mgmt-address:             hwaddr:  00:01:30:f9:ad:a0
            orgSpec:           vlanName:  v2-0488-03-0505
            orgSpec:        native-vlan:  488

Sample LLDP extra verbose and showing IPv4 mgmt-address: getldp.pl -i eth0 -l -xs
        Watching for LLDP packet on eth0 for 60 seconds...
          device-id:             hwaddr:  00:13:21:4c:da:e3
           platform:                val:  ProCurve J8762A Switch 2600-8-PWR, revision H.08.89, ROM H.08.5X (/sw/code/build/fish(ts_08_5))
       capabilities:                val:  L2(bridge)    L3R(router) 
            port-id:              local:  1
           portDesc:                val:  1
            sysName:                val:  ProCurve Switch 2600-8-PWR
       mgmt-address:               IPv4:  10.42.19.70

Sample snoop host diplaying CDP cmd: getldp.pl -i hme0 -x -d
        Command to run:
          /usr/sbin/snoop -d hme0 -s 1524 -x0 -c 1 'ether[20:2] = 0x2000' 2>&1

Sample tcpdump host displaying LLDP cmd: getldp.pl -i fxp0 -xs -l -d
        Command to run:
          /usr/sbin/tcpdump -i fxp0 -s 1524 -XX -c 1 'ether proto 0x88cc' 2>&1

Sample snoop host set to use tcpdump for LLDP and displaying cmd:
        host [2] uname -s
        SunOS
        host [0] getldp.pl -b /opt/gnu/sbin/tcpdump -i qfe0 -x -l -d
        Command to run:
          /opt/gnu/sbin/tcpdump -i qfe0 -s 1524 -XX -c 1 'ether proto 0x88cc' 2>&1

Sample error for non-executable binary: getldp.pl -i fxp0 -xs -b /var/log/messages
        /var/log/messages is not executable!

        See 'getldp.pl -h' for usage! 
(back to top) 

ioDev (download):
    translates logical IO device names to physically identifiable locations on the host (Solaris Hosts on Sun hardware only)
-------- Help Output --------
    sinatra [1] /usr/local/bin/ioDev -h

    ioDev reviews the available devices on a Solaris system and
        identifies the IO Identifier, the physical device, and bus speed.

    Usage:  ioDev [ -h ]
            ioDev [ -v ]
            ioDev [ -l ]
            ioDev [ -d | -t ] [ -x | -c ]

        -h  This help output.
        -v  Display ioDev version and exit
        -l  List out the hardware types ioDev knows about.
              (ioDev can still be used with 'unknown' types, however
               its output should be verified)
        -d  Review only available disk devices; mutually exclusive to -t (default)
        -t  Review only available tape devices; mutually exclusive to -d (optional)
        -x  Include original path in output (optional)
        -c  Output in CSV format (uses ! as delimiter (optional))

    sinatra [0] /usr/local/bin/ioDev -v
    ioDev version:  v1.7


    ----- Sample x86 Output -----
    ellington [0] /usr/local/bin/ioDev
                                  -- ioDev v1.5 --
                               ellington: i386, X4200
    Disk Device               IO Ident   Phys Device          Bus Speed
    ----------------------------------------------------------------------------
    c1t0d0                    sd1        DVD/CDROM
    c2t4d0                    sd2
    c3t200400A0B818481Fd12    sd47       PCI-E Slot 1
    c3t200400A0B818481Fd13    sd46       PCI-E Slot 1
    c3t200400A0B818481Fd14    sd51       PCI-E Slot 1         
    
    
    ----- Sample Tape Output ----
    sinatra [0] /usr/local/bin/ioDev -t
                                  -- ioDev v1.5 --                         
                      sinatra: sparc, SPARC-Enterprise-T5220                    
    Tape Device               IO Ident   Phys Device          Bus Speed    
    ----------------------------------------------------------------------------
    0 (500104f0005e22c3)      st5        PCI-E Slot 3         PCI-E x8P/x4E
    1 (500104f0005e22c0)      st4        PCI-E Slot 3         PCI-E x8P/x4E     
    2 (500104f0005e22bd)      st3        PCI-E Slot 3         PCI-E x8P/x4E
    3 (500104f0005e22ba)      st6        PCI-E Slot 3         PCI-E x8P/x4E
    4 (100000e0022200e6)      st10       PCI-E Slot 3         PCI-E x8P/x4E
    
    ----- Sample Disk Output ----
    davis [0] /usr/local/bin/ioDev -d
                                  -- ioDev v1.5 --                              
                            davis: sparc, Sun-Fire-V490                         
    Disk Device               IO Ident   Phys Device          Bus Speed         
    ----------------------------------------------------------------------------
    c0t0d0                    sd0        DVD/CDROM                              
    c1t0d0                    ssd1       Disk 1                                 
    c1t1d0                    ssd0       Disk 2                                
    c4t0d0                    sd31       PCI Slot 1           33/66 MHz         
    c4t0d1                    sd61       PCI Slot 1           33/66 MHz         
    
    ----- Sample Device List -----
    calloway [1] /usr/local/bin/ioDev -l

    ioDev is functional on the following Sun box types:

            1500
            420R
            E250
            E450
            V20z
            V210
            V240
            V280 / 280R
            420R
            V440
            V480
            V490
            V880
            U80
            Netra T 1400/1405
            Netra T1 200, Netra 120, Sun Fire v120
            Sun Fire T1000
            Sun Fire T2000
            Sun Fire X2100
            Sun Fire X2200
            Sun Fire X4100 / X4100 M2
            Sun Fire X4200 / X4200 M2
            SPARC Enterprise T5140 / T5240
            SPARC Enterprise T5220

    ---- Tape Output w/ Path ----
    armstrong [0] /usr/local/bin/ioDev -tx | head -12
                                  -- ioDev v1.7 --
                      armstrong: sparc, SPARC-Enterprise-T5220
    Tape Device               IO Ident   Phys Device          Bus Speed
    ----------------------------------------------------------------------------
    0 (500104f0005e22c3)      st5        PCI-E Slot 3         PCI-E x8P/x4E
            /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22c3,0
    1 (500104f0005e22c0)      st4        PCI-E Slot 3         PCI-E x8P/x4E
            /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22c0,0
    2 (500104f0005e22bd)      st3        PCI-E Slot 3         PCI-E x8P/x4E
            /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22bd,0
    3 (500104f0005e22ba)      st6        PCI-E Slot 3         PCI-E x8P/x4E
            /pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22ba,0

    ------ Tape CSV Output ------
    armstrong [0] /usr/local/bin/ioDev -tc | head -6
    ioDev!v1.7!armstrong!sparc!SPARC-Enterprise-T5220
    Tape Device!IO Ident!Phys Device!Bus Speed!Dev Path
    0 (500104f0005e22c3)!st5!PCI-E Slot 3!PCI-E x8P/x4E!/pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22c3,0
    1 (500104f0005e22c0)!st4!PCI-E Slot 3!PCI-E x8P/x4E!/pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22c0,0
    2 (500104f0005e22bd)!st3!PCI-E Slot 3!PCI-E x8P/x4E!/pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22bd,0
    3 (500104f0005e22ba)!st6!PCI-E Slot 3!PCI-E x8P/x4E!/pci@0/pci@0/pci@8/pci@0/pci@a/SUNW,qlc@0,1/fp@0,0/st@w500104f0005e22ba,0 
(back to top) 
ipcalc.pl (download)
    utiltity for  IPv4 range calculations based on CIDRs or netmasks
ipcalc.pl Usage:
        ipcalc.pl IPaddr/CIDR
        ipcalc.pl IPaddr /CIDR
        ipcalc.pl IPaddr NetMask

prompt# ipcalc.pl 7.7.6.191/22

        7.7.6.191/22; 4 Class Cs; 1024 IP addresses
        7.7.4.0 => 7.7.7.255 (255.255.252.0)

prompt# ipcalc.pl 7.7.6.191 255.255.255.240

        7.7.6.191/28; 16 IP addresses
        7.7.6.176 => 7.7.6.190 (255.255.255.240)
(back to top) 
lprtdiag.pl (download)
    Linux 'prtdiag' like utility
    (requires 'dmidecode' and 'lspci')
server [0] /usr/local/bin/lprtdiag.pl
        System Configuration: Supermicro   H8DM3-2
        Memory Size: 15.68 GB

        ==================================== CPUs ====================================
        CPU        Phys ID    CORE       Freq           Cache          Bogomips
        --------   --------   --------   ------------   ------------   ------------
        0          0          0          2010.305       512 KB         4024.16
        1          0          1          2010.305       512 KB         4022.11
        2          0          2          2010.305       512 KB         4020.17
        3          0          3          2010.305       512 KB         4021.15
        4          1          0          2010.305       512 KB         4020.50
        5          1          1          2010.305       512 KB         4021.00
        6          1          2          2010.305       512 KB         4020.76
        7          1          3          2010.305       512 KB         4020.57

        =============================== Memory Config ================================
        ID         Bank       Slot       Size           Type           Detail
        --------   --------   --------   ------------   ------------   ------------
        0x002B     DIMM0      BANK0      4.00 GB        DDR2           Synchronous
        0x002F     DIMM2      BANK2      4.00 GB        DDR2           Synchronous
        0x0033     DIMM4      BANK4      4.00 GB        DDR2           Synchronous
        0x0037     DIMM6      BANK6      4.00 GB        DDR2           Synchronous

        ================================ I/O Devices =================================
        PCI ID            Class and                      Vendor
                              Device
        ---------------   ----------------------------   ----------------------------
        0000:00:00.0      RAM memory                     nVidia Corporation
                          MCP55 Memory Controller

        0000:00:01.0      ISA bridge                     nVidia Corporation
                          MCP55 LPC Bridge

        0000:00:01.1      SMBus                          nVidia Corporation
                          MCP55 SMBus

        0000:00:02.0      USB Controller                 nVidia Corporation
                          MCP55 USB Controller

        0000:00:02.1      USB Controller                 nVidia Corporation
                          MCP55 USB Controller

        0000:00:04.0      IDE interface                  nVidia Corporation
                          MCP55 IDE

        0000:00:05.0      IDE interface                  nVidia Corporation
                          MCP55 SATA Controller

        0000:00:05.1      IDE interface                  nVidia Corporation
                          MCP55 SATA Controller

        0000:00:05.2      IDE interface                  nVidia Corporation
                          MCP55 SATA Controller

        0000:00:06.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI bridge

        0000:00:08.0      Bridge                         nVidia Corporation
                          MCP55 Ethernet

        0000:00:09.0      Bridge                         nVidia Corporation
                          MCP55 Ethernet

        0000:00:0a.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:0b.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:0c.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:0d.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:0e.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:0f.0      PCI bridge                     nVidia Corporation
                          MCP55 PCI Express bridge

        0000:00:18.0      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] HyperTransport Configuration

        0000:00:18.1      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Address Map

        0000:00:18.2      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] DRAM Controller

        0000:00:18.3      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Miscellaneous Control

        0000:00:18.4      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Link Control

        0000:00:19.0      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] HyperTransport Configuration

        0000:00:19.1      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Address Map

        0000:00:19.2      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] DRAM Controller

        0000:00:19.3      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Miscellaneous Control

        0000:00:19.4      Host bridge                    Advanced Micro Devices [AMD]
                          Family 10h [Opteron, Athlon64, Sempron] Link Control

        0000:01:01.0      VGA compatible controller      ATI Technologies Inc
                          ES1000
        0000:02:00.0      SCSI storage controller        LSI Logic / Symbios Logic
                          MegaRAID SAS 8208ELP/8208ELP

        0000:05:00.0      PCI bridge                     Integrated Device Technology, Inc.
                          Unknown device 8018

        0000:06:02.0      PCI bridge                     Integrated Device Technology, Inc.
                          Unknown device 8018

        0000:06:04.0      PCI bridge                     Integrated Device Technology, Inc.
                          Unknown device 8018

        0000:07:00.0      Ethernet controller            Intel Corporation
                          82571EB Gigabit Ethernet Controller (Copper)

        0000:07:00.1      Ethernet controller            Intel Corporation
                          82571EB Gigabit Ethernet Controller (Copper)

        0000:08:00.0      Ethernet controller            Intel Corporation
                          82571EB Gigabit Ethernet Controller (Copper)

        0000:08:00.1      Ethernet controller            Intel Corporation
                          82571EB Gigabit Ethernet Controller (Copper)

        0000:09:00.0      RAID bus controller            3ware Inc
                          Unknown device 1005

        0000:0b:01.0      PCI bridge                     Advanced Micro Devices [AMD]
                          AMD-8132 PCI-X Bridge

        0000:0b:01.1      PIC                            Advanced Micro Devices [AMD]
                          AMD-8132 PCI-X IOAPIC

        0000:0b:02.0      PCI bridge                     Advanced Micro Devices [AMD]
                          AMD-8132 PCI-X Bridge

        0000:0b:02.1      PIC                            Advanced Micro Devices [AMD]
                          AMD-8132 PCI-X IOAPIC


        ==================================== BIOS ====================================
        American Megatrends Inc. - version: 080014 - release: 03/31/2008
(back to top) 
op82dec.pl (download)
     DHCP option 82 suboption 2 decoder / encoder
server [0] /usr/local/bin/op82dec.pl -h

          op82dec.pl decodes / encodes the option 82 string passed to a dhcp
            server, specifically option 82 suboption 2 (relay-agent-remote-id)

          Usage:  op82dec.pl [-h|--help]
                  op82dec.pl -d [-v] op82_string0 [op82_stringN]
                  op82dec.pl -e IPaddr shelf/slot/port VPI VCI 

          Sample:  op82dec.pl -d 01:01:00:00:ac:08:20:56:22:dd:01:ae
                   01:01:00:00:ac:08:20:56:22:dd:01:ae : 172.8.32.86 : 2/0/2 : 221 : 430

                   op82dec.pl -d -v 01:01:00:00:ac:08:20:56:22:dd:01:ae
                     op82 remoteId:        01:01:00:00:ac:08:20:56:22:dd:01:ae
                           NAS IP:         172.8.32.86
                           Slot/Mod/Port:  2/0/2
                           VPI:            221
                           VCI:            430

                   op82dec.pl -e 172.8.32.86 2/0/2 221 430
                   01:01:00:00:ac:08:20:56:22:dd:01:ae : 172.8.32.86 : 2/0/2 : 221 : 430 
(back to top) 
showdisk.pl (download)
    displays how recognized disks are currently used on the system
## help output
    ironman [0] /usr/local/bin/showdisk.pl -h

    showdisk.pl displays how recognized disks are currently used on the
        system; unconfigured disks not shown

    Usage:  showdisk.pl [ -h ]
            showdisk.pl [ -v ]
            showdisk.pl [ -l ]
            showdisk.pl [ -c ]

        -h              This help output.
        -v              Display showdisk.pl version and exit
        -l              List out supported OSes
        -c              Output to CSV format ('!' delimited)

    Output notes:

        'disk' column contains:

            list of disks as derived from /dev

        'use' column can contain:

            hwr     =>      hardware RAID                   [ solaris ]
            svm     =>      Solstice DiskSuite              [ solaris ]
            vxvm    =>      Veritas Volume Manager          [ solaris ]
            mnt     =>      normal mount                    [ all hosts ]
            swp     =>      swap space                      [ all hosts ]
            zfs     =>      ZFS (Zetabyte File System)      [ solaris, freebsd ]
            ccd     =>      ccd (Concat Disk Driver)        [ freebsd ]
            geom    =>      geom (raid 0, 1, 3, 01, 10)     [ freebsd ]
            lvm     =>      Logical Volume Manager          [ linux ]
            md      =>      MD (Software RAID)              [ linux ]
            vxdmp   =>      Veritas Dynamic Multipathing    [ solaris ]
            mpxio   =>      Sun's Multiplexed I/O (DMP)     [ solaris ]

        'slice' column contains:

            either the disk slice in use or else 'disk' if the whole disk
            is being used (under FreeBSD, 'disk slice' can refer to either
            the BIOS slice and disk partition (s1a in da0s1a) or simply
            the disk partition if no BIOS slices have been configured
            (e in da0e)

        'component of' column info:

            hwr     =>      if the disk is a of a RAID volume, this column
                            will list those disks comprising the RAID volume
                            in CHID.TRGT.LUN manner, comma delimited
            svm     =>      comma delimited list of metadevices this disk or
                            disk slice is part of (only reviews two levels
                            above a base disk)
            vxvm    =>      if the disk (or slice) is part of an imported DG,
                            this column lists the VX subdisk name (SD) of
                            the disk followed by the VX disk group in
                            brackets '[]'; if part of a deported DG, this
                            column displays '-' for the SD and the DG in
                            bracketted parens '[()]'
            mnt     =>      displays the current mount point and FS type of
                            the mounted slice
            swp     =>      lists if the disk or slice is used for swap
            zfs     =>      lists the zpool that the disk /  slice is part of
            ccd     =>      lists the ccd device the disk / slice is part of
            geom    =>      lists the geom device the disk / slice is part of
            lvm     =>      lists the lvm device the disk / slice is part of
            md      =>      lists the md device the disk / slice is part of
            vxdmp   =>      lists the Veritas 'daname' that this disk is a
                            path to
            mpxio   =>      lists the MPxIO device that this disk is a path to;
                            due to Sun's method of "hiding" the underlying
                            subdisks, while MPxIO is controlling the device there
                            may not be a dev tree path for the subdisk listed
                            under column 'disk', thought there will be one for
                            the MPxIO device in the 'component of' column
 
## version output
    ironman [10] /usr/local/bin/showdisk.pl -v
    showdisk.pl version:  v0.3.2
    ironman [1]

## output of known types
    sweetleaf [0] /usr/local/bin/showdisk.pl -l

    showdisk.pl known OS and Device types:

            Solaris (under /dev/dsk):
                    cXtYdZs2, cXdYpZ, cXdYs2

            FreeBSD (under /dev):
                    ad, da, fla, aacd, mlxd, amrd, idad, twed

            Red Hat Linux / Variants (under /dev):
                    hd, sd, ed, xd

## CSV output
    beastie [0] ./showdisk.pl -c
    header!beastie: FreeBSD
    header!(runtime: 1285569437)
    disk!use!slice!component of
    da0!mnt!s1a!/ (ufs)
    da0!mnt!s1d!/var (ufs)
    da0!swp!s1b!swap

## Solaris run
    sweetleaf [0] /usr/local/bin/showdisk.pl

                                    sweetleaf: SunOS

                                (runtime: 1284666515)

                       disk                    use  slice   component of
    ========================================== ==== ======= ======================
                      c0t0d0                   svm  s0      d1, d0
                      c0t0d0                   svm  s1      d11, d10
                      c0t0d0                   svm  s3      d31, d30
                      c0t0d0                   svm  s4      d41, d40
                      c0t0d0                   svm  s7      d71, d70
                      c0t1d0                   svm  s0      d2, d0
                      c0t1d0                   svm  s1      d12, d10
                      c0t1d0                   svm  s3      d32, d30
                      c0t1d0                   svm  s4      d42, d40
                      c0t1d0                   svm  s7      d72, d70
                      c1t0d0                   hwr  disk    0.0.0, 0.1.0
                      c1t0d0                   mnt  s5      /app (ufs)
                      c1t0d0                   swp  s1      swap
              c2t2B01348AE3446720d0            vxvm disk    - [(databasedg)]
              c2t2B01348AE3446720d10           vxvm disk    - [(toolsdg)]
              c2t2B01348AE3446720d11           vxvm disk    - [(backupdg)]
              c2t2B01348AE3446720d2            vxvm disk    - [(databasedg)]
              c2t2B01348AE3446720d4            vxvm disk    - [(databasedg)]
              c2t2B01348AE3446720d5            vxvm disk    - [(databasedg)]
              c2t2B01348AE3446720d6            vxvm disk    - [(prodappdg)]
              c2t2B01348AE3446720d7            vxvm disk    - [(prodappdg)]
              c3t2078A873E12F0248d13           vxvm disk    mon01 [mondg]
              c3t2078A873E12F0248d14           vxvm disk    mon02 [mondg]
              c3t2078A873E12F0248d15           vxvm disk    mondg03 [mondg]
      c3t6700EB43825576800000232B4738E100d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E101d0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E102d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E103d0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E104d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E105d0    zfs  disk    sweetleaf02
      c3t6700EB43825576800000232B4738E106d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E107d0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E108d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E109d0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E10Ad0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E10Bd0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E10Cd0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E10Dd0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E10Ed0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E10Fd0    zfs  disk    sweetleaf03
      c3t6700EB43825576800000232B4738E110d0    zfs  disk    sweetleaf01
      c3t6700EB43825576800000232B4738E111d0    zfs  disk    sweetleaf03

## FreeBSD run: 
# beastie (freebsd test host), yes, devices get reused on this host
    beastie [0] /usr/local/bin/showdisk.pl
    
                                   beastie: FreeBSD
    
                                (runtime: 1285562334)
    
                       disk                    use  slice   component of
    ========================================== ==== ======= ======================
                       da0                     mnt  s1a     / (ufs)
                       da0                     mnt  s1d     /var (ufs)
                       da0                     swp  s1b     swap
                       da1                     ccd  s1a     ccd1
                       da1                     ccd  s1b     ccd1
                       da1                     ccd  s1d     ccd2
                       da1                     ccd  s1e     ccd0
                       da1                     geom s1a     stripe0, mirror1
                       da1                     geom s1b     mirror2, stripe3
                       da1                     geom s1d     stripe1, mirror1
                       da1                     geom s1e     mirror0               
                       da1                     geom s1f     mirror3, stripe3
                       da1                     zfs  disk    mypool  
                       da1                     zfs  s1a     apool   
                       da1                     zfs  s1b     bpool   
                       da1                     zfs  s1d     bpool   
                       da1                     zfs  s1e     npoolrz
                       da1                     zfs  s1f     npoolrz 
                       da2                     ccd  s1a     ccd1    
                       da2                     ccd  s1b     ccd1    
                       da2                     ccd  s1d     ccd2    
                       da2                     ccd  s1e     ccd0        
                       da2                     geom s1a     stripe0, mirror1
                       da2                     geom s1b     mirror2, stripe3
                       da2                     geom s1d     stripe1, mirror1
                       da2                     geom s1e     mirror0      
                       da2                     geom s1f     mirror3, stripe3
                       da2                     zfs  disk    mypool          
                       da2                     zfs  s1a     apool           
                       da2                     zfs  s1b     bpool           
                       da2                     zfs  s1d     bpool          
                       da2                     zfs  s1e     npoolrz        
                       da2                     zfs  s1f     npoolrz      

## Linux run:
# tux (linux test host), yes, devices get reused on this host
    tux [0] /usr/local/bin/showdisk.pl

                                      tux: Linux

                                (runtime: 1286256239)

                       disk                    use  slice   component of
    ========================================== ==== ======= ======================
                       sda                     mnt  1       / (ext3)
                       sda                     mnt  2       /var (ext3)
                       sda                     swp  3       swap
                       sdb                     lvm  1       cdg0
                       sdb                     lvm  2       sdg
                       sdb                     lvm  3       sdg
                       sdb                     lvm  5       mdg
                       sdb                     lvm  6       mdg
                       sdb                     md   1       md127
                       sdb                     md   3       md_d127, md10
                       sdb                     md   5       md_d127, md10, md21, md20
                       sdb                     md   6       md1, md10, md22, md20
                       sdb                     md   disk    md0
                       sdc                     lvm  1       cdg1
                       sdc                     lvm  2       sdg
                       sdc                     lvm  3       sdg
                       sdc                     lvm  5       mdg
                       sdc                     lvm  6       mdg
                       sdc                     md   1       md127
                       sdc                     md   3       md_d127
                       sdc                     md   5       md_d127, md10, md21, md20
                       sdc                     md   6       md1, md10, md22, md20
                       sdc                     md   disk    md0
(back to top) 

timetrans.pl (download):
    translates between UNIX epoch time and normal date/time formats

Help Output:
    somehost [0] timetrans.pl -h

    timetrans.pl translates between UNIX epoch time and normal date/time
        formats, optionally accepting either as input as well as the use of
        modifiers to further adjust the resulting time.

    Usage:  timetrans.pl [-h|H]
            timetrans.pl [-v]
            timetrans.pl [-d|-e] [-l|-u] [-s] [-t (+|-)time]
                         [SECONDS|[yyyy/mm/dd@HH:MM:SS|yyyy/mm/dd HH:MM:SS]]

        -h              This help output.
        -H              Sample usage examples.
        -v              Display timetrans.pl version and exit
        -d              Force output to only normal data/time format; mutually
                        exclusive of -e; if set, -s is ignored (optional)
        -e              Force output to only epoch time format; mutually exclusive
                        to -d; if set, -s is ignored (optional)
        -l              Output time in localtime; mutually exclusive to -u
                        (default)
        -u              Output time in UTC; mutually exclusive to -l (optional)
        -s              Short output; returns only the translated value; ignored
                        if either -e or -d are set; if TIME value is not set,
                        short output defaults to date/time format (optional)
        -t              Modify time by (+|-) time; accepts values of seconds
                        or increment multipliers of (s|m|h|d|w) wherein
                        +3w2d1h5m20s would add a multiplier of 3 weeks, 2
                        days 1 hour, 5 minutes, and 20 seconds to the time
                        value; if no multiplier, the value is considered to
                        be seconds; if no (+|-), the value is added (optional)

        TIME            Input time value of SECONDS from 1970/01/01 00:00:00
                        UTC (UNIX epoch) or as a normalized local date/time
                        formatted either as 'yyyy/mm/dd@HH:MM:SS' or
                        'yyyy/mm/dd HH:MM:SS'; if not specified, current
                        time is used; can be a negative value, however it
                        must be preceded by flag '--'; TIME input can also
                        be piped to timetrans.pl (optional)

    somehost [10]
Sample Usage Output:
    somehost [0] timetrans.pl -H

    timetrans.pl sample usage examples.  For option descriptions, please see:
        'timetrans.pl -h'

    EXAMPLES:

        Display version:
            somehost [0] timetrans.pl -v
            timetrans.pl version:  v0.1.1

        No parameters or time input:
            somehost [0] timetrans.pl
            2012/03/29 00:38:12 -0400
            UNIX time: 1332995892

        Using a negative time modifier with epoch time:
            somehost [0] timetrans.pl -t-1d37m 1280550076
            2010/07/29 23:44:16 -0400
            UNIX time: 1280461456

        Using normalized local date/time input:
            somehost [0] timetrans.pl 2010/07/31 00:21:16
            2010/07/31 00:21:16 -0400
            UNIX time: 1280550076

        Using normalized local date/time piped input:
            somehost [0] echo "2010/07/31:21:16" | timetrans.pl
            2010/07/31 00:21:16 -0400
            UNIX time: 1280550076

        Using piped data/time input and requesting short output:
            somehost [0] echo "2010/07/31 00:21:16" | timetrans.pl -s
            1280550076

        Using epoch time input and requesting short output:
            somehost [0] timetrans.pl -s 1280550076
            2010/07/31 00:21:16 -0400

        Using piped epoch time input with a time modifier and epoch time output:
            somehost [0] echo "1280550076" | timetrans.pl -t +2w3d4m5 -e
            1282019121

        Using a time modifier with local date/time input:
            somehost [0] timetrans.pl -t86400 2010/08/18 00:25:21
            2010/08/19 00:25:21 -0400
            UNIX time: 1282191921

        Using a negative time modifier with time/date input and time/date output:
            somehost [0] timetrans.pl -d -t -86400 2010/08/18 00:25:21
            2010/08/17 00:25:21 -0400

        Using a time modifier with local time/date input and UTC time/date output:
            somehost [0] timetrans.pl -d -u -t86400 2010/08/18 00:25:21
            2010/08/19 00:25:21 UTC

        Using a negative epoch time input:
            somehost [0] timetrans.pl -- -1282191921
            1929/05/15 15:34:39 -0400
            UNIX time: -1282191921

    somehost [0]
(back to top)
 
create_diskmap.ksh (download)
   displays grub drive numbering correlating ctd and device paths 
     in solaris; taken from the OpenSolaris project, original version 
     available here.  Output directs to /var/run/solaris_grubdisk.map.
     Sample output:

        snorkle [0] /usr/bin/cat /var/run/solaris_grubdisk.map
        0 c1t0d0 /pci@0,0/pci1000,8000@14/sd@0,0
        1 c1t1d0 /pci@0,0/pci1000,8000@14/sd@1,0
(back to top)