2013-10-12 20:50:02 +02:00
|
|
|
#! /bin/sh
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
|
|
|
# This is a small supersampling plugin that does
|
2013-12-07 15:24:09 +01:00
|
|
|
# cpu sampling every 1 second.
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2013-10-12 20:50:02 +02:00
|
|
|
# (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 "{
|
2013-12-06 21:09:24 +01:00
|
|
|
print \"scaling_cur_freq.value \" \$1 \":\" (\$2 * 1000);
|
2013-12-06 21:10:00 +01:00
|
|
|
system(\"\");
|
|
|
|
}" >> $cache
|
2013-10-12 20:50:02 +02:00
|
|
|
) &
|
|
|
|
echo $! > $pidfile
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]
|
|
|
|
then
|
|
|
|
cat <<EOF
|
|
|
|
graph_title CPU Freq 1sec stats
|
2017-02-24 23:54:53 +01:00
|
|
|
graph_category 1sec
|
2013-10-12 20:50:02 +02:00
|
|
|
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
|
2013-12-06 21:09:24 +01:00
|
|
|
scaling_cur_freq.type GAUGE
|
2013-10-12 20:50:02 +02:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# values
|
|
|
|
cat ${cache}
|
|
|
|
> ${cache}
|
|
|
|
|
|
|
|
exit 0
|