How to create CA SystemEDGE Action with a Perl or shell script utilizing the sendtrap executable.

Document ID : KB000023511
Last Modified Date : 14/02/2018
Show Technical Document Details

Question: 

How do I use a PERL or Shell script within CA SystemEDGE as a watchers action and utilize the sendtrap command within that action script?

Environment:  

UNIX/LINUX ANY

Answer: 

Perl scripts can be used as Actions within a sysedge agent monitoring entry. 

This example script will send a trap to the ip address: 10.10.10.10 with a Generic trap Type of 6, a Specific Trap Type of 8888, and with one varbind -- OID: 1.3.6.1.4.1.546.1.1.1 Type: string Value: "messageText"

 

===== start  example perl script ===============================

#!/usr/bin/perl
use IPC::Open2;
use Symbol;

my $pid;
my $writer = gensym(); # We create symbols here
my $reader = gensym(); # Because we are using old perl :-(
eval{
$pid = open2($reader, $writer,"/opt/CA/SystemEDGE/bin/sendtrap 10\.10\.10\.10 6 8888")
};
$@ && die "@!\n";
# Send args to opened sendtrap proc
print $writer ("1\.3\.6\.1\.4\.1\.546\.1\.1\.1 string \"messageText\"\n");
print $writer ("\cZ");
close $writer;

==== end example perl script ==================================

 

 Below is another example that will Send a made-up enterprise specific trap using a shell "here doc" to supply the var bindings. 

===== start  example shell script ===============================

#!/bin/sh
#
# Include bin directory for sendtrap in PATH variable
#
PATH=/opt/CA/SystemEDGE/bin:$PATH
#
#  Send a made-up enterprise specific trap using a shell "here doc" to supply
#  the var bindings.
#
sendtrap localhost 6 1234 <<EOF
1.3.6.1.4.1.9999.1.1.0 string this is an example oid
1.3.6.1.4.1.9999.1.8.0 string this is another example oid
EOF
#
# Send the same trap as above, only use "echo" to pipe the var bindings
# in via standard input.  Need 2 echo commands, so group them in a subshell.
#
(
 echo 1.3.6.1.4.1.9999.1.1.0 string this is an example oid
 1.3.6.1.4.1.9999.1.8.0 string this is another example oid
) - sendtrap localhost 6 1234

===== end  example shell script ===============================

Actions can be specified as part of a CA SystemEDGE watcher by specifying it in the sysedge.cf in the proper operand.

Sample Process watcher format:

watch procgroup <regexpr> <index> <flags> <interval> <descr> <action> <severity>