[-]
[+]
|
Changed |
nagios-plugins-snmp.spec
|
|
[-]
[+]
|
Added |
check_msa_hardware.pl
^
|
@@ -0,0 +1,259 @@
+#! /usr/bin/perl -w
+###################################################################
+# 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.
+#
+# For information : david.barbion@adeoservices.com
+####################################################################
+#
+# Script init
+#
+
+use strict;
+use Switch ;
+use List::Util qw[min max];
+use Net::SNMP qw(:snmp);
+use FindBin;
+use lib "$FindBin::Bin";
+use lib "/usr/local/nagios/libexec";
+use lib "/tmp" ;
+
+
+use utils qw($TIMEOUT %ERRORS &print_revision &support);
+
+use vars qw($PROGNAME);
+use Getopt::Long;
+use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u);
+
+$PROGNAME = $0;
+sub print_help ();
+sub print_usage ();
+
+Getopt::Long::Configure('bundling');
+GetOptions
+ ("h" => \$opt_h, "help" => \$opt_h,
+ "u=s" => \$opt_u, "username=s" => \$opt_u,
+ "p=s" => \$opt_p, "password=s" => \$opt_p,
+ "k=s" => \$opt_k, "key=s" => \$opt_k,
+ "V" => \$opt_V, "version" => \$opt_V,
+ "v=s" => \$opt_v, "snmp=s" => \$opt_v,
+ "C=s" => \$opt_C, "community=s" => \$opt_C,
+ "w=s" => \$opt_w, "warning=s" => \$opt_w,
+ "c=s" => \$opt_c, "critical=s" => \$opt_c,
+ "H=s" => \$opt_H, "hostname=s" => \$opt_H);
+
+if ($opt_V) {
+ print_revision($PROGNAME,'$Revision: 1.0');
+ exit $ERRORS{'OK'};
+}
+
+if ($opt_h) {
+ print_help();
+ exit $ERRORS{'OK'};
+}
+
+$opt_H = shift unless ($opt_H);
+(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
+
+my $snmp = "1";
+if ($opt_v && $opt_v =~ /^[0-9]$/) {
+ $snmp = $opt_v;
+}
+
+if ($snmp eq "3") {
+ if (!$opt_u) {
+ print "Option -u (--username) is required for snmpV3\n";
+ exit $ERRORS{'OK'};
+ }
+ if (!$opt_p && !$opt_k) {
+ print "Option -k (--key) or -p (--password) is required for snmpV3\n";
+ exit $ERRORS{'OK'};
+ }elsif ($opt_p && $opt_k) {
+ print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
+ exit $ERRORS{'OK'};
+ }
+}
+
+($opt_C) || ($opt_C = shift) || ($opt_C = "public");
+
+my $DS_type = "GAUGE";
+($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE");
+$DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/);
+
+
+my $name = $0;
+$name =~ s/\.pl.*//g;
+my $day = 0;
+
+#=== create a SNMP session ====
+
+my ($session, $error);
+if ($snmp eq "1" || $snmp eq "2") {
+ ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
+ if (!defined($session)) {
+ print("UNKNOWN: SNMP Session : $error\n");
+ exit $ERRORS{'UNKNOWN'};
+ }
+}elsif ($opt_k) {
+ ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
+ if (!defined($session)) {
+ print("UNKNOWN: SNMP Session : $error\n");
+ exit $ERRORS{'UNKNOWN'};
+ }
+}elsif ($opt_p) {
+ ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
+ if (!defined($session)) {
+ print("UNKNOWN: SNMP Session : $error\n");
+ exit $ERRORS{'UNKNOWN'};
+ }
+}
+
+
+# Here we go !
+my $result ;
+my $label ;
+my $oid ;
+my $unit = "";
+my $return_result ;
+my $return_code = 0 ;
+my $output ;
+my $total_connection = 0;
+# parse sysDescr
+my $sysdescr = $session->get_request(-varbindlist => [".1.3.6.1.2.1.1.1.0"]) ;
+my $outlabel = $sysdescr->{".1.3.6.1.2.1.1.1.0"}.": " ;
+
+# define some useful arrays
+my %msa_sensors_oids = (
+ ".1.3.6.1.3.94.1.8.1.1" => "Sensor unitid",
+ ".1.3.6.1.3.94.1.8.1.2" => "Sensor index",
+ ".1.3.6.1.3.94.1.8.1.3" => "Sensor name",
+ ".1.3.6.1.3.94.1.8.1.4" => "Sensor status",
+ ".1.3.6.1.3.94.1.8.1.5" => "Sensor info",
+ ".1.3.6.1.3.94.1.8.1.6" => "Sensor message",
+ ".1.3.6.1.3.94.1.8.1.7" => "Sensor type",
+ ".1.3.6.1.3.94.1.8.1.8" => "Sensor characteristic"
+ ) ;
+my %sensor_data_table = ("SENSOR_UNITID" => ".1.3.6.1.3.94.1.8.1.1",
+ "SENSOR_INDEX" => ".1.3.6.1.3.94.1.8.1.2",
+ "SENSOR_NAME" => ".1.3.6.1.3.94.1.8.1.3",
+ "SENSOR_STATUS" => ".1.3.6.1.3.94.1.8.1.4",
+ "SENSOR_INFO" => ".1.3.6.1.3.94.1.8.1.5",
+ "SENSOR_MESSAGE" => ".1.3.6.1.3.94.1.8.1.6",
+ "SENSOR_TYPE" => ".1.3.6.1.3.94.1.8.1.7",
+ "SENSOR_CHARACTERISTIC" => ".1.3.6.1.3.94.1.8.1.8",) ;
+
+# all sensors types
+my @msa_sensors_type = ("undefined",
+ "unknown",
+ "other",
+ "battery",
+ "fan",
+ "power-supply",
+ "transmitter",
+ "enclosure",
+ "board",
+ "receiver") ;
+# all sensors status
+my @msa_sensors_status = ("undefined",
+ "unknown",
+ "other",
+ "ok",
+ "warning",
+ "failed") ;
+
+# all sensors characteristics
+my @msa_sensors_characteristic = ("undefined",
+ "unknown",
+ "other",
+ "temperature",
+ "pressure",
+ "emf",
+ "currentValue",
+ "airflow",
+ "frequency",
+ "power",
+ "door"
+ ) ;
+
+# get the sensor table
+$result = $session->get_table(".1.3.6.1.3.94.1.8") ;
+my %msa_sensors_values = %{$result} ;
+
+my $sensor_id ;
+my $key ;
+my $value ;
+my @msa_sensors ;
+my $sensor ;
+# create the sensor data table
+foreach (keys %msa_sensors_values) {
+ $value = $key = $sensor_id = $_ ;
+ $sensor_id =~ s/.*\.([0-9]+)$/$1/;
+ $key =~ s/(\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*).*/$1/ ;
+ $msa_sensors[$sensor_id]{$key} = $msa_sensors_values{$value};
|
[-]
[+]
|
Added |
check_px5XX_new.pl
^
|
@@ -0,0 +1,315 @@
+#!/usr/bin/perl -w
+
+# Project : Monitoring of Quantum Library with Nagios & Centreon
+# Author : Romain Pichard
+#
+#
+# This program can monitor Quantum Libraries PX506
+# and certainly PX502 and PX510.
+#
+# The main aim is to check the UPTIME and the STATE of the library
+# with SNMP. The other aim is to translate SNMP responses
+# (1, 2, 3,...) with words.
+#
+# URL of Quantum's MIB :
+# http://www.quantum.com/ServiceandSupport/SoftwareandDocumentationDownloads/PX506/Index.aspx
+# Download the SNMP Integration CD and search the file named : QUANTUM-SNMP.mib
+#
+#
+# This program is inspired by Ken McKinlay's script
+# which named check_netapp.pl
+#
+# Parameter checks and SNMP v3 based on code by Christoph Kron
+# and S. Ghosh (check_ifstatus)
+#
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# Report bugs to cheupi@gmail.com
+#
+# 2008.02.05 Version 1.1
+
+
+use strict;
+use lib "/usr/lib/nagios/plugins";
+use utils qw($TIMEOUT %ERRORS &print_revision &support);
+use Net::SNMP;
+use Getopt::Long;
+Getopt::Long::Configure('bundling');
+
+my $PROGNAME = 'check_px5XX';
+my $PROGREVISION = '1.0';
+
+sub print_help ();
+sub usage ();
+sub process_arguments ();
+
+my ($status,$timeout,$answer,$perfdata,$hostname);
+my ($seclevel,$authproto,$secname,$authpass,$privpass,$snmp_version);
+my ($auth,$priv,$session,$error,$response,$snmpoid,$variable);
+my ($opt_h,$opt_V);
+my %snmpresponse;
+
+my $state = 'UNKNOWN';
+my $community='public';
+my $maxmsgsize = 1472; # Net::SNMP default is 1472
+my $port = 161;
+
+my $snmpUptime = '.1.3.6.1.2.1.1.3';
+my $snmpState = '.1.3.6.1.4.1.2036.2.1.1.7';
+
+my %StateLevel = (
+ 1 => 'Unavailable',
+ 2 => 'Available',
+ 3 => 'Online',
+ 4 => 'Offline',
+ 5 => 'Going online',
+ 6 => 'State not available',
+);
+
+# Just in case of problems, let's not hang Nagios
+$SIG{'ALRM'} = sub {
+ print "ERROR: No snmp response from $hostname (alarm timeout)\n";
+ exit $ERRORS{'UNKNOWN'};
+};
+
+$status = process_arguments();
+if ( $status != 0 ) {
+ print_help();
+ exit $ERRORS{'OK'};
+}
+
+alarm($timeout);
+
+# Do the query
+if ( ! defined ( $response = $session->get_table($snmpoid) ) ) {
+ $answer=$session->error;
+ $session->close;
+ $state = 'CRITICAL';
+ print "$state:$answer for $snmpoid with snmp version $snmp_version\n";
+ exit $ERRORS{$state};
+}
+$session->close;
+alarm(0);
+
+foreach my $snmpkey (keys %{$response} ) {
+ my ($oid,$key) = ( $snmpkey =~ /(.*)\.(\d+)$/ );
+ $snmpresponse{$oid}{$key} = $response->{$snmpkey};
+}
+
+if ( $variable eq 'UPTIME' ) {
+ $state = 'OK';
+ $answer = sprintf("Uptime of Quantum Library: %s",$snmpresponse{$snmpUptime}{0});
+ $perfdata = sprintf("uptime=%s",$snmpresponse{$snmpUptime}{0});
+} elsif ( $variable eq 'STATE' ) {
+ $state = 'OK';
+ $state = 'WARNING' if ( ( $snmpresponse{$snmpState}{0} == 1 ) || ( $snmpresponse{$snmpState}{0} == 5 ) || ( $snmpresponse{$snmpState}{0} == 6 ) );
+ $state = 'CRITICAL' if ( $snmpresponse{$snmpState}{0} == 4 );
+ $answer = sprintf("State of Quantum Library: %s",$StateLevel{$snmpresponse{$snmpState}{0}});
+ $perfdata = sprintf("statelevel=%d",$snmpresponse{$snmpState}{0});
+}
+
+print "$answer|$perfdata\n";
+exit $ERRORS{$state};
+
+sub usage () {
+ print "\nMissing arguments!\n\n";
+ print "check_px5XX.pl -H <ip_address> -v <variable>\n";
+ print " [-C community] [-t timeout] [-p port-number]\n";
+ print " [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n";
+ print " [-A authpasswd] [-X privpasswd]\n\n";
+ support();
+ exit $ERRORS{'UNKNOWN'};
+}
+
+sub print_help () {
+ print "check_px5XX.pl plugin for Nagios monitors the status\n";
+ print "of a Quantum Library system\n\n";
+ print "Usage:\n";
+ print " -H, --hostname\n\thostname to query (required)\n";
+ print " -C, --community\n\tSNMP read community (defaults to public)\n";
+ print " -t, --timeout\n\tseconds before the plugin tims out (default=$TIMEOUT)\n";
+ print " -p, --port\n\tSNMP port (default 161\n";
+ print " -P, --snmp_version\n\t1 for SNMP v1 (default), 2 for SNMP v2c\n\t\t3 for SNMP v3 (requires -U)\n";
+ print " -L, --seclevel\n\tchoice of \"noAuthNoPriv\", \"authNoPriv\", \"authpriv\"\n";
+ print " -U, --secname\n\tuser name for SNMPv3 context\n";
+ print " -a, --authproto\n\tauthentication protocol (MD5 or SHA1)\n";
+ print " -A, --authpass\n\tauthentication password\n";
+ print " -X, --privpass\n\tprivacy password in hex with 0x prefix generated by snmpkey\n";
+ print " -V, --version\n\tplugin version\n";
+ print " -v, --variable\n\tvariable to query, can be:\n";
+ print "\t\tUPTIME - Uptime of Quantum Library\n";
+ print "\t\tSTATE - State of Quantum Library\n";
+ print " -h, --help\n\tusage help\n\n";
+ print_revision($PROGNAME,"\$Revision: 1.2 $PROGREVISION\$");
+}
+
+sub process_arguments () {
+ $status = GetOptions (
+ 'V' => \$opt_V, 'version' => \$opt_V,
+ 'h' => \$opt_h, 'help' => \$opt_h,
+ 'P=i' => \$snmp_version, 'snmp_version=i' => \$snmp_version,
+ 'C=s' => \$community, 'community=s' => \$community,
+ 'L=s' => \$seclevel, 'seclevel=s' => \$seclevel,
+ 'a=s' => \$authproto, 'authproto=s' => \$authproto,
+ 'U=s' => \$secname, 'secname=s' => \$secname,
+ 'A=s' => \$authpass, 'authpass=s' => \$authpass,
+ 'X=s' => \$privpass, 'privpass=s' => \$privpass,
+ 'H=s' => \$hostname, 'hostname=s' => \$hostname,
+ 't=i' => \$timeout, 'timeout=i' => \$timeout,
+ 'v=s' => \$variable, 'variable=s' => \$variable,
+ );
+
+ if ( $status == 0 ) {
+ print_help();
+ exit $ERRORS{'OK'};
+ }
+
+ if ( $opt_V ) {
+ print_revision($PROGNAME,"\$Revision: 1.2 $PROGREVISION\$");
+ exit $ERRORS{'OK'};
+ }
+
+ if ( ! utils::is_hostname($hostname) ) {
+ usage();
+ exit $ERRORS{'UNKNOWN'};
+ }
+
+ unless ( defined $timeout ) {
+ $timeout = $TIMEOUT;
+ }
+
+ if ( ! $snmp_version ) {
+ $snmp_version = 1;
+ }
+
+ if ( $snmp_version =~ /3/ ) {
|