Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
CircaLucid
byCircaLucid, May 15, 2015
My config on Ubuntu 12.04.5 LTS x86. I had to create a SQL Server authentication login.
wget "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=493&cf_id=24" -O /usr/lib/nagios/plugins/check_dbmirroring.pl
chmod 755 /usr/lib/nagios/plugins/check_dbmirroring.pl
apt-get install libdbd-sybase-perl
nano /etc/nagios3/resource.cfg
# MS SQL Server user/password
$USER7$=
$USER8$=
nano /etc/nagios3/commands.cfg
define command{
command_name check_dbmirroring
command_line $USER1$/check_dbmirroring.pl -H $HOSTADDRESS$ -d $ARG1$ -u $USER7$ -p $USER8$
}
nano /etc/nagios3/conf.d/sql4.cfg
define service {
host_name sql4
service_description ActivityLog Mirroring
check_command check_dbmirroring!ActivityLog
use generic-service
}
wget "http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=493&cf_id=24" -O /usr/lib/nagios/plugins/check_dbmirroring.pl
chmod 755 /usr/lib/nagios/plugins/check_dbmirroring.pl
apt-get install libdbd-sybase-perl
nano /etc/nagios3/resource.cfg
# MS SQL Server user/password
$USER7$=
$USER8$=
nano /etc/nagios3/commands.cfg
define command{
command_name check_dbmirroring
command_line $USER1$/check_dbmirroring.pl -H $HOSTADDRESS$ -d $ARG1$ -u $USER7$ -p $USER8$
}
nano /etc/nagios3/conf.d/sql4.cfg
define service {
host_name sql4
service_description ActivityLog Mirroring
check_command check_dbmirroring!ActivityLog
use generic-service
}
byCircaLucid, January 20, 2015
Great script. I added a fix to show the serial. Here's the patch:
--- /usr/lib/nagios/plugins/check_apcupsd 2013-06-16 13:30:39.000000000 -0400
+++ /root/check_apcupsd.2 2015-01-20 12:43:31.437445687 -0500
@@ -96,7 +96,7 @@
{
echo "usage: check_apcupsd [-c critical_value] [-h hostname] [-p port]"
echo -n " [-w warning_value] "
- echo ""
+ echo ""
echo
echo "hostname and port defaults to localhost and 3551, respectively."
echo
@@ -111,6 +111,7 @@
echo " measured in minutes."
echo " linefail = Whether the line is OK or not (Back UPS only)"
echo " status = Same as 'linefail' (Back UPS ES only - maybe others)"
+ echo " serial = Shows the device serial"
echo " battstat = Whether the battery is OK or not (Back UPS only)"
exit 3
}
@@ -146,7 +147,7 @@
if [ "$ARG" != "bcharge" -a "$ARG" != "battv" -a "$ARG" != "itemp" \
-a "$ARG" != "loadpct" -a "$ARG" != "timeleft" -a "$ARG" != "linefail" \
- -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then
+ -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then
usage
fi
@@ -191,7 +192,7 @@
fi
# Back UPS reports only an OK / ERR state
-if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then
+if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then
VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
sed 's/.*: *\([0-9.][0-9.]*\)[^0-9.].*/\1/'`
if [ -z "$VALUE" ]; then
@@ -202,6 +203,23 @@
VALUE=`echo $VALUE | sed 's/^0*//'`
fi
ROUNDED=`echo $VALUE | sed 's/\..*//'`
+elif [ "$ARG" = "serial" ]; then
+ VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
+ sed 's/.*: *\([A-Z]*\).*/\1/'`
+ if [ -z "$VALUE" ]; then
+ echo "UPS does not support $ARG"
+ exit 3
+ fi
+ if [ "$VALUE" = "AS" ]; then
+ ROUNDED=1
+ else
+ ROUNDED=0
+ fi
+ VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG`
+ if [ -z "$VALUE" ]; then
+ echo "UPS does not support $ARG"
+ exit 3
+ fi
else
VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
sed 's/.*: *\([A-Z]*\).*/\1/'`
@@ -363,6 +381,16 @@
fi
echo "${STATUS} - Time Left: $VALUE Minutes|'minutes left'=${VALUE};$WARNVAL:;$CRITVAL:;;"
;;
+serial)
+ if [ $ROUNDED -gt 0 ]; then
+ STATUS="OK"
+ EXITVALUE=0
+ else
+ STATUS="CRITICAL"
+ EXITVALUE=2
+ fi
+ echo "${STATUS} - ${VALUE}"
+ ;;
esac
exit $EXITVALUE
--- /usr/lib/nagios/plugins/check_apcupsd 2013-06-16 13:30:39.000000000 -0400
+++ /root/check_apcupsd.2 2015-01-20 12:43:31.437445687 -0500
@@ -96,7 +96,7 @@
{
echo "usage: check_apcupsd [-c critical_value] [-h hostname] [-p port]"
echo -n " [-w warning_value] "
- echo ""
+ echo ""
echo
echo "hostname and port defaults to localhost and 3551, respectively."
echo
@@ -111,6 +111,7 @@
echo " measured in minutes."
echo " linefail = Whether the line is OK or not (Back UPS only)"
echo " status = Same as 'linefail' (Back UPS ES only - maybe others)"
+ echo " serial = Shows the device serial"
echo " battstat = Whether the battery is OK or not (Back UPS only)"
exit 3
}
@@ -146,7 +147,7 @@
if [ "$ARG" != "bcharge" -a "$ARG" != "battv" -a "$ARG" != "itemp" \
-a "$ARG" != "loadpct" -a "$ARG" != "timeleft" -a "$ARG" != "linefail" \
- -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then
+ -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then
usage
fi
@@ -191,7 +192,7 @@
fi
# Back UPS reports only an OK / ERR state
-if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then
+if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then
VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
sed 's/.*: *\([0-9.][0-9.]*\)[^0-9.].*/\1/'`
if [ -z "$VALUE" ]; then
@@ -202,6 +203,23 @@
VALUE=`echo $VALUE | sed 's/^0*//'`
fi
ROUNDED=`echo $VALUE | sed 's/\..*//'`
+elif [ "$ARG" = "serial" ]; then
+ VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
+ sed 's/.*: *\([A-Z]*\).*/\1/'`
+ if [ -z "$VALUE" ]; then
+ echo "UPS does not support $ARG"
+ exit 3
+ fi
+ if [ "$VALUE" = "AS" ]; then
+ ROUNDED=1
+ else
+ ROUNDED=0
+ fi
+ VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG`
+ if [ -z "$VALUE" ]; then
+ echo "UPS does not support $ARG"
+ exit 3
+ fi
else
VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | \
sed 's/.*: *\([A-Z]*\).*/\1/'`
@@ -363,6 +381,16 @@
fi
echo "${STATUS} - Time Left: $VALUE Minutes|'minutes left'=${VALUE};$WARNVAL:;$CRITVAL:;;"
;;
+serial)
+ if [ $ROUNDED -gt 0 ]; then
+ STATUS="OK"
+ EXITVALUE=0
+ else
+ STATUS="CRITICAL"
+ EXITVALUE=2
+ fi
+ echo "${STATUS} - ${VALUE}"
+ ;;
esac
exit $EXITVALUE
byCircaLucid, January 5, 2015
Works perfect for HTTP but returns a false 200 when passed an HTTPS url. Not a deal breaker for me but something to be aware of when using this plugin.
I was just looking to monitor Linux memory usage in Nagios. Only tweaks I made were to sed out the HTML tags and set DONT_INCLUDE_BUFFERS to 1. Excellent plugin though.
byCircaLucid, January 10, 2014
Works perfect but I tweeked the output format.
@perfdata = sort @perfdata;
printResultAndExit($exitVal, join(' - ', @msg) . "|" . join('\n', @perfdata));
# end main
@perfdata = sort @perfdata;
printResultAndExit($exitVal, join(' - ', @msg) . "|" . join('\n', @perfdata));
# end main
byCircaLucid, September 25, 2013
1 of 1 people found this review helpful
I installed Nagios on Ubuntu 12.04. For this script to work, I had to move #!/bin/bash to the very first line. Perfect otherwise. Thank you!
byCircaLucid, June 4, 2013
ESXi4.1 on a Dell PowerEdge 2900 works perfectly. Thank you!