#!/usr/local/bin/perl # node_down.pl # Called from the OV_Node_Down event use File::Basename; require "/opt/ov_action_scripts/send_trap.pl"; $ENV{'PATH'} = '/usr/sbin:/usr/bin:/usr/ucb:/usr/local/bin:/opt/OV/bin'; $argv0 = basename($0); ($sn) = ($argv0 =~ /(\w+)\./); $date = $ARGV[0]; $time = $ARGV[1]; $device = $ARGV[2]; $LOGFILE = "/opt/ov_action_scripts/logs/$sn.log"; $COREFILE = "/opt/ov_action_scripts/core_dev_list"; $INTERFACE = "/opt/ov_action_scripts/interface_dev_list"; $match = 0; # # See if device is in the core device list # open(CF, $COREFILE) || die "Can't open $COREFILE for read: $!\n"; while () { $match = 1 if (/^$device/); } close(CF); open(CF, $INTERFACE) || die "Can't open $COREFILE for read: $!\n"; while () { $match = 2 if (/^$interface/); } close(CF); snmpget $device .1.3.6.1.2.1.2.2.1.2.$interface if ($match) { ($shortname) = ($device =~ /^\d+\./ $interface =~ /^\d+\./) ? $device : ($device =~ /^(\w+)/); $summary = "$shortname Down"; $descr = "Node Down"; $intfc = "Interface Name"; # Forward trap to the Common Event Path by sending another trap # to the host # Trap args: # Event Source Device # Short Description (Summary) Device Down # Description Node Down # TrapData1 NODE_DOWN $rc = sendtrap("$device", "$summary", "$descr", $intfc" "NODE_DOWN"); $ti = ($rc) ? "Trap NOT forwarded" : "Trap forwarded"; # Log it open(LF, ">>$LOGFILE") || die "Can't open $LOGFILE for write: $!\n"; print LF "$date: $time: $device down ($ti)\n"; close(LF); }