nv-l
[Top] [All Lists]

Here is a script to extract trapd.conf event messages for paging

To: nv-l@lists.tivoli.com
Subject: Here is a script to extract trapd.conf event messages for paging /mail.
From: Mark van Kerkwyk <kerkwyk@COMTECH.COM.AU>
Date: Tue, 19 Jan 1999 16:27:36 +1000
Reply-to: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
Sender: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
Hi all, there was a lot of people after someones script to obtain the
severity level from trapd.conf, so here is my contribution, here is a
script I wrote to give me access to Event Messages which are formatted in
trapd.conf.
I have many apps where the event message isn't sent in the trap (some of
Domino , all cisco and Netware traps) and when you run an action from the
ruleset, you don't get any access to the trap message which appears in the
event viewer.

So, here is what we wrote here, hope it helps you out. Haven't tested it
that much but seems to work ok.

Mark :-)



#!/usr/local/bin/perl
# Requires perl 5.002+
# This script is written to replace the pager action in Netview
# as it doesn't provide all of the functionality required
#

# Generic Netview Varaibles are as follows
# NVA -> Name of machine from Netview's perspective
# NVC -> Community Name in trap
# NVG -> Generic Trap ID
# NVS -> Specific Trap
# NVE -> Enterpise OID of Trap
# NVT -> Timestamp


# Contact Details, need to be in the following format NOTE: make sure you
put a backslash in front of the @ char
# eg $mvankerk="61417667292\@telstra";

$mvankerk="61417667292\@telstra";
$jhauntin="61409454332\@telstra";
$pravin="61418249504\@telstra";
$anthony="246575\@pager.hutch.com.au";

# Read in shell environment and make it available to perl environment
for (keys %ENV)
{
    $exec="\$$_=\$ENV{$_};";
    eval($exec);
}

# Category Config
# Each entry can have more than one contact number, each seperated
# by a blank space and complete string must be enclosed within double
quotes.
# For example...
# DOMINO="61417667292@telstra 61417321323@skytel"

@NETFINITY=($mvankerk);
@NETVIEW=($mvankerk);
@CISCO=($mvankerk);
@DOMINO=($mvankerk,$jhauntin,$anthony);
@ARCSERVE=($mvankerk);
@NETWARE=($mvankerk);

# The following section extracts the Event message text and reformats the
it to work within this script.

$line="";
open(F,"/usr/OV/conf/C/trapd.conf");
while (<F>)
{
    if (m/\{$NVE\} $NVG $NVS /o) {
        $line=<F>;
        break;
    }
}
close(F);
if ($line eq "")
{
    print "FAILURE:{$NVE $NVG $NVS} Not Found\n";
}
else
{
    print "SUCCESS:{$NVE $NVG $NVS} Found\n";
}

# Substitute all the $A,$E,$G,$S etc to the format which they appear in the
 environment
# eg. $E should map to $NVE, $1 should map $NVATTR_1

# Strip all \n chars out of text
$line=~s/(\\n)/ /g;
# Convert $T to $NVT
$line=~s/(\$T)/$NVT/g;
# Convert $S to $NVS
$line=~s/(\$S)/$NVS/g;
# Convert $E to $NVE
$line=~s/(\$E)/$NVE/g;
# Convert $G to $NVG
$line=~s/(\$G)/$NVG/g;
# Convert $C to $NVC
$line=~s/(\$C)/$NVC/g;
# Convert $A to $NVA
$line=~s/(\$A)/$NVA/g;
# Convert all $1,$2 etc to $NVATTR_1,$NVATTR_2 etc...
$line=~s/(\$\d)/\$NVATTR_$1/g;
$line=~s/(\_\$)/_/g;
$line=~s/\$(\w+)/${$1}/g;

# Assign message to more readable variable
$eventmessage=substr($line,0,200);
# Convert backslashes to forwardslashes as our SMS phone don't seem to
support the backslash char
$eventmessage=~s?\\?/?;





# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Handle Netfinity Manager Traps
# The Following variables are contained within Netfinity traps
# NVATTR_1 -> Trap message
# NVATTR_2 -> Host Name of machine where trap came from
# NVATTR_3 -> Time
# NVATTR_4 -> Date
# NVATTR_5 -> Netfinity Severity Level
# NVATTR_6 -> Netfinity Alert Type
# NVATTR_7 -> Netfinity Application Alert ID
# NVATTR_8 -> Netfinity Application Alert Type
# NVATTR_9 -> Netfinity Name of machine where trap came from.

