packages: nagios-plugin-check_ipmi/check_ipmi - add check ipmitool support
glen
glen at pld-linux.org
Fri Dec 10 00:11:58 CET 2010
Author: glen Date: Thu Dec 9 23:11:58 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- add check ipmitool support
---- Files affected:
packages/nagios-plugin-check_ipmi:
check_ipmi (1.3 -> 1.4)
---- Diffs:
================================================================
Index: packages/nagios-plugin-check_ipmi/check_ipmi
diff -u packages/nagios-plugin-check_ipmi/check_ipmi:1.3 packages/nagios-plugin-check_ipmi/check_ipmi:1.4
--- packages/nagios-plugin-check_ipmi/check_ipmi:1.3 Thu Dec 9 23:35:21 2010
+++ packages/nagios-plugin-check_ipmi/check_ipmi Fri Dec 10 00:11:52 2010
@@ -34,9 +34,10 @@
ARGS="$*"
. $PROGPATH/utils.sh
-# this needs to be full path for sudo
+# ipmitool needs to be with full path for sudo
ipmitool=/usr/bin/ipmitool
sudo=/usr/bin/sudo
+modprobe=/sbin/modprobe
die() {
eval local rc=\$STATE_$1
@@ -49,9 +50,12 @@
cat >&2 <<EOF
Usage: check_ipmi <filename>
check_ipmi -S <filename>
+ check_ipmi -c
<filename> indicates the cache file for speeding up sensor readings.
+ -c
+ Checks if ipmitool can be used on this system
-S
Install sudo rules
EOF
@@ -62,7 +66,31 @@
echo "$*" | sed -e 's/^ *\| *$//g'
}
+# checks if ipmitool is even usable on this system
+check_ipmitool() {
+ echo "Checking for IPMI..."
+ $ipmitool chassis status >/dev/null 2>&1
+ if [ $? != 0 ]; then
+ echo "Chassis status failed, modprobing"
+ $modprobe ipmi_si
+ if [ $? != 0 ]; then
+ echo "ERROR: ipmi_si module did not load, probably IPMI not present"
+ echo "You can setup options to ipmi_so via modprobe.conf"
+ exit 1
+ fi
+ $modprobe ipmi_devintf
+ if [ $? != 0 ]; then
+ echo "ERROR: ipmi_devintf module did not load"
+ exit 1
+ fi
+ echo $?
+ fi
+ echo "Seems OK"
+}
+
setup_sudoers() {
+ check_ipmitool
+
new=/etc/sudoers.$$.new
umask 0227
cat /etc/sudoers > $new
@@ -105,6 +133,9 @@
echo $PROGRAM $REVISION
exit 0
;;
+ -c)
+ check_ipmitool=1
+ ;;
-S)
setup_sudo=1
;;
@@ -117,6 +148,11 @@
if [ "$setup_sudo" = 1 ]; then
setup_sudoers
+fi
+
+if [ "$check_ipmitool" = 1 ]; then
+ check_ipmitool
+ exit 0
fi
if [ -z "$cache_filename" ]; then
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_ipmi/check_ipmi?r1=1.3&r2=1.4&f=u
More information about the pld-cvs-commit
mailing list