Hi,
All 

I want to send SNMP trap when some value is set into variable with OID
example_string_oid,defined below.
I have written the code as below.
where example_string_oid is OID of my variable.

-->For sending & receiving TRAPs i am using net-snmp-5.0.6.

/* local variable declaration in write method of variable whose OID is
        example_string_oid */
 
static netsnmp_variable_list var_trap;
static netsnmp_variable_list var_obj;
char example_str[]="Trap sent by XYZ";


oid             objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0
                                        };     /* snmpTrapOID.0 */
oid             demo_trap[] = { 1, 3, 6, 1, 4, 1, 999, 1, 5 }; 
                                /*demo-trap */
oid             example_string_oid[] = { 1, 3, 6, 1, 4, 1, 999, 1, 5 ,0
                                        };

/*code written in COMMIT case of write method of variable whose OID is
        example_string_oid*/

        /*
         * trap definition objects 
         */

        var_trap.next_variable = &var_obj;      /* next variable */
        var_trap.name = objid_snmptrap; /* snmpTrapOID.0 */
        var_trap.name_length = sizeof(objid_snmptrap) / sizeof(oid);   
                /* number of sub-ids */
        var_trap.type = ASN_OBJECT_ID;
        var_trap.val.objid = demo_trap; /* demo-trap objid */
        var_trap.val_len = sizeof(demo_trap);   /* length in bytes (not
                                                number of subids!) */


        /*
         * additional objects 
         */


        var_obj.next_variable = NULL;   /* No more variables after this
                                                one */
        var_obj.name = example_string_oid;
        var_obj.name_length = sizeof(example_string_oid) / sizeof(oid);
        /* number of sub-ids */
        var_obj.type = ASN_OCTET_STR;   /* type of variable */
        var_obj.val.string = example_str;       /* value */
        var_obj.val_len = strlen(example_str);
       
        send_v2trap(&var_trap);
       

-->I am receiving trap by starting SNMP Trap daemon with options as
bellow.

#:snmptrapd -P -F "TIME=%02.2h:%02.2j:%02.2k  TRAP:%W.%q  from %b\n"

where
     -P :   Print formatted incoming traps to stderr.
     -F FORMAT :When  logging  to standard output, use the format in the
string FORMAT.
       string for FORMAT i had used is

        "TIME=%02TIME=%02.2h:%02.2j:%02.2k  TRAP:%W.%q from %b\n"
      
        where 
                 %h : current hour on the local system

                 %j : current minute on the local s%j  current minute
on                     the
local system

                 %k : current second on the local system

                 %W : trap description

                 %q : trap sub-type (numeric, in decimal)
 
                 %b : PDU source address

Problem:
 snmp trap daemon is not recieving any traps.

Thank you

regards
Harikumar



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to