eSNMP API Routines esnmp_sysuptime
esnmp_sysuptime
Converts UNIX system time obtained from gettimeofday into a value with the same time base as sysUpTime.
Format
unsigned int esnmp_sysuptime ( struct timeval *timestamp ) ;
Argument
timestamp
A pointer to struct timeval, which contains a value obtained from the gettimeofday system call. The structure is defined in include/sys/time.h.
A null pointer means return the current sysUpTime.
Description
This routine provides a mechanism to convert UNIX timestamps into eSNMP TimeTicks. The function returns the value that sysUpTime held when the passed timestamp was now.
This routine can be used as a TimeTicks data type (the time since the eSNMP master agent started) in hundredths of a second. The time base is obtained from the master agent in response to esnmp_init, so calls to this function before that time will not be accurate.
Return Values
0 | An error occurred because a gettimeofday |
| function failed. Otherwise, timestamp contains |
| the time in hundredths of a second since the |
| master agent started. |
Example |
|
#include <sys/time.h> #include <esnmp.h> struct timeval timestamp;
gettimeofday(×tamp, NULL);
.
.
.
o_integer(vb, object, esnmp_sysuptime(×tamp));