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