1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Put order in SNMP plugins by moving all of them together in snmp/

This makes it easier to find what should be used for SNMP monitoring.
This commit is contained in:
Diego Elio Pettenò 2012-08-06 21:33:00 -07:00
parent 2fc9c2400b
commit 7da1b039c2
45 changed files with 0 additions and 0 deletions

View file

@ -1,292 +0,0 @@
#!/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)

View file

@ -1,138 +0,0 @@
#!/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";
}
}

View file

@ -1,114 +0,0 @@
#!/usr/bin/ruby
"
=head1 NAME
snmp__linksys_poe - Munin plugin to monitor the current supplied by Linksys PoE
switches.
Requires ruby and the ruby SNMP library.
=head1 APPLICABLE SYSTEMS
I wrote this to query SRW2008MP switches and determined the OIDs by trial and
error. There may be other Linksys devices that this will also work for.
=head1 CONFIGURATION
This plugin defaults to SNMP version 2c and a community string of 'public'. The
defaults can be overridden in the usual way:
[snmp_*]
env.version 1
env.community private
SNMP version 3 is not supported.
=head1 INTERPRETATION
The plugin simply reports the current being supplied on each of the device's
PoE ports.
=head1 MIB INFORMATION
Information is gathered from Linksys' private MIB space, so it's probably only
applicable to Linksys devices. I have been unable to get an actual copy of
the appropriate MIB, so I don't know the actual names of the values I'm
retrieving.
=head1 MAGIC MARKERS
#%# family=snmpauto contrib
#%# capabilities=snmpconf
=head1 VERSION
1.0
=head1 BUGS
None known.
=head1 AUTHOR
Written by Phil Gold <phil_g@pobox.com>.
=head1 LICENSE
CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
To the extent possible under law, all copyright and related or neighboring
rights to this plugin are waived. Do with it as you wish.
=cut
"
require 'snmp'
idx_oid = "enterprises.3955.89.108.1.1.2"
max_oid = "enterprises.3955.89.108.1.1.6"
cur_oid = "enterprises.3955.89.108.1.1.5"
community = ENV['community'] || "public"
version = ENV['version'] == '1' ? :SNMPv1 : :SNMPv2c
case ARGV[0]
when "autoconf"
puts "no"
exit 1
when "snmpconf"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.2.1. [0-9]"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.5.1. [0-9]"
puts "require 1.3.6.1.4.1.3955.89.108.1.1.6.1. [0-9]"
exit 0;
when "config"
host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
puts "host_name #{host}"
puts "graph_title PoE Power Usage"
puts "graph_vlabel Watts"
puts "graph_category sensors"
max_current = 0
SNMP::Manager.open(:Host => host,
:Community => community,
:Version => version) do |manager|
manager.walk([idx_oid, max_oid]) do |row|
puts "iface_#{row[0].value}.label Port #{row[0].value}"
puts "iface_#{row[0].value}.cdef iface_#{row[0].value},1000,/"
puts "iface_#{row[0].value}.line #{row[1].value.to_f / 1000}"
if row[1].value > max_current
max_current = row[1].value
end
end
end
puts "graph_args --upper-limit #{max_current.to_f / 1000}"
exit 0
else
host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
SNMP::Manager.open(:Host => host,
:Community => community,
:Version => version) do |manager|
manager.walk([idx_oid, cur_oid]) do |row|
puts "iface_#{row[0].value}.value #{row[1].value}"
end
end
end

View file

