GUYS -
THANKS FOR ALL THE INPUT BUT I DO NOT CARE WHAT THE TRAPD.CONF FORMAT LOOKS
LIKE. I know it is wrong, I have already modified it to display 5
arguments.
I only
care about the data passed into a script - how many variables are passed as
environment variables in an action node call of a script. When you use an action
node, you do not recieve the variables as command line type arguments they are
only available via enviornment variables. Here is a script that deals with frame
relay DLCIs:
#!/usr/bin/perl #
**************************************************************** # *** Frame
Relay Trap
Processor
*** # **************************************************************** #
*** Status: invalid
(1)
*** # *** active
(2)
*** # *** inactive
(3)
*** #
***
*** # *** frDLCIStatusChange
TRAP-TYPE
*** # *** ENTERPRISE
frame-relay
*** # *** VARS
{frCircuitIfIndex,frCircuitDlci,frCircuitState } *** # ***
DESCRIPTION
*** # *** "This trap indicates that the
indicated Virtual *** #
*** Circuit has changed state.
It has either been *** #
*** created or invalidated, or has
toggled between *** #
*** the active and inactive
states."
*** #
****************************************************************
# open (TRAPDATA,
">>/usr2/SysLogTraps.log");
@data = "">$TimeStamp = join('
',@data[1],@data[2],@data[3]);
$Origin = $ENV{'NVA'}; $frCircuitIndex =
$ENV{'NVATTR_1'}; $frCircuitDLCI = $ENV{'NVATTR_2'}; $frCircuitState
= $ENV{'NVATTR_3'};
if ($frCircuitState == 1 ) { # *** DLCI Status Change to
Invalid *** $Status = "Invalid"; $MsgText = join("
",$TimeStamp,"Router: ",$Origin," DLCI: ",$frCircuitDLCI," is now
",$Status,"\n"); `echo '$MsgText'
| mailx -s '$MsgText' scott_barr\@csgsystems.com`; print TRAPDATA
$MsgText; }
elsif ($frCircuitState == 2 ) { # *** DLCI Status Change to
Active *** $Status = "Active"; $MsgText = join("
",$TimeStamp,"Router: ",$Origin," DLCI: ",$frCircuitDLCI," is now
",$Status,"\n"); `echo '$MsgText'
| mailx -s '$MsgText' scott_barr\@csgsystems.com`; print TRAPDATA
$MsgText; }
elsif ($frCircuitState == 3 ) { # *** DLCI Status Change to
Active *** $Status = "Inactive"; $MsgText = join("
",$TimeStamp,"Router: ",$Origin," DLCI: ",$frCircuitDLCI," is now
",$Status,"\n"); `echo '$MsgText'
| mailx -s '$MsgText' scott_barr\@csgsystems.com`; print TRAPDATA
$MsgText; }
`echo '$MsgText' >> /usr2/router_avail.log`;
close (TRAPDATA);
Notice that in the beginning of the
script the variables from the trap are pulled out using Environment variables.
There is (that I know of) NO environment variable that tells you how many
environment variables have been passed. Thus, I cannot tell if there are 3, 4 or
5 arguments in the trap. I apologize if my
previous messages haven't made this clear and if my frustration level seems to
be rising.
The simple stupid
way is to define the format for the specific trap in trapd.conf as "$*", which
shows all arguments, no matter how many are sent..
As you know, the format error comes about because in
your trapd description you have specified a particular variable that is not
there such as $4 when only 3 were sent..
Regards, ken
|