Created
January 14, 2009 02:42
-
-
Save natedaiger/46749 to your computer and use it in GitHub Desktop.
check_areca.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Nikolay Diulgerov | |
# | |
# WARNING!!! | |
# cli32 should be located at /usr/bin | |
# and should be owned by root.nagios with mode 750 | |
# AND !!! | |
# chmod u+s /usr/bin/cli32 | |
# this is because only root can start cli32 properly (ordinary user will not receive output) | |
CLIMIT=1000 | |
WLIMIT=2000 | |
STATE_OK=0 | |
STATE_CRITICAL=2 | |
STATE_WARNING=1 | |
STATE_UNKNOWN=3 | |
print_help() { | |
echo "" | |
echo "Usage: check_areca -w <warning> -c <critical>" | |
echo "" | |
echo "This plugin checks the areca controller fan speed and raid volume status." | |
echo "Needs /usr/bin/cli64 to be installed on the linux machine." | |
echo "cli64 should be owned by root.nagios with mode 750 and setuserid on execution" | |
echo "cli64 can be downloaded from areca web site" | |
echo "ftp://ftp.areca.com.tw/RaidCards/AP_Drivers/Linux/CLI" | |
exit 0 | |
} | |
case "$1" in | |
-w) | |
WLIMIT=$2 | |
CLIMIT=$4 | |
;; | |
-c) | |
CLIMIT=$2 | |
WLIMIT=$4 | |
;; | |
--help) | |
print_help | |
exit $STATE_OK | |
;; | |
-h) | |
print_help | |
exit $STATE_OK | |
;; | |
*) | |
esac | |
if [ ! -f /usr/bin/cli64 ]; | |
then | |
echo "Missing cli64 file." | |
print_help | |
exit $STATE_UNKNOWN | |
fi | |
if [ `echo $WLIMIT $CLIMIT |awk '{print ($1 < $2) ? "true" : "false" }'` = "true" ]; | |
then | |
echo "Error: WARNING value must be above CRITICAL value" | |
print_help | |
exit $STATE_UNKNOWN | |
fi | |
volumes=`cli64 vsf info|grep ARC-|wc -l` | |
if [ $volumes -ne 1 ]; | |
then | |
echo "More than one volumes or controllers" | |
exit $STATE_UNKNOWN | |
fi | |
fan_speed_areca=`cli64 hw info|grep Fan#1|awk '{print $5}'` | |
#volume_status=`cli64 vsf info|grep ARC-|awk '{print $7}'` | |
volume_status=`cli64 vsf info|grep ARC-|awk '{print $10}'` | |
check_areca () | |
{ | |
if [[ ! $fan_speed_areca =~ ^[0-9]+ ]] | |
then | |
echo "No data about fan speed. Check your controller. Fan speed:$fan_speed_areca Volume status:$volume_status" | |
exit $STATE_CRITICAL | |
fi | |
if [ `echo $fan_speed_areca $CLIMIT |awk '{print ($1 < $2) ? "true" : "false" }'` = "true" ]; | |
then | |
echo "Problems with fan speed. Fan speed:$fan_speed_areca Volume status:$volume_status" | |
exit $STATE_CRITICAL | |
fi | |
volume_ok="Normal" | |
if [ ! "$volume_status" = "$volume_ok" ]; | |
then | |
echo "Problems with raid volume. Fan speed:$fan_speed_areca Volume status:$volume_status" | |
exit $STATE_CRITICAL | |
fi | |
if [ `echo $fan_speed_areca $WLIMIT |awk '{print ($1 < $2) ? "true" : "false" }'` = "true" ]; | |
then | |
echo "Problems with fan speed. Fan speed:$fan_speed_areca Volume status:$volume_status" | |
exit $STATE_WARNING | |
fi | |
} | |
check_areca | |
echo "System OK: Fan speed:$fan_speed_areca Volume status:$volume_status" | |
exit $STATE_OK | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment