From add941762db8b575003b050c3c59fed121ccbdbb Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 4 Oct 2007 08:44:41 +0200 Subject: [PATCH] snmp plugin: Print a warning if querying a host takes longer than the confiured interval. --- src/snmp.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/snmp.c b/src/snmp.c index 3c8a4fcb..0c2b79af 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1103,10 +1103,12 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data) for (vb = res->variables; vb != NULL; vb = vb->next_variable) { +#if COLLECT_DEBUG char buffer[1024]; snprint_variable (buffer, sizeof (buffer), vb->name, vb->name_length, vb); DEBUG ("snmp plugin: Got this variable: %s", buffer); +#endif /* COLLECT_DEBUG */ for (i = 0; i < data->values_len; i++) if (snmp_oid_compare (data->values[i].oid, data->values[i].oid_len, @@ -1126,8 +1128,12 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data) static int csnmp_read_host (host_definition_t *host) { int i; + time_t time_start; + time_t time_end; - DEBUG ("snmp plugin: csnmp_read_host (%s);", host->name); + time_start = time (NULL); + DEBUG ("snmp plugin: csnmp_read_host (%s) started at %u;", host->name, + (unsigned int) time_start); if (host->sess_handle == NULL) csnmp_host_open_session (host); @@ -1145,6 +1151,16 @@ static int csnmp_read_host (host_definition_t *host) csnmp_read_value (host, data); } + time_end = time (NULL); + DEBUG ("snmp plugin: csnmp_read_host (%s) at %u;", host->name, + (unsigned int) time_end); + if ((time_end - time_start) > host->skip_num) + { + WARNING ("snmp plugin: Host `%s' should be queried every %i seconds, " + "but reading all values takes %i seconds.", + host->name, host->skip_num, time_end - time_start); + } + return (0); } /* int csnmp_read_host */ -- 2.30.2