From 02a96f20a180c2c2542af4ffff831c4270bc1703 Mon Sep 17 00:00:00 2001 From: Jo Schulze Date: Thu, 3 Jan 2008 17:32:06 +0100 Subject: [PATCH] Initial version --- plugins/other/cpufreq-info | 100 +++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 plugins/other/cpufreq-info diff --git a/plugins/other/cpufreq-info b/plugins/other/cpufreq-info new file mode 100755 index 00000000..103827a7 --- /dev/null +++ b/plugins/other/cpufreq-info @@ -0,0 +1,100 @@ +#!/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 <