/
cpu_freq_1sec
executable file
·53 lines (45 loc) · 1.19 KB
/
cpu_freq_1sec
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
#! /bin/sh
# (c) 2013 - LGPL - Steve Schnepp <steve.schnepp@pwkf.org>
pluginfull="$0" # full name of plugin
plugin="${0##*/}" # name of plugin
pidfile="$MUNIN_PLUGSTATE/munin.$plugin.pid"
cache="$MUNIN_PLUGSTATE/munin.$plugin.value"
if [ ! -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]
then
echo "# Cannot read CPU Freq"
exit 1
fi
if [ "$1" = "acquire" ]
then
(
while sleep 1
do
echo $(
date +%s
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
)
done | awk "{
print \"scaling_cur_freq.value \" \$1 \":\" (\$2 * 1000);
system(\"\");
}" >> $cache
) &
echo $! > $pidfile
exit 0
fi
if [ "$1" = "config" ]
then
cat <<EOF
graph_title CPU Freq 1sec stats
graph_category 1sec::cpu
graph_data_size custom 1d, 10s for 1w, 1m for 1t, 5m for 1y
graph_vlabel Hz
update_rate 1
scaling_cur_freq.label Current CPU Scaling Frequence
scaling_cur_freq.type GAUGE
EOF
exit 0
fi
# values
cat ${cache}
> ${cache}
exit 0