From 6f3317f40e457286de194b0aeaf98f3099a842b5 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 7 Apr 2006 15:19:43 +0000 Subject: Change latency to MS. Change 'pingData' MIB to simple 'ping' --- module/Makefile.am | 2 +- module/bsnmp-ping.c | 26 ++++++++++++++++++++------ module/ping-tree.def | 8 ++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/module/Makefile.am b/module/Makefile.am index c1b6d41..49845d9 100644 --- a/module/Makefile.am +++ b/module/Makefile.am @@ -9,8 +9,8 @@ snmp_ping_la_SOURCES = ping_tree.c ping_tree.h ping_oid.h \ bsnmp-ping.c ping_tree.c: ping-tree.def + gensnmptree -e ping > ping_oid.h < ping-tree.def gensnmptree -p ping_ < ping-tree.def - gensnmptree -e pingData > ping_oid.h < ping-tree.def CLEANFILES = ping_tree.* \ ping_oid.h diff --git a/module/bsnmp-ping.c b/module/bsnmp-ping.c index d63e0a9..012db5c 100644 --- a/module/bsnmp-ping.c +++ b/module/bsnmp-ping.c @@ -67,7 +67,7 @@ static struct lmodule *module; /* OIDs */ -static const struct asn_oid oid_ping = OIDX_pingData; +static const struct asn_oid oid_ping = OIDX_ping; /* the Object Resource registration index */ static u_int reg_index = 0; @@ -127,9 +127,23 @@ static void emsg(const char *format, ...) { va_list va; - va_start(va, format); - vsyslog(LOG_ERR, format, va); - va_end(va); + va_start (va, format); + vsyslog (LOG_ERR, format, va); + va_end (va); +} + +static uint64_t +get_current_ms () +{ + struct timeval tv; + + if (gettimeofday (&tv, NULL) < 0) { + emsg ("couldn't get current time: %s", strerror (errno)); + return get_ticks () * 10; + } + + return ((uint64_t)(tv.tv_sec)) * 1000 + + ((uint64_t)(tv.tv_usec)) / 1000; } /* ----------------------------------------------------------------------------- @@ -180,7 +194,7 @@ process_icmp (u_char *packet, int len, struct sockaddr_in *from) triptime = -1; - ctime = get_ticks (); + ctime = get_current_ms (); #ifndef icmp_data tp = &icp->icmp_ip; @@ -323,7 +337,7 @@ ping_fire (void *user_data) icp->icmp_id = ping->index; /* ID */ /* Include the current time in the packet */ - ptime = get_ticks (); + ptime = get_current_ms (); memcpy (icmp_packet + ICMP_MINLEN, &ptime, sizeof (ptime)); CLR (ping->ck_table, seq % MAX_DUP_CHK); diff --git a/module/ping-tree.def b/module/ping-tree.def index 3d50578..e80506a 100644 --- a/module/ping-tree.def +++ b/module/ping-tree.def @@ -3,7 +3,7 @@ (1 enterprises (12325 fokus (1 begemot - (204 pingData + (204 ping (0 pingCount INTEGER op_ping GET) (1 pingEntry : INTEGER op_pingentry (0 pingIndex INTEGER GET) @@ -14,9 +14,9 @@ (10 pingResponses INTEGER GET) (11 pingDropped INTEGER GET) - (12 pingLatencyAvg TIMETICKS GET) - (13 pingLatencyMin TIMETICKS GET) - (14 pingLatencyMax TIMETICKS GET) + (12 pingLatencyAvg INTEGER GET) + (13 pingLatencyMin INTEGER GET) + (14 pingLatencyMax INTEGER GET) ) ) ) -- cgit v1.2.3