0 Replies Latest reply: Dec 30, 2008 12:59 PM by Susan Miller RSS

Using PatrolCli to send SNMP traps

Susan Miller

How to use PatrolCli to send SNMP traps?



The following procedure is for Unix systems. It should be possible to perform similar
function from other OS types (i.e. NT, OpenVMS, and OS2).

1. Create the following PSL script: send_trap.psl

# PSL Serial No.: 856810495
host = "<hostname>";
tport = "162";
arg1 = host."/".tport;
arg2 = host." .1.3.6.1.4.1.1031 6 1 1";
print(snmp_trap_send(arg1,arg2,".1.3.6.1.4.1.1031.1 string test",
".1.3.6.1.4.1.1 031.2 string test 2",
".1.3.6.1.4.1.1031.3 string test 3",".1.3.6.1.4.1.1031.4 string test 4"));


Note: Replace <hostname> with the actual hostname.

2. Create a PatrolCli input file that executes the PSL: cli_input

user <username> <password>
open <hostname> <port>
execpsl -f <full_path>/send_trap.psl

Note: Replace <username>, <password>, and <full_path> with the
appropriate values.

3. Execute the PSL:

a. Source the Patrol startup script.

- . ./patrolrc.sh (ksh)
- source .patrolrc (csh)

b. Invoke PatrolCli and use cli_input as input:

PatrolCli -f cli_input

Note: It would be good to supply the full path to the cli_input.

4. SNMP trap that is received when PatrolCli is executed as described above:

172.21.1.223 1.3.6.1.4.1.1031 1 1000500
1.3.6.1.4.1.1031.1 string 4 test
1.3.6.1.4.1.1031.2 string 6 test 2
1.3.6.1.4.1.1031.3 string 6 test 3
1.3.6.1.4.1.1031.4 string 6 test 4

5. The following PSL can be cut and pasted into a PSL task on the PatrolAgent
to which the SNMP trap is directed and used for testing.

snmp_trap_ignore();
ret = snmp_trap_listen();
if ( ret == "") {
ret = "NULL";
}
printf("Listen status = %s Errno = %s\n", ret, errno);
print("Running...\n");
res = snmp_trap_receive();
if(res == "") {
print("TRAP RECEIVE ERROR\n");
} else {
printf(res);
}

while (1)
{ res = snmp_trap_receive();
if(res == "") {
print("TRAP RECEIVE ERROR\n");
} else {
printf(res);
}
}
snmp_trap_ignore();

6. In order for any of this to work, SNMP has to be functioning on the Agent that is being
used to trigger the SNMP trap and on the Agent that is being used to listen for the SNMP
trap if this is being used.

a. %PSL print(snmp_agent_config()); needs to say SNMP Support is
Active.
b. %PSL print(snmp_agent_start()); will start it if SNMP support
is not active. If this returns OK, everything is fine. If

it returns ERR, you've got trouble.