Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / snmp / snmp__sfsnmp_volt @ e3899a30

Historique | Voir | Annoter | Télécharger (3,17 ko)

1
#!/usr/bin/perl
2
# -*- perl -*-
3
#
4
# snmp__sfsnmp_volt - Munin plugin for measuring volt on a windowssystem running SpeedFan and sfsnmp
5
# Copyright (C) 2010 Nils Henrik Tvetene
6
#
7
# Author: Nils Henrik Tvetene <nils@tvetene.net>
8
# 
9
# This program is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 2 of the License, or
12
# (at your option) any later version.
13
# 
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
# 
19
# You should have received a copy of the GNU General Public License along
20
# with this program; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22

    
23
=head1 NAME
24

    
25
snmp__sfsnmp_volt - Munin plugin for measuring volts on a windowssystem running SpeedFan and sfsnmp
26

    
27
=head1 APPLICABLE SYSTEMS
28

    
29
Windows-system running SpeedFan and the sfsnmp extension
30

    
31
=head1 CONFIGURATION
32

    
33
Example config:
34
   [snmp_twinspark_sfsnmp_*]
35
      env.volt1 Vcore
36
      env.volt3.ignore true
37

    
38
Plugin is linked using hostname of monitored system:
39

    
40
ln -s /usr/share/munin/plugins/snmp__sfsnmp_volt /etc/munin/plugins/snmp_<hostname>_sfsnmp_volt
41

    
42
=head1 MAGIC MARKERS
43

    
44
#%# family=snmpauto
45
#%# capabilities=snmpconf
46

    
47

    
48
=head1 AUTHOR
49

    
50
Nils Henrik Tvetene <nils@tvetene.net>
51

    
52
=head1 LICENSE
53

    
54
GPLv2
55

    
56
=cut 
57

    
58
use strict;
59
use warnings;
60
use Munin::Plugin::SNMP;
61
use vars qw($DEBUG);
62

    
63
$DEBUG = $ENV{'MUNIN_DEBUG'};
64

    
65
# OIDs used
66
# 1.3.6.1.4.1.30503.1.1.3 number of voltages
67
# 1.3.6.1.4.1.30503.1.4.x where x is 1 => above number
68

    
69
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
70
    print "number 1.3.6.1.4.1.30503.1.1.3\n";
71
    print "index 1.3.6.1.4.1.30503.1.4.\n";
72
    exit 0;
73
}
74

    
75
my $session = Munin::Plugin::SNMP->session();
76
my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
77
my ($idx, $numVolts, @volt, @label);
78

    
79
$numVolts = $session->get_single('1.3.6.1.4.1.30503.1.1.3');
80

    
81
if (defined $ARGV[0] and $ARGV[0] eq "config") {
82
    print "host_name $host\n" unless $host eq 'localhost';
83
    print "graph_title $host volt\n";
84
    print "graph_args --base 1000 --lower-limit 0 --upper-limit 13\n";
85
    print "graph_scale no\n";
86
    print "graph_vlabel Volt\n";
87
    print "graph_category sensors\n";
88
    print "graph_info This graph shows the volt on host $host\n";
89
    foreach $idx ( 0..$numVolts-1 ) {
90
        $label[$idx] = exists $ENV{"volt".($idx+1)} ? $ENV{"volt".($idx+1)} : "volt".($idx+1);
91
        print "volt".($idx+1).".info ".$label[$idx]." volt in Celsius.\n";
92

    
93
        print "volt".($idx+1).".graph no\n" if exists $ENV{"volt".($idx+1).".ignore"};
94

    
95
        print "volt".($idx+1).".type GAUGE\n";
96
        print "volt".($idx+1).".label $label[$idx]\n";
97
        print "volt".($idx+1).".cdef volt".($idx+1).",100,/\n";
98
        print "volt".($idx+1).".min 30\n";
99
    }
100

    
101
    exit 0;
102
}
103

    
104
foreach $idx ( 0..$numVolts-1 ) {
105
    $volt[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.4.'.($idx+1));
106
    print "volt".($idx+1).".value $volt[$idx]\n";
107
}
108

    
109
exit 0;
110

    
111
__END__
112