Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

sending snmp traps in openVMS

 
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

Steven !
if you can help me write this snmp_trap for DEC C i would be greatful. First of all where do I get the source code of snmp_trapsend?
Steven Schweda
Honored Contributor

Re: sending snmp traps in openVMS

I know approximately nothing about SNMP. I
_do_ know how to run a program using the
system() function.

show symbol snmp_trapsnd

alp $ type snmp.c
#include
#include

int main( void)
{
int sts;
char *cmd = "mcr tcpip$snmp_trapsnd.exe\
1.3.6.1.6.3.1.1.4.1.0 local 0 0 0 -v2c -h 10.100.10.112";

printf( " cmd: >%s<.\n", cmd);
sts = system( cmd);

printf( " sts = %%x%08x.\n", sts);
}

alp $ cc snmp
alp $ link snmp
alp $ run snmp
cmd: >mcr tcpip$snmp_trapsnd.exe 1.3.6.1.6.3.1.1.4.1.0 local 0 0 0 -v2c -h 10.1
00.10.112<.
sts = %x00000001.

Around here, no one seems to know what "-D"
does (with or without quotation marks):

ALP $ mcr tcpip$snmp_trapsnd.exe 1.3.6.1.6.3.1.1.4.1.0 local 0 0 0 -v2c -h 10.10
0.10.112 -D "TEST MESSAGE FROM node1 USING TCP SNMP TRAP"
Unexpected arguments.
#snmp_trapsnd enterprise agent-address generic specific timeticks
[-v version] [-c community] [-h host] [-p port] [-tcp] {variable [type value]}
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

hi Steven !
as you see below without the "D" argument snmp command does not work . I found out somewhere someone using it thats how I learned. so assuming this is the right command I have to use how can I put it in the C program cause its using double quotes ?

This is a perfectly working command and
we are using it .

NODE1$ snmp_trapsnd 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0
"D" " TEST MSG "

if I omit the "D" or dont use it the command
does not work.

NODE1$ snmp_trapsnd 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0
" " " TEST MSG "
Unknown data type code
Invalid variable list.

SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

I tried to construct the command string as follows but no luck :

char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 "D" "test"";

SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

I fixed the issue as follows :

char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\" \"< \"";

now my second problem ... i need to pass the message part as parameter .. how can I do this ?
Steven Schweda
Honored Contributor

Re: sending snmp traps in openVMS

> [...] how can I do this ?

sprintf()? strcat()?

How much don't you know about C programming?
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

haha not much ..i was googling it now
Hoff
Honored Contributor

Re: sending snmp traps in openVMS

Sami, if you're going to be working here, get thee to a C programming class, and quite possibly into an IP networking class, too. The system() call is one of the more commonly-used routines used when coding in C, for instance. It appears that somebody (your boss?) has tossed you into the very deep end of the proverbial pool here (was it those pesky programmers you've referred to? or your manager?), and you really need some familiarity with IP and C before you get too far or too frustrated here.

If it's your manager that tossed you into this proverbial pool, then this is your opportunity to request training or books or more formal assistance (which helps your manager deliver on his/her commitments, and it also helps you) on these topics. I would strongly encourage you to work with your manager here, rather than with ITRC. ITRC really isn't going to help you through this, though. That's your manager's job.

There's no API for sending traps on OpenVMS, it's done through a C or Perl or Lua or other SNMP-related library that you must port over (or find somebody to port it for you) and there's no source code for the snmp_trapsnd tool (ask HP for that).

There's some basic SNMP source code stuff in

SYS$COMMON:[SYSHLP.EXAMPLES.TCPIP.SNMP]

but I'd not expect that code to get anywhere near what you're looking for here.

Your application programming interface is going to require the Perl or Lua or C or (pick your preferred OpenVMS language) SNMP library. A library which you're going to have to port, or get somebody to port for you.

I've had various tussles with TCP/IP Services and C in this area over the years. It's not a very forgiving area.

Did some quick digging using Google and there's no obvious solution here that doesn't also involve a library such as net-snmp. The snmptrap command in Mac OS X source pool is based on a C module that looks to call into the net-snmp library, for instance. And the Lua stuff all uses a LuaSNMP library. You could certainly use the RFC to build the full RFC-specified data and toss that over, but (for now) the system() of the command is almost certainly the easiest approach.

As for the "-d" switch on the command (I prefer to quote those switches, unless I know I'm running with the ODS-5 extended parsing enabled within DCL), that's a packet dump request, based on what's in the documentation:

http://h71000.www7.hp.com/doc/82final/6530/6530pro_005.html

I'd guess that you don't have extended parsing enabled here, and thus that the usual (and somewhat weird) C argument processing rules apply. DCL upcases its stuff, and the switch and the rest of the command is converted to lowercase when gets to C, so your -D is showing up at snmp_trapsnd as the -d switch.

And again, work with your manager. That'll help you get trained; it'll help your manager deliver on his/her commitments through your improved skills.

SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

thanks everyone for the valuable feedback. we solved this problem by putting the snmp command in a dcl script and then calling that dcl script via lib$spawn in C.