virt plugin: New options: ReportBlockDevices and ReportNetworkInterfaces
authorPavel Rochnyack <pavel2000@ngs.ru>
Wed, 5 Dec 2018 07:29:31 +0000 (14:29 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Wed, 5 Dec 2018 07:29:31 +0000 (14:29 +0700)
This allows to disable unneeded reports if stats are gathered by another plugin.

src/collectd.conf.pod
src/virt.c

index 09ad826..1251d24 100644 (file)
@@ -9356,6 +9356,16 @@ When B<metadata> is used in B<HostnameFormat> or B<PluginInstanceFormat>, this
 describes where the hostname is located in the libvirt metadata. The default is
 I</instance/name/text()>.
 
 describes where the hostname is located in the libvirt metadata. The default is
 I</instance/name/text()>.
 
+=item B<ReportBlockDevices> B<true>|B<false>
+
+Enabled by default. Allows to disable stats reporting of block devices for
+whole plugin.
+
+=item B<ReportNetworkInterfaces> B<true>|B<false>
+
+Enabled by default. Allows to disable stats reporting of network interfaces for
+whole plugin.
+
 =item B<ExtraStats> B<string>
 
 Report additional extra statistics. The default is no extra statistics, preserving
 =item B<ExtraStats> B<string>
 
 Report additional extra statistics. The default is no extra statistics, preserving
index 56e44fb..876fe30 100644 (file)
@@ -143,6 +143,9 @@ static const char *config_keys[] = {"Connection",
 /* PersistentNotification is false by default */
 static bool persistent_notification = false;
 
 /* PersistentNotification is false by default */
 static bool persistent_notification = false;
 
+static bool report_block_devices = true;
+static bool report_network_interfaces = true;
+
 /* Thread used for handling libvirt notifications events */
 static virt_notif_thread_t notif_thread;
 
 /* Thread used for handling libvirt notifications events */
 static virt_notif_thread_t notif_thread;
 
@@ -1368,6 +1371,16 @@ static int lv_config(const char *key, const char *value) {
     return 0;
   }
 
     return 0;
   }
 
+  if (strcasecmp(key, "ReportBlockDevices") == 0) {
+    report_block_devices = IS_TRUE(value);
+    return 0;
+  }
+
+  if (strcasecmp(key, "ReportNetworkInterfaces") == 0) {
+    report_network_interfaces = IS_TRUE(value);
+    return 0;
+  }
+
   /* Unrecognised option. */
   return -1;
 }
   /* Unrecognised option. */
   return -1;
 }
@@ -2624,10 +2637,12 @@ static int refresh_lists(struct lv_read_instance *inst) {
       goto cont;
 
     /* Block devices. */
       goto cont;
 
     /* Block devices. */
-    lv_add_block_devices(state, dom, domname, xpath_ctx);
+    if (report_block_devices)
+      lv_add_block_devices(state, dom, domname, xpath_ctx);
 
     /* Network interfaces. */
 
     /* Network interfaces. */
-    lv_add_network_interfaces(state, dom, domname, xpath_ctx);
+    if (report_network_interfaces)
+      lv_add_network_interfaces(state, dom, domname, xpath_ctx);
 
   cont:
     if (xpath_ctx)
 
   cont:
     if (xpath_ctx)