-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvey_health
executable file
·161 lines (128 loc) · 3.53 KB
/
convey_health
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
uptime - Plugin to monitor the convey's health
=head1 NOTES
Checks for the four convey outputs (anything else is treated as bad output)
System OK (Green LED is on)
Coprocessor Status : Successfully initialized coprocessor
Host Sensors: OK
CoProcessor Sensors: OK
=head1 AUTHOR
Written by Jon Daley, based on the uptime plugin
=head1 LICENSE
Public domain
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
CACHE_FILE=/var/run/munin/convey_health_cached
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Convey Health'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel health'
echo 'graph_category conveyhost'
echo 'graph_order green_led host_sensors coprocessor coprocessor_sensors coprocessor_command'
echo 'green_led.label Green LED'
echo 'green_led.critical 0:0'
echo 'green_led.draw AREA'
echo 'green_led.info 0 means OK'
print_critical green_led
print_warning green_led
echo 'coprocessor.label Coprocessor Status'
echo 'coprocessor.critical 0:0'
echo 'coprocessor.draw STACK'
echo 'coprocessor.info 0 means OK'
print_critical coprocessor
print_warning coprocessor
echo 'host_sensors.label Host Sensors'
echo 'host_sensors.critical 0:0'
echo 'host_sensors.draw STACK'
echo 'host_sensors.info 0 means OK'
print_critical host_sensors
print_warning host_sensors
echo 'coprocessor_sensors.label Coprocessor Sensors'
echo 'coprocessor_sensors.critical 0:0'
echo 'coprocessor_sensors.draw STACK'
echo 'coprocessor_sensors.info 0 means OK'
print_critical coprocessor_sensors
print_warning coprocessor_sensors
echo 'coprocessor_command.label Coprocessor Command'
echo 'coprocessor_command.critical 0:0'
echo 'coprocessor_command.draw STACK'
echo 'coprocessor_command.info 0 means OK'
print_critical coprocessor_command
print_warning coprocessor_command
echo 'installed_component.label Installed Component Check'
echo 'installed_component.critical 0:0'
echo 'installed_component.draw STACK'
echo 'installed_component.info 0 means OK'
print_critical installed_component
print_warning installed_component
exit 0
fi
# the health_check script takes too long for munin, so we
# need to cache the data in a cronjob, and retrieve the data
# later
if [ "$1" = "cronjob" ]; then
/opt/convey/support/health_check > $CACHE_FILE
exit 0
else
OUT=`cat $CACHE_FILE`
fi
# analyze output
echo $OUT | grep -q 'System OK (Green LED is on)'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
GREEN_LED=0
else
GREEN_LED=1
fi
echo $OUT | grep -q 'Coprocessor Status : OK'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
COPROCESSOR=0
else
COPROCESSOR=1
fi
echo $OUT | grep -q 'Host Sensors : OK'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
HOST_SENSORS=0
else
HOST_SENSORS=1
fi
echo $OUT | grep -q 'Coprocessor Sensors : OK'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
COPROCESSOR_SENSORS=0
else
COPROCESSOR_SENSORS=1
fi
echo $OUT | grep -q 'Coprocessor Command Response : OK'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
COPROCESSOR_COMMAND=0
else
COPROCESSOR_COMMAND=1
fi
echo $OUT | grep -q 'Installed component check : OK'
FOUND=$?
if [ ${FOUND:-} == 0 ] ; then
INSTALLED_COMPONENT=0
else
INSTALLED_COMPONENT=1
fi
# print final output
echo "green_led.value $GREEN_LED"
echo "coprocessor.value $COPROCESSOR"
echo "host_sensors.value $HOST_SENSORS"
echo "coprocessor_sensors.value $COPROCESSOR_SENSORS"
echo "coprocessor_command.value $COPROCESSOR_COMMAND"
echo "installed_component.value $INSTALLED_COMPONENT"