Projet

Général

Profil

Révision 253d8ebd

ID253d8ebd1a852d69334ed7935b1438fb5c8ff00d
Parent 1c9538f5
Enfant e803e46a

Ajouté par Sec il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/cpuspeed_sane
1
#!/bin/sh
2
#
3
# Plugin to graph cpu speed on FreeBSD
4
#
5
# Parameters:
6
#
7
# 	sysctl      - Override path to sysctl program
8
#
9
#%# family=auto
10
#%# capabilities=autoconf
11

  
12
sysctl=${sysctl:-/sbin/sysctl}
13

  
14
if [ "$1" = "autoconf" ]; then
15
	if [ -x ${sysctl} ]; then
16
		${sysctl} dev.cpu.0.freq 2>/dev/null | grep 'dev' >/dev/null 2>/dev/null
17
		if [ "$?" = "0" ]; then
18
		    echo yes
19
		    exit 0
20
		fi
21
		echo "no (dev.cpu.0.freq not found)"
22
		exit 1
23
	else
24
		echo "no (sysctl binary not found)"
25
		exit 2
26
	fi
27
fi
28

  
29
if [ "$1" = "config" ]; then
30

  
31
	echo 'graph_title CPU speed'
32
	echo 'graph_args --base 1000 -l 0'
33
	echo 'graph_vlabel speed in MHz'
34
	echo 'graph_category system'
35
	echo 'graph_info This graph shows CPU speed.'
36

  
37
	echo cpu0.label cpu0
38
	echo cpu0.info CPU0 Speed
39

  
40
        exit 0
41
fi
42

  
43
file=/usr/local/var/munin/plugin-state/cpuspeed
44

  
45
echo -n "cpu0.value "
46
if find $file -mtime -300s 2>/dev/null|grep -Fq $file ; then
47
	head -1 $file
48
else 
49
	$sysctl -n dev.cpu.0.freq
50
fi
51

  
52
# Get/cache cpuspeed "later".
53
export sysctl file
54
sh -c '(
55
 rand=$(dd if=/dev/urandom bs=1 count=1 2>/dev/null|od -A n -D)
56
 rand=$(expr $rand \* 60 / 256 + 25)
57
 sleep $rand
58
 $sysctl -n dev.cpu.0.freq > $file
59
)&' >/dev/null 2>&1 

Formats disponibles : Unified diff