-
Notifications
You must be signed in to change notification settings - Fork 10
/
pisense_
executable file
·178 lines (142 loc) · 4.25 KB
/
pisense_
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
pisense_ - Wildcard-plugin to monitor Raspberry Pi sensors (temp, volts, clock speed)
=head1 CONFIGURATION
This plugin needs to be run as root for vcgencmd to work.
[pisense_*]
user root
=head2 ENVIRONMENT VARIABLES
This plugin does not use environment variables.
=head2 WILDCARD PLUGIN
This is a wildcard plugin. To specify if you want temperature,
clock speed or volts, link this file to _volt, _temp
or _clock.
For example,
ln -s /usr/share/munin/plugins/pisense_ \
/etc/munin/plugins/pisense_clock
will monitor the clock speeds of your pi.
Note:
If you do not specify anything, or the special "multi", the plugin
will revert to multipgraph behavior.
=head1 BUGS
None known.
=head1 NOTES
This plugin is shamelessley based on the ip_ plugin (structure).
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=head1 AUTHOR
Tony (tony@darkstorm.co.uk).
Multigraph by Steve Schnepp <steve.schnepp@pwkf.org>.
=head1 LICENSE
It's yours, do with it what you like.
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
sensor=${0##*/pisense_}
if [ -z "$sensor" -o "$sensor" = "multi" ]
then
# multigraph asked
MULTI=1
fi
VCGENCMD=""
for FILE in /opt/vc/bin/vcgencmd /usr/bin/vcgencmd; do
if [ -e "$FILE" ]; then
VCGENCMD="$FILE"
fi
done
if [ "$1" = "autoconf" ]; then
if [ "$VCGENCMD" = "" ]; then
echo "no (could not locate vcgencmd)"
exit 0
elif ! "$VCGENCMD" firmware >/dev/null 2>/dev/null; then
echo "no (could not run $VCGENCMD as user $(whoami))"
exit 0
else
echo yes
exit 0
fi
fi
if [ "$VCGENCMD" = "" ]; then
echo "vcgencmd not found"
exit 1
fi
# this is flawed, vcgencmd always returns with RC 0. Needs expanding.
if [ "$1" = "suggest" ]; then
if "$VCGENCMD" measure_temp >/dev/null 2>/dev/null; then
echo temp
fi
if "$VCGENCMD" measure_volts >/dev/null 2>/dev/null; then
echo volt
fi
if "$VCGENCMD" measure_clock core >/dev/null 2>/dev/null; then
echo clock
fi
exit 0
fi
if [ "$1" = "config" ]; then
if [ ! -z "$MULTI" -o "$sensor" = "temp" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_temp"
echo "graph_title Raspberry Pi core temp"
echo "graph_args --base 1000"
echo "graph_vlabel degrees Celsius"
echo "graph_category sensors"
echo "temp.label Core Temperature"
echo "temp.min 0"
fi
if [ ! -z "$MULTI" -o "$sensor" = "clock" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_clock"
echo "graph_title Raspberry Pi clock frequencies"
echo "graph_args --base 1000"
echo "graph_vlabel Hertz"
echo "graph_category sensors"
for clock in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi
do
echo "clock$clock.label $clock clock frequency"
echo "clock$clock.min 0"
echo "clock$clock.type GAUGE"
done
fi
if [ ! -z "$MULTI" -o "$sensor" = "volt" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_volt"
echo "graph_title Raspberry Pi voltages"
echo "graph_args --base 1000"
echo "graph_vlabel Volts"
echo "graph_category sensors"
for volt in core sdram_c sdram_i sdram_p
do
echo "volt$volt.label $volt voltage"
echo "volt$volt.min 0"
echo "volt$volt.type GAUGE"
done
fi
exit 0
fi;
if [ ! -z "$MULTI" -o "$sensor" = "temp" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_temp"
temp=$("$VCGENCMD" measure_temp | awk -F"=" '{print $2}' | awk -F"'" '{print $1}')
echo "temp.value $temp"
fi
if [ ! -z "$MULTI" -o "$sensor" = "clock" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_clock"
for clock in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi
do
clockval=$("$VCGENCMD" measure_clock $clock | awk -F"=" '{print $2}')
echo "clock$clock.value $clockval"
done
fi
if [ ! -z "$MULTI" -o "$sensor" = "volt" ]
then
[ ! -z "$MULTI" ] && echo "multigraph pisense_volt"
for volt in core sdram_c sdram_i sdram_p
do
voltage=$("$VCGENCMD" measure_volts $volt | awk -F"=" '{print $2}' | tr -d "V")
echo "volt$volt.value $voltage"
done
fi