/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_temperature
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_temperature

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2193 - (show annotations) (download)
Mon Feb 14 13:43:20 2011 UTC (11 years, 7 months ago) by ronalds
File size: 3945 byte(s)
0.3.15 - check_temperature now distinguishes CPU temperature and system temperature thresholds

1 #!/bin/bash
2
3 if [ $# -lt 5 ]; then
4 echo "usage: $0 <hostname> <warn_cpu> <error_cpu> <warn_system> <error_system> [debug]" >&2
5 echo "UNKNOWN - missing required argument(s)"
6 exit 3
7 fi
8
9 hostname=$1
10 warn_cpu=$2
11 error_cpu=$3
12 warn_sys=$4
13 error_sys=$5
14 temperature=""
15 user="monitor"
16 password="/etc/nagios/pass_temperature"
17
18 debug=0
19 if [ $# -gt 5 ]; then
20 debug=1
21 fi
22
23 stat_text[0]="OK"
24 stat_text[1]="WARNING"
25 stat_text[2]="CRITICAL"
26 stat_text[3]="UNKNOWN"
27
28 [ $debug -gt 0 ] && echo $hostname >&2
29
30 ipminame="`echo $hostname | cut -d'.' -f1`.ipmi.nikhef.nl"
31
32 [ $debug -gt 0 ] && echo $ipminame >&2
33
34 if echo $hostname | grep "wn-" > /dev/null
35 then
36 x=`echo $hostname | cut -d'-' -f2`
37 elif echo $hostname | grep "tbn" > /dev/null
38 then
39 x="tbn"
40 else
41 x=`echo $hostname | cut -d'.' -f1`
42 fi
43
44
45 [ $debug -gt 0 ] && echo $x
46
47
48 case $x in
49 bull)
50 msg="This is a bull"
51 perf=""
52 ret=3;; # UNKNOWN, bull should not appear
53
54 val)
55 temperature=`ipmitool -H $ipminame -U $user -f $password -L USER \
56 sensor get 'CPU Temp 1' 'CPU Temp 2' 'Sys Temp' | \
57 grep "Sensor Reading" | cut -d' ' -f 12`
58 temperature[1]=`echo ${temperature[0]} | awk '{print $1}'`
59 temperature[2]=`echo ${temperature[0]} | awk '{print $2}'`
60 temperature[3]=`echo ${temperature[0]} | awk '{print $3}'`
61
62 if [ $debug -gt 0 ]
63 then
64 echo "Temperature of $hostname CPU1 is ${temperature[1]}" >&2
65 echo "Temperature of $hostname CPU2 is ${temperature[2]}" >&2
66 echo "Temperature of $hostname System is ${temperature[3]}" >&2
67 fi
68 if [ ${temperature[1]} -gt $error_cpu ] ||
69 [ ${temperature[2]} -gt $error_cpu ] ||
70 [ ${temperature[3]} -gt $error_sys ]
71 then
72 ret=2
73 elif [ ${temperature[1]} -gt $warn_cpu ] ||
74 [ ${temperature[2]} -gt $warn_cpu ] ||
75 [ ${temperature[3]} -gt $warn_sys ]
76 then
77 ret=1
78 else
79 ret=0
80 fi
81 msg="CPU Temp 1: ${temperature[1]}°C - CPU Temp 2: ${temperature[2]}°C - Sys Temp: ${temperature[3]}°C"
82 perf="'T(cpu1)'=${temperature[1]}°C;$warn_cpu;$error_cpu;; 'T(cpu2)'=${temperature[2]}°C;$warn_cpu;$error_cpu;; 'T(sys)'=${temperature[3]}°C;$warn_sys;$error_sys;;"
83 ;;
84
85 lui1|lui2)
86 temperature=`ipmitool -H $ipminame -U $user -f $password -L USER \
87 sensor get 'Ambient Temp' | \
88 grep "Sensor Reading" | cut -d' ' -f 12`
89
90 [ $debug -gt 0 ] && echo "Temperature of $hostname is ${temperature[0]}" >&2
91
92 if [ ${temperature[0]} -gt $error_sys ]
93 then
94 ret=2
95
96 elif [ ${temperature[0]} -gt $warn_sys ]
97 then
98 ret=1
99 else
100 ret=0
101 fi
102 msg="Ambient Temp: ${temperature[0]}°C"
103 perf="'T(sys)'=${temperature[0]}°C;$warn_sys;$error_sys;; "
104 ;;
105
106 smrt)
107 temperature="`expect /usr/local/lib/nagios/plugins/smrt.exp $ipminame`"
108
109 temperature[1]=`echo ${temperature[0]} | \
110 sed -e 's/.*CurrentReading=//g' | sed -e 's/\r.*//g'`
111
112 if [ $debug -gt 0 ]
113 then
114 echo "This is the output of expect\n ${temperature[0]}" >&2
115 echo "Temperature of $hostname is ${temperature[1]}" >&2
116 fi
117
118 if [ ${temperature[1]} -gt $error_sys ]
119 then
120 ret=2
121
122 elif [ ${temperature[1]} -gt $warn_sys ]
123 then
124 ret=1
125
126 else
127 ret=0
128 fi
129 msg="Ambient Temp: ${temperature[1]}°C"
130 perf="'T(sys)'=${temperature[1]}°C;$warn_sys;$error_sys;; "
131 ;;
132
133 tbn)
134 msg="test node"
135 ret=0
136 ;;
137
138 *)
139 msg="Unkown Server $x"
140 ret=3
141 ;;
142 esac
143
144
145 # output and return
146 echo "${stat_text[$ret]} - $msg|$perf"
147 exit $ret
148

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28