HardwareInfo.tst: New test to display DMI/SMBIOS hardware information
authorAlexander Barton <alex@barton.de>
Thu, 6 Oct 2011 14:46:17 +0000 (16:46 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 6 Oct 2011 14:46:17 +0000 (16:46 +0200)
client/lib/tests/HardwareInfo.tst [new file with mode: 0644]

diff --git a/client/lib/tests/HardwareInfo.tst b/client/lib/tests/HardwareInfo.tst
new file mode 100644 (file)
index 0000000..1d88529
--- /dev/null
@@ -0,0 +1,37 @@
+# NagCollect -- Nagios Data Collector for Passive Checks
+# Copyright (c)2010-2011 Alexander Barton, alex@barton.de
+
+# Check Hardware Information from DMI/SMBIOS
+
+type -p dmidecode >/dev/null 2>&1
+if [ $? -eq 0 ]; then
+
+       SERVICE="HwInfo_p"
+       STATUS=0
+
+       sn=`dmidecode -s system-serial-number`
+       product=`dmidecode -s system-product-name`
+       manufacturer=`dmidecode -s system-manufacturer`
+
+       case "$product" in
+         "VMware Virtual Platform")
+               sn=""; ;;
+       esac
+       case "$sn" in
+         *"OEM"*|*"O.E.M"*)
+               sn=""; ;;
+       esac
+
+       if [ -n "$manufacturer" -a -n "$product" ]; then
+               TEXT="$manufacturer: $product"
+       else
+               TEXT="$manufacturer$product"
+       fi
+
+       if [ -n "$sn" ]; then
+               [ -n "$TEXT" ] \
+                       && TEXT="$TEXT, S/N $sn" \
+                       || TEXT="S/N $sn"
+       fi
+
+fi