-
Notifications
You must be signed in to change notification settings - Fork 3
/
check_snmp_qnap_temperature
executable file
·77 lines (64 loc) · 1.74 KB
/
check_snmp_qnap_temperature
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# Program : check_snmp_qnap_disks
# :
# Author : Jason Rivers <[email protected]>
# :
# Purpose : Nagios plugin to return Information about Disks in a QNAP NAS
# :
# Parameters : --help
# : --version
# :
# Returns : Standard Nagios status_* codes
# :
# Licence : GPL
#
# Notes : See --help for details
#============:==============================================================
#set -x
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
EXITCODE=$STATE_UNKNOWN
OID_MODEL_NUMBER=".1.3.6.1.4.1.24681.1.2.12"
OID_SYS_TEMP=".1.3.6.1.4.1.24681.1.2.6"
SNMPWALK=/usr/bin/snmpwalk
SNMPGET=/usr/bin/snmpget
SNMP_COMMUNITY="public"
SNMP_VERSION="2c"
WARNING=42
CRITICAL=45
while getopts H:v:C:w:c:hV OPT
do
case "$OPT" in
H) REMOTE_HOSTNAME="$OPTARG" ;;
v) SNMP_VERSION="$OPTARG" ;;
C) SNMP_COMMUNITY="$OPTARG" ;;
w) WARNING=$OPTARG ;;
c) CRITICAL=$OPTARG ;;
h) print_help
exit "$STATE_UNKNOWN" ;;
V) print_version
exit "$STATE_UNKNOWN";;
esac
done
DISK_COUNTER=1
EXITMSG=""
SYSTEM_TEMP=`$SNMPWALK -c $SNMP_COMMUNITY -v $SNMP_VERSION $REMOTE_HOSTNAME ${OID_SYS_TEMP} -Oav | cut -c "10-11"`
PERFDATA="temperature=${SYSTEM_TEMP}"
if [ $SYSTEM_TEMP -ge $CRITICAL ]; then
EXITCODE=$STATE_CRITICAL
EXITMSG="CRITICAL: System temperature ${SYSTEM_TEMP}C"
elif [ $SYSTEM_TEMP -ge $WARNING ]; then
EXITCODE=$STATE_WARNING
EXITMSG="WARNING: System temperature ${SYSTEM_TEMP}C"
elif [ $SYSTEM_TEMP -lt $WARNING ]; then
EXITCODE=$STATE_OK
EXITMSG="OK: System temperature ${SYSTEM_TEMP}C"
else
EXITCODE=$STATE_UNKNOWN
EXITMSG="UNKNOWN: Unable to get system temperature"
fi
echo "${EXITMSG}|${PERFDATA}"
exit $EXITCODE