if ( $NVE eq "1.3.6.1.4.1.2.6.71" )
{
for (@NETFINITY)
{
 $contact=$_;
if (/\./)
 {
   `echo 'Subject:Netfinity alert from Netview' >/tmp/tmpmsg`;
   `echo '$eventmessage' >>/tmp/tmpmsg`;
   `mail $contact </tmp/tmpmsg`;
print " $NVT: Emailed Netfinity Contact ${contact} -> '$eventmessage'\n";
 }
else
 {
`nvpage $contact  Netfinity Host:$NVA , '$eventmessage'`;
print " $NVT: Paged Netfinity Contact ${contact} -> '$eventmessage'\n";
 }
print "---------------------------------------------------------\n";
}
}


# Handle Netview Traps
# The Following variables are contained within Netview traps
# NVATTR_1 ->
# NVATTR_2 -> Host Name of machine where trap came from
# NVATTR_3 -> Trap Message
# NVATTR_4 -> Date
# NVATTR_5 ->
# NVATTR_6 ->
# NVATTR_7 ->
# NVATTR_8 ->
# NVATTR_9 ->

if ( $NVE eq "1.3.6.1.4.1.2.6.3.1" )
{
for (@NETVIEW)
{
 $contact=$_;
if (/\./)
 {
   `echo 'Subject:Netview Alert' >/tmp/tmpmsg`;
   `echo 'Netview Host: $NVA - Msg:$NVATTR_3' >>/tmp/tmpmsg`;
   `mail $contact </tmp/tmpmsg`;

print " $NVT: Emailed Netview Contact ${contact} -> '$eventmessage'\n";
 }
else
 {
`nvpage $contact  Netview Host:$NVA - Msg:$NVATTR_3`;
print " $NVT: Paged Netview Contact ${contact} -> Host:$NVA , 'Host:$NVA
Msg:$NVATTR_3'\n";
 }
print "---------------------------------------------------------\n";
}
}


# Handle ArcServe Traps
# The Following variables are contained within ArcServe traps
# NVATTR_1 ->
# NVATTR_2 -> Trap Message

if ( $NVE eq "1.3.6.1.4.1.46.877" )
{
for (@ARCSERVE)
{
 $contact=$_;
if (/\./)
 {
   `echo 'Subject:ArcServe alert from Netview' >/tmp/tmpmsg`;
   `echo '$eventmessage' >>/tmp/tmpmsg`;
   `mail $contact </tmp/tmpmsg`;

print " $NVT: Emailed ArcServe Contact ${contact} -> '$eventmessage'\n";
 }
else
 {
`nvpage $contact  ArcServe '$eventmessage'`;
print " $NVT: Paged ArcServe Contact ${contact} -> '$eventmessage'\n";
 }
print "---------------------------------------------------------\n";
}
}



# Handle Domino Traps
# The Following variables are contained within Domino traps
# NVATTR_1 ->
# NVATTR_2 ->
# NVATTR_3 ->
# NVATTR_4 ->
# NVATTR_5 -> Trap Message
# NVATTR_6 ->
# NVATTR_7 ->
# NVATTR_8 ->
# NVATTR_9 ->

if ( $NVE eq "1.3.6.1.4.1.334.72" )
{
for (@DOMINO)
{
 $contact=$_;
 if (/\./)
 {
   `echo 'Subject:Domino alert from Netview' >/tmp/tmpmsg`;
   `echo '$eventmessage' >>/tmp/tmpmsg`;
   `mail $contact </tmp/tmpmsg`;

print " $NVT: Emailed Domino Contact ${contact} -> '$eventmessage'\n";
 }
else
 {
`nvpage $contact '$eventmessage'`;
print " $NVT: Paged Domino Contact ${contact} -> '$eventmessage'\n";
 }
print "---------------------------------------------------------\n";


}
}


# Handle Netware Alarm & NDS Traps
# The Following variables are contained within Domino traps
# NVATTR_1 ->
# NVATTR_2 ->
# NVATTR_3 ->
# NVATTR_4 ->
# NVATTR_5 -> Trap Message
# NVATTR_6 ->
# NVATTR_7 ->
# NVATTR_8 ->
# NVATTR_9 ->

if ( $NVE eq "1.3.6.1.4.1.23.2.10" || $NVE eq "1.3.6.1.4.1.23.2.34" )
{
for (@NETWARE)
{
 $contact=$_;
if (/\./)
 {
   `echo 'Subject:Netware alert from Netview' >/tmp/tmpmsg`;
   `echo '$eventmessage' >>/tmp/tmpmsg`;
   `mail $contact </tmp/tmpmsg`;

print " $NVT: Emailed Netware Contact ${contact} -> '$eventmessage'\n";
 }
else
 {
`nvpage $contact  Netware  '$eventmessage'`;
print " $NVT: Paged Netfinity Contact ${contact} -> '$eventmessage'\n";
 }
print "---------------------------------------------------------\n";
}
}

<Prev in Thread] Current Thread [Next in Thread>
  • Here is a script to extract trapd.conf event messages for paging /mail., Mark van Kerkwyk <=

Archive operated by Skills 1st Ltd

See also: The NetView Web