#!/bin/ksh # /home/root/bin/ifevent # $1 = Ip address of agent # $2 = timestamp # $3 = objectid of agent node # $4 = objectid of interface PATH=$PATH:/usr/OV/bin:/home/root/bin source=$1 target=`hostname` ndobjid=$3 ifobjid=$4 # IP Status: Unknown(1) Normal(2) Marginal(3) Critical(4) Unmanaged(5) User1(6) User2(7) IPStatus=`get_field2 $ifobjid "IP Status"` ifselname=`get_field2 $ifobjid "Selection Name"` ndselname=`get_field2 $ndobjid "Selection Name"` ndSNMPsysObjectId=`get_field2 $ndobjid "SNMP sysObjectID"` QMAC=`get_field2 $ifobjid "SNMP ifPhysAddr"|cut -c1-8` isPrinter=`get_field2 $ndobjid "isPrinter"` QSNMPAgent=`get_field2 $ndobjid "SNMPAgent"` ifDescr=`get_field2 $ifobjid "SNMP ifDescr"` c1t4ifDescr=`echo $ifDescr|cut -c1-4` ifipaddr=`get_field2 $ifobjid "IP Address"` c1t10ifipaddr=`echo $ifipaddr|cut -c1-10` QGCI=`echo $ifipaddr|cut -c1-7` c1t6ifipaddr=`echo $ifipaddr|cut -c1-6` isSNMPSupported=`get_field2 $ndobjid "isSNMPSupported"` ifTypeDown=`get_field2 $ifobjid "SNMP ifType"` ifCount=`get_field2 $ndobjid "TopM Interface Count"` qCorrStat2=`get_field2 $ndobjid "CorrStat2"` qdfHist=`get_field2 $ndobjid "dfHist"` # interface=User1(6) node=Unknown(1) if [MAC=0x400000...locally-administered AND NOT NT-WS] if [ "$QMAC" = "0x400000" -a \ "$ndSNMPsysObjectId" != "1.3.6.1.4.1.311.1.1.3.1.1" ] ; then exit 0 fi # interface and node = User1(6) if [any kind of printer=148 OR NT-Workstation or NETscout=189] if [ "$isPrinter" = "TRUE" -o "$QSNMPAgent" = "148" -o \ "$QSNMPAgent" = "189" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.108.1.1.7" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.311.1.1.3.1.1" ] ; then exit 0 fi # S U M P F ! # interface and node = User1(6) if GCI (auch Synonym fuer andere uninteressante? ...) # z.B. BSB-Server-Fil-Sumpf, 3Com Superstack, Fluke Lanmeter, seltsame Server 172.21.15., ... if [ "$QGCI" = "172.20." -o "$QGCI" = "128.1.1" -o "$QGCI" = "10.251." -o \ "$QGCI" = "10.253." -o \ "$qdfHist" = "ABS" -o \ "$qCorrStat2" = "WTF" -o \ "$c1t6ifipaddr" = "OVwDbG" -o \ "$ifDescr" = "trpd0" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.2.6.108.1.1" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.43.1.8.24" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.260.1.99" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.260.1.100" -o \ "$ndSNMPsysObjectId" = "1.3.6.1.4.1.1226.685" -a \ "$ndselname" != "NT628" ] ; then exit 0 fi # interface and node = User1(6) if [SNMP ifType = Other(1) AND NO SNMP ifDescr] if [ "$ifTypeDown" = "1" -a "$c1t4ifDescr" = "OVwD" -a "$isSNMPSupported" != "TRUE" -a \ "$ndselname" != "NT116" -a "$ndselname" != "NT117" -a "$ndselname" != "DCPB" -a \ "$ndselname" != "DCPF" -a "$ndselname" != "DCPG" ] ; then exit 0 fi # unnoetige weglassen eventinfo=`grep "$ndselname" /etc/hosts|grep -v "^#"|awk '{print $3, $4}'|sort -b -u -k2,2` esistjetzt=`date` esistjetzt=`echo $esistjetzt|cut -c1-19` quackfile=/tmp/qwe.quack.$RANDOM if [ "$ifCount" = "1" ] ; then if [ "$IPStatus" = "2" ] ; then # /home/root/bin/set_field2 $ndobjid CorrStat5 OK /usr/OV/bin/event -E 50462721 -h $ndselname -d "Node:$ifipaddr Interface:$ifselname up. Status Poll OK. $eventinfo" >/dev/null echo "$ndselname Node:$ifipaddr Interface:$ifselname up. Status Poll OK. $eventinfo " >$quackfile /home/root/bin/sysuptime $ndselname & # echo "`date` $ndselname `snmpget -t15 -r3 $ndselname system.sysUptime.0`" >>/tmp/sysUptime.log else # /home/root/bin/set_field2 $ndobjid CorrStat5 NOK /usr/OV/bin/event -E 50462720 -h $ndselname -d "Node:$ifipaddr Interface:$ifselname down. Status Poll Timeout. $eventinfo" >/dev/null echo "$ndselname Node:$ifipaddr Interface:$ifselname down. Status Poll Timeout. $eventinfo " >$quackfile /home/root/bin/ovxpopup $ndselname Node:$ifipaddr Interface:$ifselname down. Status Poll Timeout. $eventinfo >/dev/null 2>&1 & # sleep 30 # ping -c5 $ifipaddr fi /home/root/bin/writeall $quackfile rm $quackfile >/dev/null 2>&1 exit 0 fi if [ "$IPStatus" = "2" ] ; then # /home/root/bin/set_field2 $ndobjid CorrStat5 OK /usr/OV/bin/event -E 50462721 -h $ndselname -d "Interface:$ifipaddr $ifselname up. Status Poll OK. $eventinfo" >/dev/null echo "$ndselname Interface:$ifipaddr $ifselname up. Status Poll OK. $eventinfo" >$quackfile # /home/root/bin/sysuptime $ndselname & # echo "`date` $ndselname `snmpget -t15 -r3 $ndselname system.sysUptime.0`" >>/tmp/sysUptime.log else # /home/root/bin/set_field2 $ndobjid CorrStat5 NOK /usr/OV/bin/event -E 50462720 -h $ndselname -d "Interface:$ifipaddr $ifselname down. Status Poll Timeout. $eventinfo" >/dev/null echo "$ndselname Interface:$ifipaddr $ifselname down. Status Poll Timeout. $eventinfo" >$quackfile fi /home/root/bin/writeall $quackfile rm $quackfile >/dev/null 2>&1 # sleep 30 # ping -c5 $ifipaddr