root / plugins / raspberry-pi / cpu_freq_1sec @ 17f78427
Historique | Voir | Annoter | Télécharger (1,28 ko)
| 1 |
#! /bin/sh |
|---|---|
| 2 |
# |
| 3 |
# This is a small supersampling plugin that does |
| 4 |
# cpu sampling every 1 second. |
| 5 |
# |
| 6 |
# (c) 2013 - LGPL - Steve Schnepp <steve.schnepp@pwkf.org> |
| 7 |
|
| 8 |
pluginfull="$0" # full name of plugin |
| 9 |
plugin="${0##*/}" # name of plugin
|
| 10 |
pidfile="$MUNIN_PLUGSTATE/munin.$plugin.pid" |
| 11 |
cache="$MUNIN_PLUGSTATE/munin.$plugin.value" |
| 12 |
|
| 13 |
|
| 14 |
if [ ! -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ] |
| 15 |
then |
| 16 |
echo "# Cannot read CPU Freq" |
| 17 |
exit 1 |
| 18 |
fi |
| 19 |
|
| 20 |
if [ "$1" = "acquire" ] |
| 21 |
then |
| 22 |
( |
| 23 |
while sleep 1 |
| 24 |
do |
| 25 |
echo $( |
| 26 |
date +%s |
| 27 |
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq |
| 28 |
) |
| 29 |
done | awk "{
|
| 30 |
print \"scaling_cur_freq.value \" \$1 \":\" (\$2 * 1000); |
| 31 |
system(\"\"); |
| 32 |
}" >> $cache |
| 33 |
) & |
| 34 |
echo $! > $pidfile |
| 35 |
exit 0 |
| 36 |
fi |
| 37 |
|
| 38 |
|
| 39 |
if [ "$1" = "config" ] |
| 40 |
then |
| 41 |
cat <<EOF |
| 42 |
graph_title CPU Freq 1sec stats |
| 43 |
graph_category 1sec |
| 44 |
graph_data_size custom 1d, 10s for 1w, 1m for 1t, 5m for 1y |
| 45 |
graph_vlabel Hz |
| 46 |
update_rate 1 |
| 47 |
scaling_cur_freq.label Current CPU Scaling Frequence |
| 48 |
scaling_cur_freq.type GAUGE |
| 49 |
EOF |
| 50 |
exit 0 |
| 51 |
fi |
| 52 |
|
| 53 |
# values |
| 54 |
cat ${cache}
|
| 55 |
> ${cache}
|
| 56 |
|
| 57 |
exit 0 |