@ -1,346 +0,0 @@
#!/bin/bash
#==============================================================================#
# #
# check status of sensor of HW Group Poseidon 3268. For more info refer to: #
# http://www.hw-group.com/products/poseidon/poseidon_3268_en.html #
# 2012 by Florian Lechner #
# #
#==============================================================================#
# #
# 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, either version 2 of the License, or #
# (at your option) any later version. #
# #
# 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, see <http://www.gnu.org/licenses/>. #
# #
#==============================================================================#
# Munin autoconf and snmpautoconf magic
#%# family=auto snmpauto contrib
#%# capabilities=snmpconf
E_OK="0" # everything went allright
E_UNKNOWN="1" # "catch all" for otherwise unhandled errors
E_ARG="81" # invalid argument
E_USAGE="82" # wrong program name or arguments
E_SNMPGET="83" # error while executing the 'snmpget' utility
E_COMMANDNOTFOUND="127" # unable to locate binary
#==============================================================================#
# SNMP OIDs from the Poseidon MIB #
#==============================================================================#
SYS_LOC_OID=".1.3.6.1.2.1.1.6.0" # SNMP-location
SYS_NAME_OID=".1.3.6.1.2.1.1.5.0" # device name (string)
SYS_DESCR_OID=".1.3.6.1.2.1.1.1" # text describing the device
SYS_UPTIME_OID=".1.3.6.1.2.1.1.3.0" # time(in tens of milliseconds
#+ since the last reboot
IN_NAME_OID=".1.3.6.1.4.1.21796.3.3.1.1.3." # binary input name (string)
IN_STATE_OID=".1.3.6.1.4.1.21796.3.3.1.1.2." # binary input states(integer)
IN_ALARM_OID=".1.3.6.1.4.1.21796.3.3.1.1.4." # alarm for the binary input,
#+ generated by the device
#+ under defined conditions
#+ 0=Invalid, 1=Normal,
#+ 2=AlarmState, 3=Alarm
SENS_NAME_OID=".1.3.6.1.4.1.21796.3.3.3.1.2." # sensor name (string)
SENS_STATE_OID=".1.3.6.1.4.1.21796.3.3.3.1.4." # binary input states(integer)
SENS_VALUE_OID=".1.3.6.1.4.1.21796.3.3.3.1.6." # integer (decimal * 10)
SENS_ID_OID=".1.3.6.1.4.1.21796.3.3.99.1.2.1.4." # unique sensor ID (integer)
#+ representation of the
#+ temperature (integer)
SENS_UNIT_OID=".1.3.6.1.4.1.21796.3.3.3.1.9." # 0=°C,1=°F,2=°K,3=%,4=V,5=mA,
RTS_OUTPUT_OID=".1.3.6.1.4.1.21796.3.3.2.1.2." # binary input state (integer)
#+ 6=unknown, 7=pulse, 8=switch
# define some Poseidon specific stuff:
STATE_OK="1"
STATE_WARN="2"
STATE_CRIT="3"
UNITS=("C" "F" "K" "%" "V" "mA" "unknown" "pulse" "switch")
TYPES=("Temp" "Temp" "Temp" "Hum" "Volt" "Curr" "Unkn" "Pulse" "Switch")
declare -A sensorsOfType
IFS="
"
#==============================================================================#
# printMuninConfig ()
# print output for munin auto configuration
printMuninConfig () {
if [ ! $hostAddr = 'localhost' ]; then
cat <<- EOT
host_name $hostAddr
EOT
fi
for ((_sensorType=0; _sensorType<=${#UNITS[*]};_sensorType++)); do
# skip graphs without sensors
if [ -z "${sensorsOfType[$_sensorType]}" ]; then
continue
fi
_firstSensor="1"
# print specific config for each sensor
for _sensorNr in ${sensorsOfType[$_sensorType]}; do
getSensorData $_sensorNr
getSystemInfo
if [ $_firstSensor = "1" ]; then
# graph headers
cat <<- EOT
multigraph $sensorType
graph_title $sensorLocation - $sensorType [$sensorUnit]
graph_args --base 1000 -l 0
graph_vlabel $sensorUnit
graph_category environment
graph_info This graph shows $sensorType history.
EOT
fi
_firstSensor="0"
cat <<- EOT
$sensorType$_sensorNr.label $sensorName
$sensorType$_sensorNr.info This graph shows $sensorType$_sensorNr history.
$sensorType$_sensorNr.draw LINE2
EOT
done
done
}
# printMuninSnmpConfig ()
# print output for munin snmp auto configuration
printMuninSnmpConfig () {
cat <<- EOT
require $SENS_VALUE_OID$sensorNumber [0-9]
require $SENS_STATE_OID$sensorNumber
EOT
return 0;
}
# printMuninStatus ()
# print status output for munin
printMuninStatus () {
for ((_sensorType=0; _sensorType<=${#UNITS[*]};_sensorType++)); do
# skip graphs without sensors
if [ -z "${sensorsOfType[$_sensorType]}" ]; then
continue
fi
_firstSensor="1"
# print config section
for _sensorNr in ${sensorsOfType[$_sensorType]}; do
getSensorData $_sensorNr
if [ $_firstSensor = "1" ]; then
# graph headers
cat <<- EOT
multigraph $sensorType
EOT
fi
_firstSensor="0"
# print graph details
cat <<- EOT
$sensorType$_sensorNr.value $(( $sensorValue / 10 ))
EOT
done
echo ""
done
}
# getSensorData(sensorNr)
# fetch state, value, name unit and sensor type for the sensor
#+ with the number "sensorNr"
getSensorData() {
_sensorNr=$1
sensorState=`snmpGet $hostAddr $SENS_STATE_OID$_sensorNr || err \
"Fatal: snmpget failed with code \"$?\"! Exiting..." $E_SNMPGET`
sensorValue=`snmpGet $hostAddr $SENS_VALUE_OID$_sensorNr || err \
"Fatal: snmpget failed with code \"$?\"! Exiting..." $E_SNMPGET`
sensorName=`snmpGet $hostAddr $SENS_NAME_OID$_sensorNr || err \
"Fatal: snmpget failed with code \"$?\"! Exiting..." $E_SNMPGET`
sensorUnit=`getSensorUnitString $_sensorNr`
sensorType=`getSensorType $_sensorNr`
}
# getSystemInfo()
# fetch general information about the system
getSystemInfo() {
sensorLocation="`snmpGet $hostAddr $SYS_LOC_OID`"
}
# snmpGet (hostAddr, OID)
# use snmpget to fetch a given OID, using above configuration
snmpGet () {
_oid="$2"
_host="$1"
_exit="0"
# fetch the requested OID
_longValue="`snmpget -O v\
-m $MIBS\
-v $SNMPVERSION\
-c $SNMPCOMMUNITY\
$_host $_oid 2>/dev/null`"
_exitStatus="$?"
echo ${_longValue#*:} # remove the type from the answer
return $_exitStatus
}
# get unit (string)
#+ find out the unit of the output of a given sensor. possible units are:
#+ "C" "F" "K" "%" "V" "mA" "unknown" "pulse" "switch"
getSensorUnitString () {
_sensorNr=$1
_sensorUnit=`snmpGet $hostAddr $SENS_UNIT_OID$_sensorNr || err \
"Fatal: snmpget failed with code \"$?\"! Exiting..." $E_SNMPGET`
echo ${UNITS[$_sensorUnit]}
}
# get type (string)
#+ find out what type of sensor we are dealing with. possible types are:
#+ "Temp" "Hum" "Volt" "Curr" "Unkn" "Pulse" "Switch"
getSensorType () {
_sensorNr=$1
_sensorUnit=`snmpGet $hostAddr $SENS_UNIT_OID$_sensorNr || err \
"Fatal: snmpget failed with code \"$?\"! Exiting..." $E_SNMPGET`
echo ${TYPES[$_sensorUnit]}
}
# getAvailableSensorsByType ()
# check what sensors are available and store them
#+ in the array for the respective unit
getAvailableSensorsByType () {
_thisSensorNr="1"
# initial fetch
_snmpget=`snmpGet $hostAddr $SENS_UNIT_OID$_thisSensorNr`
_nextSensorExits=$?
_unit=`echo "$_snmpget" | tr -d " "`
# add next sensor if it exists
while [ true ]; do
# add sensors of the same type to a list
sensorsOfType[$_unit]="${sensorsOfType[$_unit]} $_thisSensorNr"
# fetch next sensor
_thisSensorNr=$(($_thisSensorNr+1))
_snmpget=`snmpGet $hostAddr $SENS_UNIT_OID$_thisSensorNr`
_nextSensorExits=$?
# are we done?
if [ $_nextSensorExits -ne 0 ]; then
break
fi
_unit=`echo "$_snmpget" |cut -d" " -f 4`
done
}
# sanitize (<string>)
# use bash builtin substitutions to sanitize string
#+ allowed chars are: a-z,A-Z,0-9 and "."
#+ if chars have been removed return 1, else return 0
sanitize () {
input="$1"
sanitizedInput="${1//[^a-zA-Z0-9.]/}"
echo "$sanitizedInput"
if [ "$input" = "$sanitizedInput" ]; then
return 0
else
return 1
fi
}
# usage ()
# print usage
usage () {
echo "usage: snmp_<host>_poseidon-sensors [config|snmpconf]" 1>&2
exit $E_USAGE
}
# err (ErrorMsg, Exitcode)
# basic error handling
err () {
if [ $# -eq 2 -a "$2" -lt 256 ]; then
_errorMsg="$1"
_exitCode="$2"
else
_errorMsg="Fatal: An unknown error occured! Exiting..."
_exitCode="$E_UNKNOWN"
fi
# print error message to STDERR ...
echo "$_errorMsg" >&2
# ... and exit with error code.
exit $_exitCode
}
#==============================================================================#
# SNMP Config
MIBS=":" # we don't use any configured MIBs so we don't
#+ have to deal with errors in the MIBs
if [ -z $SNMPVERSION ]; then
SNMPVERSION="1" # as of firmware 3.1.5 only SNMPv1 is supported
fi
if [ -z $SNMPCOMMUNITY ]; then
SNMPCOMMUNITY="public" # SNMP community string to read from the device
fi
# handle -h option
while getopts ":h" opt; do
case $opt in
h) usage
;;
\?) echo "Invalid option: -$OPTARG" >&2
usage
;;
esac
done
# check for snmpget binary
if [ ! -x `which snmpget` ]; then
err "Fatal: unable to locate \'snmpget\'! Exiting..." $E_COMMANDNOTFOUND
fi
# extract pluginname ...
myName="`basename "$0" | cut -d "_" -f 1,3`"
# ...and hostname
hostAddr="`basename "$0" | cut -d "_" -f 2`"
if [ "$myName" = "snmp_poseidon-sensors" ]; then
hostAddr=`sanitize $hostAddr || err \
"Fatal: Invalid argument \"$hostAddr\"! Exiting..." $E_ARG`
if [ -z "$hostAddr" ]; then
usage munin
fi
getAvailableSensorsByType
if [ "$1" = "config" ]; then
printMuninConfig
exit $E_OK
elif [ "$1" = "snmpconfig" ]; then
printMuninSnmpConfig
exit $E_OK
else
printMuninStatus
exit $E_OK
fi
else
usage
fi

View file

@ -1,112 +0,0 @@
#!/usr/bin/perl
# -*- perl -*-
#
# snmp__sfsnmp_fan - Munin plugin for measuring fan on a windowssystem running SpeedFan and sfsnmp
# Copyright (C) 2010 Nils Henrik Tvetene
#
# Author: Nils Henrik Tvetene <nils@tvetene.net>
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
snmp__sfsnmp_fan - Munin plugin for measuring fanspeed on a windowssystem running SpeedFan and sfsnmp
=head1 APPLICABLE SYSTEMS
Windows-system running SpeedFan and the sfsnmp extension
=head1 CONFIGURATION
Example config:
[snmp_twinspark_sfsnmp_*]
env.fan1 CPU
env.fan7.ignore true
Plugin is linked using hostname of monitored system:
ln -s /usr/share/munin/plugins/snmp__sfsnmp_fan /etc/munin/plugins/snmp_<hostname>_sfsnmp_fan
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 AUTHOR
Nils Henrik Tvetene <nils@tvetene.net>
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
# OIDs used
# 1.3.6.1.4.1.30503.1.1.2 number of fans
# 1.3.6.1.4.1.30503.1.3.x where x is 1 => above number
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "number 1.3.6.1.4.1.30503.1.1.2\n";
print "index 1.3.6.1.4.1.30503.1.3.\n";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
my ($idx, $numFans, @fan, @label);
$numFans = $session->get_single('1.3.6.1.4.1.30503.1.1.2');
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title $host fan\n";
print "graph_args --base 1000 --lower-limit 1000\n";
print "graph_scale no\n";
print "graph_printf %3.0lf\n";
print "graph_vlabel fan RPM\n";
print "graph_category sensors\n";
print "graph_info This graph shows the fans on host $host\n";
foreach $idx ( 0..$numFans-1 ) {
$label[$idx] = exists $ENV{"fan".($idx+1)} ? $ENV{"fan".($idx+1)} : "fan".($idx+1);
print "fan".($idx+1).".info ".$label[$idx]." fan in RPM's.\n";
print "fan".($idx+1).".graph no\n" if exists $ENV{"fan".($idx+1).".ignore"};
print "fan".($idx+1).".type GAUGE\n";
print "fan".($idx+1).".label $label[$idx]\n";
print "fan".($idx+1).".min 1000\n";
}
exit 0;
}
foreach $idx ( 0..$numFans-1 ) {
$fan[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.3.'.($idx+1));
print "fan".($idx+1).".value $fan[$idx]\n";
}
exit 0;
__END__

View file

@ -1,111 +0,0 @@
#!/usr/bin/perl
# -*- perl -*-
#
# snmp__sfsnmp_temp - Munin plugin for measuring temperatures on a windowssystem running SpeedFan and sfsnmp
# Copyright (C) 2010 Nils Henrik Tvetene
#
# Author: Nils Henrik Tvetene <nils@tvetene.net>
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
snmp__sfsnmp_temp - Munin plugin for measuring temperatures on a windowssystem running SpeedFan and sfsnmp
=head1 APPLICABLE SYSTEMS
Windows-system running SpeedFan and the sfsnmp extension
=head1 CONFIGURATION
Example config:
[snmp_twinspark_sfsnmp_temp]
env.temp1 System
env.temp7.ignore true
Plugin is linked using hostname of monitored system:
ln -s /usr/share/munin/plugins/snmp__sfsnmp_temp /etc/munin/plugins/snmp_<hostname>_sfsnmp_temp
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 AUTHOR
Nils Henrik Tvetene <nils@tvetene.net>
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
# OIDs used
# 1.3.6.1.4.1.30503.1.1.1 number of temperatures
# 1.3.6.1.4.1.30503.1.2.x where x is 1 => above number
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "number 1.3.6.1.4.1.30503.1.1.1\n";
print "index 1.3.6.1.4.1.30503.1.2.\n";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
my ($idx, $numTemps, @temp, @label);
$numTemps = $session->get_single('1.3.6.1.4.1.30503.1.1.1');
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title $host temperatures\n";
print "graph_args --base 1000 --lower-limit 30\n";
print "graph_vlabel degrees Celcius\n";
print "graph_category sensors\n";
print "graph_info This graph shows the temperatures on host $host\n";
foreach $idx ( 0..$numTemps-1 ) {
$label[$idx] = exists $ENV{"temp".($idx+1)} ? $ENV{"temp".($idx+1)} : "temp".($idx+1);
print "temp".($idx+1).".info ".$label[$idx]." temperature in Celsius.\n";
print "temp".($idx+1).".graph no\n" if exists $ENV{"temp".($idx+1).".ignore"};
print "temp".($idx+1).".type GAUGE\n";
print "temp".($idx+1).".label $label[$idx]\n";
print "temp".($idx+1).".cdef temp".($idx+1).",100,/\n";
print "temp".($idx+1).".min 30\n";
}
exit 0;
}
foreach $idx ( 0..$numTemps-1 ) {
$temp[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.2.'.($idx+1));
print "temp".($idx+1).".value $temp[$idx]\n";
}
exit 0;
__END__

View file

@ -1,112 +0,0 @@
#!/usr/bin/perl
# -*- perl -*-
#
# snmp__sfsnmp_volt - Munin plugin for measuring volt on a windowssystem running SpeedFan and sfsnmp
# Copyright (C) 2010 Nils Henrik Tvetene
#
# Author: Nils Henrik Tvetene <nils@tvetene.net>
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
snmp__sfsnmp_volt - Munin plugin for measuring volts on a windowssystem running SpeedFan and sfsnmp
=head1 APPLICABLE SYSTEMS
Windows-system running SpeedFan and the sfsnmp extension
=head1 CONFIGURATION
Example config:
[snmp_twinspark_sfsnmp_*]
env.volt1 Vcore
env.volt3.ignore true
Plugin is linked using hostname of monitored system:
ln -s /usr/share/munin/plugins/snmp__sfsnmp_volt /etc/munin/plugins/snmp_<hostname>_sfsnmp_volt
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 AUTHOR
Nils Henrik Tvetene <nils@tvetene.net>
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
# OIDs used
# 1.3.6.1.4.1.30503.1.1.3 number of voltages
# 1.3.6.1.4.1.30503.1.4.x where x is 1 => above number
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "number 1.3.6.1.4.1.30503.1.1.3\n";
print "index 1.3.6.1.4.1.30503.1.4.\n";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
my ($idx, $numVolts, @volt, @label);
$numVolts = $session->get_single('1.3.6.1.4.1.30503.1.1.3');
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title $host volt\n";
print "graph_args --base 1000 --lower-limit 0 --upper-limit 13\n";
print "graph_scale no\n";
print "graph_vlabel Volt\n";
print "graph_category sensors\n";
print "graph_info This graph shows the volt on host $host\n";
foreach $idx ( 0..$numVolts-1 ) {
$label[$idx] = exists $ENV{"volt".($idx+1)} ? $ENV{"volt".($idx+1)} : "volt".($idx+1);
print "volt".($idx+1).".info ".$label[$idx]." volt in Celsius.\n";
print "volt".($idx+1).".graph no\n" if exists $ENV{"volt".($idx+1).".ignore"};
print "volt".($idx+1).".type GAUGE\n";
print "volt".($idx+1).".label $label[$idx]\n";
print "volt".($idx+1).".cdef volt".($idx+1).",100,/\n";
print "volt".($idx+1).".min 30\n";
}
exit 0;
}
foreach $idx ( 0..$numVolts-1 ) {
$volt[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.4.'.($idx+1));
print "volt".($idx+1).".value $volt[$idx]\n";
}
exit 0;
__END__

View file

@ -1,104 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
snmp__thecus_fans - Munin plugin to retrive fanspeed readings from a Thecus
NAS device running SNMP.
=head1 APPLICABLE SYSTEMS
All Thecus NAS devices which have the third party NETSNMPD module installed.
This is available at http://www.fajo.de/main/thecus/modules/netsnmpd
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices.
[snmp_*]
env.version 2
env.community public
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
=head1 INTERPRETATION
The plugin reports the current fan speed readings as reported by the thecusIO
module.
=head1 MIB INFORMATION
Private MIB
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
0.0.20120307
=head1 BUGS
None known.
=head1 AUTHOR
Copyright (C) 2011 - 2012 Andreas Thienemann <andreas@bawue.net>
Based on the snmp__uptime plugin as a template.
=head1 LICENSE
GPLv2 or (at your option) any later version.
=cut
use strict;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "index 1.3.6.1.4.1.14822.101.21.\n";
print "require 1.3.6.1.4.1.14822.101.21.5200.1.1.0 [0-9]\n";
print "require 1.3.6.1.4.1.14822.101.21.5200.1.2.0 [0-9]\n";
exit 0;
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title Thecus Fans
graph_args --base 1000 -l 0
graph_vlabel RPM
graph_info This graph shows the RPMs of the fans as reported by the ThecusIO module.
graph_category sensors
fan1.label Fan 1
fan1.info Thecus CPU Fan
fan2.label Fan 2
fan2.info Thecus System Fan
";
exit 0;
}
my $session = Munin::Plugin::SNMP->session(-translate =>
[ -timeticks => 0x0 ]);
my $fan1 = $session->get_single ("1.3.6.1.4.1.14822.101.21.5200.1.1.0") || 'U';
my $fan2 = $session->get_single ("1.3.6.1.4.1.14822.101.21.5200.1.2.0") || 'U';
#print "Retrived uptime is '$uptime'\n" if $DEBUG;
print "fan1.value ", $fan1, "\n";
print "fan2.value ", $fan2, "\n";

View file

@ -1,36 +0,0 @@
#!/bin/sh
#
# Plugin to monitor battery from UPS APC 9619
# 2009/04/10 12:27:02 radar AT aol DOT pl
#
# ln -s /usr/share/munin/plugins/snmp__ups_battery /etc/munin/plugins/snmp_UPS.IP_ups_battery
#
# Magic markers (optional - only used by munin-config and some installation scripts):
#%# family=contrib
UPSHOST=$(basename $0 | awk -F'_|_' '{print $2}')
if [ "$1" = "config" ]; then
UPSMODEL=$(snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.1.1.1.0 | awk -F'"|"' '{print $2}')
echo "graph_title $UPSMODEL - Battery"
echo "graph_args --base 1000 -l 0 -u 100"
echo "graph_vlabel %"
echo "graph_scale no"
echo "graph_category sensors"
echo "graph_info This graph shows the battery capacity/load read from $UPSMODEL"
echo "batterycapacity.label Battery Capacity"
echo "batterycapacity.type GAUGE"
echo "batterycapacity.draw LINE3"
echo "batterycapacity.info Battery Capacity"
echo "batterycapacity.colour ff0000"
echo "batteryload.label Battery Load"
echo "batteryload.type GAUGE"
echo "batteryload.draw AREA"
echo "batteryload.info Battery Load"
exit 0
fi
echo -n "batterycapacity.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.2.2.1.0 | awk '{print $NF}'
echo -n "batteryload.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.4.2.3.0 | awk '{print $NF}'

View file

@ -1,29 +0,0 @@
#!/bin/sh
#
# Plugin to monitor temperature from UPS APC 9619
# 2009/04/10 12:27:02 radar AT aol DOT pl
#
# ln -s /usr/share/munin/plugins/snmp__ups_temp /etc/munin/plugins/snmp_UPS.IP_ups_temp
#
# Magic markers (optional - only used by munin-config and some installation scripts):
#%# family=contrib
UPSHOST=$(basename $0 | awk -F'_|_' '{print $2}')
if [ "$1" = "config" ]; then
UPSMODEL=$(snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.1.1.1.0 | awk -F'"|"' '{print $2}')
echo "graph_title $UPSMODEL- Temperature"
echo "graph_args --base 1000 -l 0 "
echo "graph_vlabel degrees C"
echo "graph_category sensors"
echo "graph_info This graph shows the temperature read from $UPSMODEL"
echo "temperature.label sensor UPS"
echo "temperature.type GAUGE"
echo "temperature.info Temperature from sensor UPS."
echo "temperature.warning 25"
echo "temperature.critical 30"
exit 0
fi
echo -n "temperature.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1 | awk '{print $NF}'

View file

@ -1,34 +0,0 @@
#!/bin/sh
#
# Plugin to monitor voltage from UPS APC 9619
# 2009/04/10 12:27:02 radar AT aol DOT pl
#
# ln -s /usr/share/munin/plugins/snmp__ups_voltage /etc/munin/plugins/snmp_UPS.IP_ups_voltage
#
# Magic markers (optional - only used by munin-config and some installation scripts):
#%# family=contrib
UPSHOST=$(basename $0 | awk -F'_|_' '{print $2}')
if [ "$1" = "config" ]; then
UPSMODEL=$(snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.1.1.1.0 | awk -F'"|"' '{print $2}')
echo "graph_title $UPSMODEL - Voltage"
echo "graph_args --base 1000"
echo "graph_vlabel Voltage in (-) / out (+)"
echo "graph_category sensors"
echo "graph_info This graph shows the voltage read from $UPSMODEL"
echo "voltagein.label V"
echo "voltagein.type GAUGE"
echo "voltagein.info Voltage."
echo "voltagein.graph no"
echo "voltageout.label V"
echo "voltageout.type GAUGE"
echo "voltageout.info Voltage."
echo "voltageout.negative voltagein"
exit 0
fi
echo -n "voltagein.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.3.2.1.0 | awk '{print $NF}'
echo -n "voltageout.value "
snmpwalk -v 2c -c public $UPSHOST .1.3.6.1.4.1.318.1.1.1.4.2.1.0 | awk '{print $NF}'