added pi things
Costa Tsaousis (ktsaou) committed
Sep 22, 2014 at 20:05 UTC
f1424df13468aa08c4968cd405fa032f1a45e971
1 file changed
+73
charts.d/pi.chart.sh
new
+73
@@ -0,0 +1,73 @@
1
+#!/bin/sh
2
+
3
+pi_update_every=1
4
+
5
+pi_check() {
6
+ return 0
7
+}
8
+
9
+pi_create() {
10
+ # create the charts
11
+ cat <<EOF
12
+CHART pi.cpu_temp '' "Pi CPU Temperature" "Celcius degrees" pi '' line 30001 $pi_update_every
13
+DIMENSION cpu_temp cpu absolute 1 1000
14
+
15
+CHART pi.gpu_temp '' "Pi GPU Temperature" "Celcius degrees" pi '' line 30001 $pi_update_every
16
+DIMENSION gpu_temp gpu absolute 1 1000
17
+
18
+CHART pi.clock '' "Pi CPU Clock" "MHz" pi '' line 30003 $pi_update_every
19
+DIMENSION cpu_clock clock absolute 1 1000
20
+
21
+EOF
22
+
23
+ return 0
24
+}
25
+
26
+
27
+pi_update() {
28
+ # the first argument to this function is the microseconds since last update
29
+ # pass this parameter to the BEGIN statement (see bellow).
30
+
31
+ # do all the work to collect / calculate the values
32
+ # for each dimension
33
+ # remember: KEEP IT SIMPLE AND SHORT
34
+
35
+ # 1. wget the counters page from squid
36
+ # 2. sed to remove spaces; replace . with _; remove spaces around =; prepend each line with: local squid_
37
+ # 3. egrep lines starting with:
38
+ # local squid_client_http_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
39
+ # local squid_server_all_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
40
+ # 4. then execute this as a script with the eval
41
+ #
42
+ # be very carefull with eval:
43
+ # prepare the script and always grep at the end the lines that are usefull, so that
44
+ # even if something goes wrong, no other code can be executed
45
+
46
+ local cpuTemp=$(cat /sys/class/thermal/thermal_zone0/temp)
47
+
48
+ local gpuTemp=$(/opt/vc/bin/vcgencmd measure_temp)
49
+ local gpuTemp=${gpuTemp//\'C/0}
50
+ local gpuTemp=${gpuTemp//temp=/}
51
+ local gpuTemp=${gpuTemp//\./0}
52
+
53
+ local cpuSpeed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq)
54
+
55
+ # write the result of the work.
56
+ cat <<VALUESEOF
57
+BEGIN pi.cpu_temp $1
58
+SET cpu_temp = $cpuTemp
59
+END
60
+
61
+BEGIN pi.gpu_temp $1
62
+SET gpu_temp = $gpuTemp
63
+END
64
+
65
+BEGIN pi.clock $1
66
+SET cpu_clock = $cpuSpeed
67
+END
68
+
69
+VALUESEOF
70
+
71
+ return 0
72
+}
73
+