From: Florian Forster Date: Wed, 27 Aug 2008 08:12:55 +0000 (+0200) Subject: Merge branch 'collectd-4.3' into collectd-4.4 X-Git-Tag: collectd-4.4.3~2 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=3f2f61c7d74d9204405a4b0c21390451c98665a7;hp=9d90a7e3515dcd22d07f2b9a91324379aede8d4a;p=collectd.git Merge branch 'collectd-4.3' into collectd-4.4 --- diff --git a/.gitignore b/.gitignore index 46630013..03bd0c46 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,9 @@ src/collectd*.1 src/collectd*.5 src/types.db.5 src/config.h.in~ +src/libiptc/.libs +src/libiptc/*.la +src/libiptc/*.lo src/liboconfig/.libs src/liboconfig/*.la src/liboconfig/*.lo diff --git a/AUTHORS b/AUTHORS index bd5daa42..7f92d55c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,7 +4,8 @@ This package was written by: apcups plugin by: Anthony Gialluca -cpufreq, multimeter and irq plugin by: +cpufreq, multimeter and irq plugin, as well as some bugfixes in the exec plugin +by: Peter Holik hddtemp plugin by: @@ -28,6 +29,9 @@ nfs plugin by: perl plugin by: Sebastian Harl +powerdns plugin and initial `tail' subsystem by: + Luke Herberling + processes plugin by: Lyonel Vincent @@ -40,12 +44,15 @@ serial plugin by: tape plugin by: Scott Garrett +teamspeak2 plugin by: + Stefan Hacker + users plugin by: Sebastian Harl uuid plugin by: - Dan Berrange - Richard W.M. Jones + Dan Berrange + Richard W.M. Jones vserver plugin by: Sebastian Harl @@ -67,6 +74,10 @@ Much time and effort to find a nasty bug in the ntpd-plugin has been contributed by: LuboÅ¡ Staněk +Support for the statgrab library has been added to the cpu, disk and users +plugins by + Oleg King + collectd is available at: diff --git a/ChangeLog b/ChangeLog index 8b074b4b..35e8b36c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,67 @@ +2008-07-15, Version 4.4.2 + * build system: Use pkg-config to detect the upsclient library. + * collectd: Try even harder to determine the endianess of the + architecture collectd is being built on. + * disk plugin: Fix for Linux 2.4: A wrong field was used as the name + of disks. + * dns plugin: Fix compilation errors with BIND versions 19991001 + through 19991005. + * network plugin: Bugfix in the init routine: The init function + cleared a buffer regardless of its contents. This could lead to lost + values under Solaris. + * nginx plugin: Remove usage of the thread-unsafe `strtok' function. + * vserver plugin: Remove usage of the thread-unsafe `readdir' + function. + * wireless plugin: Work around incorrect noise and power values + returned by some broken drivers. + +2008-06-03, Version 4.4.1 + * collectd: Fix the `DataSource' option within `Type' blocks. Thanks + to kyrone for reporting this. + * collectd: Fixed min/max output in notifications generated by + threshold checking. + * collectd-nagios: Fix the protocol used to communicate with the + daemon. + * perl plugin: Fail noisily, but don't shutdown the daemon, if + initialization has errors. An issue with Perl 5.10 has been fixed. + * teamspeak2 plugin: Fixed an out of bounce array access. Thanks to + René Rebe and Siegmund Gorr for reporting this. + +2008-05-06, Version 4.4.0 + * collectd: Internal code cleanups. + * collectd: Added support for a `Flush' command in the unixsock and + exec plugins. This command can be used to force a plugin (or all) to + flush its values to disk. + * collectd: Thresholds can now be configured to apply to one data + source only, making it possible to configure different thresholds + for each data source. + * apache, nginx plugins: Added the possibility to disable host and/or + peer verification. + * ascent plugin: The new ascent plugin reads and parses the statistics + page of an Ascent server. + * cpu plugin: Support for the statgrab library has been added. + * disk plugin: The possibility to ignore certain disks or collect only + specific disks has been added. + * disk plugin: Support for the statgrab library has been added. + * ipmi plugin: The new ipmi plugin uses the OpenIPMI library to read + sensor values via IPMI, the intelligent platform management + interface. + * iptables plugin: The iptc library that is used by the iptables + plugin has been added to the distribution, because it is not + provided by all distributions and removed from at least one. + * powerdns plugin: The new powerdns plugin reads statistics from an + authoritative or a recursing PowerDNS name server. + * rrdtool plugin: The size of the files generated with the default + configuration has been decreased. + * tail plugin: The new tail plugin can be used to gather statistics by + continuously reading from log files. + * teamspeak2 plugin: The new teamspeak2 plugin connects to a + TeamSpeak2 server and collects statistics about the number of users + and number of channels. + * users plugin: Support for the statgrab library has been added. + * vmem plugin: The new vmem plugin collects very detailed statistics + about the virtual memory subsystem of Linux. + 2008-04-22, Version 4.3.3 * build system: Improved detection of several libraries, especially if they are in non-standard paths. @@ -501,7 +565,7 @@ the data into text files rather than RRD files. 2006-04-09, Version 3.8.4 - * Applied patch by Vincent Stehlé which improves the disk-name + * Applied patch by Vincent Stehlé which improves the disk-name resolution in the `hddtemp' plugin for Linux systems. 2006-04-02, Version 3.8.3 @@ -613,7 +677,7 @@ 2005-10-16, Version 3.1.0 (Revision 194) * Added the `setsid' syscall to the startup code. - * Support for hddtemp has been added (thanks to Vincent Stehlé) + * Support for hddtemp has been added (thanks to Vincent Stehlé) 2005-09-30, Version 3.0.0 (Revision 184) * The ability to send/receive data to/from the network (think diff --git a/README b/README index 8c0be1da..904e7c73 100644 --- a/README +++ b/README @@ -26,6 +26,9 @@ Features Sensors in Macs running Mac OS X / Darwin: Temperature, fanspeed and voltage sensors. + - ascent + Statistics about Ascent, a free server for the game `World of Warcraft'. + - battery Batterycharge, -current and voltage of ACPI and PMU based laptop batteries. @@ -156,6 +159,10 @@ Features - swap Pages swapped out onto harddisk or whatever is called `swap' by the OS.. + - tail + Follows (tails) logfiles, parses them by lines and submits matched + values. + - tape Bytes and operations read and written on tape devices. Solaris only. @@ -165,6 +172,10 @@ Features - users Users currently logged in. + - vmem + Virtual memory statistics, e. g. the number of page-ins/-outs or the + number of pagefaults. + - vserver System resources used by Linux VServers. See . @@ -305,7 +316,7 @@ Prerequisites platforms. * libcurl (optional) - If you want to use the `apache' and/or `nginx' plugins. + If you want to use the `apache', `ascent', or `nginx' plugin. * libhal (optional) If present, the uuid plugin will check for UUID from HAL. @@ -363,7 +374,7 @@ Prerequisites Collect statistics from virtual machines. * libxml2 (optional) - Parse XML data provided by libvirt. + Parse XML data. This is needed for the `ascent' and `libvirt' plugins. Configuring / Compiling / Installing diff --git a/TODO b/TODO index 2a5b7ca4..08fcec1e 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ +For version 4.4: +* PowerDNS plugin + For version 4.3: * unixsock plugin: Remove the custom cache if possible. diff --git a/bindings/perl/Collectd.pm b/bindings/perl/Collectd.pm index 4ba9751b..cca349ec 100644 --- a/bindings/perl/Collectd.pm +++ b/bindings/perl/Collectd.pm @@ -1,5 +1,5 @@ # collectd - Collectd.pm -# Copyright (C) 2007 Sebastian Harl +# Copyright (C) 2007, 2008 Sebastian Harl # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -42,6 +42,9 @@ our %EXPORT_TAGS = ( plugin_register plugin_unregister plugin_dispatch_values + plugin_flush + plugin_flush_one + plugin_flush_all plugin_dispatch_notification plugin_log ) ], @@ -52,6 +55,7 @@ our %EXPORT_TAGS = ( TYPE_SHUTDOWN TYPE_LOG TYPE_NOTIF + TYPE_FLUSH TYPE_DATASET ) ], 'ds_types' => [ qw( @@ -101,7 +105,8 @@ my %types = ( TYPE_WRITE, "write", TYPE_SHUTDOWN, "shutdown", TYPE_LOG, "log", - TYPE_NOTIF, "notify" + TYPE_NOTIF, "notify", + TYPE_FLUSH, "flush" ); foreach my $type (keys %types) { @@ -290,6 +295,34 @@ sub plugin_unregister { } } +sub plugin_flush { + my %args = @_; + + my $timeout = -1; + + DEBUG ("Collectd::plugin_flush:" + . (defined ($args{'timeout'}) ? " timeout = $args{'timeout'}" : "") + . (defined ($args{'plugins'}) ? " plugins = $args{'plugins'}" : "")); + + if (defined ($args{'timeout'}) && ($args{'timeout'} > 0)) { + $timeout = $args{'timeout'}; + } + + if (! defined $args{'plugins'}) { + plugin_flush_all ($timeout); + } + else { + if ("ARRAY" eq ref ($args{'plugins'})) { + foreach my $plugin (@{$args{'plugins'}}) { + plugin_flush_one ($timeout, $plugin); + } + } + else { + plugin_flush_one ($timeout, $args{'plugins'}); + } + } +} + 1; # vim: set sw=4 ts=4 tw=78 noexpandtab : diff --git a/bindings/perl/Collectd/Unixsock.pm b/bindings/perl/Collectd/Unixsock.pm index 71a6d094..29fac3e9 100644 --- a/bindings/perl/Collectd/Unixsock.pm +++ b/bindings/perl/Collectd/Unixsock.pm @@ -406,6 +406,63 @@ sub putnotif return; } # putnotif +=item I<$obj>-EB (B =E I<$timeout>, B =E [...]); + +Flush cached data. + +Valid options are: + +=over 4 + +=item B + +If this option is specified, only data older than I<$timeout> seconds is +flushed. + +=item B + +If this option is specified, only the selected plugins will be flushed. + +=back + +=cut + +sub flush +{ + my $obj = shift; + my %args = @_; + + my $fh = $obj->{'sock'} or confess; + + my $status = 0; + my $msg = "FLUSH"; + + if ($args{'timeout'}) + { + $msg .= " timeout=" . $args{'timeout'}; + } + + if ($args{'plugins'}) + { + foreach my $plugin (@{$args{'plugins'}}) + { + $msg .= " plugin=" . $plugin; + } + } + + $msg .= "\n"; + + send ($fh, $msg, 0) or confess ("send: $!"); + $msg = undef; + recv ($fh, $msg, 1024, 0) or confess ("recv: $!"); + + ($status, $msg) = split (' ', $msg, 2); + return (1) if ($status == 0); + + $obj->{'error'} = $msg; + return; +} + =item I<$obj>-Edestroy (); Closes the socket before the object is destroyed. This function is also diff --git a/configure.in b/configure.in index 17d006d2..8ca5d691 100644 --- a/configure.in +++ b/configure.in @@ -50,6 +50,18 @@ case $host_os in esac AC_MSG_RESULT([$ac_system]) +if test "x$ac_system" = "xLinux" +then + AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources]) + if test -z "$KERNEL_DIR" + then + KERNEL_DIR="/lib/modules/`uname -r`/source" + fi + + KERNEL_CFLAGS="-I$KERNEL_DIR/include" + AC_SUBST(KERNEL_CFLAGS) +fi + # # Checks for header files. # @@ -278,8 +290,13 @@ have_net_ip_vs_h="no" have_ip_vs_h="no" if test "x$ac_system" = "xLinux" then + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $KERNEL_CFLAGS" + AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"]) AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"]) + + CFLAGS=$SAVE_CFLAGS fi # For quota module @@ -1602,6 +1619,7 @@ then LDFLAGS=$SAVE_LDFLAGS fi +with_own_libiptc="no" AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])], [ if test "x$withval" != "xno" && test "x$withval" != "xyes" @@ -1626,22 +1644,45 @@ then AC_CHECK_LIB(iptc, iptc_init, [ AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).]) - ], [with_libiptc="no (libiptc not found)"]) + ], + [ + with_libiptc="yes" + with_own_libiptc="yes" + ]) fi -if test "x$with_libiptc" = "xyes" +if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes" then AC_CHECK_HEADERS(libiptc/libiptc.h, [ AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the header file.]) - ], [with_libiptc="no (libiptc/libiptc.h not found)"]) + ], + [ + with_libiptc="yes" + with_own_libiptc="yes" + ]) fi if test "x$with_libiptc" = "xyes" then - collect_libiptc=1 -else - collect_libiptc=0 + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $KERNEL_CFLAGS" + + AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [], + [ + with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)" + with_own_libiptc="no" + ], + [ +#include "$srcdir/src/libiptc/ipt_kernel_headers.h" + ]) + + CFLAGS=$SAVE_CFLAGS fi AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes") +AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes") +if test "x$with_own_libiptc" = "xyes" +then + AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.]) +fi with_snmp_config="net-snmp-config" with_snmp_cflags="" @@ -1951,6 +1992,85 @@ then fi AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes") +with_libopenipmipthread="yes" +with_libopenipmipthread_cflags="" +with_libopenipmipthread_libs="" + +AC_MSG_CHECKING([for pkg-config]) +temp_result="no" +if test "x$PKG_CONFIG" = "x" +then + with_libopenipmipthread="no" + temp_result="no" +else + temp_result="$PKG_CONFIG" +fi +AC_MSG_RESULT([$temp_result]) + +if test "x$with_libopenipmipthread" = "xyes" +then + AC_MSG_CHECKING([for libOpenIPMIpthread]) + $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null + if test "$?" != "0" + then + with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)" + fi + AC_MSG_RESULT([$with_libopenipmipthread]) +fi + +if test "x$with_libopenipmipthread" = "xyes" +then + AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS]) + temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`" + if test "$?" = "0" + then + with_libopenipmipthread_cflags="$temp_result" + else + with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)" + temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed" + fi + AC_MSG_RESULT([$temp_result]) +fi + +if test "x$with_libopenipmipthread" = "xyes" +then + AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS]) + temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`" + if test "$?" = "0" + then + with_libopenipmipthread_ldflags="$temp_result" + else + with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)" + temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed" + fi + AC_MSG_RESULT([$temp_result]) +fi + +if test "x$with_libopenipmipthread" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags" + + AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h, + [with_libopenipmipthread="yes"], + [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"], +[#include +#include +#include +#include +]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi + +if test "x$with_libopenipmipthread" = "xyes" +then + BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags" + BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags" + AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS) + AC_SUBST(BUILD_WITH_OPENIPMI_LIBS) +fi + dnl Check for libvirt and libxml2 libraries. with_libxml2="no (pkg-config isn't available)" with_libxml2_cflags="" @@ -2172,6 +2292,7 @@ AC_COLLECTD([debug], [enable], [feature], [debugging]) AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) AC_COLLECTD([getifaddrs],[enable], [feature], [getifaddrs under Linux]) +plugin_ascent="no" plugin_battery="no" plugin_cpu="no" plugin_cpufreq="no" @@ -2179,6 +2300,7 @@ plugin_df="no" plugin_disk="no" plugin_entropy="no" plugin_interface="no" +plugin_ipmi="no" plugin_ipvs="no" plugin_irq="no" plugin_libvirt="no" @@ -2193,6 +2315,7 @@ plugin_swap="no" plugin_tape="no" plugin_tcpconns="no" plugin_users="no" +plugin_vmem="no" plugin_vserver="no" plugin_wireless="no" @@ -2213,6 +2336,7 @@ then plugin_serial="yes" plugin_swap="yes" plugin_tcpconns="yes" + plugin_vmem="yes" plugin_vserver="yes" plugin_wireless="yes" @@ -2243,10 +2367,23 @@ fi # libstatgrab if test "x$with_libstatgrab" = "xyes" then + plugin_cpu="yes" + plugin_disk="yes" plugin_interface="yes" plugin_load="yes" plugin_memory="yes" plugin_swap="yes" + plugin_users="yes" +fi + +if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes" +then + plugin_ascent="yes" +fi + +if test "x$with_libopenipmipthread" = "xyes" +then + plugin_ipmi="yes" fi if test "x$have_processor_info" = "xyes" @@ -2327,6 +2464,7 @@ collectd plugins:]) AC_PLUGIN([apache], [$with_libcurl], [Apache httpd statistics]) AC_PLUGIN([apcups], [yes], [Statistics of UPSes by APC]) AC_PLUGIN([apple_sensors], [$with_libiokit], [Apple's hardware sensors]) +AC_PLUGIN([ascent], [$plugin_ascent], [AscentEmu player statistics]) AC_PLUGIN([battery], [$plugin_battery], [Battery statistics]) AC_PLUGIN([cpu], [$plugin_cpu], [CPU usage statistics]) AC_PLUGIN([cpufreq], [$plugin_cpufreq], [CPU frequency statistics]) @@ -2340,6 +2478,7 @@ AC_PLUGIN([exec], [yes], [Execution of external programs]) AC_PLUGIN([hddtemp], [yes], [Query hddtempd]) AC_PLUGIN([interface], [$plugin_interface], [Interface traffic statistics]) AC_PLUGIN([iptables], [$with_libiptc], [IPTables rule counters]) +AC_PLUGIN([ipmi], [$plugin_ipmi], [IPMI sensor statistics]) AC_PLUGIN([ipvs], [$plugin_ipvs], [IPVS connection statistics]) AC_PLUGIN([irq], [$plugin_irq], [IRQ statistics]) AC_PLUGIN([libvirt], [$plugin_libvirt], [Virtual machine statistics]) @@ -2358,6 +2497,7 @@ AC_PLUGIN([ntpd], [yes], [NTPd statistics]) AC_PLUGIN([nut], [$with_libupsclient], [Network UPS tools statistics]) AC_PLUGIN([perl], [$plugin_perl], [Embed a Perl interpreter]) AC_PLUGIN([ping], [$with_liboping], [Network latency statistics]) +AC_PLUGIN([powerdns], [yes], [PowerDNS statistics]) AC_PLUGIN([processes], [$plugin_processes], [Process statistics]) AC_PLUGIN([rrdtool], [$with_rrdtool], [RRDTool output plugin]) AC_PLUGIN([sensors], [$with_lm_sensors], [lm_sensors statistics]) @@ -2365,11 +2505,14 @@ AC_PLUGIN([serial], [$plugin_serial], [serial port traffic]) AC_PLUGIN([snmp], [$with_libnetsnmp], [SNMP querying plugin]) AC_PLUGIN([swap], [$plugin_swap], [Swap usage statistics]) AC_PLUGIN([syslog], [$have_syslog], [Syslog logging plugin]) +AC_PLUGIN([tail], [yes], [Parsing of logfiles]) AC_PLUGIN([tape], [$plugin_tape], [Tape drive statistics]) AC_PLUGIN([tcpconns], [$plugin_tcpconns], [TCP connection statistics]) +AC_PLUGIN([teamspeak2], [yes], [TeamSpeak2 server 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([vmem], [$plugin_vmem], [Virtual memory statistics]) AC_PLUGIN([vserver], [$plugin_vserver], [Linux VServer statistics]) AC_PLUGIN([wireless], [$plugin_wireless], [Wireless statistics]) AC_PLUGIN([xmms], [$with_libxmms], [XMMS statistics]) @@ -2411,7 +2554,7 @@ fi AC_SUBST(PERL_BINDINGS) AC_SUBST(PERL_BINDINGS_OPTIONS) -AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile) +AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile) if test "x$with_rrdtool" = "xyes" \ && test "x$librrd_threadsafe" != "xyes" @@ -2425,6 +2568,11 @@ then with_liboping="yes (shipped version)" fi +if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes" +then + with_libiptc="yes (shipped version)" +fi + if test "x$with_libperl" = "xyes" then with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)" @@ -2451,6 +2599,7 @@ Configuration: libnetlink . . . . $with_libnetlink libnetsnmp . . . . $with_libnetsnmp liboconfig . . . . $with_liboconfig + libopenipmi . . . . $with_libopenipmipthread liboping . . . . . $with_liboping libpcap . . . . . . $with_libpcap libperl . . . . . . $with_libperl @@ -2474,6 +2623,7 @@ Configuration: apache . . . . . . $enable_apache apcups . . . . . . $enable_apcups apple_sensors . . . $enable_apple_sensors + ascent . . . . . . $enable_ascent battery . . . . . . $enable_battery cpu . . . . . . . . $enable_cpu cpufreq . . . . . . $enable_cpufreq @@ -2487,6 +2637,7 @@ Configuration: hddtemp . . . . . . $enable_hddtemp interface . . . . . $enable_interface iptables . . . . . $enable_iptables + ipmi . . . . . . . $enable_ipmi ipvs . . . . . . . $enable_ipvs irq . . . . . . . . $enable_irq libvirt . . . . . . $enable_libvirt @@ -2505,6 +2656,7 @@ Configuration: nut . . . . . . . . $enable_nut perl . . . . . . . $enable_perl ping . . . . . . . $enable_ping + powerdns . . . . . $enable_powerdns processes . . . . . $enable_processes rrdtool . . . . . . $enable_rrdtool sensors . . . . . . $enable_sensors @@ -2512,11 +2664,14 @@ Configuration: snmp . . . . . . . $enable_snmp swap . . . . . . . $enable_swap syslog . . . . . . $enable_syslog + tail . . . . . . . $enable_tail tape . . . . . . . $enable_tape tcpconns . . . . . $enable_tcpconns + teamspeak2 . . . . $enable_teamspeak2 unixsock . . . . . $enable_unixsock users . . . . . . . $enable_users uuid . . . . . . . $enable_uuid + vmem . . . . . . . $enable_vmem vserver . . . . . . $enable_vserver wireless . . . . . $enable_wireless xmms . . . . . . . $enable_xmms diff --git a/contrib/collection3/README b/contrib/collection3/README new file mode 100644 index 00000000..01d01bb7 --- /dev/null +++ b/contrib/collection3/README @@ -0,0 +1,42 @@ + collection3 - Web frontend for collectd +========================================= +http://collectd.org/ + +About +----- + + collection3 is a graphing front-end for the RRD files created by and filled + with collectd. It is written in Perl and should be run as an CGI-script. + Graphs are generated on-the-fly, so no cron job or similar is necessary. + +Layout +------ + + The files used by collection3 are organized in a typical UNIX fashion: The + configuration resides in etc/, executable scripts are in bin/, supplementary + Perl modules are in lib/ and static data for displaying the web page are in + share/. + + All files in all subdirectories except bin/ should NOT be executable. + Ideally, the webserver should not serve them either. Consider using + `.htaccess' files or other means to configure the web server to deny access + to these directories. + +Dependencies +------------ + + collection3 depends on the following Perl modules not included in the Perl + distribution itself: + + * Config::General + * HTML::Entities + * RRDs + +Copyright and License +--------------------- + + Copyright (C) 2008 Florian octo Forster + + collection3 is provided under the terms of the GNU General Public License, + version 2 (GPLv2). + diff --git a/contrib/collection3/bin/graph.cgi b/contrib/collection3/bin/graph.cgi new file mode 100755 index 00000000..1524a660 --- /dev/null +++ b/contrib/collection3/bin/graph.cgi @@ -0,0 +1,186 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use lib ('../lib'); + +use FindBin ('$RealBin'); +use Carp (qw(confess cluck)); +use CGI (':cgi'); +use RRDs (); + +use Collectd::Graph::Config (qw(gc_read_config gc_get_scalar)); +use Collectd::Graph::TypeLoader (qw(tl_load_type)); + +use Collectd::Graph::Common (qw(sanitize_type get_selected_files + epoch_to_rfc1123 flush_files)); +use Collectd::Graph::Type (); + +our $Debug = param ('debug'); +our $Begin = param ('begin'); +our $End = param ('end'); +our $GraphWidth = param ('width'); + +if ($Debug) +{ + print < 0) && ($Begin > $End)) + { + my $temp = $End; + $End = $Begin; + $Begin = $temp; + } +} + +my $type = param ('type') or die; +my $obj; + +$obj = tl_load_type ($type); +if (!$obj) +{ + confess ("tl_load_type ($type) failed"); +} + +$type = ucfirst (lc ($type)); +$type =~ s/_([A-Za-z])/\U$1\E/g; +$type = sanitize_type ($type); + +my $files = get_selected_files (); +if ($Debug) +{ + require Data::Dumper; + print STDOUT Data::Dumper->Dump ([$files], ['files']); +} +for (@$files) +{ + $obj->addFiles ($_); +} + +my $expires = time (); +# IF (End is `now') +# OR (Begin is before `now' AND End is after `now') +if (($End == 0) || (($Begin <= $expires) && ($End >= $expires))) +{ + # 400 == width in pixels + my $timespan; + + if ($End == 0) + { + $timespan = $expires - $Begin; + } + else + { + $timespan = $End - $Begin; + } + $expires += int ($timespan / 400.0); +} +# IF (End is not `now') +# AND (End is before `now') +# ==> Graph will never change again! +elsif (($End > 0) && ($End < $expires)) +{ + $expires += (366 * 86400); +} +elsif ($Begin > $expires) +{ + $expires = $Begin; +} + +# Send FLUSH command to the daemon if necessary and possible. +flush_files ($files, + begin => $Begin, + end => $End, + addr => gc_get_scalar ('UnixSockAddr', undef), + interval => gc_get_scalar ('Interval', 10)); + +print STDOUT header (-Content_type => 'image/png', + -Last_Modified => epoch_to_rfc1123 ($obj->getLastModified ()), + -Expires => epoch_to_rfc1123 ($expires)); + +if ($Debug) +{ + print "\$expires = $expires;\n"; +} + +my $args = $obj->getRRDArgs (0); + +if ($Debug) +{ + require Data::Dumper; + print STDOUT Data::Dumper->Dump ([$obj], ['obj']); + print STDOUT join (",\n", @$args) . "\n"; + print STDOUT "Last-Modified: " . epoch_to_rfc1123 ($obj->getLastModified ()) . "\n"; +} +else +{ + my @timesel = (); + + if ($End) # $Begin is always true + { + @timesel = ('-s', $Begin, '-e', $End); + } + else + { + @timesel = ('-s', $Begin); # End is implicitely `now'. + } + + $| = 1; + RRDs::graph ('-', '-a', 'PNG', '--width', $GraphWidth, @timesel, @$args); + if (my $err = RRDs::error ()) + { + print STDERR "RRDs::graph failed: $err\n"; + exit (1); + } +} + +exit (0); + +# vim: set shiftwidth=2 softtabstop=2 tabstop=8 : diff --git a/contrib/collection3/bin/index.cgi b/contrib/collection3/bin/index.cgi new file mode 100755 index 00000000..be20928c --- /dev/null +++ b/contrib/collection3/bin/index.cgi @@ -0,0 +1,388 @@ +#!/usr/bin/perl + +# Copyright (C) 2008 Florian octo Forster +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; only version 2 of the License is applicable. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +use strict; +use warnings; +use lib ('../lib'); +use utf8; + +use FindBin ('$RealBin'); +use CGI (':cgi'); +use CGI::Carp ('fatalsToBrowser'); +use HTML::Entities ('encode_entities'); + +use Data::Dumper; + +use Collectd::Graph::Config (qw(gc_read_config gc_get_scalar)); +use Collectd::Graph::TypeLoader (qw(tl_load_type)); +use Collectd::Graph::Common (qw(get_files_from_directory get_all_hosts + get_timespan_selection get_selected_files get_host_selection + get_plugin_selection flush_files)); +use Collectd::Graph::Type (); + +our $Debug = param ('debug') ? 1 : 0; + +our $TimeSpans = +{ + Hour => 3600, + Day => 86400, + Week => 7 * 86400, + Month => 31 * 86400, + Year => 366 * 86400 +}; + +my $action = param ('action') || 'list_hosts'; +our %Actions = +( + list_hosts => \&action_list_hosts, + show_selection => \&action_show_selection +); + +if (!exists ($Actions{$action})) +{ + print STDERR "No such action: $action\n"; + exit 1; +} + +gc_read_config ("$RealBin/../etc/collection.conf"); + +$Actions{$action}->(); +exit (0); + +sub can_handle_xhtml +{ + my %types = (); + + if (!defined $ENV{'HTTP_ACCEPT'}) + { + return; + } + + for (split (',', $ENV{'HTTP_ACCEPT'})) + { + my $type = lc ($_); + my $q = 1.0; + + if ($type =~ m#^([^;]+);q=([0-9\.]+)$#) + { + $type = $1; + $q = 0.0 + $2; + } + $types{$type} = $q; + } + + if (!defined ($types{'application/xhtml+xml'})) + { + return; + } + elsif (!defined ($types{'text/html'})) + { + return (1); + } + elsif ($types{'application/xhtml+xml'} < $types{'text/html'}) + { + return; + } + else + { + return (1); + } +} # can_handle_xhtml + +{my $html_started; +sub start_html +{ + return if ($html_started); + + my $end; + my $begin; + my $timespan; + + $end = time (); + $timespan = get_timespan_selection (); + $begin = $end - $timespan; + + if (can_handle_xhtml ()) + { + print < + + +HTML + } + else + { + print < + +HTML + } + print < + collection.cgi, Version 3 + + +