~ubuntu-branches/ubuntu/maverick/munin/maverick

« back to all changes in this revision

Viewing changes to node/node.d.sunos/temperature.in

  • Committer: Bazaar Package Importer
  • Author(s): Holger Levsen, Stig Sandbeck Mathisen, Tom Feiner
  • Date: 2010-01-14 12:10:51 UTC
  • mfrom: (8.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100114121051-6xovy6hqfh1wrl0u
Tags: 1.4.3-2
[ Stig Sandbeck Mathisen ]
* Add versioned dependency for librrds-perl.
  If used with librrds-perl 1.2 or older, the font path is wrong.

[ Tom Feiner ]
* Update watch file.
* Add patch from munin ticket #828, to suppress "occasional" unknown 
  states to avoid alerts. Thanks to Steve Wilson for the patch!
* Removed asterisks from NEWS.Debian and rewrite as non bulleted list, as
  advised by the developers reference.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!@@PERL@@
2
 
#
3
 
# Plugin to monitor temperature inside Sun systems
4
 
#
5
 
# Usage: Place in /etc/munin/node.d/ (or link it there  using ln -s)
6
 
#
7
 
# Parameters understood:
8
 
#
9
 
#       config   (required)
10
 
#       autoconf (optional - used by munin-config)
11
 
#
12
 
# Revision 1.1  2004/04/16 Richard van den Berg <richard@vdberg.org>
13
 
#
14
 
# $Log$
15
 
# Revision 1.3  2004/05/20 19:02:38  jimmyo
16
 
# Set categories on a bunch of plugins
17
 
#
18
 
# Revision 1.2  2004/05/15 21:33:30  jimmyo
19
 
# "Upped" som plugins from contrib/manual to manual or auto.
20
 
#
21
 
#
22
 
#%# family=auto
23
 
#%# capabilities=autoconf
24
 
 
25
 
$arch=`uname -m`;
26
 
chomp($arch);
27
 
$prtdiag="/usr/platform/$arch/sbin/prtdiag";
28
 
@tempnam=();
29
 
@tempval=();
30
 
 
31
 
if($ARGV[0] eq "config") {
32
 
        printconfig();
33
 
        exit(0);
34
 
}
35
 
 
36
 
if($ARGV[0] eq "autoconf") {
37
 
        if(! -x $prtdiag) {
38
 
                print "no\n";
39
 
                exit(1);
40
 
        }
41
 
        gettemps();
42
 
        if($#tempnam>=0) {
43
 
                print "yes\n";
44
 
                exit(0);
45
 
        }
46
 
 
47
 
        print "no\n";
48
 
        exit(1);
49
 
}
50
 
 
51
 
gettemps();
52
 
printtemps();
53
 
 
54
 
exit(0);
55
 
 
56
 
sub printtemps {
57
 
        for($i=0;$i<=$#tempnam;$i++){
58
 
                $name=$tempnam[$i];
59
 
                $name =~ s/\s+/_/go;
60
 
                print "temp_$name.value $tempval[$i]\n";
61
 
        }
62
 
}
63
 
 
64
 
sub gettemps {
65
 
        open(PRTDIAG,"$prtdiag -v|") || return;
66
 
        $found=0;
67
 
        while(<PRTDIAG>) {
68
 
                $found=1 if(m/^[^\s].*temperature/i);
69
 
                $found=0 if(m/^$/);
70
 
                if($found) {
71
 
                        $tmp=substr($_,8);
72
 
                        if($tmp =~ m/ ([0-9]+)/g) {
73
 
                          push(@tempval,$1);
74
 
                                push(@tempnam,substr($_,0,index($_,"  ")));
75
 
                                $tempnam[$#tempnam] =~ s/^\s//go;
76
 
                                $tempnam[$#tempnam] =~ s#^.*/##go;
77
 
                        }
78
 
                }
79
 
        }
80
 
        close(PRTDIAG);
81
 
}
82
 
 
83
 
sub printconfig {
84
 
        gettemps();
85
 
        print "graph_title Temperature\n";
86
 
        print "graph_args -l 0\n";
87
 
        print "graph_category sensors\n";
88
 
        print "graph_vlabel temp in C\n";
89
 
        for($i=0;$i<=$#tempnam;$i++){
90
 
                $name=$tempnam[$i];
91
 
                $name =~ s/\s+/_/go;
92
 
                print "temp_$name.label $tempnam[$i]\n";
93
 
        }
94
 
}