root / plugins / sfsnmp / snmp__sfsnmp_temp @ 17f78427
Historique | Voir | Annoter | Télécharger (3,17 ko)
| 1 |
#!/usr/bin/perl |
|---|---|
| 2 |
# -*- perl -*- |
| 3 |
# |
| 4 |
# snmp__sfsnmp_temp - Munin plugin for measuring temperatures 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_temp - Munin plugin for measuring temperatures 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_temp] |
| 35 |
env.temp1 System |
| 36 |
env.temp7.ignore true |
| 37 |
|
| 38 |
Plugin is linked using hostname of monitored system: |
| 39 |
|
| 40 |
ln -s /usr/share/munin/plugins/snmp__sfsnmp_temp /etc/munin/plugins/snmp_<hostname>_sfsnmp_temp |
| 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.1 number of temperatures |
| 67 |
# 1.3.6.1.4.1.30503.1.2.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.1\n"; |
| 71 |
print "index 1.3.6.1.4.1.30503.1.2.\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, $numTemps, @temp, @label); |
| 78 |
|
| 79 |
$numTemps = $session->get_single('1.3.6.1.4.1.30503.1.1.1');
|
| 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 temperatures\n"; |
| 84 |
print "graph_args --base 1000 --lower-limit 30\n"; |
| 85 |
print "graph_vlabel degrees Celsius\n"; |
| 86 |
print "graph_category sensors\n"; |
| 87 |
print "graph_info This graph shows the temperatures on host $host\n"; |
| 88 |
foreach $idx ( 0..$numTemps-1 ) {
|
| 89 |
$label[$idx] = exists $ENV{"temp".($idx+1)} ? $ENV{"temp".($idx+1)} : "temp".($idx+1);
|
| 90 |
print "temp".($idx+1).".info ".$label[$idx]." temperature in Celsius.\n"; |
| 91 |
|
| 92 |
print "temp".($idx+1).".graph no\n" if exists $ENV{"temp".($idx+1).".ignore"};
|
| 93 |
|
| 94 |
print "temp".($idx+1).".type GAUGE\n"; |
| 95 |
print "temp".($idx+1).".label $label[$idx]\n"; |
| 96 |
print "temp".($idx+1).".cdef temp".($idx+1).",100,/\n"; |
| 97 |
print "temp".($idx+1).".min 30\n"; |
| 98 |
} |
| 99 |
|
| 100 |
exit 0; |
| 101 |
} |
| 102 |
|
| 103 |
foreach $idx ( 0..$numTemps-1 ) {
|
| 104 |
$temp[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.2.'.($idx+1));
|
| 105 |
print "temp".($idx+1).".value $temp[$idx]\n"; |
| 106 |
} |
| 107 |
|
| 108 |
exit 0; |
| 109 |
|
| 110 |
__END__ |
| 111 |
|
