Code

Merge branch 'collectd-5.0' into collectd-5.1
[collectd.git] / src / snmp.c
index b8bbee44b05d86f4ce5503f8e7a5a3c0a3b29a62..f4966694222e7a600c2ac2866eeea478aaf6edc5 100644 (file)
@@ -751,7 +751,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;
@@ -803,8 +804,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;
   }
@@ -1025,8 +1029,8 @@ static int csnmp_strvbcopy (char *dst, /* {{{ */
 
 static int csnmp_instance_list_add (csnmp_list_instances_t **head,
     csnmp_list_instances_t **tail,
-    struct snmp_pdu const *res,
-    oid_t const *root)
+    const struct snmp_pdu *res,
+    const host_definition_t *hd, const data_definition_t *dd)
 {
   csnmp_list_instances_t *il;
   struct variable_list *vb;
@@ -1052,7 +1056,7 @@ static int csnmp_instance_list_add (csnmp_list_instances_t **head,
   memset (il, 0, sizeof (*il));
   il->next = NULL;
 
-  status = csnmp_oid_suffix (&il->suffix, &vb_name, root);
+  status = csnmp_oid_suffix (&il->suffix, &vb_name, &dd->instance.oid);
   if (status != 0)
   {
     sfree (il);
@@ -1077,7 +1081,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);
   }
@@ -1392,7 +1397,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_head, &instance_list_tail,
-            res, &data->instance.oid) != 0)
+           res, host, data) != 0)
       {
         ERROR ("snmp plugin: csnmp_instance_list_add failed.");
         status = -1;
@@ -1460,7 +1465,7 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
       memset (vt, 0, sizeof (*vt));
 
       vt->value = csnmp_value_list_to_value (vb, ds->ds[i].type,
-          data->scale, data->shift);
+          data->scale, data->shift, host->name, data->name);
       memcpy (&vt->suffix, &suffix, sizeof (vt->suffix));
       vt->next = NULL;
 
@@ -1612,7 +1617,7 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
       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);
+            data->scale, data->shift, host->name, data->name);
   } /* for (res->variables) */
 
   if (res != NULL)