Merge branch 'rj/libvirtstats'
authorFlorian Forster <octo@huhu.verplant.org>
Tue, 6 Nov 2007 17:23:45 +0000 (18:23 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 6 Nov 2007 17:23:45 +0000 (18:23 +0100)
Conflicts:

AUTHORS

1  2 
AUTHORS
configure.in
src/Makefile.am
src/collectd.conf.pod

diff --combined AUTHORS
+++ b/AUTHORS
@@@ -60,10 -60,9 +60,13 @@@ Much time and effort to find a nasty bu
  contributed by:
    Luboš Staněk <lubek at users.sourceforge.net>
  
 +uuid module by:
 +  Dan Berrange <berrange@redhat.com>
 +  Richard W.M. Jones <rjones@redhat.com>
 +
+ Libvirt integration by:
+   Richard Jones <rjones@redhat.com>
  collectd is available at:
    <http://collectd.org/>
  
diff --combined configure.in
@@@ -17,7 -17,6 +17,7 @@@ AC_PROG_CP
  AC_PROG_INSTALL
  AC_PROG_LN_S
  AC_PROG_MAKE_SET
 +AM_PROG_CC_C_O
  AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
  
  dnl configure libtool
@@@ -670,20 -669,6 +670,20 @@@ AC_CHECK_LIB(resolv, res_search
  [with_libresolv="no"])
  AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
  
 +dnl Check for HAL (hardware abstraction library)
 +with_libhal="yes"
 +AC_CHECK_LIB(hal,libhal_device_property_exists,
 +           [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
 +           [with_libhal="no"])
 +if test "x$with_libhal" = "xyes"; then
 +      PKG_PROG_PKG_CONFIG
 +      if test "x$PKG_CONFIG" != "x"; then
 +              BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
 +              BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
 +              AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
 +              AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
 +      fi
 +fi
  
  m4_divert_once([HELP_WITH], [
  collectd additional packages:])
@@@ -883,7 -868,7 +883,7 @@@ AC_CHECK_LIB(IOKit, IOServiceGetMatchin
  [
        with_libiokit="yes"
        collectd_libiokit=1
- ], 
+ ],
  [
        with_libiokit="no"
        collectd_libiokit=0
@@@ -1141,7 -1126,6 +1141,6 @@@ AC_ARG_WITH(liboping, [AS_HELP_STRING([
        fi
  ],
  [
-       #753
        with_liboping="yes"
  ])
  
@@@ -1272,7 -1256,7 +1271,7 @@@ AC_ARG_WITH(libiptc, [AS_HELP_STRING([-
        fi
  ],
  [
-       if test "x$ac_system" = "xLinux"
+       if test "x$ac_system" = "xLinux"
        then
                with_libiptc="yes"
        else
@@@ -1306,14 -1290,14 +1305,14 @@@ with_snmp_cflags="
  with_snmp_libs=""
  AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
  [
-       if test "x$withval" = "xno"
+       if test "x$withval" = "xno"
        then
                with_libnetsnmp="no"
        else if test "x$withval" = "xyes"
        then
                with_libnetsnmp="yes"
        else
-               if test -x "$withval"
+               if test -x "$withval"
                then
                        with_snmp_config="$withval"
                        with_libnetsnmp="yes"
@@@ -1433,7 -1417,7 +1432,7 @@@ the
  fi
  if test "x$with_libupsclient" = "xyes"
  then
-       AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [], 
+       AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
  [#include <stdlib.h>
  #include <stdio.h>
  #include <upsclient.h>])
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
  
+ dnl Check for libvirt and libxml2 libraries.
+ AC_CHECK_LIB(xml2,xmlXPathEval,
+            [with_libxml2="yes"],
+            [with_libxml2="no"])
+ with_libvirt="no"
+ if test "x$with_libxml2" = "xyes"; then
+     AC_CHECK_LIB(virt,virDomainBlockStats,
+                [with_libvirt="yes"],
+                [with_libvirt="no (symbol virDomainBlockStats not found)"])
+ fi
+ dnl Add the right compiler flags and libraries.
+ if test "x$with_libvirt" = "xyes"; then
+     PKG_PROG_PKG_CONFIG
+     if test "x$PKG_CONFIG" != "x"; then
+       BUILD_WITH_LIBVIRTSTATS_CFLAGS="`pkg-config --cflags libvirt` `pkg-config --cflags libxml-2.0`"
+       BUILD_WITH_LIBVIRTSTATS_LIBS="`pkg-config --libs libvirt` `pkg-config --libs libxml-2.0`"
+       AC_SUBST(BUILD_WITH_LIBVIRTSTATS_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBVIRTSTATS_LIBS)
+     fi
+ fi
+ dnl End of check for libvirt and libxml2 libraries.
  # Check for enabled/disabled features
  #
  
@@@ -1874,6 -1882,7 +1897,7 @@@ AC_PLUGIN([interface],   [$plugin_inter
  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([libvirtstats],[$with_libvirt],      [Virtual machine statistics])
  AC_PLUGIN([load],        [$plugin_load],       [System load])
  AC_PLUGIN([logfile],     [yes],                [File logging plugin])
  AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
@@@ -1900,7 -1909,6 +1924,7 @@@ AC_PLUGIN([tape],        [$plugin_tape]
  AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
  AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
  AC_PLUGIN([users],       [$plugin_users],      [User statistics])
 +AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
  AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
  AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
  AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
@@@ -1973,6 -1981,8 +1997,8 @@@ Configuration
      libsensors  . . . . $with_lm_sensors
      libstatgrab . . . . $with_libstatgrab
      libupsclient  . . . $with_libupsclient
+     libvirt . . . . . . $with_libvirt
+     libxml2 . . . . . . $with_libxml2
      libxmms . . . . . . $with_libxmms
  
    Features:
      iptables  . . . . . $enable_iptables
      ipvs  . . . . . . . $enable_ipvs
      irq . . . . . . . . $enable_irq
+     libvirtstats  . . . $enable_libvirtstats
      load  . . . . . . . $enable_load
      logfile . . . . . . $enable_logfile
      mbmon . . . . . . . $enable_mbmon
      tcpconns  . . . . . $enable_tcpconns
      unixsock  . . . . . $enable_unixsock
      users . . . . . . . $enable_users
 +    uuid  . . . . . . . $enable_uuid
      vserver . . . . . . $enable_vserver
      wireless  . . . . . $enable_wireless
      xmms  . . . . . . . $enable_xmms
diff --combined src/Makefile.am
@@@ -278,6 -278,16 +278,16 @@@ collectd_LDADD += "-dlopen" irq.l
  collectd_DEPENDENCIES += irq.la
  endif
  
+ if BUILD_PLUGIN_LIBVIRTSTATS
+ pkglib_LTLIBRARIES += libvirtstats.la
+ libvirtstats_la_SOURCES = libvirtstats.c
+ libvirtstats_la_CFLAGS = $(BUILD_WITH_LIBVIRTSTATS_CFLAGS)
+ libvirtstats_la_LIBADD = $(BUILD_WITH_LIBVIRTSTATS_LIBS)
+ libvirtstats_la_LDFLAGS = -module -avoid-version
+ collectd_LDADD += "-dlopen" libvirtstats.la
+ collectd_DEPENDENCIES += libvirtstats.la
+ endif
  if BUILD_PLUGIN_LOAD
  pkglib_LTLIBRARIES += load.la
  load_la_SOURCES = load.c
@@@ -578,16 -588,6 +588,16 @@@ collectd_LDADD += "-dlopen" users.l
  collectd_DEPENDENCIES += users.la
  endif
  
 +if BUILD_PLUGIN_UUID
 +pkglib_LTLIBRARIES += uuid.la
 +uuid_la_SOURCES = uuid.c
 +uuid_la_CFLAGS  = $(BUILD_WITH_LIBHAL_CFLAGS)
 +uuid_la_LIBADD  = $(BUILD_WITH_LIBHAL_LIBS)
 +uuid_la_LDFLAGS = -module -avoid-version
 +collectd_LDADD += "-dlopen" uuid.la
 +collectd_DEPENDENCIES += uuid.la
 +endif
 +
  if BUILD_PLUGIN_VSERVER
  pkglib_LTLIBRARIES += vserver.la
  vserver_la_SOURCES = vserver.c
diff --combined src/collectd.conf.pod
@@@ -355,6 -355,66 +355,66 @@@ and all other interrupts are collected
  
  =back
  
+ =head2 Plugin C<libvirtstats>
+ This plugin allows CPU, disk and network load to be monitored for
+ virtualized guests on the machine.  The statistics are collected
+ through libvirt (L<http://libvirt.org/>).
+ Only I<Connection> is required.
+ =over 4
+ =item B<Connection> I<uri>
+ Connect to the hypervisor given by I<uri>.  For example if using
+ Xen use:
+  Connection "xen:///"
+ Details are URIs allowed are given at L<http://libvirt.org/uri.html>.
+ =item B<RefreshInterval> I<seconds>
+ Refresh the list of domains and devices every I<seconds>.  The default
+ is 60 seconds.  Setting this to be the same or smaller than the
+ I<Interval> 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.
+ =item B<Domain> I<name>
+ =item B<BlockDevice> I<name:dev>
+ =item B<InterfaceDevice> I<name:dev>
+ =item B<IgnoreSelected> I<true>|I<false>
+ Select which domains and devices are monitored.
+ If I<IgnoreSelected> is not given or I<false> then only the
+ listed domains and disk/network devices are monitored.
+ If I<IgnoreSelected> is I<true> then the test is reversed
+ and the listed domains and disk/network devices are ignored,
+ while the rest are monitored.
+ 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 monitor all domains and all their devices.
+ Example:
+  BlockDevice "/:hdb/"
+  IgnoreSelected "true"
+ Ignore all I<hdb> devices on any domain, but other block devices
+ (eg. I<hda>) will be monitored.
+ =back
  =head2 Plugin C<logfile>
  
  =over 4
@@@ -869,35 -929,6 +929,35 @@@ L<chmod(1)>. Defaults to B<0770>
  
  =back
  
 +=head2 Plugin C<uuid>
 +
 +This plugin, if loaded, causes the Hostname to be taken from the
 +machine's UUID.  The UUID is a universally unique designation for the
 +machine, usually taken from the machine's BIOS.  This is most useful
 +if the machine is running in a virtual environment such as Xen, in
 +which case the UUID is preserved across shutdowns and migration.
 +
 +The following methods are used to find the machine's UUID, in order:
 +
 +Check I</etc/uuid> (or I<UUIDFile>).
 +
 +Check for UUID from HAL (L<http://www.freedesktop.org/wiki/Software/hal>)
 +if present.
 +
 +Check for UUID from C<dmidecode> / SMBIOS.
 +
 +Check for UUID from Xen hypervisor.
 +
 +If no UUID can be found then the hostname is not modified.
 +
 +=over 4
 +
 +=item B<UUIDFile> I<Path>
 +
 +Take the UUID from the given file (default I</etc/uuid>).
 +
 +=back
 +
  =head2 Plugin C<vserver>
  
  This plugin doesn't have any options. B<VServer> support is only available for