-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_raid.sh
33 lines (27 loc) · 934 Bytes
/
check_raid.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/ksh
###################################################
# Nagios plugin to check RAID status on OpenBSD #
# Author: Alexis VACHETTE ([email protected]) #
###################################################
VERSION="Version 1.0"
AUTHOR="(c) 2015 Alexis VACHETTE ([email protected])"
RAID_STATUS=`/usr/sbin/sysctl -a | grep hw.sensors.$1 | cut -f2 -d"=" | cut -f1 -d","`
# Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# Main #########################################################################
if [[ "$RAID_STATUS" == *"failed"* ]]; then
echo "CRITICAL - RAID $RAID_STATUS"
exit $STATE_CRITICAL
elif [[ "$RAID_STATUS" == *"degraded"* ]]; then
echo "CRITICAL - RAID $RAID_STATUS"
exit $STATE_CRITICAL
elif [[ "$RAID_STATUS" == *"rebuilding"* ]]; then
echo "WARNING - RAID $RAID_STATUS"
exit $STATE_WARNING
else
echo "OK - RAID $RAID_STATUS"
exit $STATE_OK
fi