rendered paste body#!/usr/local/bin/perl
use strict;
use SNMP;
use Data::Dumper;
$ENV{'MIBS'}="ALL"; #Load all available MIBs
my $SNMP_TARGET = shift;
my $SNMP_COMMUNITY = shift;
my $DESTNAME = shift;
my $WARN = shift;
my $CRIT = shift;
my $SESSION = new SNMP::Session (DestHost => $SNMP_TARGET,
Community => $SNMP_COMMUNITY,
Version => 1);
my $results = $SESSION->gettable( "snapmirrorStatusTable" );
foreach my $key ( sort { $a <=> $b } keys %$results ){
my $entry = $results->{$key};
if( $entry->{snapmirrorDst} eq $DESTNAME ){
my $lag = $entry->{snapmirrorLag}/100;
if( $lag > $CRIT ){
print "CRITICAL: Snapmirror Lag is $lag seconds! Threshold is $CRIT.$/";
exit( 2 );
} elsif ( $lag > $WARN ){
print "WARNING: Snapmirror Lag is $lag seconds! Warning at $WARN, Critical at $CRIT.$/";
exit( 1 );
} else {
print "OK: Snapmirror lag is $lag seconds. Warning at $WARN, Critical at $CRIT.$/";
exit( 0 );
}
}
}
Service definition:
define service{
use generic-service
host_name filerhostname
service_description Snapmirror Lag: destfiler:apps
check_command check_snapmirror_lag!snmpcommunity!destfiler:apps!7200!14400
}
define command {
command_name check_snapmirror_lag
command_line /usr/bin/perl $USER1$/snapmirrorlag.pl $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$ $ARG4$
}