I played a little bit with this also. Here is a program that you can start from:
*%%%* Compiling instructions -------------------------+
*%%% crtrpgmod
*%%% module(%LIBO/%OBJ)
*%%% srcfile(%LIBS/%FIC)
*%%% srcmbr(%MBR)
*%%% DBGVIEW(*LIST)
*%%%#
*%%% crtpgm
*%%% pgm(%libo/%obj)
*%%% module(*pgm)
*%%% actgrp(snmp)
*%%%#
*%%% dltmod
*%%% module(%libo/%obj)
*%%%&
*******************************************************
*dftactgrp(*no) bnddir('QC2LE')
bnddir('QC2LE')
d Translate PR ExtPgm('QDCXLATE')
d Length 5P 0 const
d Data 32766A options(*varsize)
d Table 10A const
d getsnmp pr 10i 0 extproc('snmpGet')
d pdu_ptr * value
d host_ptr * value options(*string)
d timeout 10i 0 value
d comm_ptr * value options(*string)
d comm_len 10i 0 value
d getnextsnmp pr 10i 0 extproc('snmpGetnext')
d pdu_ptr * value
d host_ptr * value options(*string)
d timeout 10i 0 value
d comm_ptr * value options(*string)
d comm_len 10i 0 value
d varBind ds
d next * inz(*NULL)
d pOid * inz(%addr(oid))
d asnType 1a
d valLen 10i 0 inz(50)
d valPtr * inz(%addr(value))
d snmppdu ds
d pduType 1a
d errSts 10i 0
d errIdx 10i 0
d pVarBind * inz(%addr(varBind))
d x s 10i 0
d @null c const(x'00')
d asn_unknown c const(x'00')
d asn_integer c const(x'02')
d asn_string c const(x'04')
d asn_null c const(x'05')
d asn_object_id c const(x'06')
d asn_ipaddress c const(x'40')
d asn_counter c const(x'41')
d asn_gauge c const(x'42')
d asn_timeticks c const(x'43')
d asn_opaque c const(x'44')
d operation s 7a
d p@value s 50a
d p@valuei s 10s 0
d value s 50a
d p@oid s 50a
d oid s 50a
d host s 100a
d cmty s 10a
d valueds ds
d DSvalue 50a
d DSvaluei 10i 0 overlay(dsvalue)
c *entry plist
c parm host
c parm cmty
c parm operation
c parm p@oid
c parm p@value
c clear value
c callp Translate(%len(value):value:'QTCPASC')
c callp Translate(%len(%trim(cmty)):cmty:'QTCPASC')
c eval oid = %trim(p@oid) + @null
c eval host = %trim(host) + @null
c if operation = 'GET'
c eval x = getsnmp(%addr(snmppdu) :
c %addr(host) :
c 5:%addr(cmty):
c %len(%trim(cmty)))
c else
c eval x = getnextsnmp(%addr(snmppdu) :
c %addr(host) :
c 5:%addr(cmty):
c %len(%trim(cmty)))
c endif
c eval p@oid = %trim(oid)
c select
c asntype wheneq asn_unknown
c callp Translate(50:value:'QTCPEBC')
c eval p@value = value
c asntype wheneq asn_integer
c eval dsvalue = value
c eval p@value = %char(dsvaluei)
c asntype wheneq asn_string
c callp Translate(50:value:'QTCPEBC')
c eval p@value = value
c asntype wheneq asn_null
c callp Translate(50:value:'QTCPEBC')
c eval p@value = value
c asntype wheneq asn_object_id
c eval p@value = value
c asntype wheneq asn_ipaddress
c eval p@value = value
c asntype wheneq asn_counter
c eval dsvalue = value
c eval p@value = %char(dsvaluei)
c asntype wheneq asn_gauge
c eval dsvalue = value
c eval p@value = %char(dsvaluei)
c asntype wheneq asn_timeticks
c eval dsvalue = value
c eval p@value = %char(dsvaluei)
c asntype wheneq asn_opaque
c callp Translate(50:value:'QTCPEBC')
c eval p@value = value
c endsl
c return
Denis Robitaille
Directeur Service technique TI
CASCADES INC.
412 Marie Victorin
Kingsey falls(QuÃbec) Canada J0A 1B0
T : 819 363-6130
F : 819 363-6155
Jon S <rvrratjon@xxxxxxxxxxx> 5/21/2010 4:36 >>>
I have several projects with a couple of different customers that need me to use SNMP to check status and do updates via GetRequest and SetRequest to various appliances. I am not finding much in the way of RPG examples out there, some in C, but I know RPG can do it. Has anyone done this and can maybe throw me a bone? I am just not even sure where to start. I start reading the various documentation and after about 5 minutes, my brain is mush. Any help would be appreciated.
Thanks, Jon
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
As an Amazon Associate we earn from qualifying purchases.