mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Initial version
This commit is contained in:
parent
1c9538f5df
commit
253d8ebd1a
59
plugins/other/cpuspeed_sane
Executable file
59
plugins/other/cpuspeed_sane
Executable file
@ -0,0 +1,59 @@
|
||||
#!/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_info This graph shows CPU speed.'
|
||||
|
||||
echo cpu0.label cpu0
|
||||
echo cpu0.info CPU0 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
|
Loading…
Reference in New Issue
Block a user