ethstat plugin: Fix indentation. It was a mess, sorry.
[collectd.git] / src / snmp.c
index e78ade9..7a84851 100644 (file)
@@ -703,7 +703,8 @@ static void csnmp_host_open_session (host_definition_t *host)
 
 /* TODO: Check if negative values wrap around. Problem: negative temperatures. */
 static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
-    double scale, double shift)
+    double scale, double shift,
+    const char *host_name, const char *data_name)
 {
   value_t ret;
   uint64_t tmp_unsigned = 0;
@@ -748,8 +749,11 @@ static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
          oid_buffer);
     else
 #endif
-      WARNING ("snmp plugin: I don't know the ASN type \"%i\" (OID: %s)",
-         (int) vl->type, oid_buffer);
+      WARNING ("snmp plugin: I don't know the ASN type #%i "
+               "(OID: \"%s\", data block \"%s\", host block \"%s\")",
+          (int) vl->type, oid_buffer,
+          (data_name != NULL) ? data_name : "UNKNOWN",
+          (host_name != NULL) ? host_name : "UNKNOWN");
 
     defined = 0;
   }
@@ -958,7 +962,8 @@ static int csnmp_strvbcopy (char *dst, /* {{{ */
 
 static int csnmp_instance_list_add (csnmp_list_instances_t **head,
     csnmp_list_instances_t **tail,
-    const struct snmp_pdu *res)
+    const struct snmp_pdu *res,
+    const host_definition_t *hd, const data_definition_t *dd)
 {
   csnmp_list_instances_t *il;
   struct variable_list *vb;
@@ -998,7 +1003,8 @@ static int csnmp_instance_list_add (csnmp_list_instances_t **head,
   }
   else
   {
-    value_t val = csnmp_value_list_to_value (vb, DS_TYPE_COUNTER, 1.0, 0.0);
+    value_t val = csnmp_value_list_to_value (vb, DS_TYPE_COUNTER,
+        /* scale = */ 1.0, /* shift = */ 0.0, hd->name, dd->name);
     ssnprintf (il->instance, sizeof (il->instance),
        "%llu", val.counter);
   }
@@ -1057,7 +1063,7 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat
   sstrncpy (vl.host, host->name, sizeof (vl.host));
   sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin));
 
-  vl.interval = (int) CDTIME_T_TO_TIME_T (host->interval);
+  vl.interval = host->interval;
 
   subid = 0;
   have_more = 1;
@@ -1286,7 +1292,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
       /* Allocate a new `csnmp_list_instances_t', insert the instance name and
        * add it to the list */
       if (csnmp_instance_list_add (&instance_list, &instance_list_ptr,
-           res) != 0)
+           res, host, data) != 0)
       {
        ERROR ("snmp plugin: csnmp_instance_list_add failed.");
        status = -1;
@@ -1342,7 +1348,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
 
       vt->subid = vb->name[vb->name_length - 1];
       vt->value = csnmp_value_list_to_value (vb, ds->ds[i].type,
-         data->scale, data->shift);
+          data->scale, data->shift, host->name, data->name);
       vt->next = NULL;
 
       if (value_table_ptr[i] == NULL)
@@ -1445,7 +1451,7 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
   sstrncpy (vl.type, data->type, sizeof (vl.type));
   sstrncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance));
 
-  vl.interval = (int) CDTIME_T_TO_TIME_T (host->interval);
+  vl.interval = host->interval;
 
   req = snmp_pdu_create (SNMP_MSG_GET);
   if (req == NULL)
@@ -1492,8 +1498,8 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
     for (i = 0; i < data->values_len; i++)
       if (snmp_oid_compare (data->values[i].oid, data->values[i].oid_len,
            vb->name, vb->name_length) == 0)
-       vl.values[i] = csnmp_value_list_to_value (vb, ds->ds[i].type,
-           data->scale, data->shift);
+        vl.values[i] = csnmp_value_list_to_value (vb, ds->ds[i].type,
+            data->scale, data->shift, host->name, data->name);
   } /* for (res->variables) */
 
   if (res != NULL)
@@ -1518,9 +1524,8 @@ static int csnmp_read_host (user_data_t *ud)
 
   host = ud->data;
 
-  /* FIXME: Convert "interval_g" to cdtime_t, too. */
   if (host->interval == 0)
-    host->interval = TIME_T_TO_CDTIME_T (interval_g);
+    host->interval = interval_g;
 
   time_start = cdtime ();