File: temperature.in

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (94 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!@@PERL@@
#
# Plugin to monitor temperature inside Sun systems
#
# Usage: Place in /etc/munin/node.d/ (or link it there  using ln -s)
#
# Parameters understood:
#
#       config   (required)
#       autoconf (optional - used by munin-config)
#
# Revision 1.1	2004/04/16 Richard van den Berg <richard@vdberg.org>
#
# $Log$
# Revision 1.3  2004/05/20 19:02:38  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.2  2004/05/15 21:33:30  jimmyo
# "Upped" som plugins from contrib/manual to manual or auto.
#
#
#%# family=auto
#%# capabilities=autoconf

$arch=`uname -m`;
chomp($arch);
$prtdiag="/usr/platform/$arch/sbin/prtdiag";
@tempnam=();
@tempval=();

if($ARGV[0] eq "config") {
	printconfig();
	exit(0);
}

if($ARGV[0] eq "autoconf") {
	if(! -x $prtdiag) {
		print "no\n";
		exit(1);
	}
	gettemps();
	if($#tempnam>=0) {
		print "yes\n";
		exit(0);
	}

	print "no\n";
	exit(1);
}

gettemps();
printtemps();

exit(0);

sub printtemps {
	for($i=0;$i<=$#tempnam;$i++){
		$name=$tempnam[$i];
		$name =~ s/\s+/_/go;
		print "temp_$name.value $tempval[$i]\n";
	}
}

sub gettemps {
	open(PRTDIAG,"$prtdiag -v|") || return;
	$found=0;
	while(<PRTDIAG>) {
		$found=1 if(m/^[^\s].*temperature/i);
		$found=0 if(m/^$/);
		if($found) {
			$tmp=substr($_,8);
			if($tmp =~ m/ ([0-9]+)/g) {
			  push(@tempval,$1);
				push(@tempnam,substr($_,0,index($_,"  ")));
				$tempnam[$#tempnam] =~ s/^\s//go;
				$tempnam[$#tempnam] =~ s#^.*/##go;
			}
		}
	}
	close(PRTDIAG);
}

sub printconfig {
	gettemps();
	print "graph_title Temperature\n";
	print "graph_args -l 0\n";
	print "graph_category sensors\n";
	print "graph_vlabel temp in C\n";
	for($i=0;$i<=$#tempnam;$i++){
		$name=$tempnam[$i];
		$name =~ s/\s+/_/go;
		print "temp_$name.label $tempnam[$i]\n";
	}
}