You are aware that bdf is a HPUX command, are you sure that that is the platform? Also it would seem that the output is expecting to see a Veritas volume.
I am trying to use a modified code to check for lan, disk but with no success, please can you give me some hints:
#check if NIC cards are OK
if [ `ioscan -fnC lan |wc -l` != 1 ]
then
if [ `ioscan -fnC lan |grep CLAIMED|wc -l` != `ioscan -fnC lan |grep NO_HW|wc -l` ]
then
outputW "Ethernet: Offline NICs detected."
else
outputOK "Ethernet: All NICs are online"
fi
else
outputOK "Ethernet: No NICs found."
fi
# check if Disks are OK
if [ `ioscan -fnC disk |wc -l` != 1 ]
then
if [ `ioscan -fnC disk |grep CLAIMED|wc -l` != `ioscan -fnC disk |grep NO_HW|wc -l` ]
then
outputW "Disks: Not CLAIMED disks detected."
else
outputOK "Disks: All Disks are CLAIMED"
fi
else
outputOK "Disks: No Disks found."
fi
prep03[133]/tmp/fr #ioscan -fnC lan
Class I H/W Path Driver S/W State H/W Type Description
===================================================================
lan 0 0/1/1/0 igelan CLAIMED INTERFACE HP PCI-X 1000Mbps Dual-port Built-in
lan 1 0/1/1/1 igelan CLAIMED INTERFACE HP PCI-X 1000Mbps Dual-port Built-in
lan 2 0/2/2/0 igelan CLAIMED INTERFACE HP PCI-X 1000Mbps Dual-port Built-in
lan 3 0/2/2/1 igelan CLAIMED INTERFACE HP PCI-X 1000Mbps Dual-port Built-in
prep03[134]/tmp/fr #nwmgr
Name/ Interface Station Sub- Interface Related
ClassInstance State Address system Type Interface
============== ========= ============== ======== ============== =========
lan2 UP 0x78E7D1723F0E igelan 1000Base-SX
lan0 DOWN 0x78E7D1723F0C igelan 1000Base-SX
lan1 DOWN 0x78E7D1723F0D igelan 1000Base-SX
lan3 UP 0x78E7D1723F0F igelan 1000Base-SX
lan900 DOWN 0x000000000000 hp_apa hp_apa
lan901 DOWN 0x000000000000 hp_apa hp_apa
lan902 DOWN 0x000000000000 hp_apa hp_apa
lan903 DOWN 0x000000000000 hp_apa hp_apa
lan904 DOWN 0x000000000000 hp_apa hp_apa
prep03[135]/tmp/fr #ioscan -fnC fc
Class I H/W Path Driver S/W State H/W Type Description
====================================================================
fc 0 0/3/0/0/0/0 fclp CLAIMED INTERFACE HP 403621-B21 4Gb PCIe 2-port LPe1105 FC Mezzanine Adapter
/dev/fclp0
fc 1 0/3/0/0/0/1 fclp CLAIMED INTERFACE HP 403621-B21 4Gb PCIe 2-port LPe1105 FC Mezzanine Adapter
/dev/fclp1
prep03[136]/tmp/fr #ioscan -fnC disk
Class I H/W Path Driver S/W State H/W Type Description
==================================================================
disk 0 0/2/1/0.0.0.0.0 sdisk CLAIMED DEVICE HP IR Volume
/dev/dsk/c0t0d0 /dev/dsk/c0t0d0s2 /dev/rdsk/c0t0d0 /dev/rdsk/c0t0d0s2
/dev/dsk/c0t0d0s1 /dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s1 /dev/rdsk/c0t0d0s3
prep03[137]/tmp/fr #
Let's pick one of the tests and assume that OutputW and OutputOK are other scripts or local functions.
There is a basic logic error here. The main condition does not work unless perhaps there is only ever one disk on a HP-UX system! Not sure about the syntax either.
We should run ioscan only once because it is a very powerful program and can cause the view to change. Be aware that running ioscan can cause dead hardware to completely disappear from the inventory (and therefore not show as NO_HW).
Let's try something lke this (untested and purely to demonstrate logic and not recommended).
ioscan -fnC disk > /tmp/ioscan_fnC_disk # Store output from ioscan
total_count=$(egrep "CLAIMED|NO_HW" ioscan_fnC_disk|wc -l)
dead_count=$(grep "NO_HW" ioscan_fnC_disk|wc -l)
if [ ${total_count} -eq 0 ]
then
outputW "Disks: No Disks found."
else
if [ ${dead_count} -gt 0 ]
then
outputW "Disks: Not CLAIMED disks detected."
else
outputOK "Disks: All Disks are CLAIMED"
fi
fi
rm -f ioscan_fnC_disk # Clean up workfile
On my systems I run ioscan -fn (i.e. all hardware) daily and compare this output with the output from the same command yesterday. No attempt to predict every possible error output from ioscan. If there are differences, this is reported as a major error. Obviously if you detect a failure and repair it you will get one false alert for the broken hardware re-appearing.
I started doing this after discovering that a major hardware failure can cause a crash and reboot during which the dead hardware can completely and silently disappear from the ioscan inventory.
That reminds me. Don't forget to have a script to read the syslog and identify anything abnormal (and I don't mean broken printers).