Re: timeticks in second and send a easy trap
"Tako Chang" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
> On 17/12/2007, Tako Chang <[email protected]> wrote: > > > > I find that TimeTicks is a basic type in snmp > > > > but it uses "1/100 second" as its unit. > > > > > > > Simply define an INTEGER-valued object, and specify > > > a UNITS clause of "seconds". > > > > > > See (for example): > > > IP_MIB::ipReasmTimeout > > > > I querry ipReasmTimeout.0 and get IP-MIB::ipReasmTimeout.0 = INTEGER: 0 > > Actually, I want it to be parsed into a readable format like ?? Days ?? > hr > > ?? min ??sec > > That's something you will have to implement for yourself. > As far as basic SNMP is concerned, you have a choice > between the standard type TickTicks (in 1/100s), which > most toolkit should be able to interpret. > Or else an INTEGER-based value, which you will need > to convert into a suitable printable format yourself. There's > nothing standard that would give you that for one-second > measurement. > The closest would be the DateAndTime pseudo-type, > though this really refers to clock time, rather than time > intervals. Thanks very much^^ > > > > > > I define a trap in my MIB > > > > > > What is the actualy definition of the trap/notification? > > > > > flagEnable OBJECT-TYPE > > SYNTAX INTEGER{ > > enable(1), > > disable(2) > > } > > ACCESS read-write > > STATUS mandatory > > ::= { testMIB 1 } > > > > demoTrap TRAP-TYPE > > ENTERPRISE ipavSTBCommonTrap > > VARIABLES { > > flagEnable > > } > > DESCRIPTION "Send a message to the manager when the DHCP setting is > > chaged" > > ::= 1 > > So this MIB is written in SMIv1? > That's pretty much obsolete by now. You should really be looking at > writing MIBs in SMIv2 (i.e. NOTIFICATION-TYPE definitions) Sorry, I will amend it! But if i use NOTIFICATION-TYPE, can I send message as a SNMPv1 trap? I don't realize the relationship between SMIv2 and SNMPv2 > flagEnable is a global variable and can be access by MY_API > > My_registercb( testTrap() ) will register a callback to MY_API and when > the > > value of flagEnable > > is changed by MY_API, testTrap() will be executed. > > > > so, I plan to write send_easy_trap() in this function, > > "send_easy_trap" isn't really sufficient for your requirements here. > You should probably look at using 'send_enterprise_trap_vars()' > in order to specify your Enterprise OID value. > > Dave > [MIB] myMibTrap ::= { enterprise 920 } demoTrap NOTIFICATION-TYPE STATUS current DESCRIPTION "Send a message to the manager when the DHCP setting is chaged" ::= { myMibTrap 1 } [/MIB] int specific = 1; oid trapOid = { SNMP_OID_ENTERPRISES, 920 }; oid flagOid = { PRIVATE_OID_DHCP_FLAG }; struct variable_list varList; int testTrap_callback(int value) { printf("Send a trap!!!!"); varList.next_variable = NULL; varList.name = flagOid; varList.name_length = sizeof(flagOid); varList.type = ASN_INTEGER; varList.val = value; varList.val_len = sizeof(value); send_enterprise_trap_vars( SNMP_TRAP_ENTERPRISESPECIFIC, specific, trapOid, sizeof(trapOid), varList); } Is the above code right ? and does some useful function to set the variable_list ^^ ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ 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