HardwareInfo.tst: new test to display Apple hardware serial numbers
authorAlexander Barton <alex@barton.de>
Mon, 5 Sep 2011 13:17:13 +0000 (15:17 +0200)
committerAlexander Barton <alex@barton.de>
Mon, 5 Sep 2011 13:17:13 +0000 (15:17 +0200)
client/lib/tests/Darwin/HardwareInfo.tst [new file with mode: 0644]

diff --git a/client/lib/tests/Darwin/HardwareInfo.tst b/client/lib/tests/Darwin/HardwareInfo.tst
new file mode 100644 (file)
index 0000000..e4a9c54
--- /dev/null
@@ -0,0 +1,23 @@
+# NagCollect -- Nagios Data Collector for Passive Checks
+# Copyright (c)2010-2011 Alexander Barton, alex@barton.de
+
+# Check Apple Hardware Serial Number
+
+SERVICE="HwSn_p"
+STATUS=1
+
+model_name=`system_profiler SPHardwareDataType | \
+       grep "Model Name: " | head -n 1 | cut -d':' -f2 | sed -e 's/ //g'`
+
+model_identifier=`system_profiler SPHardwareDataType | \
+       grep "Model Identifier: " | head -n 1 | cut -d':' -f2 | sed -e 's/ //g'`
+
+model_sn=`system_profiler SPHardwareDataType | \
+       grep "Serial Number" | head -n 1 | cut -d':' -f2 | sed -e 's/ //g'`
+
+if [ -n "$model_name" -a -n "$model_identifier" -a -n "$model_sn" ]; then
+       TEXT="$model_name, S/N $model_sn ($model_identifier)"
+       [ -n "$model_name" -a -n "$model_identifier" -a -n "$model_sn" ] \
+               && STATUS=0 \
+               || STATUS=1
+fi