File: temperature.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (96 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (11)
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
95
96
#!@@PERL@@
# -*- perl -*-

=head1 NAME

temperature - Plugin to monitor temperature inside Sun systems

=head1 CONFIGURATION

No configuration

=head1 AUTHOR

2004/04/16 Richard van den Berg <richard@vdberg.org>

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

$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 (no $prtdiag)\n";
		exit(0);
	}
	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";
	}
}