From: Florian Forster Date: Thu, 4 Oct 2007 06:44:41 +0000 (+0200) Subject: snmp plugin: Print a warning if querying a host takes longer than the confiured interval. X-Git-Tag: collectd-4.1.3~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=add941762db8b575003b050c3c59fed121ccbdbb;p=collectd.git snmp plugin: Print a warning if querying a host takes longer than the confiured interval. --- 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 */