#!/usr/bin/perl # Program: check-vvr.pl # Description: Verify current Veritas Volume Replicator status # Version: 1.0 # Last Update: 3 September 2001 # Written by: Dusan U. Baljevic # # Copyright 2001-2014 Dusan Baljevic # # 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 3 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 . $ENV{'PATH'} = '/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin'; $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne ''; $ENV{'IFS'} = '' if $ENV{'IFS'} ne ''; use POSIX 'uname'; ( undef, $Hostname, undef, undef, undef ) = uname; use strict; require Mail::Send; use vars qw($RecipientX $DGGROUP $WARNING $VALUE_TO_CHECK $Treshold @values $header $msg $fh $rlink $Hostname); $RecipientX = "VVR-admin\@company.com"; $DGGROUP = "dg01-t3-05dg"; $Treshold = 5; open( CHECK, "vxprint |awk '/city/ && ! /awk/ {print \$2}' |" ) || die "Cannot check VVR status"; while () { chomp; $rlink = $_; open( FINAL, "vxrlink -g $DGGROUP status $rlink 2>&1 | awk '/outstanding/ {print}' |" ) || die "Cannot check $DGGROUP status"; while () { chomp; next if !grep( /outstanding/i, $_ ); $WARNING = $_; ( $VALUE_TO_CHECK = $WARNING ) =~ s/^.*\(//ig; $VALUE_TO_CHECK =~ s/\).*$//ig; if ( $VALUE_TO_CHECK >= $Treshold ) { $msg = new Mail::Send; $msg->to("$RecipientX"); $msg->subject("WARNING: VVR Backlog"); $msg->set( $header, @values ); $msg->add( $header, @values ); $msg->delete($header); $fh = $msg->open; print $fh "The treshold value for $rlink ($Treshold%) has been exceeded:\n\n"; print $fh "$WARNING\n"; print $fh "Admins/Operations: Check it IMMEDIATELY.\n"; $fh->close; } } } exit(0);