Re: Is NOTIFICATION TYPE necessary to send trap?

"Raghavendra Prasad" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Dear Wes,

   Could you please be bit more explicit. I seem to have implemented
what have you suggested in the following small example it works and
successfully sends the traps

I am sending trap for the following mib node:
configType OBJECT-TYPE
	SYNTAX INTEGER
	{
				standard ( 1 ),
				high-power ( 2 )
	}
	ACCESS  read-write
	STATUS  mandatory
	DESCRIPTION
	"Standard = Solid state power amplifier High-power = Dual klystron
power amplifier
  1 - standard
  2 - high-power"
	::= { config 1}



This is the piece of code that sends the trap

void
init_config_trap(void)
{
    config =  get_config_pointer();

    snmp_alarm_register(5, /* seconds */
                        SA_REPEAT, /* repeat (every 5 seconds). */
                        send_configTypeNotification_trap, /* our callback */
                        NULL /*No callback data needed */
        );

}

int
send_configTypeNotification_trap( void )
{
    oid snmptrap_oid[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
    netsnmp_variable_list  *var_list = NULL;
    oid configType_oid[] = { 1,3,6,1,4,1,6212,2,2,1, 0 };

      snmp_varlist_add_variable(&var_list,
        snmptrap_oid, OID_LENGTH(snmptrap_oid),
        ASN_OBJECT_ID,
        configType_oid, sizeof(configType_oid));



    /*
     * Add any objects from the trap definition
     */
    snmp_varlist_add_variable(&var_list,
        configType_oid, OID_LENGTH(configType_oid),
        ASN_INTEGER,
           (u_char *)&(config->configType), /* Set an appropriate
value for configType */
           sizeof(config->configType) );

    /*
     * Send the trap to the list of configured destinations
     *  and clean up
     */
   DEBUGMSGTL(("config", "Sending the configType trap \n"));

    send_v2trap( var_list );
    snmp_free_varbind( var_list );

    return SNMP_ERR_NOERROR;
}



In the above example I am assuming that  "snmptrap_oid[] = {1, 3, 6,
1, 6, 3, 1, 1, 4, 1, 0};"  is the generic OID you were refering to in
your reply.

Does this working piece of code correctlty intreprete your  previous
reply?? kindly confirm.

With regards,
Raghavendra

On 9/4/08, Wes Hardaker <[email protected]> wrote:
>>>>>> On Wed, 3 Sep 2008 11:13:58 +0200, "Raghavendra Prasad"
>>>>>> <[email protected]> said:
>
> RP> is NOTIFICATION TYPE  a must to send traps? Can't I send a trap with
> RP> just a normal MIB node OID,  instead of combining normal OID with
> RP> NOTIFICATION OID(like in examples/notification.c file) - if so how? In
> RP> our project this option will be a great boon
>
> You can use any OID, technically, as a notification OID...  But no, a
> notification "type" is defined by an OID that represents it.  You could
> always define a generic OID and just send extra varbind data within it,
> but you have to, at a minimum, define an OID that represents the
> notification you want to send.
> --
> Wes Hardaker
> Sparta, Inc.
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.