root / plugins / raspberry-pi / cpu_freq_1sec @ c3660c2a
Historique | Voir | Annoter | Télécharger (1,28 ko)
| 1 | 3233ad49 | Steve Schnepp | #! /bin/sh |
|---|---|---|---|
| 2 | ca5aafbe | Steve Schnepp | # |
| 3 | # This is a small supersampling plugin that does |
||
| 4 | # cpu sampling every 1 second. |
||
| 5 | # |
||
| 6 | 3233ad49 | Steve Schnepp | # (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 | 48d3de60 | Steve Schnepp | print \"scaling_cur_freq.value \" \$1 \":\" (\$2 * 1000); |
| 31 | 3669b92a | Steve Schnepp | system(\"\"); |
| 32 | }" >> $cache |
||
| 33 | 3233ad49 | Steve Schnepp | ) & |
| 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::cpu |
||
| 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 | 48d3de60 | Steve Schnepp | scaling_cur_freq.type GAUGE |
| 49 | 3233ad49 | Steve Schnepp | EOF |
| 50 | exit 0 |
||
| 51 | fi |
||
| 52 | |||
| 53 | # values |
||
| 54 | cat ${cache}
|
||
| 55 | > ${cache}
|
||
| 56 | |||
| 57 | exit 0 |
