mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin-Gallery: Better 2nd level headings
This commit is contained in:
parent
6ffdebec0d
commit
f769371079
22 changed files with 0 additions and 0 deletions
188
plugins/synology/snmp__synology
Executable file
188
plugins/synology/snmp__synology
Executable file
|
@ -0,0 +1,188 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2014 Johann Schmitz <johann@j-schmitz.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__synology_ - Health and system status monitoring plugin for Synology NAS systems
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
Make sure your Synology device is accessible via SNMP (e.g. via snmpwalk) and the munin-node
|
||||
has been configured correctly.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
0.0.1
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
Open a ticket at https://github.com/ercpe/contrib if you find one.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Johann Schmitz <johann@j-schmitz.net>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
from pysnmp.entity.rfc3413.oneliner import cmdgen
|
||||
|
||||
disktable_id = '1.3.6.1.4.1.6574.2.1.1.2'
|
||||
disktable_model = '1.3.6.1.4.1.6574.2.1.1.3'
|
||||
disktable_temp = '1.3.6.1.4.1.6574.2.1.1.6'
|
||||
sys_temperature = '1.3.6.1.4.1.6574.1.2.0'
|
||||
|
||||
class SynologySNMPClient(object):
|
||||
def __init__(self, host, port, community):
|
||||
self.hostname = host
|
||||
self.transport = cmdgen.UdpTransportTarget((host, int(port)))
|
||||
self.auth = cmdgen.CommunityData('test-agent', community)
|
||||
self.gen = cmdgen.CommandGenerator()
|
||||
|
||||
def _get_disks(self):
|
||||
disk_table = '1.3.6.1.4.1.6574.2.1'
|
||||
errorIndication, errorStatus, errorIndex, varBindTable = self.gen.bulkCmd(
|
||||
self.auth,
|
||||
self.transport,
|
||||
0, 24,
|
||||
disk_table)
|
||||
|
||||
if errorIndication:
|
||||
logging.error("SNMP bulkCmd for devices failed: %s, %s, %s" % (errorIndication, errorStatus, errorIndex))
|
||||
return
|
||||
|
||||
devices = {}
|
||||
for row in varBindTable:
|
||||
for oid, value in row:
|
||||
oid = str(oid)
|
||||
if not oid.startswith(disk_table):
|
||||
continue
|
||||
|
||||
disk_id = oid[oid.rindex('.')+1:]
|
||||
|
||||
values = devices.get(disk_id, [None, None, None])
|
||||
if oid.startswith(disktable_id):
|
||||
values[0] = str(value).strip()
|
||||
if oid.startswith(disktable_model):
|
||||
values[1] = str(value).strip()
|
||||
if oid.startswith(disktable_temp):
|
||||
values[2] = int(value)
|
||||
devices[disk_id] = values
|
||||
|
||||
for x in sorted(devices.keys()):
|
||||
yield tuple([x] + devices[x])
|
||||
|
||||
def _get_sys_temperature(self):
|
||||
errorIndication, errorStatus, errorIndex, varBindTable = self.gen.getCmd(
|
||||
self.auth,
|
||||
self.transport,
|
||||
sys_temperature)
|
||||
|
||||
if errorIndication:
|
||||
logging.error("SNMP getCmd for %s failed: %s, %s, %s" % (sys_temperature, errorIndication, errorStatus, errorIndex))
|
||||
return None
|
||||
|
||||
return int(varBindTable[0][1])
|
||||
|
||||
def print_config(self):
|
||||
print """multigraph synology_hdd_temperatures
|
||||
host_name {hostname}
|
||||
graph_title HDD temperatures on {hostname}
|
||||
graph_vlabel Temperature in °C
|
||||
graph_args --base 1000
|
||||
graph_category system
|
||||
graph_info HDD temperatures on {hostname}""".format(hostname=self.hostname)
|
||||
|
||||
for id, name, model, temp in self._get_disks():
|
||||
print """disk{disk_id}.info Temperature of {name} ({model})
|
||||
disk{disk_id}.label {name} ({model})
|
||||
disk{disk_id}.type GAUGE
|
||||
disk{disk_id}.min 0""".format(disk_id=id, name=name, model=model)
|
||||
|
||||
|
||||
print """multigraph synology_sys_temperature
|
||||
host_name {hostname}
|
||||
graph_title System temperatures of {hostname}
|
||||
graph_vlabel Temperature in °C
|
||||
graph_args --base 1000
|
||||
graph_category system
|
||||
graph_info System temperature of {hostname}
|
||||
sys_temp.info System temperature
|
||||
sys_temp.label Temperature
|
||||
sys_temp.type GAUGE
|
||||
sys_temp.min 0
|
||||
""".format(hostname=self.hostname)
|
||||
|
||||
def execute(self):
|
||||
print """multigraph synology_hdd_temperatures"""
|
||||
for id, name, model, temp in self._get_disks():
|
||||
print """disk{disk_id}.value {temp}""".format(disk_id=id, temp=temp)
|
||||
|
||||
print """multigraph synology_sys_temperature"""
|
||||
print "sys_temp.value {temp}".format(temp=self._get_sys_temperature())
|
||||
|
||||
|
||||
host = None
|
||||
port = os.getenv('port', 161)
|
||||
community = os.getenv('community', None)
|
||||
debug = bool(os.getenv('MUNIN_DEBUG', os.getenv('DEBUG', 0)))
|
||||
|
||||
if debug:
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-7s %(message)s')
|
||||
|
||||
try:
|
||||
match = re.search("^(?:|.*\/)snmp_([^_]+)_synology$", sys.argv[0])
|
||||
host = match.group(1)
|
||||
match = re.search("^([^:]+):(\d+)$", host)
|
||||
if match is not None:
|
||||
host = match.group(1)
|
||||
port = match.group(2)
|
||||
except Exception as ex:
|
||||
logging.error("Caught exception: %s" % ex)
|
||||
|
||||
|
||||
if "snmpconf" in sys.argv[1:]:
|
||||
print "require 1.3.6.1.4.1.6574.2.1.1"
|
||||
sys.exit(0)
|
||||
else:
|
||||
if not (host and port and community):
|
||||
print "# Bad configuration. Cannot run with Host=%s, port=%s and community=%s" % (host, port, community)
|
||||
sys.exit(1)
|
||||
|
||||
c = SynologySNMPClient(host, port, community)
|
||||
|
||||
if "config" in sys.argv[1:]:
|
||||
c.print_config()
|
||||
else:
|
||||
c.execute()
|
109
plugins/synology/snmp__synology_hddtemp
Normal file
109
plugins/synology/snmp__synology_hddtemp
Normal file
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
# vim: ft=perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
snmp__syno_hddtemp - Munin plugin to monitor the temperature of
|
||||
harddisks in an Synology NAS.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any Synology NAS device which provides the synoDisk MIB.
|
||||
|
||||
=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 temperature of each disk installed in °C.
|
||||
|
||||
=head1 MIB INFORMATION
|
||||
|
||||
This plugin requires support for the synoDisk. It reports
|
||||
the temperature of the installed disks.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id$
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2015 Thomas Arthofer
|
||||
|
||||
This plugin was derived from snmp__netstat by Lars Strand with updates
|
||||
by Matthew Boyle.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2.
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin::SNMP;
|
||||
|
||||
my $oid_drives = '1.3.6.1.4.1.6574.2.1.1';
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
||||
print "require ${oid_drives}. [0-9]\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my ($session, $error) = Munin::Plugin::SNMP->session();
|
||||
|
||||
my $table = $session->get_hash(
|
||||
-baseoid => $oid_drives, # IF-MIB
|
||||
-cols => {
|
||||
2 => 'name',
|
||||
3 => 'type',
|
||||
6 => 'temp',
|
||||
}
|
||||
);
|
||||
|
||||
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 HDD temperature\n";
|
||||
print "graph_category sensors\n";
|
||||
print "graph_vlabel Degrees Celsius\n";
|
||||
print "graph_info This graph shows the temperature of all HDDs in the Diskstation.\n";
|
||||
|
||||
foreach my $key ( sort keys %$table )
|
||||
{
|
||||
print "temp$key.label $table->{$key}->{'name'}\n";
|
||||
print "temp$key.info Temperature of $table->{$key}->{'name'} ($table->{$key}->{'type'})\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
my $names = $session->get_entries(-columns => [ $oid_drives ]);
|
||||
|
||||
foreach my $key ( sort keys %$table )
|
||||
{
|
||||
print "temp$key.value $table->{$key}->{'temp'}\n";
|
||||
}
|
91
plugins/synology/snmp__synology_temperature
Normal file
91
plugins/synology/snmp__synology_temperature
Normal file
|
@ -0,0 +1,91 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- cperl -*-
|
||||
# vim: ft=perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
snmp__syno_temperature - Munin plugin to retrieve current temperature from a
|
||||
Synology NAS.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any Synology NAS device which provides the synoSystem MIB.
|
||||
|
||||
=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
|
||||
|
||||
This plugin queries the current temperature of the NAS.
|
||||
|
||||
=head1 MIB INFORMATION
|
||||
|
||||
This plugin requires support for the synoSystem MIB by Synology.
|
||||
It reports the contents of the temperature OID.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id$
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2015 Thomas Arthofer
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2 or (at your option) any later version.
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin::SNMP;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||||
print "require 1.3.6.1.4.1.6574.1.2.0 [0-9]\n"; # Number
|
||||
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 Temperatures
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel Degrees Celsius
|
||||
graph_category sensors
|
||||
graph_info This graph shows the temperature of the diskstation.
|
||||
temp.label CPU
|
||||
temp.info The temperature of the onboard CPU.
|
||||
";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $session = Munin::Plugin::SNMP->session(-translate =>
|
||||
[ -timeticks => 0x0 ]);
|
||||
|
||||
my $temp = $session->get_single (".1.3.6.1.4.1.6574.1.2.0") || 'ERROR';
|
||||
|
||||
print "Retrived uptime is '$temp'\n" if $Munin::Plugin::SNMP::DEBUG;
|
||||
|
||||
print "temp.value ", $temp, "\n";
|
102
plugins/synology/snmp__synology_ups
Normal file
102
plugins/synology/snmp__synology_ups
Normal file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- cperl -*-
|
||||
# vim: ft=perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
snmp__syno_ups - Munin plugin to retrieve various information of the
|
||||
UPS attached to a Synology NAS.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any Synology NAS device which provides the synoUPS MIB.
|
||||
|
||||
=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 following stats about the UPS attached:
|
||||
- Load in %
|
||||
- Charge in %
|
||||
|
||||
=head1 MIB INFORMATION
|
||||
|
||||
This plugin requires support for the synoUPS MIB by Synology.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=snmpauto
|
||||
#%# capabilities=snmpconf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id$
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2015 Thomas Arthofer
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2 or (at your option) any later version.
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Munin::Plugin::SNMP;
|
||||
|
||||
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||||
print "require 1.3.6.1.4.1.6574.4.3.1.1.0 [0-9]\n"; # Charge
|
||||
print "require 1.3.6.1.4.1.6574.4.2.12.1.0 [0-9]\n"; # Load
|
||||
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 UPS
|
||||
graph_args --base 1000 -l 0
|
||||
graph_vlabel Status of UPS
|
||||
graph_category system
|
||||
graph_info This graph shows the status of the attached UPS.
|
||||
charge.label Charge
|
||||
charge.info Charge status of battery.
|
||||
charge.draw LINE2
|
||||
load.label Load
|
||||
load.info Load on the UPS
|
||||
";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $session = Munin::Plugin::SNMP->session(-translate =>
|
||||
[ -timeticks => 0x0 ]);
|
||||
|
||||
my $charge = $session->get_single (".1.3.6.1.4.1.6574.4.3.1.1.0") || 'ERROR';
|
||||
$charge = unpack "f", reverse pack "H*", $charge;
|
||||
|
||||
my $load = $session->get_single (".1.3.6.1.4.1.6574.4.2.12.1.0") || 'ERROR';
|
||||
$load = unpack "f", reverse pack "H*", $load;
|
||||
|
||||
print "Retrived charge '$charge'\n" if $Munin::Plugin::SNMP::DEBUG;
|
||||
print "Retrived load '$load'\n" if $Munin::Plugin::SNMP::DEBUG;
|
||||
|
||||
print "charge.value ", $charge, "\n";
|
||||
print "load.value ", $load, "\n";
|
Loading…
Add table
Add a link
Reference in a new issue