This would be really cool but i also suspect it's too late for 5.6.
I also wonder if there would be a way to do this more generically for
all the apps.
ID: 3054817
Last Update: Attachment added ( nightcoding )
Details:
I would consider it desirable to have snmpwalk output the response time
for every single request, not only for the complete walk as it is
currently implemented via the -Ct option.
So I suggest the following patch introducing an option -CT to do this.
It outputs to stdout like this:
0.000193 s: SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00
0.000954 s: SNMPv2-MIB::sysORUpTime.8 = No more variables left in this MIB View
(It is past the end of the MIB tree)
Would this format fit into the larger concepts of net-snmp?
Index: snmpwalk.c
===================================================================
--- snmpwalk.c (Revision 19354)
+++ snmpwalk.c (Arbeitskopie)
@@ -69,6 +69,7 @@
#define NETSNMP_DS_WALK_DONT_CHECK_LEXICOGRAPHIC 3
#define NETSNMP_DS_WALK_TIME_RESULTS 4
#define NETSNMP_DS_WALK_DONT_GET_REQUESTED 5
+#define NETSNMP_DS_WALK_TIME_RESULTS_SINGLE 6
oid objid_mib[] = { 1, 3, 6, 1, 2, 1 };
int numprinted = 0;
@@ -90,7 +91,9 @@
fprintf(stderr,
"\t\t\t c: do not check returned OIDs are increasing\n");
fprintf(stderr,
- "\t\t\t t: Display wall-clock time to complete the request\n");
+ "\t\t\t t: Display wall-clock time to complete the walk\n");
+ fprintf(stderr,
+ "\t\t\t T: Display wall-clock time to complete each request\n");
fprintf(stderr, "\t\t\t E {OID}: End the walk at the specified OID\n");
}
@@ -151,6 +154,11 @@
case 'E':
end_name = argv[optind++];
break;
+
+ case 'T':
+ netsnmp_ds_toggle_boolean(NETSNMP_DS_APPLICATION_ID,
+ NETSNMP_DS_WALK_TIME_RESULTS_SINGLE);
+ break;
default:
fprintf(stderr, "Unknown flag passed to -C: %c\n",
@@ -180,7 +188,7 @@
int status;
int check;
int exitval = 0;
- struct timeval tv1, tv2;
+ struct timeval tv1, tv2, tv_a, tv_b;
netsnmp_ds_register_config(ASN_BOOLEAN, "snmpwalk", "includeRequested",
NETSNMP_DS_APPLICATION_ID,
@@ -202,6 +210,10 @@
NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_WALK_TIME_RESULTS);
+ netsnmp_ds_register_config(ASN_BOOLEAN, "snmpwalk", "timeResultsSingle",
+ NETSNMP_DS_APPLICATION_ID,
+ NETSNMP_DS_WALK_TIME_RESULTS_SINGLE);
+
/*
* get the common command line arguments
*/
@@ -297,8 +309,12 @@
/*
* do the request
*/
+ if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_WALK_TIME_RESULTS_SINGLE))
+ gettimeofday(&tv_a, NULL);
status = snmp_synch_response(ss, pdu, &response);
if (status == STAT_SUCCESS) {
+ if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_WALK_TIME_RESULTS_SINGLE))
+ gettimeofday(&tv_b, NULL);
if (response->errstat == SNMP_ERR_NOERROR) {
/*
* check resulting variables
@@ -314,6 +330,10 @@
continue;
}
numprinted++;
+ if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_WALK_TIME_RESULTS_SINGLE))
+ fprintf(stdout, "%f s: ",
+ (double) (tv_b.tv_usec - tv_a.tv_usec)/1000000 +
+ (double) (tv_b.tv_sec - tv_a.tv_sec));
print_variable(vars->name, vars->name_length, vars);
if ((vars->type != SNMP_ENDOFMIBVIEW) &&
(vars->type != SNMP_NOSUCHOBJECT) &&
--
Wes Hardaker
Please mail all replies to [email protected]
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders