Wednesday, February 12, 2014

Random system info gathering with kickstarts

I started writing up little commands to get system info for when new hardware that comes in.


]# for i in $(cat /proc/net/dev | grep ':' | cut -d ':' -f 1); do echo "Interface : $i" "  $(ethtool $i | grep Link)"; done
Interface : lo          Link detected: yes
Interface : em1         Link detected: yes
Interface : em2         Link detected: no
Interface : em3         Link detected: no
Interface : em4         Link detected: no
Interface : p3p1        Link detected: no
Interface : p3p2        Link detected: no
Interface : p3p3        Link detected: no
Interface : p3p4        Link detected: no


01 ~]# for i in $(cat /proc/net/dev | grep ':' | cut -d ':' -f 1); do echo -e NIC  : $i $(cat /sys/class/net/"$i"/address); done 
NIC : lo 00:00:00:00:00:00
NIC : em1 00:00:00:00:00:00
NIC : em2 00:00:00:00:00:00
NIC : em3 00:00:00:00:00:00
NIC : em4 00:00:00:00:00:00
NIC : p3p1 00:00:00:00:00:00
NIC : p3p2 00:00:00:00:00:00
NIC : p3p3 00:00:00:00:00:00
NIC : p3p4 00:00:00:00:00:00


 ~]# service ipmi start
Starting ipmi drivers:                                     [  OK  ]
1 ~]# mac=$(ipmitool lan print | grep 'MAC Address' | cut -f 16 -d' ') && echo -e NIC : mgmt $mac
NIC : mgmt 00:00:00:00:00:00


01 ~]# dmidecode -t 1
# dmidecode 2.11
SMBIOS 2.7 present.

Handle 0x0100, DMI type 1, 27 bytes
System Information
        Manufacturer: Dell Inc.
        Product Name: PowerEdge pony
        Version: Not Specified
        Serial Number: xxxxxxxxxxxxx
        UUID: xxxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx
        Wake-up Type: Power Switch
        SKU Number: Not Specified
        Family: Not Specified


What I ended up doing was putting this in the end my post section at the bottom of my kickstarts so I can capture all this info.

%post --interpreter=/bin/bash
(
# Turn on bash debugging for more meaningful output in logfile
set -x

service ipmi start
for i in $(cat /proc/net/dev | grep ':' | cut -d ':' -f 1); do echo "Interface : $i" "  $(ethtool $i | grep Link)"; done >> /root/host-info.log
for i in $(cat /proc/net/dev | grep ':' | cut -d ':' -f 1); do echo -e NIC  : $i $(cat /sys/class/net/"$i"/address); done  >> /root/host-info.log
mac=$(ipmitool lan print | grep 'MAC Address' | cut -f 16 -d' ') && echo -e NIC : mgmt $mac >> /root/host-info.log
dmidecode -t 1 >> /root/host-info.log

) &> /root/ks_output.log
%end

No comments: