mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
Plugin-Gallery: Get better 2nd level headings
amule -> filetransfer (amule) torrent -> filetransfer (rtorrent)
This commit is contained in:
parent
95de964ec9
commit
4b400a7320
30 changed files with 19 additions and 19 deletions
111
plugins/disk/hp_temp
Executable file
111
plugins/disk/hp_temp
Executable file
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# Temperature read from hplog -t
|
||||
# in the plugin config the user need to be set to root:
|
||||
#
|
||||
# [hp_temp]
|
||||
# user root
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin;
|
||||
|
||||
my $mode = ($ARGV[0] or "print");
|
||||
|
||||
if ($mode eq 'autoconf')
|
||||
{
|
||||
if (`/sbin/hplog -t` eq '')
|
||||
{
|
||||
print "no (no temperature devices to monitor)\n"
|
||||
}
|
||||
else
|
||||
{
|
||||
print "yes\n"
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($mode eq 'config')
|
||||
{
|
||||
# headers for the temperatur
|
||||
print "graph_title HP Temperature sensors in Celsius\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel degrees Celsius\n";
|
||||
print "graph_category sensors\n";
|
||||
}
|
||||
|
||||
# threshold: ($name).critical
|
||||
# ($name).warning -5% of threshold
|
||||
|
||||
open(HPT, "hplog -t 2>/dev/null |") || die("Cannot open hplog: $!\n");
|
||||
<HPT>; # header line, skipping
|
||||
while (<HPT>)
|
||||
{
|
||||
# we need the following locations (fixed)
|
||||
# ID: 1-2
|
||||
# LOCATION: 18-32
|
||||
# STATUS: 34-42
|
||||
# CURRENT: 43-52
|
||||
# THRESHOLD: (for init only) 53-62
|
||||
chomp;
|
||||
if (length($_) > 1)
|
||||
{
|
||||
my $status = substr($_, 33, 8); # Normal, Absent, etc
|
||||
$status =~ s/\s+$//g;
|
||||
# if status is not Abstent, we go ahead
|
||||
if ($status ne 'Absent')
|
||||
{
|
||||
my $id = substr($_, 0, 2);
|
||||
$id =~ s/\s+//g;
|
||||
my $location = substr($_, 17, 14);
|
||||
# strip any trailing spaces
|
||||
$location =~ s/\s+$//g;
|
||||
$location .= ' '.$id;
|
||||
my $temp = substr($_, 42, 9);
|
||||
# post work: current extract C number only
|
||||
$temp =~ /\dF\/([\d ]{3})C$/;
|
||||
$temp = $1;
|
||||
if ($temp)
|
||||
{
|
||||
$temp =~ s/\s+//g;
|
||||
# create a unique name from location
|
||||
# remove all . / ( ) and replace space with _
|
||||
my $name = lc($location);
|
||||
$name =~ s/[\.\/\(\)]//g;
|
||||
# strip all trailing spaces
|
||||
$name =~ s/\s+$//g;
|
||||
# convert spaces left to underscore
|
||||
$name =~ s/\ /_/g;
|
||||
# add the ID to be 100% unique
|
||||
$name .= '_'.$id;
|
||||
|
||||
if ($mode eq 'config')
|
||||
{
|
||||
# only needed here in config
|
||||
my $threshold = substr($_, 52, 9);
|
||||
# extract only C
|
||||
$threshold =~ /\dF\/([\d ]{3})C$/;
|
||||
$threshold = $1;
|
||||
if ($threshold)
|
||||
{
|
||||
$threshold =~ s/\s+//g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$threshold = 100;
|
||||
}
|
||||
# calc warning from threshold, 5% less
|
||||
my $warning = sprintf("%.0f", $threshold * 95 / 100);
|
||||
|
||||
print $name.".label ".$location."\n";
|
||||
print $name.".warning ".$warning."\n";
|
||||
print $name.".critical ".$threshold."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $name.".value ".$temp."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close(HPT);
|
165
plugins/disk/hpasmcli2_
Executable file
165
plugins/disk/hpasmcli2_
Executable file
|
@ -0,0 +1,165 @@
|
|||
#!/usr/bin/env perl -w
|
||||
#
|
||||
# Plugin to monitor Proliant server health status using hpasmcli.
|
||||
#
|
||||
# Config variables:
|
||||
# user root -- requrired by hpasmcli
|
||||
# env.hpasmcli -- path to hpasmcli executable (optional)
|
||||
# env.degree -- Unit of temperatures (C or F / default value is C)
|
||||
#
|
||||
#
|
||||
# Author: Tsuyoshi Wada <mail@tuyo.jp>
|
||||
#
|
||||
# v1.0 2007/12/08 - First version
|
||||
#
|
||||
# Copyright (c) 2007 Tsuyoshi Wada
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Magic markers
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
use strict;
|
||||
|
||||
my $hpasmcli = exists $ENV{hpasmcli} ? $ENV{hpasmcli} : undef;
|
||||
$hpasmcli = `which hpasmcli` unless $hpasmcli;
|
||||
chomp $hpasmcli;
|
||||
$hpasmcli = undef unless -x $hpasmcli;
|
||||
my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
|
||||
until ($hpasmcli or @dirs == 0) {
|
||||
my $dir = shift @dirs;
|
||||
my $path = $dir.'/hpasmcli';
|
||||
$hpasmcli = $path if -x $path;
|
||||
}
|
||||
my $degree = exists $ENV{degree} ? $ENV{degree} : 'C';
|
||||
my $deg_name = $degree eq 'C' ? "Celsius": "Fahrenheit";
|
||||
|
||||
if (defined($ARGV[0])) {
|
||||
if ($ARGV[0] eq 'autoconf') {
|
||||
if ($hpasmcli and -x $hpasmcli) {
|
||||
my @chk_result = `$hpasmcli -s \"help\"`;
|
||||
if ($? eq "0") {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
} else {
|
||||
my $reason = 'Unknown error';
|
||||
foreach my $line (@chk_result) {
|
||||
if ($line =~ /^ERROR/i) {
|
||||
chomp($line);
|
||||
$reason = $line;
|
||||
last;
|
||||
}
|
||||
}
|
||||
print "no ($reason)\n";
|
||||
exit 1;
|
||||
}
|
||||
} else {
|
||||
print "no (hpasmcli not found)\n";
|
||||
exit 1;
|
||||
}
|
||||
} elsif ($ARGV[0] eq 'suggest') {
|
||||
print "temp\nfans\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
$0 =~ /hpasmcli2_(.+)*$/;
|
||||
my $show_target = $1;
|
||||
my @show_result = `$hpasmcli -s \"show $show_target\"`;
|
||||
my %output;
|
||||
|
||||
if (defined($show_target) and $show_target eq 'temp') {
|
||||
foreach my $line (@show_result) {
|
||||
if ($line =~ /^#/) {
|
||||
$line =~ s/\s+/ /g;
|
||||
$line =~ s/^\s//g;
|
||||
my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
|
||||
next if ($temp eq "-");
|
||||
$loc =~ s/\/|#//g;
|
||||
$temp = $degree eq 'C' ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
|
||||
$temp =~ s/C|F//g;
|
||||
$threshold = $degree eq 'C' ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
|
||||
$threshold =~ s/C|F//g;
|
||||
$sensor =~s/#//g;
|
||||
$output{$sensor} = {
|
||||
'location' => lc($loc),
|
||||
'temp' => $temp,
|
||||
'threshold' => $threshold
|
||||
};
|
||||
}
|
||||
}
|
||||
if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
|
||||
print "graph_title hpasm: Temperature\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel Degrees in $deg_name\n";
|
||||
print "graph_category sensors\n";
|
||||
print "graph_info This graph shows the temperatures as reported by hpasmcli.\n";
|
||||
foreach my $key (sort keys %output) {
|
||||
print "temp$key.label $output{$key}->{'location'}\n";
|
||||
print "temp$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
|
||||
print "temp$key.critical $output{$key}->{'threshold'}\n";
|
||||
}
|
||||
} else {
|
||||
foreach my $key (sort keys %output) {
|
||||
print "temp$key.value $output{$key}->{'temp'}\n";
|
||||
}
|
||||
}
|
||||
} elsif (defined($show_target) and $show_target eq 'fans') {
|
||||
foreach my $line (@show_result) {
|
||||
if ($line =~ /^#/) {
|
||||
$line =~ s/\s+/ /g;
|
||||
$line =~ s/^\s//g;
|
||||
my ($fan, $loc, $present, $speed, $rate, $redundant, $partner, $pluggable) = split(/\s/, $line);
|
||||
next if ($present ne "Yes");
|
||||
$loc =~ s/\/|#//g;
|
||||
$rate =~ s/\%//g;
|
||||
my $threshold = '100';
|
||||
$fan =~s/#//g;
|
||||
$output{$fan} = {
|
||||
'location' => lc($loc),
|
||||
'rate' => $rate,
|
||||
'threshold' => $threshold
|
||||
};
|
||||
}
|
||||
}
|
||||
if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
|
||||
print "graph_title hpasm: Fans\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel of max (%)\n";
|
||||
print "graph_category sensors\n";
|
||||
print "graph_info This graph shows the info of fans as reported by hpasmcli.\n";
|
||||
foreach my $key (sort keys %output) {
|
||||
print "fan$key.label FAN$key $output{$key}->{'location'}\n";
|
||||
print "fan$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
|
||||
print "fan$key.critical $output{$key}->{'threshold'}\n";
|
||||
}
|
||||
} else {
|
||||
foreach my $key (sort keys %output) {
|
||||
print "fan$key.value $output{$key}->{'rate'}\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die "Unknown target specified ($show_target)\n";
|
||||
}
|
||||
|
||||
exit 0;
|
292
plugins/disk/snmp__areca_
Executable file
292
plugins/disk/snmp__areca_
Executable file
|
@ -0,0 +1,292 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2009 - 2012 Andreas Thienemann <andreas@bawue.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Library General Public License as published by
|
||||
# the Free Software Foundation; version 2 only
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
"""
|
||||
=head1 NAME
|
||||
|
||||
snmp__areca_ - Munin plugin to get temperature, voltage or fan speed values
|
||||
from Areca network enabled RAID controllers via SNMP.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
All machines with a SNMP capable ARECA raid controller.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
Make sure your Areca controller is accessible via SNMP from the munin host:
|
||||
snmpwalk -v 1 -c snmp_community ip.add.re.ss
|
||||
|
||||
The plugin is a wildcard plugin and can thus be used to retrieve different
|
||||
values depending on the name of the file.
|
||||
|
||||
Linking it as snmp_10.8.1.230_areca_fan would retrieve the fan speed values from
|
||||
the Areca controller at 10.8.1.230.
|
||||
|
||||
Valid values are fan, temp and volt.
|
||||
|
||||
Add the following to your /etc/munin/plugin-conf.d/snmp__areca file:
|
||||
|
||||
[snmp_ip.add.re.ss_*]
|
||||
community private
|
||||
version 1
|
||||
|
||||
Then test the plugin by calling the following commands:
|
||||
|
||||
munin-run snmp_10.8.1.230_areca_temp config
|
||||
munin-run snmp_10.8.1.230_areca_temp
|
||||
|
||||
Both commands should output sensible data without failing.
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin shows the temperature in Celsius or the fanspeed in rotations per minute.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=contrib
|
||||
#%# capabilities=
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
0.0.1
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known. If you know of any, please raise a ticket at https://trac.bawue.org/munin/wiki/areca__snmp_
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Andreas Thienemann <andreas@bawue.net>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
"""
|
||||
|
||||
import pprint
|
||||
import time
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
from pysnmp import v1, v2c, role, asn1
|
||||
|
||||
request_conf = {
|
||||
"volt" : {
|
||||
"label" : "Voltages",
|
||||
"vlabel" : "Volt",
|
||||
"graph" : "--base 1000 --logarithmic",
|
||||
"oid" : ".1.3.6.1.4.1.18928.1.2.2.1.8"
|
||||
},
|
||||
"fan" : {
|
||||
"label" : "Fans",
|
||||
"vlabel" : "RPM",
|
||||
"graph" : "--base 1000 -l 0",
|
||||
"oid" : ".1.3.6.1.4.1.18928.1.2.2.1.9"
|
||||
},
|
||||
"temp" : {
|
||||
"label" : "Temperatures",
|
||||
"vlabel" : "Celsius",
|
||||
"graph" : "--base 1000 -l 0",
|
||||
"oid" : ".1.3.6.1.4.1.18928.1.2.2.1.10"
|
||||
}
|
||||
}
|
||||
|
||||
# Sanity check and parsing of the commandline
|
||||
host = None
|
||||
port = 161
|
||||
request = None
|
||||
try:
|
||||
match = re.search("^(?:|.*\/)snmp_([^_]+)_areca_(.+)$", sys.argv[0])
|
||||
host = match.group(1)
|
||||
request = match.group(2)
|
||||
match = re.search("^([^:]+):(\d+)$", host)
|
||||
if match is not None:
|
||||
host = match.group(1)
|
||||
port = match.group(2)
|
||||
except:
|
||||
pass
|
||||
|
||||
if host is None or request is None:
|
||||
print "# Error: Incorrect filename. Cannot parse host or request."
|
||||
sys.exit(1)
|
||||
|
||||
# Parse env variables
|
||||
if os.getenv("community") is not None:
|
||||
community = os.getenv("community")
|
||||
else:
|
||||
community = "public"
|
||||
if os.getenv("version") is not None:
|
||||
version = os.getenv("version")
|
||||
else:
|
||||
version = "1"
|
||||
|
||||
|
||||
def get_data():
|
||||
# Fetch the data
|
||||
results = snmpwalk(request_conf[request]["oid"])
|
||||
|
||||
# parse data
|
||||
vals = []
|
||||
for i in range(0, len(results)):
|
||||
idx, res = results[i][0].split(request_conf[request]["oid"])[1].split(".")[1:], results[i][1]
|
||||
if idx[1] == '1':
|
||||
vals.append([])
|
||||
vals[int(idx[2])-1].append(res)
|
||||
if idx[1] == '2':
|
||||
vals[int(idx[2])-1].append(res)
|
||||
if idx[1] == '3':
|
||||
if request == "volt":
|
||||
res = float(res)/1000
|
||||
vals[int(idx[2])-1].append(res)
|
||||
|
||||
return vals
|
||||
|
||||
def snmpwalk(root):
|
||||
|
||||
# Create SNMP manager object
|
||||
client = role.manager((host, port))
|
||||
|
||||
# Create a SNMP request&response objects from protocol version
|
||||
# specific module.
|
||||
try:
|
||||
req = eval('v' + version).GETREQUEST()
|
||||
nextReq = eval('v' + version).GETNEXTREQUEST()
|
||||
rsp = eval('v' + version).GETRESPONSE()
|
||||
|
||||
except (NameError, AttributeError):
|
||||
print '# Unsupported SNMP protocol version: %s\n%s' % (version, usage)
|
||||
sys.exit(-1)
|
||||
|
||||
# Store tables headers
|
||||
head_oids = [root]
|
||||
|
||||
encoded_oids = map(asn1.OBJECTID().encode, head_oids)
|
||||
|
||||
result = [];
|
||||
|
||||
while 1:
|
||||
|
||||
# Encode OIDs, encode SNMP request message and try to send
|
||||
# it to SNMP agent and receive a response
|
||||
(answer, src) = client.send_and_receive(req.encode(community=community, encoded_oids=encoded_oids))
|
||||
|
||||
# Decode SNMP response
|
||||
rsp.decode(answer)
|
||||
|
||||
# Make sure response matches request (request IDs, communities, etc)
|
||||
if req != rsp:
|
||||
raise 'Unmatched response: %s vs %s' % (str(req), str(rsp))
|
||||
|
||||
# Decode BER encoded Object IDs.
|
||||
oids = map(lambda x: x[0], map(asn1.OBJECTID().decode, rsp['encoded_oids']))
|
||||
|
||||
# Decode BER encoded values associated with Object IDs.
|
||||
vals = map(lambda x: x[0](), map(asn1.decode, rsp['encoded_vals']))
|
||||
|
||||
# Check for remote SNMP agent failure
|
||||
if rsp['error_status']:
|
||||
# SNMP agent reports 'no such name' when walk is over
|
||||
if rsp['error_status'] == 2:
|
||||
# Switch over to GETNEXT req on error
|
||||
# XXX what if one of multiple vars fails?
|
||||
if not (req is nextReq):
|
||||
req = nextReq
|
||||
continue
|
||||
# One of the tables exceeded
|
||||
for l in oids, vals, head_oids:
|
||||
del l[rsp['error_index']-1]
|
||||
else:
|
||||
raise 'SNMP error #' + str(rsp['error_status']) + ' for OID #' + str(rsp['error_index'])
|
||||
|
||||
# Exclude completed OIDs
|
||||
while 1:
|
||||
for idx in range(len(head_oids)):
|
||||
if not asn1.OBJECTID(head_oids[idx]).isaprefix(oids[idx]):
|
||||
# One of the tables exceeded
|
||||
for l in oids, vals, head_oids:
|
||||
del l[idx]
|
||||
break
|
||||
else:
|
||||
break
|
||||
|
||||
if not head_oids:
|
||||
return result
|
||||
|
||||
# Print out results
|
||||
for (oid, val) in map(None, oids, vals):
|
||||
result.append((oid, str(val)))
|
||||
# print oid + ' ---> ' + str(val)
|
||||
|
||||
# BER encode next SNMP Object IDs to query
|
||||
encoded_oids = map(asn1.OBJECTID().encode, oids)
|
||||
|
||||
# Update request object
|
||||
req['request_id'] = req['request_id'] + 1
|
||||
|
||||
# Switch over GETNEXT PDU for if not done
|
||||
if not (req is nextReq):
|
||||
req = nextReq
|
||||
|
||||
raise "error"
|
||||
|
||||
|
||||
def print_config():
|
||||
print "graph_title " + request_conf[request]["label"]
|
||||
print "graph_vlabel " + request_conf[request]["vlabel"]
|
||||
print "graph_args " + request_conf[request]["graph"]
|
||||
print "graph_category sensors"
|
||||
print "host_name", host
|
||||
for dataset in get_data():
|
||||
if request == "volt":
|
||||
if dataset[1] == "Battery Status":
|
||||
continue
|
||||
else:
|
||||
print request + dataset[0] + ".label", dataset[1]
|
||||
ref_val = float(dataset[1].split()[-1][:-1])
|
||||
print request + dataset[0] + ".warning", str(ref_val * 0.95) + ":" + str(ref_val * 1.05)
|
||||
print request + dataset[0] + ".critical", str(ref_val * 0.80) + ":" + str(ref_val * 1.20)
|
||||
if request == "temp":
|
||||
print request + dataset[0] + ".label", dataset[1]
|
||||
if dataset[1].startswith("CPU"):
|
||||
print request + dataset[0] + ".warning", 55
|
||||
print request + dataset[0] + ".critical", 60
|
||||
if dataset[1].startswith("System"):
|
||||
print request + dataset[0] + ".warning", 40
|
||||
print request + dataset[0] + ".critical", 45
|
||||
if request == "fan":
|
||||
print request + dataset[0] + ".label", dataset[1]
|
||||
print request + dataset[0] + ".warning", 2400
|
||||
print request + dataset[0] + ".critical", 2000
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if "config" in sys.argv[1:]:
|
||||
print_config()
|
||||
elif "snmpconf" in sys.argv[1:]:
|
||||
print "require 1.3.6.1.4.1.18928.1.2.2.1.8.1.1"
|
||||
sys.exit(0)
|
||||
else:
|
||||
for dataset in get_data():
|
||||
# Filter Battery Status (255 == Not installed)
|
||||
if request == "volt" and dataset[1] == "Battery Status":
|
||||
continue
|
||||
print request + dataset[0] + ".value", dataset[2]
|
||||
sys.exit(0)
|
138
plugins/disk/snmp__hp_temp
Executable file
138
plugins/disk/snmp__hp_temp
Executable file
|
@ -0,0 +1,138 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Copyright (C) 2006 Lars Strand
|
||||
#
|
||||
# Munin-plugin to monitor temperature on HP-servers.
|
||||
# Uses SNMP, and needs hpasmd.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#
|
||||
#
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
use strict;
|
||||
use Net::SNMP;
|
||||
|
||||
my $DEBUG = 0;
|
||||
my $MAXLABEL = 20;
|
||||
|
||||
my $host = $ENV{host} || undef;
|
||||
my $port = $ENV{port} || 161;
|
||||
my $community = $ENV{community} || "public";
|
||||
|
||||
# Taken from CPQHLTH-MIB.mib
|
||||
my %locations = (
|
||||
1 => "other",
|
||||
2 => "unknown",
|
||||
3 => "system",
|
||||
4 => "systemBoard",
|
||||
5 => "ioBoard",
|
||||
6 => "cpu",
|
||||
7 => "memory",
|
||||
8 => "storage",
|
||||
9 => "removableMedia",
|
||||
10 => "powerSupply",
|
||||
11 => "ambient",
|
||||
12 => "chassis",
|
||||
13 => "bridgeCard"
|
||||
);
|
||||
|
||||
#my $response;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
|
||||
{
|
||||
print "index 1.3.6.1.4.1.232.6.2.6.8.1.\n";
|
||||
print "require 1.3.6.1.4.1.232.6.2.6.8.1.4.1.1. [1-4]\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_HP_temp$/)
|
||||
{
|
||||
$host = $1;
|
||||
if ($host =~ /^([^:]+):(\d+)$/)
|
||||
{
|
||||
$host = $1;
|
||||
$port = $2;
|
||||
}
|
||||
}
|
||||
elsif (!defined($host))
|
||||
{
|
||||
print "# Debug: $0 -- $1\n" if $DEBUG;
|
||||
die "# Error: couldn't understand what I'm supposed to monitor.";
|
||||
}
|
||||
|
||||
# Sensor locations
|
||||
my $cpqHeTemperatureLocale = "1.3.6.1.4.1.232.6.2.6.8.1.3.1.";
|
||||
|
||||
# Temperatures
|
||||
my $cpqHeTemperatureCelsius = "1.3.6.1.4.1.232.6.2.6.8.1.4.1.";
|
||||
|
||||
# Temperatures thresholds
|
||||
my $cpqHeTemperatureThreshold = "1.3.6.1.4.1.232.6.2.6.8.1.5.1.";
|
||||
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(
|
||||
-hostname => $host,
|
||||
-community => $community,
|
||||
-port => $port
|
||||
);
|
||||
|
||||
if (!defined ($session)) {
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
# Fetch the values.
|
||||
my $temp_locales = $session->get_table($cpqHeTemperatureLocale);
|
||||
|
||||
if (!defined ($temp_locales)) {
|
||||
die "Croaking: $error";
|
||||
}
|
||||
|
||||
my @i = ();
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
||||
#print "host_name $host\n";
|
||||
print "graph_title Temperature (in C)\n";
|
||||
print "graph_category sensors\n";
|
||||
print "graph_args --upper-limit 100 -l 0\n";
|
||||
print "graph_vlabel C\n";
|
||||
print "graph_info This graph shows the temperatures on a HP server.\n";
|
||||
|
||||
while (my ($oid, $loc_id) = each (%$temp_locales)) {
|
||||
@i = split(/\./, $oid);
|
||||
my $t = $session->get_request($cpqHeTemperatureThreshold . $i[-1]);
|
||||
while (my ($ooid, $threshold) = each(%$t)) {
|
||||
print "$locations{$loc_id}$i[-1].label $locations{$loc_id}\n";
|
||||
print "$locations{$loc_id}$i[-1].info Temperature sensor on $locations{$loc_id}\n";
|
||||
print "$locations{$loc_id}$i[-1].critical $threshold\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Fetch values
|
||||
while (my ($oid, $loc_id) = each (%$temp_locales)) {
|
||||
@i = split(/\./, $oid);
|
||||
my $t = $session->get_request($cpqHeTemperatureCelsius . $i[-1]);
|
||||
while (my ($ooid, $temperature) = each(%$t)) {
|
||||
print "$locations{$loc_id}$i[-1].value $temperature\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue