mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Plugin to graph cpu speed on FreeBSD
|
|
#
|
|
# Parameters:
|
|
#
|
|
# sysctl - Override path to sysctl program
|
|
#
|
|
#%# family=auto
|
|
#%# capabilities=autoconf
|
|
|
|
sysctl=${sysctl:-/sbin/sysctl}
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
if [ -x ${sysctl} ]; then
|
|
${sysctl} dev.cpu.0.freq 2>/dev/null | grep 'dev' >/dev/null 2>/dev/null
|
|
if [ "$?" = "0" ]; then
|
|
echo yes
|
|
exit 0
|
|
fi
|
|
echo "no (dev.cpu.0.freq not found)"
|
|
exit 1
|
|
else
|
|
echo "no (sysctl binary not found)"
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo 'graph_title CPU speed'
|
|
echo 'graph_args --base 1000 -l 0'
|
|
echo 'graph_vlabel speed in MHz'
|
|
echo 'graph_category system'
|
|
echo 'graph_scale no'
|
|
echo 'graph_info Current CPU speed in MHz. Available levels for the CPU:' `$sysctl -n dev.cpu.0.freq_levels|sed 's!/[0-9]*!!g;s! !, !g'` 'MHz'
|
|
|
|
echo cpu0.label cpu0
|
|
echo cpu0.info `$sysctl -n hw.model` Speed
|
|
|
|
exit 0
|
|
fi
|
|
|
|
file=/usr/local/var/munin/plugin-state/cpuspeed
|
|
|
|
echo -n "cpu0.value "
|
|
if find $file -mtime -300s 2>/dev/null|grep -Fq $file ; then
|
|
head -1 $file
|
|
else
|
|
$sysctl -n dev.cpu.0.freq
|
|
fi
|
|
|
|
# Get/cache cpuspeed "later".
|
|
export sysctl file
|
|
sh -c '(
|
|
rand=$(dd if=/dev/urandom bs=1 count=1 2>/dev/null|od -A n -D)
|
|
rand=$(expr $rand \* 60 / 256 + 25)
|
|
sleep $rand
|
|
$sysctl -n dev.cpu.0.freq > $file
|
|
)&' >/dev/null 2>&1
|