From 62f948605f54e1f5575699360376d75a2f849faf Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 16 Sep 2014 11:17:55 +0200 Subject: [PATCH] virt plugin: Rename the "libvirt" plugin to "virt". "libvirt" confused libtool and caused problems when re-building from source. --- configure.ac | 19 ++--- src/Makefile.am | 22 +++--- src/collectd.conf.in | 26 +++--- src/collectd.conf.pod | 196 +++++++++++++++++++++++----------------------- src/configfile.c | 11 +++ src/{libvirt.c => virt.c} | 8 +- 6 files changed, 147 insertions(+), 135 deletions(-) rename src/{libvirt.c => virt.c} (99%) diff --git a/configure.ac b/configure.ac index bee5f72a..bcd8b602 100644 --- a/configure.ac +++ b/configure.ac @@ -4972,7 +4972,6 @@ plugin_interface="no" plugin_ipmi="no" plugin_ipvs="no" plugin_irq="no" -plugin_libvirt="no" plugin_load="no" plugin_log_logstash="no" plugin_memory="no" @@ -4988,8 +4987,9 @@ plugin_tape="no" plugin_tcpconns="no" plugin_ted="no" plugin_thermal="no" -plugin_users="no" plugin_uptime="no" +plugin_users="no" +plugin_virt="no" plugin_vmem="no" plugin_vserver="no" plugin_wireless="no" @@ -5214,11 +5214,6 @@ then plugin_interface="yes" fi -if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes" -then - plugin_libvirt="yes" -fi - if test "x$have_getloadavg" = "xyes" then plugin_load="yes" @@ -5283,6 +5278,12 @@ then plugin_users="yes" fi +if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes" +then + plugin_virt="yes" +fi + + m4_divert_once([HELP_ENABLE], [ collectd plugins:]) @@ -5341,7 +5342,6 @@ AC_PLUGIN([iptables], [$with_libiptc], [IPTables rule counters]) AC_PLUGIN([ipvs], [$plugin_ipvs], [IPVS connection statistics]) AC_PLUGIN([irq], [$plugin_irq], [IRQ statistics]) AC_PLUGIN([java], [$with_java], [Embed the Java Virtual Machine]) -AC_PLUGIN([libvirt], [$plugin_libvirt], [Virtual machine statistics]) AC_PLUGIN([load], [$plugin_load], [System load]) AC_PLUGIN([logfile], [yes], [File logging plugin]) AC_PLUGIN([log_logstash], [$plugin_log_logstash], [Logstash json_event compatible logging]) @@ -5417,6 +5417,7 @@ AC_PLUGIN([uptime], [$plugin_uptime], [Uptime statistics]) AC_PLUGIN([users], [$plugin_users], [User statistics]) AC_PLUGIN([uuid], [yes], [UUID as hostname plugin]) AC_PLUGIN([varnish], [$with_libvarnish], [Varnish cache statistics]) +AC_PLUGIN([virt], [$plugin_virt], [Virtual machine statistics]) AC_PLUGIN([vmem], [$plugin_vmem], [Virtual memory statistics]) AC_PLUGIN([vserver], [$plugin_vserver], [Linux VServer statistics]) AC_PLUGIN([wireless], [$plugin_wireless], [Wireless statistics]) @@ -5706,7 +5707,6 @@ Configuration: ipvs . . . . . . . . $enable_ipvs irq . . . . . . . . . $enable_irq java . . . . . . . . $enable_java - libvirt . . . . . . . $enable_libvirt load . . . . . . . . $enable_load logfile . . . . . . . $enable_logfile lpar . . . . . . . . $enable_lpar @@ -5781,6 +5781,7 @@ Configuration: users . . . . . . . . $enable_users uuid . . . . . . . . $enable_uuid varnish . . . . . . . $enable_varnish + virt . . . . . . . . $enable_virt vmem . . . . . . . . $enable_vmem vserver . . . . . . . $enable_vserver wireless . . . . . . $enable_wireless diff --git a/src/Makefile.am b/src/Makefile.am index b8623653..340c7928 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -566,17 +566,6 @@ collectd_LDADD += "-dlopen" java.la collectd_DEPENDENCIES += java.la endif -if BUILD_PLUGIN_LIBVIRT -pkglib_LTLIBRARIES += libvirt.la -libvirt_la_SOURCES = libvirt.c -libvirt_la_CFLAGS = $(AM_CFLAGS) \ - $(BUILD_WITH_LIBVIRT_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS) -libvirt_la_LIBADD = $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS) -libvirt_la_LDFLAGS = -module -avoid-version -collectd_LDADD += "-dlopen" libvirt.la -collectd_DEPENDENCIES += libvirt.la -endif - if BUILD_PLUGIN_LOAD pkglib_LTLIBRARIES += load.la load_la_SOURCES = load.c @@ -1375,6 +1364,17 @@ collectd_LDADD += "-dlopen" varnish.la collectd_DEPENDENCIES += varnish.la endif +if BUILD_PLUGIN_VIRT +pkglib_LTLIBRARIES += virt.la +virt_la_SOURCES = virt.c +virt_la_CFLAGS = $(AM_CFLAGS) \ + $(BUILD_WITH_LIBVIRT_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS) +virt_la_LIBADD = $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS) +virt_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" virt.la +collectd_DEPENDENCIES += virt.la +endif + if BUILD_PLUGIN_VMEM pkglib_LTLIBRARIES += vmem.la vmem_la_SOURCES = vmem.c diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 91c040a3..8e1bae71 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -126,7 +126,6 @@ #@BUILD_PLUGIN_IPVS_TRUE@LoadPlugin ipvs #@BUILD_PLUGIN_IRQ_TRUE@LoadPlugin irq #@BUILD_PLUGIN_JAVA_TRUE@LoadPlugin java -#@BUILD_PLUGIN_LIBVIRT_TRUE@LoadPlugin libvirt @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load #@BUILD_PLUGIN_LPAR_TRUE@LoadPlugin lpar #@BUILD_PLUGIN_LVM_TRUE@LoadPlugin lvm @@ -190,6 +189,7 @@ #@BUILD_PLUGIN_UUID_TRUE@LoadPlugin uuid #@BUILD_PLUGIN_VARNISH_TRUE@LoadPlugin varnish #@BUILD_PLUGIN_MIC_TRUE@LoadPlugin mic +#@BUILD_PLUGIN_VIRT_TRUE@LoadPlugin virt #@BUILD_PLUGIN_VMEM_TRUE@LoadPlugin vmem #@BUILD_PLUGIN_VSERVER_TRUE@LoadPlugin vserver #@BUILD_PLUGIN_WIRELESS_TRUE@LoadPlugin wireless @@ -529,18 +529,6 @@ # # -# -# Connection "xen:///" -# RefreshInterval 60 -# Domain "name" -# BlockDevice "name:device" -# InterfaceDevice "name:device" -# IgnoreSelected false -# HostnameFormat name -# InterfaceFormat name -# PluginInstanceFormat name -# - # # ReportRelative true # @@ -1194,6 +1182,18 @@ # # +# +# Connection "xen:///" +# RefreshInterval 60 +# Domain "name" +# BlockDevice "name:device" +# InterfaceDevice "name:device" +# IgnoreSelected false +# HostnameFormat name +# InterfaceFormat name +# PluginInstanceFormat name +# + # # Verbose false # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 8ecc92d6..939cfdaa 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -860,7 +860,7 @@ and are checked by default depends on the distribution you use. This plugin reads absolute air pressure using digital barometer sensor MPL115A2 or MPL3115 from Freescale (sensor attached to any I2C bus available in -the computer, for HW details see +the computer, for HW details see I or I). The sensor type - one fo these two - is detected automatically by the plugin @@ -973,7 +973,7 @@ Temperature sensor which should be used as a reference when normalizing the pres When specified more sensors a minumum is found and uses each time. The temperature reading directly from this pressure sensor/plugin is typically not suitable as the pressure sensor -will be probably inside while we want outside temperature. +will be probably inside while we want outside temperature. The collectd reference name is something like /-/- ( is usually omitted when there is just single value type). @@ -1786,7 +1786,7 @@ There must be at least one B option inside each B block. =item B [I I ...] Names the columns whose content is used as metadata for the data sets -that are dispatched to the daemon. +that are dispatched to the daemon. The actual data type in the columns is not that important. The plugin will automatically cast the values to the right type if it know how to do that. So @@ -2430,101 +2430,6 @@ independent from the I argument passed to B. =back -=head2 Plugin C - -This plugin allows CPU, disk and network load to be collected for virtualized -guests on the machine. This means that these characteristics can be collected -for guest systems without installing any software on them - collectd only runs -on the hosting system. The statistics are collected through libvirt -(L). - -Only I is required. - -=over 4 - -=item B I - -Connect to the hypervisor given by I. For example if using Xen use: - - Connection "xen:///" - -Details which URIs allowed are given at L. - -=item B I - -Refresh the list of domains and devices every I. The default is 60 -seconds. Setting this to be the same or smaller than the I will cause -the list of domains and devices to be refreshed on every iteration. - -Refreshing the devices in particular is quite a costly operation, so if your -virtualization setup is static you might consider increasing this. If this -option is set to 0, refreshing is disabled completely. - -=item B I - -=item B I - -=item B I - -=item B I|I - -Select which domains and devices are collected. - -If I is not given or I then only the listed domains and -disk/network devices are collected. - -If I is I then the test is reversed and the listed -domains and disk/network devices are ignored, while the rest are collected. - -The domain name and device names may use a regular expression, if the name is -surrounded by I and collectd was compiled with support for regexps. - -The default is to collect statistics for all domains and all their devices. - -Example: - - BlockDevice "/:hdb/" - IgnoreSelected "true" - -Ignore all I devices on any domain, but other block devices (eg. I) -will be collected. - -=item B B - -When the libvirt plugin logs data, it sets the hostname of the collected data -according to this setting. The default is to use the guest name as provided by -the hypervisor, which is equal to setting B. - -B means use the guest's UUID. This is useful if you want to track the -same guest across migrations. - -B means to use the global B setting, which is probably not -useful on its own because all guests will appear to have the same name. - -You can also specify combinations of these fields. For example B -means to concatenate the guest name and UUID (with a literal colon character -between, thus I<"foo:1234-1234-1234-1234">). - -=item B B|B
- -When the libvirt plugin logs interface data, it sets the name of the collected -data according to this setting. The default is to use the path as provided by -the hypervisor (the "dev" property of the target node), which is equal to -setting B. - -B
means use the interface's mac address. This is useful since the -interface path might change between reboots of a guest or across migrations. - -=item B B - -When the libvirt plugin logs data, it sets the plugin_instance of the collected -data according to this setting. The default is to use the guest name as provided -by the hypervisor, which is equal to setting B. - -B means use the guest's UUID. - -=back - =head2 Plugin C The I collects the system load. These numbers give a rough overview @@ -6504,6 +6409,101 @@ Collect statistics about worker threads. False by default. =back +=head2 Plugin C + +This plugin allows CPU, disk and network load to be collected for virtualized +guests on the machine. This means that these metrics can be collected for guest +systems without installing any software on them - I only runs on the +host system. The statistics are collected through libvirt +(L). + +Only I is required. + +=over 4 + +=item B I + +Connect to the hypervisor given by I. For example if using Xen use: + + Connection "xen:///" + +Details which URIs allowed are given at L. + +=item B I + +Refresh the list of domains and devices every I. The default is 60 +seconds. Setting this to be the same or smaller than the I will cause +the list of domains and devices to be refreshed on every iteration. + +Refreshing the devices in particular is quite a costly operation, so if your +virtualization setup is static you might consider increasing this. If this +option is set to 0, refreshing is disabled completely. + +=item B I + +=item B I + +=item B I + +=item B B|B + +Select which domains and devices are collected. + +If I is not given or B then only the listed domains and +disk/network devices are collected. + +If I is B then the test is reversed and the listed +domains and disk/network devices are ignored, while the rest are collected. + +The domain name and device names may use a regular expression, if the name is +surrounded by I and collectd was compiled with support for regexps. + +The default is to collect statistics for all domains and all their devices. + +Example: + + BlockDevice "/:hdb/" + IgnoreSelected "true" + +Ignore all I devices on any domain, but other block devices (eg. I) +will be collected. + +=item B B + +When the libvirt plugin logs data, it sets the hostname of the collected data +according to this setting. The default is to use the guest name as provided by +the hypervisor, which is equal to setting B. + +B means use the guest's UUID. This is useful if you want to track the +same guest across migrations. + +B means to use the global B setting, which is probably not +useful on its own because all guests will appear to have the same name. + +You can also specify combinations of these fields. For example B +means to concatenate the guest name and UUID (with a literal colon character +between, thus I<"foo:1234-1234-1234-1234">). + +=item B B|B
+ +When the libvirt plugin logs interface data, it sets the name of the collected +data according to this setting. The default is to use the path as provided by +the hypervisor (the "dev" property of the target node), which is equal to +setting B. + +B
means use the interface's mac address. This is useful since the +interface path might change between reboots of a guest or across migrations. + +=item B B + +When the libvirt plugin logs data, it sets the plugin_instance of the collected +data according to this setting. The default is to use the guest name as provided +by the hypervisor, which is equal to setting B. + +B means use the guest's UUID. + +=back + =head2 Plugin C The C plugin collects information about the usage of virtual memory. diff --git a/src/configfile.c b/src/configfile.c index fbb3cd33..02fd96f6 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -281,6 +281,8 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) return (-1); name = ci->values[0].value.string; + if (strcmp ("libvirt", name) == 0) + name = "virt"; /* default to the global interval set before loading this plugin */ memset (&ctx, 0, sizeof (ctx)); @@ -383,6 +385,15 @@ static int dispatch_block_plugin (oconfig_item_t *ci) return (-1); name = ci->values[0].value.string; + if (strcmp ("libvirt", name) == 0) + { + /* TODO(octo): Remove this legacy. */ + WARNING ("The \"libvirt\" plugin has been renamed to \"virt\" to avoid problems with the build system. " + "Your configuration is still using the old name. " + "Please change it to use \"virt\" as soon as possible. " + "This compatibility code will go away eventually."); + name = "virt"; + } if (IS_TRUE (global_option_get ("AutoLoadPlugin"))) { diff --git a/src/libvirt.c b/src/virt.c similarity index 99% rename from src/libvirt.c rename to src/virt.c index b0c694a3..6118c0fd 100644 --- a/src/libvirt.c +++ b/src/virt.c @@ -1,5 +1,5 @@ /** - * collectd - src/libvirt.c + * collectd - src/virt.c * Copyright (C) 2006-2008 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ #include /* Plugin name */ -#define PLUGIN_NAME "libvirt" +#define PLUGIN_NAME "virt" static const char *config_keys[] = { "Connection", @@ -574,14 +574,14 @@ lv_read (void) minfo = malloc (VIR_DOMAIN_MEMORY_STAT_NR * sizeof (virDomainMemoryStatStruct)); if (minfo == NULL) { - ERROR ("libvirt plugin: malloc failed."); + ERROR ("virt plugin: malloc failed."); continue; } status = virDomainMemoryStats (domains[i], minfo, VIR_DOMAIN_MEMORY_STAT_NR, 0); if (status < 0) { - ERROR ("libvirt plugin: virDomainMemoryStats failed with status %i.", + ERROR ("virt plugin: virDomainMemoryStats failed with status %i.", status); sfree (minfo); continue; -- 2.11.0