Re: how can I get the time when trap happened
Dave Shield <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <CAKoMtGZ-WjgWEjjUrT653wUM6+KzyhTuwEDfthUoBCBcZriQgg@mail.gmail.com> |
2012/2/1 朱飞 <[email protected]>: > In the standard of snmp trap, time is sent on sysUpTime which is the time > since snmp agent initialized, but how can I get the time when trap happened, > like "2012-1-31 8:57:47.24"? The first thing to realise is that the box sending the trap may well not know what the current "wall clock" time actually is when it sends the trap message. SNMP was originally designed to be as simple as possible (so it could be used to monitor small embedded systems, as well as general purpose computers). One of the decisions was deliberately *not* to use wall-clock timestamps within the protocol - since this would require every box being monitored to be configured with the current time, whenever it was powered on. One approach would be to use the time that you *received* the trap (which is likely to be very soon after the trap was sent). The trap receiver is typically a general purpose system, which will have this information - even if the network boxes sending the traps may not. An alternative would be to query the box for: a) the current value of sysUpTime.0, and b) the current value of hrSystemDate.0 (if available) This would then allow you to calculate the base date-and-time when the agent last started, and hence map the trap's sysUpTime.0 into a wall-clock time. Note that this will be the time from the point of view of the sending box, rather than the notification receiver. In a large network (e.g. one covering several countries), these may well be in different timezones, and hence the reported times could appear different. If you can control the code that generates the trap, it might even be possible to include hrSystemDate.0 in the payload varbind list, which would give you the sending date/time information immediately. Dave ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ 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