#!/bin/bash # # Plugin to measure CPU frequency via cpufreq-info binary. # This makes the plugin run on linux machines only. # However the same goes for using sysfs directly. # # Contributed by Jo Schulze # # Config variables: # # # Requires: # cpufrequtils http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html # # @remarks # jo20061130 using cpufreq-info should simplify the whole thing # jo20061202 tested on AMD K8 X2, intel Core 2 Duo # # $Log$ # # Magic markers - optional - used by installation scripts and # munin-config: # #%# family=manual #%# capabilities=autoconf LC_ALL="C" CINFOBIN="/usr/bin/cpufreq-info" nCPU=$(grep -c "^processor" /proc/cpuinfo) function getFreq () { i=0 while ((i < nCPU)); do affc=`$CINFOBIN -a -c $i` internal=`echo $affc | tr ' ' '_'` cpus=( $affc ) n=${#cpus[@]} freq=`$CINFOBIN -f -c $i` echo "freq_$internal.value $freq" ((i += n)) done } function getAvail () { i=0 while ((i < nCPU)); do affc=`$CINFOBIN -a -c $i` internal=`echo $affc | tr ' ' '_'` label=`echo $affc | tr ' ' ','` cpus=( $affc ) n=${#cpus[@]} echo "freq_$internal.label CPU $i (Core $label)" echo "freq_$internal.type GAUGE" echo "freq_$internal.info Hz" ((i += n)) done } function config () { cat <