Operating System - OpenVMS
1827452 Members
4806 Online
109965 Solutions
New Discussion

sending snmp traps in openVMS

 
SAMI AHMAD
Regular Advisor

sending snmp traps in openVMS

hi !
I can send snmp traps from a dcl command job as follows , my question is can anyone guide me to do the same from DEC C ?


"
snmp_trapsnd 1.3.6.1.6.3.1.1.4.1.0 local 0 0 0 "-v2c" -h 10.100.10.112 -D "TEST MESSAGE FROM node1 USING TCP SNMP TRAP"
18 REPLIES 18
Steven Schweda
Honored Contributor

Re: sending snmp traps in openVMS

You mean other than system() or LIB$SPAWN()?

Find some source code for snmp_traps[e]nd,
and steal it?

(Read the RFC, and write your own?)
Hoff
Honored Contributor

Re: sending snmp traps in openVMS

If what is included in the manual "HP TCP/IP Services for OpenVMS SNMP Programming and Reference" and in the SNMP-related RFCs is insufficient for your requirements, then look to Google and look to the ITRC discussion where somebody last asked this:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1247180

including at

http://sourceforge.net/projects/net-snmp/

Also:

http://64.223.189.234/node/1117
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

hi Hoff !

in your earlier reponse to this topic you had mentioned 'or you could haul over netsnmp or one of the perl modules' ... how can I use perl module to send the snmp trap ?
Martin Vorlaender
Honored Contributor

Re: sending snmp traps in openVMS

>>>
'or you could haul over netsnmp or one of the perl modules' ... how can I use perl module to send the snmp trap ?
<<<

There's Net::SNMP ,see e.g.

http://search.cpan.org/~dtown/Net-SNMP-5.2.0/lib/Net/SNMP.pm#trap()_-_send_a_SNMP_trap_to_the_remote_manager

HTH,
Martin

Disclaimer: I haven't tried it, but the requirements make it look doable.
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

hi Martin !
this url is not working :(
can you please check ? also is NET:SNMP is a third party product ?
Martin Vorlaender
Honored Contributor

Re: sending snmp traps in openVMS

Ahmad,

the URL worked when I clicked it. If it doesn't work for you, go to http://search.cpan.org/ and enter Net::SNMP (that's TWO colons) in the search box.

Net::SNMP is a Perl module that needs a few other prerequisite modules to be installed, but it does not (AFAICT) rely on other libraries like net-snmp.

cu,
Martin
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

Thanks Martin!

ok the url is working now for me ,below is the function to send trap but I dont see anywhere how to specify the msg you want to send as trap ? this is the dcl command I use to send trap msg :

snmp_trapsnd 1.3.6.1.6.3.1.1.4.1.0 local 0 0 0 "-v2c" -h 10.100.10.112 -D "TEST MESSAGE"

how can I send the above test msg to the server using the function below ?

$result = $session->trap(
[-delay => $seconds,] # non-blocking
[-enterprise => $oid,]
[-agentaddr => $ipaddress,]
[-generictrap => $generic,]
[-specifictrap => $specific,]
[-timestamp => $timeticks,]
-varbindlist => \@oid_value,
);
Steven Schweda
Honored Contributor

Re: sending snmp traps in openVMS

How is a perl method better than, say,
snmp_trapsnd + system() "from DEC C"?
SAMI AHMAD
Regular Advisor

Re: sending snmp traps in openVMS

hi Steven !

I dont know of a way to send snmp trap from dECC .. thats why i started this thread. are you saying its possible ? tell me how
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.