From: Florian Forster Date: Mon, 7 Feb 2011 07:00:31 +0000 (+0100) Subject: Merge branch 'pw/exclude_regex' X-Git-Tag: collectd-5.1.0~81 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=6bd4bf7b21f84746010792b885b9b71791dccb79;hp=57c08630c7b8dfc4c6b094f8bcb16450d0171a73;p=collectd.git Merge branch 'pw/exclude_regex' --- diff --git a/.gitignore b/.gitignore index e8f9af66..cbdd62f8 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,9 @@ bindings/java/org/collectd/java/*.class # python stuff *.pyc + +# tag stuff +src/tags + +# backup stuff +*~ diff --git a/AUTHORS b/AUTHORS index 4b133fa0..c57f90b2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ Alvaro Barcellos Amit Gupta - Multiple servers in the apache plugin. + - curl_xml plugin. Anthony Dewhurst - zfs_arc plugin. @@ -33,6 +34,10 @@ Anthony Gialluca Antony Dovgal - memcached plugin. +Aurélien Reynaud + - LPAR plugin. + - Various fixes for AIX, HP-UX and Solaris. + Bruno Prémont - BIND plugin. - Many bugreports and -fixes in various plugins, @@ -71,6 +76,9 @@ Franck Lombardi Jason Pepas - nfs plugin. +Jérôme Renard + - varnish plugin. + Luboš Staněk - sensors plugin improvements. - Time and effort to find a nasty bug in the ntpd-plugin. @@ -139,6 +147,9 @@ Peter Holik - Some bugfixes in the exec plugin. - Notifications in the ipmi plugin. +Phoenix Kayo + - pinba plugin. + Piotr Hosowicz - SMF manifest for collectd. @@ -155,6 +166,9 @@ Rodolphe Quiédeville Scott Garrett - tape plugin. +Sebastien Pahl + - AMQP plugin. + Simon Kuhnle - OpenBSD code for the cpu and memory plugins. diff --git a/ChangeLog b/ChangeLog index 74c5ccba..95a3e71e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,270 @@ +yyyy-mm-dd, Version 5.0.0 + * collectd: The "FQDNLookup" option is now enabled by default. + * collectd: The internal representation of time has been changed to + allow a higher accuracy than one second. + * collectdcmd: This new command line utility can send various commands + to collectd using the UnixSock plugin. Thanks to Håkon Dugstad + Johnsen and Sebastian Harl for their code. + * collectd-nagios: The "-m" option has been implemented (treat NaNs as + critical). + * collectd-tg: Traffic generator creating bogus network traffic + compatible to the Network plugin. This utility can be used to + stress-test new write plugins and collectd in general. + * libcollectdclient: Creating and sending network packets has been + added to the collectd client library. + * All data sets: The data source name of all data sets with exactly + one data source has been changed to "value". + * All plugins: All "counter" data sources have been converted to + "derive" data sources. All plugins now use "derive" by default, but + plugins such as the network plugin can still handle "counter", of + course. The minimum value of all derive data sources is zero, the + maximum value is unspecified. + * amqp plugin: The new AMQP plugin can send data to and receive data + from an AMQP broker. Thanks to Sebastien Pahl for his code. + * apache plugin: Backwards compatibility code has been removed. + Support for the IBM HTTP Server has been added. Thanks to Manuel + Luis Sanmartín Rozada for his patch. + * contextswitch plugin: Support for sysctlbyname(3) has been added. + Thanks to Kimo Rosenbaum for his patch. + * df plugin: The default behavior has been changed to be equivalent to + the "ReportReserved" behavior of v4. + * dns plugin: Improved RFC 1035 name parsing has been imported from + "dnstop". + * exec plugin: Backwards compatibility code has been removed. + * GenericJMX plugin: The "InstancePrefix" option has been added to + "Connection" blocks. + * hddtemp plugin: The "TranslateDevicename" config option has been + removed. + * interface plugin: Use the "plugin instance" to store the interface + value. + * libvirt plugin: The "InterfaceFormat" option has been added. Thanks + to Ruben Kerkhof for his patch. + * lpar plugin: New plugins for "logical partitions", a virtualization + technique of POWER CPUs. Thanks to Aurélien Reynaud for his code and + patience. + * modbus plugin: Support for libmodbus 2.9.2 has been added and the + license has been changes to LGPLv2.1. + * mysql plugin: Backwards compatibility code has been removed. The + data sets used have been improved. + * network plugin: The default buffer size has been increased to + 1452 bytes. + * perl plugin: Backwards compatibility code has been removed. + * postgresql plugin: Backwards compatibility code has been removed. + * redis plugin: Plugin for collecting statistics from Redis, a key- + value store, has been added. Thanks to Andres J. Diaz for his code. + * swap plugin: Implement collection of physical and virtual memory + statistics under Solaris. The new default is collecting physical + memory. Thanks to Aurélien Reynaud for his patches. + * threshold plugin: The threshold configuration has been moved into + this separate plugin. + * unixsock plugin: The "DeleteSocket" option has been added. + * varnish plugin: The new Varnish plugin reads statistics from + Varnish, a web accelerator. Thanks to Jérôme Renard and Marc + Fournier for their contributions. + * write_redis: New plugin for writing data to Redis, a key-value + store. + * zfs_arc plugin: The data sets have been replaced by more elegant + alternatives. + * v5upgrade target: Target for converting v4 data sets to the v5 + schema. + +2010-11-27, Version 4.10.2 + * Documentation: Various documentation fixes. + * collectd: If including one configuration file fails, continue with + the rest of the configuration if possible. + * collectd: Fix a bug in the read function scheduling. In rare cases + read functions may not have been called as often as requested. + * collectd: Concurrency issues with errno(3) under AIX have been + fixed: A thread-safe version of errno has to be requested under AIX. + Thanks to Aurélien Reynaud for his patch. + * collectd: A left-over hard-coded 2 has been replaced by the + configurable timeout value. + * curl, memcachec, tail plugins: Fix handling of "DERIVE" data + sources. Matching the end of a string has been improved; thanks to + Sebastian Harl for the patch. + * curl_json plugin: Fix a problem when parsing 64bit integers. Reading + JSON data from non-HTTP sources has been fixed. + * netapp plugin: Pass the interval setting to the dispatch function. + Restore compatibility to NetApp Release 7.3. Thanks to Sven Trenkel + for the patch. + * network plugin: Be less verbose about unchecked signatures, in order + to prevent spamming the logs. + * notify_email plugin: Concurrency problems have been fixed. + * python plugin: Set "sys.argv", since many scripts don't expect that + it may not be set. Thanks to Sven Trenkel for the patch. + * rrdtool, rrdcached plugin: Fix a too strict assertion when creating + RRD files. + * swap plugin: A bug which lead to incorrect I/O values has been + fixed. + * value match: A minor memory leak has been fixed. Thanks to Sven + Trenkel for the patch. + +2010-07-09, Version 4.10.1 + * Build system: Checking for "strtok_r" under Solaris has been fixed. + * Portability: Fixes for Solaris 8 have been applied. Thanks to + Alexander Wuerstlein for his patch. + * collectd: The shutdown speed when terminating the read threads has + been improved. + * libcollectdclient: A format error in the PUTVAL command has been + removed. Thanks to Johan Van den Brande for fixing this. + * df plugin: An error message shown when "cu_mount_getlist" fails has + been added. + * processes plugin: Missing initialization code for IO members of a + struct has been added. Thanks to Aurélien Reynaud for fixing this. + * python plugin: Memory leaks in the write and notification callbacks + have been fixed. A possible crash when the plugin was loaded but not + configured has been fixed. Thanks to Sven Trenkel for his patches. + * snmp plugin: Verbosity with regard to unknown ASN types has been + increased. A build problem on PowerPC and ARM processors has been + fixed by Aurélien Reynaud; thanks! + * powerdns plugin: Compatibility changes for PowerDNS 2.9.22 and above + have been applied. Thanks to Luke Heberling for his changes. + +2010-05-01, Version 4.10.0 + * collectd: JSON output now includes the "dstypes" and "dsnames" + fields. This makes it easier for external applications to interpret + the data. Thanks to Chris Buben for his work. + * collectd: The new "Timeout" option can be used to specify a + "timeout" for missing values. This is used in the threshold checking + code to detect missing values. Thanks to Andrés J. Díaz for the + patch. + * apache plugin: Support for "IdleWorkers" (Apache 1.*: "IdleServers") + has been added. + * curl plugin: The new "ExcludeRegex" allows to easily exclude certain + lines from the match. + * curl_xml plugin: This new plugin allows to read XML files using cURL + and extract metrics included in the files. Thanks to Amit Gupta for + his work. + * filecount plugin: The new "IncludeHidden" option allows to include + "hidden" files and directories in the statistics. Thanks to Vaclav + Malek for the patch. + * logfile plugin: The new "PrintSeverity" option allows to include the + severity of a message in the output. Thanks to Clément Stenac for + his patch. + * memcachec plugin: The new "ExcludeRegex" allows to easily exclude + certain lines from the match. + * modbus plugin: This new plugin allows to read registers from + Modbus-TCP enabled devices. + * network plugin: The new "Interface" option allows to set the + interface to be used for multicast and, if supported, unicast + traffic. Thanks to Max Henkel for his work. + * openvpn plugin: The "CollectUserCount" and "CollectIndividualUsers" + options allow more detailed control over how to report sessions of + multiple users. Thanks to Fabian Schuh for his work. + * pinba plugin: This new plugin receives timing information from the + Pinba PHP extension, which can be used for profiling PHP code and + webserver performance. Thanks to Phoenix Kayo for his work. + * ping plugin: The new "MaxMissed" allows to re-resolve a hosts + address when it doesn't reply to a number of ping requests. Thanks + to Stefan Völkel for the patch. + * postgresql plugin: The "Interval" config option has been added. The + plugin has been relicensed under the 2-clause BSD license. Thanks to + Sebastian Harl for his work. + * processes plugin: Support for "code" and "data" virtual memory sizes + has been added. Thanks to Clément Stenac for his patch. + * python plugin: Support for Python 3 has been implemented. Thanks to + Sven Trenkel for his work. + * routeros plugin: Support for collecting CPU load, memory usage, used + and free disk space, sectors written and number of bad blocks from + MikroTik devices has been added. + * swap plugin: Support for Linux < 2.6 has been added. Thanks to Lorin + Scraba for his patch. + * tail plugin: The new "ExcludeRegex" allows to easily exclude certain + lines from the match. Thanks to Peter Warasin for his patch. + * write_http plugin: The "StoreRates" option has been added. Thanks to + Paul Sadauskas for his patch. + * regex match: The "Invert" option has been added. Thanks to Julien + Ammous for his patch. + +2010-11-27, Version 4.9.4 + * Documentation: Various documentation fixes. + * collectd: If including one configuration file fails, continue with + the rest of the configuration if possible. + * collectd: Fix a bug in the read function scheduling. In rare cases + read functions may not have been called as often as requested. + * collectd: Concurrency issues with errno(3) under AIX have been + fixed: A thread-safe version of errno has to be requested under AIX. + Thanks to Aurélien Reynaud for his patch. + * curl, memcachec, tail plugins: Fix handling of "DERIVE" data + sources. Matching the end of a string has been improved; thanks to + Sebastian Harl for the patch. + * curl_json plugin: Fix a problem when parsing 64bit integers. Reading + JSON data from non-HTTP sources has been fixed. + * netapp plugin: Pass the interval setting to the dispatch function. + Restore compatibility to NetApp Release 7.3. Thanks to Sven Trenkel + for the patch. + * network plugin: Be less verbose about unchecked signatures, in order + to prevent spamming the logs. + * notify_email plugin: Concurrency problems have been fixed. + * python plugin: Set "sys.argv", since many scripts don't expect that + it may not be set. Thanks to Sven Trenkel for the patch. + * rrdtool, rrdcached plugin: Fix a too strict assertion when creating + RRD files. + * value match: A minor memory leak has been fixed. Thanks to Sven + Trenkel for the patch. + +2010-07-09, Version 4.9.3 + * Build system: Checking for "strtok_r" under Solaris has been fixed. + * Portability: Fixes for Solaris 8 have been applied. Thanks to + Aurélien Reynaud and Alexander Wuerstlein for their patches. + * collectd: The shutdown speed when terminating the read threads has + been improved. + * collectd-nagios: The format of the performance data has been fixed. + * libcollectdclient: A format error in the PUTVAL command has been + removed. Thanks to Johan Van den Brande for fixing this. + * df plugin: An error message shown when "cu_mount_getlist" fails has + been added. + * processes plugin: Missing initialization code for IO members of a + struct has been added. Thanks to Aurélien Reynaud for fixing this. + * python plugin: Memory leaks in the write and notification callbacks + have been fixed. A possible crash when the plugin was loaded but not + configured has been fixed. Thanks to Sven Trenkel for his patches. + * rrdcached plugin: A build issue has been resolved. Thanks to + Thorsten von Eicken for the patch. + * snmp plugin: Verbosity with regard to unknown ASN types has been + increased. A build problem on PowerPC and ARM processors has been + fixed by Aurélien Reynaud; thanks! + * powerdns plugin: Compatibility changes for PowerDNS 2.9.22 and above + have been applied. Thanks to Luke Heberling for his changes. + +2010-04-22, Version 4.9.2 + * Build system, various plugins: Fixes for AIX compatibility have been + added. Thanks to Manuel Sanmartin for his patches. + * Build system: Checking for "nanosleep" on old Solaris machines has + been fixed. Thanks to Vincent McIntyre and Sebastian Harl for + figuring out a way to make this work. + * collectd: Append a newline to messages written to STDERR. + * collectd: Serialization of NANs in JSON format has been fixed. + Thanks to Chris Buben for pointing out the resulting syntax error. + * collectd: Checks whether a "sleep" returned early have been added; + the cases are now handled correctly. Thanks to Michael Stapelberg + for the patch. + * collectd: Continue reading files in a directory when parsing one + file fails. + * apache plugin: Collection of the number of active connections has + been fixed for Apache 2.*. + * contextswitch plugin: Handle large counter/derive values correctly. + Thanks to Martin Merkel for reporting the bug. + * exec plugin: Error messages have been improved. The "running" flag + is now cleared correctly when forking a child fails. + * iptables plugin: Fix a violation of aliasing rules. This resolves a + warning / error with new GCC versions. Thanks to Jan Engelhardt for + the work-around. + * java plugin: The Java API files are now packaged into a .jar file. + Thanks to Amit Gupta for his patch. + * network plugin: Fix a segmentation fault when receiving packets with + an unknown data source type. + * network plugin: A memory leak when receiving encrypted network + packets has been fixed. + * openvpn plugin: Fix naming schema when reading "MULTI1" type status + files. + * oracle plugin: Fix checking for lost connections and reconnect in + this case. Thanks to Sven Trenkel for pointing out the problem. + * unixsock plugin: A memory leak in the "LISTVAL" command has been + fixed. Thanks to Peter Warasin for pointing it out. + * write_http plugin: Use the "any" authentication schema. This used to + be "digest". Thanks to Paul Sadauskas for the patch. + 2010-01-14, Version 4.9.1 * Documentation: Some manpage fixes. * Default config: Added sample configuration for missing plugins. @@ -52,6 +319,42 @@ * scale target: This target to scale (multiply) values by an arbitrary value has been added. +2010-04-22, Version 4.8.5 + * collectd: Append a newline to messages written to STDERR. + * network plugin: Fix a segmentation fault when receiving packets with + an unknown data source type. + +2010-04-07, Version 4.8.4 + * Build system, various plugins: Fixes for AIX compatibility have been + added. Thanks to Manuel Sanmartin for his patches. + * Build system: Checking for "nanosleep" on old Solaris machines has + been fixed. Thanks to Vincent McIntyre and Sebastian Harl for + figuring out a way to make this work. + * collectd: Serialization of NANs in JSON format has been fixed. + Thanks to Chris Buben for pointing out the resulting syntax error. + * collectd: Checks whether a "sleep" returned early have been added; + the cases are now handled correctly. Thanks to Michael Stapelberg + for the patch. + * collectd: Continue reading files in a directory when parsing one + file fails. + * apache plugin: Collection of the number of active connections has + been fixed for Apache 2.*. + * exec plugin: Error messages have been improved. The "running" flag + is now cleared correctly when forking a child fails. + * iptables plugin: Fix a violation of aliasing rules. This resolves a + warning / error with new GCC versions. Thanks to Jan Engelhardt for + the work-around. + * java plugin: The Java API files are now packaged into a .jar file. + Thanks to Amit Gupta for his patch. + * network plugin: A memory leak when receiving encrypted network + packets has been fixed. + * oracle plugin: Fix checking for lost connections and reconnect in + this case. Thanks to Sven Trenkel for pointing out the problem. + * unixsock plugin: A memory leak in the "LISTVAL" command has been + fixed. Thanks to Peter Warasin for pointing it out. + * write_http plugin: Use the "any" authentication schema. This used to + be "digest". Thanks to Paul Sadauskas for the patch. + 2010-01-14, Version 4.8.3 * Documentation: Some manpage fixes. * rrdtool plugin: Fix a bug with random write timeouts. Due to an diff --git a/README b/README index 96fbdf3e..811c594c 100644 --- a/README +++ b/README @@ -57,6 +57,10 @@ Features Retrieves JSON data via cURL and parses it according to user configuration. + - curl_xml + Retrieves XML data via cURL and parses it according to user + configuration. + - dbi Executes SQL statements on various databases and interprets the returned data. @@ -121,6 +125,10 @@ Features - load System load average over the last 1, 5 and 15 minutes. + - lpar + Detailed CPU statistics of the “Logical Partitions” virtualization + technique built into IBM's POWER processors. + - libvirt CPU, disk and network I/O statistics from virtual machines. @@ -143,6 +151,10 @@ Features Memory utilization: Memory occupied by running processes, page cache, buffer cache and free. + - modbus + Reads values from Modbus/TCP enabled devices. Supports reading values + from multiple "slaves" so gateway devices can be used. + - multimeter Information provided by serial multimeters, such as the `Metex M-4650CR'. @@ -200,6 +212,10 @@ Features write your own plugins in Perl and return arbitrary values using this API. See collectd-perl(5). + - pinba + Receive and dispatch timing values from Pinba, a profiling extension for + PHP. + - ping Network latency: Time to reach the default gateway or another given host. @@ -223,6 +239,10 @@ Features collectd without the need to start a heavy interpreter every interval. See collectd-python(5) for details. + - redis + The redis plugin gathers information from a redis server, including: + uptime, used memory, total connections etc. + - routeros Query interface and wireless registration statistics from RouterOS. @@ -276,6 +296,9 @@ Features - users Users currently logged in. + - varnish + Various statistics from Varnish, an HTTP accelerator. + - vmem Virtual memory statistics, e. g. the number of page-ins/-outs or the number of pagefaults. @@ -293,9 +316,13 @@ Features - zfs_arc Statistics for ZFS' “Adaptive Replacement Cache” (ARC). - * Output can be written or send to various destinations by the following + * Output can be written or sent to various destinations by the following plugins: + - amqp + Sends JSON-encoded data to an Advanced Message Queuing Protocol (AMQP) + server, such as RabbitMQ. + - csv Write to comma separated values (CSV) files. This needs lots of diskspace but is extremely portable and can be analysed with almost @@ -415,6 +442,10 @@ Features * Miscellaneous plugins: + - threshold + Checks values against configured thresholds and creates notifications if + values are out of bounds. See collectd-threshold(5) for details. + - uuid Sets the hostname to an unique identifier. This is meant for setups where each client may migrate to another physical host, possibly going @@ -426,7 +457,7 @@ Features network plugins, makes sure your resources are used efficiently. Also, since collectd is programmed multithreaded it benefits from hyperthreading and multicore processors and makes sure that the daemon isn't idle if only - one plugins waits for an IO-operation to complete. + one plugin waits for an IO-operation to complete. * Once set up, hardly any maintenance is necessary. Setup is kept as easy as possible and the default values should be okay for most users. @@ -492,6 +523,10 @@ Prerequisites * libclntsh (optional) Used by the `oracle' plugin. + * libcredis (optional) + Used by the redis plugin. Please note that you require a 0.2.2 version + or higher. + * libcurl (optional) If you want to use the `apache', `ascent', `curl', `nginx', or `write_http' plugin. @@ -537,11 +572,17 @@ Prerequisites Used by the `memcachec' plugin to connect to a memcache daemon. + * libmodbus (optional) + Used by the “modbus” plugin to communicate with Modbus/TCP devices. The + “modbus” plugin works with version 2.0.3 of the library – due to frequent + API changes other versions may or may not compile cleanly. + + * libmysqlclient (optional) Unsurprisingly used by the `mysql' plugin. - * libnatapp (optional) + * libnetapp (optional) Required for the “netapp” plugin. This library is part of the “Manage ONTAP SDK” published by NetApp. @@ -570,6 +611,9 @@ Prerequisites Used to capture packets by the `dns' plugin. + * libperfstat (optional) + Used by various plugins to gather statistics under AIX. + * libperl (optional) Obviously used by the `perl' plugin. The library has to be compiled with ithread support (introduced in Perl 5.6.0). @@ -579,10 +623,19 @@ Prerequisites The PostgreSQL C client library used by the `postgresql' plugin. + * libprotobuf-c, protoc-c (optional) + Used by the `pinba' plugin to generate a parser for the network packets + sent by the Pinba PHP extension. + + * libpython (optional) Used by the `python' plugin. Currently, only 2.3 ≦ Python < 3 is supported. + * librabbitmq (optional; also called “rabbitmq-c”) + Used by the AMQP plugin for AMQP connections, for example to RabbitMQ. + + * librouteros (optional) Used by the `routeros' plugin to connect to a device running `RouterOS'. @@ -629,6 +682,10 @@ Prerequisites Parse JSON data. This is needed for the `curl_json' plugin. + * libvarnish (optional) + Fetches statistics from a Varnish instance. This is needed for the Varnish plugin + + Configuring / Compiling / Installing ------------------------------------ diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am index fa253f65..f8e936a8 100644 --- a/bindings/java/Makefile.am +++ b/bindings/java/Makefile.am @@ -24,7 +24,7 @@ EXTRA_DIST = org/collectd/api/CollectdConfigInterface.java \ org/collectd/java/GenericJMX.java \ org/collectd/java/JMXMemory.java -java-build-stamp: org/collectd/api/*.java +java-build-stamp: org/collectd/api/*.java org/collectd/java/*.java $(JAVAC) -d "." "$(srcdir)/org/collectd/api"/*.java $(JAVAC) -d "." "$(srcdir)/org/collectd/java"/*.java mkdir -p .libs diff --git a/bindings/java/org/collectd/api/CollectdFlushInterface.java b/bindings/java/org/collectd/api/CollectdFlushInterface.java index 3e492ddf..410c61c6 100644 --- a/bindings/java/org/collectd/api/CollectdFlushInterface.java +++ b/bindings/java/org/collectd/api/CollectdFlushInterface.java @@ -29,5 +29,5 @@ package org.collectd.api; */ public interface CollectdFlushInterface { - public int flush (int timeout, String identifier); + public int flush (Number timeout, String identifier); } diff --git a/bindings/java/org/collectd/api/ValueList.java b/bindings/java/org/collectd/api/ValueList.java index 1baeff24..b8d6f40f 100644 --- a/bindings/java/org/collectd/api/ValueList.java +++ b/bindings/java/org/collectd/api/ValueList.java @@ -87,10 +87,16 @@ public class ValueList extends PluginData { _ds = new DataSet (_type, dsrc); } + /** + * Returns the interval (in milliseconds) of the value list. + */ public long getInterval() { return _interval; } + /** + * Sets the interval (in milliseconds) of the value list. + */ public void setInterval(long interval) { _interval = interval; } diff --git a/bindings/java/org/collectd/java/GenericJMXConfConnection.java b/bindings/java/org/collectd/java/GenericJMXConfConnection.java index ffa9ded4..0c81bc9a 100644 --- a/bindings/java/org/collectd/java/GenericJMXConfConnection.java +++ b/bindings/java/org/collectd/java/GenericJMXConfConnection.java @@ -1,6 +1,6 @@ /* * collectd/java - org/collectd/java/GenericJMXConfConnection.java - * Copyright (C) 2009 Florian octo Forster + * Copyright (C) 2009,2010 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 @@ -45,6 +45,7 @@ class GenericJMXConfConnection private String _username = null; private String _password = null; private String _host = null; + private String _instance_prefix = null; private String _service_url = null; private MBeanServerConnection _jmx_connection = null; private List _mbeans = null; @@ -162,6 +163,12 @@ private void connect () /* {{{ */ if (tmp != null) this._service_url = tmp; } + else if (child.getKey ().equalsIgnoreCase ("InstancePrefix")) + { + String tmp = getConfigString (child); + if (tmp != null) + this._instance_prefix = tmp; + } else if (child.getKey ().equalsIgnoreCase ("Collect")) { String tmp = getConfigString (child); @@ -211,7 +218,8 @@ private void connect () /* {{{ */ { int status; - status = this._mbeans.get (i).query (this._jmx_connection, pd); + status = this._mbeans.get (i).query (this._jmx_connection, pd, + this._instance_prefix); if (status != 0) { this._jmx_connection = null; diff --git a/bindings/java/org/collectd/java/GenericJMXConfMBean.java b/bindings/java/org/collectd/java/GenericJMXConfMBean.java index 1587bd5f..b1fbfb3e 100644 --- a/bindings/java/org/collectd/java/GenericJMXConfMBean.java +++ b/bindings/java/org/collectd/java/GenericJMXConfMBean.java @@ -1,6 +1,6 @@ /* * collectd/java - org/collectd/java/GenericJMXConfMBean.java - * Copyright (C) 2009 Florian octo Forster + * Copyright (C) 2009,2010 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 @@ -67,22 +67,6 @@ class GenericJMXConfMBean return (v.getString ()); } /* }}} String getConfigString */ - private String join (String separator, List list) /* {{{ */ - { - StringBuffer sb; - - sb = new StringBuffer (); - - for (int i = 0; i < list.size (); i++) - { - if (i > 0) - sb.append ("-"); - sb.append (list.get (i)); - } - - return (sb.toString ()); - } /* }}} String join */ - /* * * ObjectName "object name" @@ -170,7 +154,8 @@ class GenericJMXConfMBean return (this._name); } /* }}} */ - public int query (MBeanServerConnection conn, PluginData pd) /* {{{ */ + public int query (MBeanServerConnection conn, PluginData pd, /* {{{ */ + String instance_prefix) { Set names; Iterator iter; @@ -197,11 +182,12 @@ class GenericJMXConfMBean ObjectName objName; PluginData pd_tmp; List instanceList; - String instance; + StringBuffer instance; objName = iter.next (); pd_tmp = new PluginData (pd); instanceList = new ArrayList (); + instance = new StringBuffer (); Collectd.logDebug ("GenericJMXConfMBean: objName = " + objName.toString ()); @@ -224,14 +210,22 @@ class GenericJMXConfMBean } } + if (instance_prefix != null) + instance.append (instance_prefix); + if (this._instance_prefix != null) - instance = new String (this._instance_prefix - + join ("-", instanceList)); - else - instance = join ("-", instanceList); - pd_tmp.setPluginInstance (instance); + instance.append (this._instance_prefix); + + for (int i = 0; i < instanceList.size (); i++) + { + if (i > 0) + instance.append ("-"); + instance.append (instanceList.get (i)); + } + + pd_tmp.setPluginInstance (instance.toString ()); - Collectd.logDebug ("GenericJMXConfMBean: instance = " + instance); + Collectd.logDebug ("GenericJMXConfMBean: instance = " + instance.toString ()); for (int i = 0; i < this._values.size (); i++) this._values.get (i).query (conn, objName, pd_tmp); diff --git a/bindings/perl/lib/Collectd.pm b/bindings/perl/lib/Collectd.pm index f1b5d859..ca3b5d23 100644 --- a/bindings/perl/lib/Collectd.pm +++ b/bindings/perl/lib/Collectd.pm @@ -465,35 +465,6 @@ sub plugin_flush { } } -sub plugin_flush_one { - my $timeout = shift; - my $name = shift; - - WARNING ("Collectd::plugin_flush_one is deprecated - " - . "use Collectd::plugin_flush instead."); - - if (! (defined ($timeout) && defined ($name))) { - ERROR ("Usage: Collectd::plugin_flush_one(timeout, name)"); - return; - } - - plugin_flush (plugins => $name, timeout => $timeout); -} - -sub plugin_flush_all { - my $timeout = shift; - - WARNING ("Collectd::plugin_flush_all is deprecated - " - . "use Collectd::plugin_flush instead."); - - if (! defined ($timeout)) { - ERROR ("Usage: Collectd::plugin_flush_all(timeout)"); - return; - } - - plugin_flush (timeout => $timeout); -} - sub fc_call { my $type = shift; my $name = shift; diff --git a/configure.in b/configure.in index 32805063..8db24ca4 100644 --- a/configure.in +++ b/configure.in @@ -47,6 +47,9 @@ AC_PROG_LEX AC_PROG_YACC PKG_PROG_PKG_CONFIG +AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no]) +AM_CONDITIONAL(HAVE_PROTOC_C, test "x$have_protoc_c" = "xyes") + AC_MSG_CHECKING([for kernel type ($host_os)]) case $host_os in *linux*) @@ -88,6 +91,10 @@ if test "x$ac_system" = "xSolaris" then AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.]) fi +if test "x$ac_system" = "xAIX" +then + AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.]) +fi # Where to install .pc files. pkgconfigdir="${libdir}/pkgconfig" @@ -101,9 +108,13 @@ AC_ARG_ENABLE(standards, if test "x$enable_standards" = "xyes" then AC_DEFINE(_ISOC99_SOURCE, 1, [Define to enforce ISO C99 compliance.]) - AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Define to enforce POSIX.1-2001 compliance.]) - AC_DEFINE(_XOPEN_SOURCE, 600, [Define to enforce X/Open 6 (XSI) compliance.]) + AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.]) + AC_DEFINE(_XOPEN_SOURCE, 700, [Define to enforce X/Open 7 (XSI) compliance.]) AC_DEFINE(_REENTRANT, 1, [Define to enable reentrancy interfaces.]) + if test "x$GCC" = "xyes" + then + CFLAGS="$CFLAGS -std=c99" + fi fi AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes") @@ -115,7 +126,7 @@ AC_HEADER_SYS_WAIT AC_HEADER_DIRENT AC_HEADER_STDBOOL -AC_CHECK_HEADERS(stdio.h stdint.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h) +AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h) # For ping library AC_CHECK_HEADERS(netinet/in_systm.h, [], [], @@ -477,10 +488,17 @@ AC_HEADER_TIME # Checks for library functions. # AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf) +AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname) AC_FUNC_STRERROR_R +SAVE_CFLAGS="$CFLAGS" +# Emulate behavior of src/Makefile.am +if test "x$GCC" = "xyes" +then + CFLAGS="$CFLAGS -Wall -Werror" +fi + AC_CACHE_CHECK([for strtok_r], [c_cv_have_strtok_r_default], AC_LINK_IFELSE( @@ -511,7 +529,6 @@ AC_CACHE_CHECK([for strtok_r], if test "x$c_cv_have_strtok_r_default" = "xno" then - SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -D_REENTRANT=1" AC_CACHE_CHECK([if strtok_r needs _REENTRANT], @@ -543,15 +560,51 @@ then ) fi +CFLAGS="$SAVE_CFLAGS" +if test "x$c_cv_have_strtok_r_reentrant" = "xyes" +then + CFLAGS="$CFLAGS -D_REENTRANT=1" +fi + AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree) socket_needs_socket="no" AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket))) AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes") +clock_gettime_needs_rt="no" +clock_gettime_needs_posix4="no" +have_clock_gettime="no" +AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"]) +if test "x$have_clock_gettime" = "xno" +then + AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes" + have_clock_gettime="yes"]) +fi +if test "x$have_clock_gettime" = "xno" +then + AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes" + have_clock_gettime="yes"]) +fi +if test "x$have_clock_gettime" = "xyes" +then + AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.]) +else + AC_MSG_WARN(cannot find clock_gettime) +fi + nanosleep_needs_rt="no" -AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep))) -AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes") +nanosleep_needs_posix4="no" +AC_CHECK_FUNCS(nanosleep, + [], + AC_CHECK_LIB(rt, nanosleep, + [nanosleep_needs_rt="yes"], + AC_CHECK_LIB(posix4, nanosleep, + [nanosleep_needs_posix4="yes"], + AC_MSG_ERROR(cannot find nanosleep)))) + +AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes") +AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes") AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"]) AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"]) @@ -561,13 +614,127 @@ AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"]) AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"]) AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"]) AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"]) +AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"]) AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"]) AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"]) AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"]) -AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"]) -# For load module -AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"]) +# Check for strptime {{{ +if test "x$GCC" = "xyes" +then + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wall -Wextra -Werror" +fi + +AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"]) +if test "x$have_strptime" = "xyes" +then + AC_CACHE_CHECK([whether strptime is exported by default], + [c_cv_have_strptime_default], + AC_COMPILE_IFELSE( +AC_LANG_PROGRAM( +[[ +AC_INCLUDES_DEFAULT +#include +]], +[[ + struct tm stm; + (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm); +]]), + [c_cv_have_strptime_default="yes"], + [c_cv_have_strptime_default="no"])) +fi +if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno" +then + AC_CACHE_CHECK([whether strptime needs standards mode], + [c_cv_have_strptime_standards], + AC_COMPILE_IFELSE( +AC_LANG_PROGRAM( +[[ +#ifndef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +#endif +#ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200112L +#endif +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 500 +#endif +AC_INCLUDES_DEFAULT +#include +]], +[[ + struct tm stm; + (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm); +]]), + [c_cv_have_strptime_standards="yes"], + [c_cv_have_strptime_standards="no"])) + + if test "x$c_cv_have_strptime_standards" = "xyes" + then + AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).]) + else + have_strptime="no" + fi +fi + +if test "x$GCC" = "xyes" +then + CFLAGS="$SAVE_CFLAGS" +fi + +# }}} Check for strptime + +AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"]) +if test "x$have_swapctl" = "xyes"; then + AC_CACHE_CHECK([whether swapctl takes two arguments], + [c_cv_have_swapctl_two_args], + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# undef _LARGEFILE64_SOURCE +#endif +#include +#include ]], + [[ + int num = swapctl(0, NULL); + ]] + ), + [c_cv_have_swapctl_two_args="yes"], + [c_cv_have_swapctl_two_args="no"] + ) + ) + AC_CACHE_CHECK([whether swapctl takes three arguments], + [c_cv_have_swapctl_three_args], + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# undef _LARGEFILE64_SOURCE +#endif +#include +#include ]], + [[ + int num = swapctl(0, NULL,0); + ]] + ), + [c_cv_have_swapctl_three_args="yes"], + [c_cv_have_swapctl_three_args="no"] + ) + ) +fi +# Check for different versions of `swapctl' here.. +if test "x$have_swapctl" = "xyes"; then + if test "x$c_cv_have_swapctl_two_args" = "xyes"; then + AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1, + [Define if the function swapctl exists and takes two arguments.]) + fi + if test "x$c_cv_have_swapctl_three_args" = "xyes"; then + AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1, + [Define if the function swapctl exists and takes three arguments.]) + fi +fi # Check for NAN AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])], @@ -589,7 +756,7 @@ if test "x$nan_type" = "xnone"; then [[ #include #include -static float foo = NAN; +static double foo = NAN; ]], [[ if (isnan (foo)) @@ -615,7 +782,7 @@ if test "x$nan_type" = "xnone"; then #include #define __USE_ISOC99 1 #include -static float foo = NAN; +static double foo = NAN; ]], [[ if (isnan (foo)) @@ -649,7 +816,7 @@ if test "x$nan_type" = "xnone"; then #ifndef isnan # define isnan(f) ((f) != (f)) #endif -static float foo = NAN; +static double foo = NAN; ]], [[ if (isnan (foo)) @@ -707,6 +874,9 @@ if test "x$fp_layout_type" = "xunknown"; then #if HAVE_STDINT_H # include #endif +#if HAVE_INTTYPES_H +# include +#endif #if HAVE_STDBOOL_H # include #endif @@ -751,6 +921,9 @@ if test "x$fp_layout_type" = "xunknown"; then #if HAVE_STDINT_H # include #endif +#if HAVE_INTTYPES_H +# include +#endif #if HAVE_STDBOOL_H # include #endif @@ -803,6 +976,9 @@ if test "x$fp_layout_type" = "xunknown"; then #if HAVE_STDINT_H # include #endif +#if HAVE_INTTYPES_H +# include +#endif #if HAVE_STDBOOL_H # include #endif @@ -935,12 +1111,12 @@ fi AC_MSG_CHECKING([if have htonll defined]) have_htonll="no" - AC_RUN_IFELSE([ + AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #include #include -#ifdef HAVE_INTTYPES_H -#include +#if HAVE_INTTYPES_H +# include #endif ], [ return htonll(0); @@ -971,6 +1147,13 @@ AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_p #include ]) +AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], + [], + [ + #include + #include + ]) + AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage], [ AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1, @@ -1101,6 +1284,12 @@ fi if test "x$with_perfstat" = "xyes" then AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)]) + # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9 + AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include @], [Path to libcredis.])], +[ + if test "x$withval" = "xyes" + then + with_libcredis="yes" + else if test "x$withval" = "xno" + then + with_libcredis="no" + else + with_libcredis="yes" + LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include" + LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib" + fi; fi +], +[with_libcredis="yes"]) + +SAVE_CPPFLAGS="$CPPFLAGS" +SAVE_LDFLAGS="$LDFLAGS" + +CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS" +LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS" + +if test "x$with_libcredis" = "xyes" +then + if test "x$LIBCREDIS_CPPFLAGS" != "x" + then + AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS]) + fi + AC_CHECK_HEADERS(credis.h, + [with_libcredis="yes"], + [with_libcredis="no (credis.h not found)"]) +fi +if test "x$with_libcredis" = "xyes" +then + if test "x$LIBCREDIS_LDFLAGS" != "x" + then + AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS]) + fi + AC_CHECK_LIB(credis, credis_info, + [with_libcredis="yes"], + [with_libcredis="no (symbol 'credis_info' not found)"]) + +fi + +CPPFLAGS="$SAVE_CPPFLAGS" +LDFLAGS="$SAVE_LDFLAGS" + +if test "x$with_libcredis" = "xyes" +then + BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS" + BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS" + AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS) + AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS) +fi +AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes") +# }}} + # --with-libcurl {{{ with_curl_config="curl-config" with_curl_cflags="" @@ -1846,6 +2093,98 @@ fi AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes") # }}} +# --with-libmodbus {{{ +with_libmodbus_config="" +with_libmodbus_cflags="" +with_libmodbus_libs="" +AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])], +[ + if test "x$withval" = "xno" + then + with_libmodbus="no" + else if test "x$withval" = "xyes" + then + with_libmodbus="use_pkgconfig" + else if test -d "$with_libmodbus/lib" + then + AC_MSG_NOTICE([Not checking for libmodbus: Manually configured]) + with_libmodbus_cflags="-I$withval/include" + with_libmodbus_libs="-L$withval/lib -lmodbus" + with_libmodbus="yes" + fi; fi; fi +], +[with_libmodbus="use_pkgconfig"]) + +# configure using pkg-config +if test "x$with_libmodbus" = "xuse_pkgconfig" +then + if test "x$PKG_CONFIG" = "x" + then + with_libmodbus="no (Don't have pkg-config)" + fi +fi +if test "x$with_libmodbus" = "xuse_pkgconfig" +then + AC_MSG_NOTICE([Checking for modbus using $PKG_CONFIG]) + $PKG_CONFIG --exists 'modbus' 2>/dev/null + if test $? -ne 0 + then + with_libmodbus="no (pkg-config doesn't know modbus)" + fi +fi +if test "x$with_libmodbus" = "xuse_pkgconfig" +then + with_libmodbus_cflags="`$PKG_CONFIG --cflags 'modbus'`" + if test $? -ne 0 + then + with_libmodbus="no ($PKG_CONFIG failed)" + fi + with_libmodbus_libs="`$PKG_CONFIG --libs 'modbus'`" + if test $? -ne 0 + then + with_libmodbus="no ($PKG_CONFIG failed)" + fi +fi +if test "x$with_libmodbus" = "xuse_pkgconfig" +then + with_libmodbus="yes" +fi + +# with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do +# the actual checks. +if test "x$with_libmodbus" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags" + + AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_libmodbus" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + SAVE_LDFLAGS="$LDFLAGS" + + CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags" + LDFLAGS="$LDFLAGS $with_libmodbus_libs" + + AC_CHECK_LIB(modbus, modbus_connect, + [with_libmodbus="yes"], + [with_libmodbus="no (symbol modbus_connect not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +fi +if test "x$with_libmodbus" = "xyes" +then + BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags" + BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs" + AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS) + AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS) +fi +# }}} + # --with-libmysql {{{ with_mysql_config="mysql_config" with_mysql_cflags="" @@ -2255,7 +2594,7 @@ then fi AC_CHECK_HEADERS(oping.h, [with_liboping="yes"], - [with_liboping="no ('oping.h' not found)"]) + [with_liboping="no (oping.h not found)"]) fi if test "x$with_liboping" = "xyes" then @@ -2421,19 +2760,14 @@ then fi if test "x$with_libpcap" = "xyes" then - AC_CHECK_HEADERS(pcap.h, - [ - AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the header file.]) - ], [with_libpcap="no (pcap.h not found)"]) + AC_CHECK_HEADERS(pcap.h,, + [with_libpcap="no (pcap.h not found)"]) fi if test "x$with_libpcap" = "xyes" then - collect_libpcap=1 -else - collect_libpcap=0 + AC_CHECK_HEADERS(pcap-bpf.h,, + [with_libpcap="no (pcap-bpf.h not found)"]) fi -AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap], - [Wether or not to use the pcap library]) AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes") # }}} @@ -2791,7 +3125,7 @@ fi if test "x$with_python" = "xyes" then AC_MSG_CHECKING([for Python CPPFLAGS]) - python_include_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_python_inc()" | "$with_python_prog" 2>&1` + python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1` python_config_status=$? if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x" @@ -2814,7 +3148,7 @@ fi if test "x$with_python" = "xyes" then AC_MSG_CHECKING([for Python LDFLAGS]) - python_library_path=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0)" | "$with_python_prog" 2>&1` + python_library_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0))" | "$with_python_prog" 2>&1` python_config_status=$? if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x" @@ -2829,7 +3163,7 @@ fi if test "x$with_python" = "xyes" then AC_MSG_CHECKING([for Python LIBS]) - python_library_flags=`echo "import distutils.sysconfig;print distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0)" | "$with_python_prog" 2>&1` + python_library_flags=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0))" | "$with_python_prog" 2>&1` python_config_status=$? if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x" @@ -2867,6 +3201,57 @@ then fi # }}} --with-python +# --with-librabbitmq {{{ +with_librabbitmq_cppflags="" +with_librabbitmq_ldflags="" +AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])], +[ + if test "x$withval" != "xno" && test "x$withval" != "xyes" + then + with_librabbitmq_cppflags="-I$withval/include" + with_librabbitmq_ldflags="-L$withval/lib" + with_librabbitmq="yes" + else + with_librabbitmq="$withval" + fi +], +[ + with_librabbitmq="yes" +]) +if test "x$with_librabbitmq" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags" + + AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_librabbitmq" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + SAVE_LDFLAGS="$LDFLAGS" + CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags" + LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags" + + AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +fi +if test "x$with_librabbitmq" = "xyes" +then + BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags" + BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags" + BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq" + AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS) + AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS) + AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS) + AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.]) +fi +AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes") +# }}} + # --with-librouteros {{{ AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])], [ @@ -2898,7 +3283,7 @@ then fi AC_CHECK_HEADERS(routeros_api.h, [with_librouteros="yes"], - [with_librouteros="no ('routeros_api.h' not found)"]) + [with_librouteros="no (routeros_api.h not found)"]) fi if test "x$with_librouteros" = "xyes" then @@ -3097,7 +3482,7 @@ then if test "$?" != "0" then with_libstatgrab_pkg_config="no" - with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)" + with_libstatgrab="no (pkg-config doesn't know libstatgrab)" temp_result="not found" fi AC_MSG_RESULT([$temp_result]) @@ -3256,7 +3641,7 @@ AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes") with_libupsclient_config="" with_libupsclient_cflags="" with_libupsclient_libs="" -AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])], +AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])], [ if test "x$withval" = "xno" then @@ -3317,7 +3702,7 @@ then $PKG_CONFIG --exists 'libupsclient' 2>/dev/null if test $? -ne 0 then - with_libupsclient="no (pkg-config doesn't know library)" + with_libupsclient="no (pkg-config doesn't know libupsclient)" fi fi if test "x$with_libupsclient" = "xuse_pkgconfig" @@ -3506,6 +3891,98 @@ fi AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes") # }}} +# --with-libvarnish {{{ +with_libvarnish_cppflags="" +with_libvarnish_cflags="" +with_libvarnish_libs="" +AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])], +[ + if test "x$withval" = "xno" + then + with_libvarnish="no" + else if test "x$withval" = "xyes" + then + with_libvarnish="use_pkgconfig" + else if test -d "$with_libvarnish/lib" + then + AC_MSG_NOTICE([Not checking for libvarnish: Manually configured]) + with_libvarnish_cflags="-I$withval/include" + with_libvarnish_libs="-L$withval/lib -lvarnish -lvarnishcompat -lvarnishapi" + with_libvarnish="yes" + fi; fi; fi +], +[with_libvarnish="use_pkgconfig"]) + +# configure using pkg-config +if test "x$with_libvarnish" = "xuse_pkgconfig" +then + if test "x$PKG_CONFIG" = "x" + then + with_libvarnish="no (Don't have pkg-config)" + fi +fi +if test "x$with_libvarnish" = "xuse_pkgconfig" +then + AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG]) + $PKG_CONFIG --exists 'varnishapi' 2>/dev/null + if test $? -ne 0 + then + with_libvarnish="no (pkg-config doesn't know varnishapi)" + fi +fi +if test "x$with_libvarnish" = "xuse_pkgconfig" +then + with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`" + if test $? -ne 0 + then + with_libvarnish="no ($PKG_CONFIG failed)" + fi + with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`" + if test $? -ne 0 + then + with_libvarnish="no ($PKG_CONFIG failed)" + fi +fi +if test "x$with_libvarnish" = "xuse_pkgconfig" +then + with_libvarnish="yes" +fi + +# with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do +# the actual checks. +if test "x$with_libvarnish" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags" + AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_libvarnish" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + #SAVE_LDFLAGS="$LDFLAGS" + + CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags" + #LDFLAGS="$LDFLAGS $with_libvarnish_libs" + + AC_CHECK_LIB(varnishapi, VSL_OpenStats, + [with_libvarnish="yes"], + [with_libvarnish="no (symbol VSL_OpenStats not found)"], + [$with_libvarnish_libs]) + + CPPFLAGS="$SAVE_CPPFLAGS" + #LDFLAGS="$SAVE_LDFLAGS" +fi +if test "x$with_libvarnish" = "xyes" +then + BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags" + BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs" + AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS) + AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS) +fi +# }}} + # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{ with_libxml2="no (pkg-config isn't available)" with_libxml2_cflags="" @@ -3520,7 +3997,7 @@ then then with_libxml2="yes" else - with_libxml2="no (pkg-config doesn't know library)" + with_libxml2="no (pkg-config doesn't know libxml-2.0)" fi pkg-config --exists libvirt 2>/dev/null @@ -3528,7 +4005,7 @@ then then with_libvirt="yes" else - with_libvirt="no (pkg-config doesn't know library)" + with_libvirt="no (pkg-config doesn't know libvirt)" fi fi if test "x$with_libxml2" = "xyes" @@ -3645,7 +4122,7 @@ then $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null if test "$?" != "0" then - with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)" + with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)" fi AC_MSG_RESULT([$with_libopenipmipthread]) fi @@ -3706,7 +4183,11 @@ fi PKG_CHECK_MODULES([LIBNOTIFY], [libnotify], [with_libnotify="yes"], - [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"]) + [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then + with_libnotify="no" + else + with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)" + fi]) # Check for enabled/disabled features # @@ -3789,7 +4270,7 @@ AC_DEFUN( enable_plugin="yes" force="yes" else - enable_plugin="no" + enable_plugin="no (disabled on command line)" fi; fi ], [ @@ -3842,6 +4323,7 @@ plugin_contextswitch="no" plugin_cpu="no" plugin_cpufreq="no" plugin_curl_json="no" +plugin_curl_xml="no" plugin_df="no" plugin_disk="no" plugin_entropy="no" @@ -3898,7 +4380,7 @@ then plugin_vserver="yes" plugin_wireless="yes" - if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes" + if test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes" then plugin_ipvs="yes" fi @@ -3948,11 +4430,6 @@ then plugin_tape="yes" fi -if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris" -then - plugin_swap="yes" -fi - # libstatgrab if test "x$with_libstatgrab" = "xyes" then @@ -3968,7 +4445,10 @@ fi if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes" then plugin_ascent="yes" - plugin_bind="yes" + if test "x$have_strptime" = "xyes" + then + plugin_bind="yes" + fi fi if test "x$with_libopenipmipthread" = "xyes" @@ -3981,6 +4461,11 @@ then plugin_curl_json="yes" fi +if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes" +then + plugin_curl_xml="yes" +fi + if test "x$have_processor_info" = "xyes" then plugin_cpu="yes" @@ -3989,11 +4474,15 @@ if test "x$have_sysctl" = "xyes" then plugin_cpu="yes" plugin_memory="yes" - plugin_swap="yes" plugin_uptime="yes" + if test "x$ac_system" = "xDarwin" + then + plugin_swap="yes" + fi fi if test "x$have_sysctlbyname" = "xyes" then + plugin_contextswitch="yes" plugin_cpu="yes" plugin_memory="yes" plugin_tcpconns="yes" @@ -4081,7 +4570,7 @@ then plugin_swap="yes" fi -if test "x$have_swapctl" = "xyes" +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes" then plugin_swap="yes" fi @@ -4121,6 +4610,7 @@ AC_ARG_ENABLE([all-plugins], m4_divert_once([HELP_ENABLE], []) +AC_PLUGIN([amqp], [$with_librabbitmq], [AMQP output plugin]) 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]) @@ -4134,6 +4624,7 @@ AC_PLUGIN([cpu], [$plugin_cpu], [CPU usage statistics]) AC_PLUGIN([csv], [yes], [CSV output plugin]) AC_PLUGIN([curl], [$with_libcurl], [CURL generic web statistics]) AC_PLUGIN([curl_json], [$plugin_curl_json], [CouchDB statistics]) +AC_PLUGIN([curl_xml], [$plugin_curl_xml], [CURL generic xml statistics]) AC_PLUGIN([dbi], [$with_libdbi], [General database statistics]) AC_PLUGIN([df], [$plugin_df], [Filesystem usage statistics]) AC_PLUGIN([disk], [$plugin_disk], [Disk usage statistics]) @@ -4154,6 +4645,7 @@ 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([lpar], [$with_perfstat], [AIX logical partitions statistics]) AC_PLUGIN([madwifi], [$have_linux_wireless_h], [Madwifi wireless statistics]) AC_PLUGIN([match_empty_counter], [yes], [The empty counter match]) AC_PLUGIN([match_hashed], [yes], [The hashed match]) @@ -4164,6 +4656,7 @@ AC_PLUGIN([mbmon], [yes], [Query mbmond]) AC_PLUGIN([memcachec], [$with_libmemcached], [memcachec statistics]) AC_PLUGIN([memcached], [yes], [memcached statistics]) AC_PLUGIN([memory], [$plugin_memory], [Memory usage]) +AC_PLUGIN([modbus], [$with_libmodbus], [Modbus plugin]) AC_PLUGIN([multimeter], [$plugin_multimeter], [Read multimeter values]) AC_PLUGIN([mysql], [$with_libmysql], [MySQL statistics]) AC_PLUGIN([netapp], [$with_libnetapp], [NetApp plugin]) @@ -4180,12 +4673,15 @@ AC_PLUGIN([onewire], [$with_libowcapi], [OneWire sensor statistics]) AC_PLUGIN([openvpn], [yes], [OpenVPN client statistics]) AC_PLUGIN([oracle], [$with_oracle], [Oracle plugin]) AC_PLUGIN([perl], [$plugin_perl], [Embed a Perl interpreter]) +# FIXME: Check for libevent, too. +AC_PLUGIN([pinba], [$have_protoc_c], [Pinba statistics]) AC_PLUGIN([ping], [$with_liboping], [Network latency statistics]) AC_PLUGIN([postgresql], [$with_libpq], [PostgreSQL database statistics]) AC_PLUGIN([powerdns], [yes], [PowerDNS statistics]) AC_PLUGIN([processes], [$plugin_processes], [Process statistics]) AC_PLUGIN([protocols], [$plugin_protocols], [Protocol (IP, TCP, ...) statistics]) AC_PLUGIN([python], [$with_python], [Embed a Python interpreter]) +AC_PLUGIN([redis], [$with_libcredis], [Redis plugin]) AC_PLUGIN([routeros], [$with_librouteros], [RouterOS plugin]) AC_PLUGIN([rrdcached], [$librrd_rrdc_update], [RRDTool output plugin]) AC_PLUGIN([rrdtool], [$with_librrd], [RRDTool output plugin]) @@ -4201,19 +4697,23 @@ AC_PLUGIN([target_notification], [yes], [The notification target]) AC_PLUGIN([target_replace], [yes], [The replace target]) AC_PLUGIN([target_scale],[yes], [The scale target]) AC_PLUGIN([target_set], [yes], [The set target]) +AC_PLUGIN([target_v5upgrade], [yes], [The v5upgrade target]) AC_PLUGIN([tcpconns], [$plugin_tcpconns], [TCP connection statistics]) AC_PLUGIN([teamspeak2], [yes], [TeamSpeak2 server statistics]) AC_PLUGIN([ted], [$plugin_ted], [Read The Energy Detective values]) AC_PLUGIN([thermal], [$plugin_thermal], [Linux ACPI thermal zone statistics]) +AC_PLUGIN([threshold], [yes], [Threshold checking plugin]) AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant], [TokyoTyrant database statistics]) AC_PLUGIN([unixsock], [yes], [Unixsock communication plugin]) 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([vmem], [$plugin_vmem], [Virtual memory statistics]) AC_PLUGIN([vserver], [$plugin_vserver], [Linux VServer statistics]) AC_PLUGIN([wireless], [$plugin_wireless], [Wireless statistics]) AC_PLUGIN([write_http], [$with_libcurl], [HTTP output plugin]) +AC_PLUGIN([write_redis], [$with_libcredis], [Redis output plugin]) AC_PLUGIN([xmms], [$with_libxmms], [XMMS statistics]) AC_PLUGIN([zfs_arc], [$plugin_zfs_arc], [ZFS ARC statistics]) @@ -4359,7 +4859,7 @@ then with_librrd="yes (warning: librrd is not thread-safe)" fi -if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes" +if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xyes" then with_libiptc="yes (shipped version)" fi @@ -4388,6 +4888,7 @@ Configuration: Libraries: libcurl . . . . . . . $with_libcurl libdbi . . . . . . . $with_libdbi + libcredis . . . . . . $with_libcredis libesmtp . . . . . . $with_libesmtp libganglia . . . . . $with_libganglia libgcrypt . . . . . . $with_libgcrypt @@ -4397,6 +4898,7 @@ Configuration: libkstat . . . . . . $with_kstat libkvm . . . . . . . $with_libkvm libmemcached . . . . $with_libmemcached + libmodbus . . . . . . $with_libmodbus libmysql . . . . . . $with_libmysql libnetapp . . . . . . $with_libnetapp libnetlink . . . . . $with_libnetlink @@ -4410,16 +4912,20 @@ Configuration: libperl . . . . . . . $with_libperl libpq . . . . . . . . $with_libpq libpthread . . . . . $with_libpthread + librabbitmq . . . . . $with_librabbitmq librouteros . . . . . $with_librouteros librrd . . . . . . . $with_librrd libsensors . . . . . $with_libsensors libstatgrab . . . . . $with_libstatgrab libtokyotyrant . . . $with_libtokyotyrant libupsclient . . . . $with_libupsclient + libvarnish . . . . . $with_libvarnish libvirt . . . . . . . $with_libvirt libxml2 . . . . . . . $with_libxml2 libxmms . . . . . . . $with_libxmms libyajl . . . . . . . $with_libyajl + libevent . . . . . . $with_libevent + protobuf-c . . . . . $have_protoc_c oracle . . . . . . . $with_oracle python . . . . . . . $with_python @@ -4431,6 +4937,7 @@ Configuration: perl . . . . . . . . $with_perl_bindings Modules: + amqp . . . . . . . $enable_amqp apache . . . . . . . $enable_apache apcups . . . . . . . $enable_apcups apple_sensors . . . . $enable_apple_sensors @@ -4444,6 +4951,7 @@ Configuration: csv . . . . . . . . . $enable_csv curl . . . . . . . . $enable_curl curl_json . . . . . . $enable_curl_json + curl_xml . . . . . . $enable_curl_xml dbi . . . . . . . . . $enable_dbi df . . . . . . . . . $enable_df disk . . . . . . . . $enable_disk @@ -4464,6 +4972,7 @@ Configuration: libvirt . . . . . . . $enable_libvirt load . . . . . . . . $enable_load logfile . . . . . . . $enable_logfile + lpar... . . . . . . . $enable_lpar madwifi . . . . . . . $enable_madwifi match_empty_counter . $enable_match_empty_counter match_hashed . . . . $enable_match_hashed @@ -4474,6 +4983,7 @@ Configuration: memcachec . . . . . . $enable_memcachec memcached . . . . . . $enable_memcached memory . . . . . . . $enable_memory + modbus . . . . . . . $enable_modbus multimeter . . . . . $enable_multimeter mysql . . . . . . . . $enable_mysql netapp . . . . . . . $enable_netapp @@ -4490,12 +5000,14 @@ Configuration: openvpn . . . . . . . $enable_openvpn oracle . . . . . . . $enable_oracle perl . . . . . . . . $enable_perl + pinba . . . . . . . . $enable_pinba ping . . . . . . . . $enable_ping postgresql . . . . . $enable_postgresql powerdns . . . . . . $enable_powerdns processes . . . . . . $enable_processes protocols . . . . . . $enable_protocols python . . . . . . . $enable_python + redis . . . . . . . . $enable_redis routeros . . . . . . $enable_routeros rrdcached . . . . . . $enable_rrdcached rrdtool . . . . . . . $enable_rrdtool @@ -4511,19 +5023,23 @@ Configuration: target_replace . . . $enable_target_replace target_scale . . . . $enable_target_scale target_set . . . . . $enable_target_set + target_v5upgrade . . $enable_target_v5upgrade tcpconns . . . . . . $enable_tcpconns teamspeak2 . . . . . $enable_teamspeak2 ted . . . . . . . . . $enable_ted thermal . . . . . . . $enable_thermal + threshold . . . . . . $enable_threshold tokyotyrant . . . . . $enable_tokyotyrant unixsock . . . . . . $enable_unixsock uptime . . . . . . . $enable_uptime users . . . . . . . . $enable_users uuid . . . . . . . . $enable_uuid + varnish . . . . . . . $enable_varnish vmem . . . . . . . . $enable_vmem vserver . . . . . . . $enable_vserver wireless . . . . . . $enable_wireless write_http . . . . . $enable_write_http + write_redis . . . . . $enable_write_redis xmms . . . . . . . . $enable_xmms zfs_arc . . . . . . . $enable_zfs_arc diff --git a/contrib/GenericJMX.conf b/contrib/GenericJMX.conf index f4dd8f0e..1d3fe564 100644 --- a/contrib/GenericJMX.conf +++ b/contrib/GenericJMX.conf @@ -91,6 +91,12 @@ # + ###################################### + # Define the "jmx_memory" type as: # + # jmx_memory value:GAUGE:0:U # + # See types.db(5) for details. # + ###################################### + # Generic heap/nonheap memory usage. ObjectName "java.lang:type=Memory" @@ -99,7 +105,7 @@ # Creates four values: committed, init, max, used - Type "memory" + Type "jmx_memory" #InstancePrefix "" #InstanceFrom "" Table true @@ -109,11 +115,12 @@ # Creates four values: committed, init, max, used - Type "memory" + Type "jmx_memory" #InstancePrefix "" #InstanceFrom "" Table true Attribute "NonHeapMemoryUsage" + InstancePrefix "nonheap-" @@ -124,7 +131,7 @@ InstanceFrom "name" - Type "memory" + Type "jmx_memory" #InstancePrefix "" #InstanceFrom "" Table true diff --git a/contrib/collectd2html.pl b/contrib/collectd2html.pl index 7953d67c..fe4e2bdb 100644 --- a/contrib/collectd2html.pl +++ b/contrib/collectd2html.pl @@ -44,7 +44,7 @@ use Getopt::Long qw(:config no_ignore_case bundling pass_through); my $DIR = "/var/lib/collectd"; my $HOST = undef; my $IMG_FMT = "PNG"; -my $RECURSIVE = 0; +my $RECURSIVE = 1; GetOptions ( "host=s" => \$HOST, @@ -63,12 +63,12 @@ if (defined($HOST) && ($DIR !~ m/\/$HOST\/?$/) && (-d "$DIR/$HOST")) { my @COLORS = (0xff7777, 0x7777ff, 0x55ff55, 0xffcc77, 0xff77ff, 0x77ffff, 0xffff77, 0x55aaff); -my @tmp = `/bin/hostname`; chomp(@tmp); +my @tmp = `/bin/hostname -f`; chomp(@tmp); $HOST = $tmp[0] if (! defined $HOST); my $svg_p = ($IMG_FMT eq "SVG"); my $IMG_SFX = $svg_p ? ".svg" : ".png"; my $IMG_DIR = "${HOST}.dir"; -my $HTML = "${HOST}.html"; +my $HTML = "${HOST}.xhtml"; ################################################################################ # @@ -118,14 +118,20 @@ open(OUT, ">$HTML"); my $title="Rrd plot for $HOST"; print OUT < - + + + $title + -
END # list interesting rrd @@ -140,27 +146,28 @@ else { } chomp(@list); -foreach my $rrd (sort @list){ +@list = sort @list; +foreach my $rrd (@list){ $rrd =~ m/^$DIR\/(.*)\.rrd$/; push(@rrds, $1); } # table of contents print OUT <

$title

-

+

$title

+

END foreach my $bn (@rrds){ my $cleaned_bn = $bn; $cleaned_bn =~ tr/%\//__/; print OUT <$bn +$bn END } print OUT < +

END # graph interesting rrd @@ -205,7 +212,7 @@ for (my $i = 0; $i < scalar(@rrds); ++$i) { my $cleaned_bn = $bn; $cleaned_bn =~ tr/%\//__/; print OUT <

$bn

+

$bn

END # graph various ranges @@ -222,24 +229,28 @@ END my $cleaned_img = $img; $cleaned_img =~ s/%/%25/g; if (! $svg_p) { print OUT <${bn} $span

+

${bn} $span

END } else { print OUT < - ${bn} $span

+

+ ${bn} $span

END } } print OUT <[top] +

[top]

END } print OUT < +
+

+ Valid XHTML 1.0 Strict +

END diff --git a/contrib/collectd_unixsock.py b/contrib/collectd_unixsock.py index ebe549c8..ebe040d6 100644 --- a/contrib/collectd_unixsock.py +++ b/contrib/collectd_unixsock.py @@ -28,14 +28,15 @@ # 3. This notice may not be removed or altered from any source distribution. import socket +import sys class Collectd(): def __init__(self, path='/var/run/collectd-unixsock', noisy=False): self.noisy = noisy - self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - self._sock.connect(path) + self.path = path + self._sock = self._connect() def flush(self, timeout=None, plugins=[], identifiers=[]): """Send a FLUSH command. @@ -138,8 +139,20 @@ class Collectd(): return self._cmd('PUTVAL %s' % ' '.join(args)) def _cmd(self, c): + try: + return self._cmdattempt(c) + except socket.error, (errno, errstr): + sys.stderr.write("[error] Sending to socket failed: [%d] %s\n" + % (errno, errstr)) + self._sock = self._connect() + return self._cmdattempt(c) + + def _cmdattempt(self, c): if self.noisy: print "[send] %s" % c + if not self._sock: + sys.stderr.write("[error] Socket unavailable. Can not send.") + return False self._sock.send(c + "\n") status_message = self._readline() if self.noisy: @@ -151,18 +164,39 @@ class Collectd(): return int(code) return False + def _connect(self): + try: + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(self.path) + if self.noisy: + print "[socket] connected to %s" % self.path + return sock + except socket.error, (errno, errstr): + sys.stderr.write("[error] Connecting to socket failed: [%d] %s" + % (errno, errstr)) + return None + def _readline(self): """Read single line from socket""" - data = '' - buf = [] - recv = self._sock.recv - while data != "\n": - data = recv(1) - if not data: - break - if data != "\n": - buf.append(data) - return ''.join(buf) + if not self._sock: + sys.stderr.write("[error] Socket unavailable. Can not read.") + return None + try: + data = '' + buf = [] + recv = self._sock.recv + while data != "\n": + data = recv(1) + if not data: + break + if data != "\n": + buf.append(data) + return ''.join(buf) + except socket.error, (errno, errstr): + sys.stderr.write("[error] Reading from socket failed: [%d] %s" + % (errno, errstr)) + self._sock = self._connect() + return None def _readlines(self, sizehint=0): """Read multiple lines from socket""" @@ -179,7 +213,13 @@ class Collectd(): return list def __del__(self): - self._sock.close() + if not self._sock: + return + try: + self._sock.close() + except socket.error, (errno, errstr): + sys.stderr.write("[error] Closing socket failed: [%d] %s" + % (errno, errstr)) if __name__ == '__main__': diff --git a/contrib/collection.cgi b/contrib/collection.cgi index 100c0c73..af64fb1c 100755 --- a/contrib/collection.cgi +++ b/contrib/collection.cgi @@ -976,6 +976,28 @@ sub load_graph_definitions 'GPRINT:avg:LAST:%5.1lf%s Last', 'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l' ], + apache_connections => ['DEF:min={file}:count:MIN', + 'DEF:avg={file}:count:AVERAGE', + 'DEF:max={file}:count:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Connections", + 'GPRINT:min:MIN:%6.2lf Min,', + 'GPRINT:avg:AVERAGE:%6.2lf Avg,', + 'GPRINT:max:MAX:%6.2lf Max,', + 'GPRINT:avg:LAST:%6.2lf Last' + ], + apache_idle_workers => ['DEF:min={file}:count:MIN', + 'DEF:avg={file}:count:AVERAGE', + 'DEF:max={file}:count:MAX', + "AREA:max#$HalfBlue", + "AREA:min#$Canvas", + "LINE1:avg#$FullBlue:Idle Workers", + 'GPRINT:min:MIN:%6.2lf Min,', + 'GPRINT:avg:AVERAGE:%6.2lf Avg,', + 'GPRINT:max:MAX:%6.2lf Max,', + 'GPRINT:avg:LAST:%6.2lf Last' + ], apache_requests => ['DEF:min={file}:count:MIN', 'DEF:avg={file}:count:AVERAGE', 'DEF:max={file}:count:MAX', diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf index e56017e1..3bb3d8b1 100644 --- a/contrib/collection3/etc/collection.conf +++ b/contrib/collection3/etc/collection.conf @@ -93,6 +93,13 @@ GraphWidth 400 RRDOptions -l 0 DSName "value Hit ratio" + + DataSources value + RRDTitle "Bitrate ({instance})" + RRDVerticalLabel "Bit/s" + RRDFormat "%5.1lf%s" + DSName "value Bitrate" + DataSources value DSName value Percent @@ -143,13 +150,15 @@ GraphWidth 400 RRDVerticalLabel "Byte" RRDFormat "%5.1lf%s" DSName "sis_saved SIS saved " + DSName "reserved Reserved " DSName "free Free " DSName "used Used " DSName "snap_normal_used Snap used (normal)" DSName "snap_reserved Snap reserved " DSName "snap_reserve_used Snap used (resv) " - Order sis_saved free used snap_normal_used snap_reserved snap_reserve_used + Order sis_saved reserved free used snap_normal_used snap_reserved snap_reserve_used Color sis_saved 00e0e0 + Color reserved ffb000 Color free 00ff00 Color snap_reverse ff8000 Color used ff0000 @@ -388,13 +397,27 @@ GraphWidth 400 DSName "buffered Buffered" DSName "locked Locked " DSName "used Used " + DSName "available Available " + DSName "system_cache System Cache " + DSName "pool_paged Paged Pool " + DSName "pool_nonpaged Nonpaged Pool" + DSName "working_set Working Set " + DSName "system_code System Code " + DSName "system_driver System Driver" #Order used buffered cached free - Order free cached buffered used + Order free cached buffered used available system_cache system_driver system_code pool_paged pool_nonpaged working_set Color free 00e000 Color cached 0000ff Color buffered ffb000 Color locked ff00ff Color used ff0000 + Color available 00e000 + Color system_cache 0000ff + Color system_driver ff00ff + Color system_code a000a0 + Color pool_paged ffb000 + Color pool_nonpaged ff8000 + Color working_set ff0000 Module GenericStacked @@ -544,6 +567,16 @@ GraphWidth 400 Module PsCputime + + Module GenericIO + DataSources read write + DSName "read Read " + DSName write Written + RRDTitle "Process disk traffic ({instance})" + RRDVerticalLabel "Bytes per second" +# RRDOptions ... + RRDFormat "%5.1lf%s" + DataSources value DSName value RSS @@ -571,6 +604,27 @@ GraphWidth 400 Color blocked ff00ff Color stopped a000a0 + + DataSources value + RRDTitle "Signal power ({instance})" + RRDVerticalLabel "dB" + RRDFormat "%5.1lf" + DSName "value Signal power" + + + DataSources value + RRDTitle "Signal quality ({instance})" + RRDVerticalLabel "Percent" + RRDFormat "%5.1lf%%" + DSName "value Signal quality" + + + DataSources value + RRDTitle "Signal / noise ratio ({instance})" + RRDVerticalLabel "dBm" + RRDFormat "%5.1lf" + DSName "value S/N" + Module GenericStacked DataSources value diff --git a/contrib/collection3/lib/Collectd/Graph/Common.pm b/contrib/collection3/lib/Collectd/Graph/Common.pm index f88c22b5..c6e25081 100644 --- a/contrib/collection3/lib/Collectd/Graph/Common.pm +++ b/contrib/collection3/lib/Collectd/Graph/Common.pm @@ -106,7 +106,9 @@ sub group_files_by_plugin_instance for (my $i = 0; $i < @files; $i++) { my $file = $files[$i]; - my $key = $file->{'plugin_instance'} || ''; + my $key1 = $file->{'hostname'} || ''; + my $key2 = $file->{'plugin_instance'} || ''; + my $key = "$key1-$key2"; $data->{$key} ||= []; push (@{$data->{$key}}, $file); diff --git a/contrib/exec-munin.px b/contrib/exec-munin.px index 907ea9bc..3e62ce00 100755 --- a/contrib/exec-munin.px +++ b/contrib/exec-munin.px @@ -46,7 +46,8 @@ use Regexp::Common ('number'); our $ConfigFile = '/etc/exec-munin.conf'; our $TypeMap = {}; our $Scripts = []; -our $Interval = 300; +our $Interval = defined ($ENV{'COLLECTD_INTERVAL'}) ? (0 + $ENV{'COLLECTD_INTERVAL'}) : 300; +our $Hostname = defined ($ENV{'COLLECTD_HOSTNAME'}) ? $ENV{'COLLECTD_HOSTNAME'} : ''; main (); exit (0); @@ -189,7 +190,7 @@ sub execute_script my $pinst; my $time = time (); my $script = shift; - my $host = hostname () || 'localhost'; + my $host = $Hostname || hostname () || 'localhost'; if (!open ($fh, '-|', $script)) { print STDERR "Cannot execute $script: $!"; @@ -206,8 +207,11 @@ sub execute_script my $field = $1; my $value = $2; my $type = (defined ($TypeMap->{$field})) ? $TypeMap->{$field} : $field; + my $ident = "$host/munin-$pinst/$type"; - print "$host/munin-$pinst/$type interval=$Interval $time:$value\n"; + $ident =~ s/"/\\"/g; + + print qq(PUTVAL "$ident" interval=$Interval $time:$value\n); } } diff --git a/contrib/exec-nagios.px b/contrib/exec-nagios.px index a9f46633..4b112f95 100755 --- a/contrib/exec-nagios.px +++ b/contrib/exec-nagios.px @@ -24,7 +24,8 @@ use Regexp::Common ('number'); our $ConfigFile = '/etc/exec-nagios.conf'; our $TypeMap = {}; our $Scripts = []; -our $Interval = 300; +our $Interval = defined ($ENV{'COLLECTD_INTERVAL'}) ? (0 + $ENV{'COLLECTD_INTERVAL'}) : 300; +our $Hostname = defined ($ENV{'COLLECTD_HOSTNAME'}) ? $ENV{'COLLECTD_HOSTNAME'} : ''; main (); exit (0); @@ -88,6 +89,8 @@ with the C). =back +=back + =cut sub handle_config_addtype @@ -233,6 +236,7 @@ sub handle_performance_data my $type = shift; my $time = shift; my $line = shift; + my $ident = "$host/$plugin-$pinst/$type-$tinst"; my $tinst; my $value; @@ -248,7 +252,9 @@ sub handle_performance_data return; } - print "PUTVAL $host/$plugin-$pinst/$type-$tinst interval=$Interval ${time}:$value\n"; + $ident =~ s/"/\\"/g; + + print qq(PUTVAL "$ident" interval=$Interval ${time}:$value\n); } sub execute_script @@ -258,7 +264,7 @@ sub execute_script my $time = time (); my $script = shift; my @args = (); - my $host = hostname () || 'localhost'; + my $host = $Hostname || hostname () || 'localhost'; my $state = 0; my $serviceoutput; @@ -293,7 +299,7 @@ sub execute_script if ($perfdata) { - push (@serviceperfdata, split (' ', $perfdata)); + push (@serviceperfdata, split (' ', $perfdata)); } $state = 1; @@ -308,8 +314,8 @@ sub execute_script if ($perfdata) { - push (@serviceperfdata, split (' ', $perfdata)); - $state = 2; + push (@serviceperfdata, split (' ', $perfdata)); + $state = 2; } } else # ($state == 2) @@ -347,7 +353,7 @@ sub execute_script for (@serviceperfdata) { handle_performance_data ($host, 'nagios', $pinst, $script->{'type'}, - $time, $_); + $time, $_); } } } # execute_script diff --git a/contrib/exec-smartctl b/contrib/exec-smartctl index d4698160..99b69860 100755 --- a/contrib/exec-smartctl +++ b/contrib/exec-smartctl @@ -18,31 +18,29 @@ # smart ALL = (root) NOPASSWD: SMARTCTL # -- >8 -- -HOST="huhu" -INTERVAL=60 +HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}" +INTERVAL="${COLLECTD_INTERVAL:-60}" -while true +while sleep "$INTERVAL" do TEMP=$((sudo smartctl -d 3ware,0 -A /dev/twe0 | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); if [ $? -ne 0 ] then TEMP="U" fi - echo "$HOST/exec-smart/temperature-3ware_0 interval=$INTERVAL N:$TEMP" + echo "PUTVAL $HOSTNAME/exec-smart/temperature-3ware_0 interval=$INTERVAL N:$TEMP" TEMP=$((sudo smartctl -d 3ware,1 -A /dev/twe0 | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); if [ $? -ne 0 ] then TEMP="U" fi - echo "$HOST/exec-smart/temperature-3ware_1 interval=$INTERVAL N:$TEMP" + echo "PUTVAL $HOSTNAME/exec-smart/temperature-3ware_1 interval=$INTERVAL N:$TEMP" TEMP=$((sudo smartctl -d ata -A /dev/sda | grep Temperature_Celsius | awk '{ print $10; }') 2>/dev/null); if [ $? -ne 0 ] then TEMP="U" fi - echo "$HOST/exec-smart/temperature-sata_0 interval=$INTERVAL N:$TEMP" - - sleep $INTERVAL + echo "PUTVAL $HOSTNAME/exec-smart/temperature-sata_0 interval=$INTERVAL N:$TEMP" done diff --git a/contrib/migrate-4-5.px b/contrib/migrate-4-5.px new file mode 100755 index 00000000..1e54683a --- /dev/null +++ b/contrib/migrate-4-5.px @@ -0,0 +1,245 @@ +#!/usr/bin/perl + +# collectd - contrib/migrate-4-5.px +# Copyright (C) 2010 Florian Forster +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# Authors: +# Florian Forster + +use strict; +use warnings; + +use Getopt::Long ('GetOptions'); +use Data::Dumper (); +use File::Basename ('dirname'); + +our $InDir = '/var/lib/collectd'; +our $OutDir = '/tmp/collectd-5'; +our $RRDtool = 'rrdtool'; + +our %TypesCounterToDerive = # {{{ +( + apache_bytes => ["count"], + apache_requests => ["count"], + arc_counts => ["demand_data", "demand_metadata", "prefetch_data", "prefetch_metadata"], + arc_l2_bytes => ["read", "write"], + ath_stat => ["value"], + compression => ["uncompressed", "compressed"], + connections => ["value"], + cpu => ["value"], + current => ["value"], + df => ["used", "free"], + disk_merged => ["read", "write"], + disk_octets => ["read", "write"], + disk_ops => ["read", "write"], + disk_ops_complex => ["value"], + disk_time => ["read", "write"], + dns_answer => ["value"], + dns_notify => ["value"], + dns_octets => ["queries", "responses"], + dns_opcode => ["value"], + dns_qtype => ["value"], + dns_query => ["value"], + dns_question => ["value"], + dns_rcode => ["value"], + dns_reject => ["value"], + dns_request => ["value"], + dns_resolver => ["value"], + dns_response => ["value"], + dns_transfer => ["value"], + dns_update => ["value"], + dns_zops => ["value"], + fscache_stat => ["value"], + fork_rate => ["value"], + http_request_methods => ["count"], + http_requests => ["count"], + http_response_codes => ["count"], + if_collisions => ["value"], + if_dropped => ["rx", "tx"], + if_errors => ["rx", "tx"], + if_multicast => ["value"], + if_octets => ["rx", "tx"], + if_packets => ["rx", "tx"], + if_rx_errors => ["value"], + if_tx_errors => ["value"], + io_octets => ["rx", "tx"], + io_packets => ["rx", "tx"], + ipt_bytes => ["value"], + ipt_packets => ["value"], + irq => ["value"], + memcached_command => ["value"], + memcached_octets => ["rx", "tx"], + memcached_ops => ["value"], + mysql_commands => ["value"], + mysql_handler => ["value"], + mysql_locks => ["value"], + mysql_log_position => ["value"], + mysql_octets => ["rx", "tx"], + nfs_procedure => ["value"], + nginx_requests => ["value"], + node_octets => ["rx", "tx"], + node_stat => ["value"], + operations => ["value"], + pg_blks => ["value"], + pg_n_tup_c => ["value"], + pg_scan => ["value"], + pg_xact => ["value"], + protocol_counter => ["value"], + ps_cputime => ["user", "syst"], + ps_pagefaults => ["minflt", "majflt"], + ps_code => ["value"], + ps_data => ["value"], + serial_octets => ["rx", "tx"], + swap_io => ["value"], + virt_cpu_total => ["ns"], + virt_vcpu => ["ns"], + vmpage_action => ["value"], + vmpage_faults => ["minflt", "majflt"], + vmpage_io => ["in", "out"], +); # }}} %TypesCounterToDerive + +our %TypesRenameDataSource = # {{{ +( + absolute => "count", + apache_bytes => "count", + apache_connections => "count", + apache_idle_workers => "count", + apache_requests => "count", + apache_scoreboard => "count", + conntrack => "entropy", + contextswitch => "contextswitches", + delay => "seconds", + entropy => "entropy", + file_size => "bytes", + frequency => "frequency", + frequency_offset => "ppm", + http_request_methods => "count", + http_requests => "count", + http_response_codes => "count", + percent => "percent", + ping => "ping", + records => "count", + time_dispersion => "seconds", + timeleft => "timeleft", + time_offset => "seconds", + users => "users", + virt_cpu_total => "ns", + virt_vcpu => "ns", +); # }}} %TypesRenameDataSource + +sub handle_file # {{{ +{ + my @path = @_; + my $path = join ('/', @path); + + if (!($path =~ m/\.rrd$/)) + { + return; + } + + my $tmp = pop (@path); + $tmp =~ s/\.rrd$//; + my ($type, $type_inst) = split (m/-/, $tmp, 2); + $type_inst ||= ''; + + $tmp = pop (@path); + my ($plugin, $plugin_inst) = split (m/-/, $tmp, 2); + $plugin_inst ||= ''; + + if ($TypesRenameDataSource{$type}) + { + my $old_ds = $TypesRenameDataSource{$type}; + print "$RRDtool tune \"$path\" --data-source-rename ${old_ds}:value\n"; + } + + if ($TypesCounterToDerive{$type}) + { + my $ds_names = $TypesCounterToDerive{$type}; + + for (@$ds_names) + { + my $name = $_; + print "$RRDtool tune \"$path\" --data-source-type ${name}:DERIVE --minimum ${name}:0 --maximum ${name}:U\n"; + } + } + + if ((($plugin eq 'df') || ($plugin eq 'interface')) + && (!$plugin_inst) && ($type_inst)) + { + my $dir = join ('/', @path); + print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n"; + } +} # }}} sub handle_file + +sub scan_dir # {{{ +{ + my @dir_parts = @_; + my $dir_str = join ('/', @dir_parts); + my $dh; + + opendir ($dh, $dir_str) || die; + while (my $entry = readdir ($dh)) + { + my $entry_path = "$dir_str/$entry"; + + if ($entry =~ m/^\./) + { + next; + } + + if (-d $entry_path) + { + scan_dir (@dir_parts, $entry); + } + elsif (-f $entry_path) + { + handle_file (@dir_parts, $entry); + } + } + closedir ($dh); +} # }}} sub scan_dir + +sub exit_usage # {{{ +{ + print STDERR < Source directory + Default: $InDir + --outdir Destination directory + Default: $OutDir + --rrdtool Path to the RRDtool binary + Default: $RRDtool + +EOF + exit (1); +} # }}} sub exit_usage + +GetOptions ("indir|i=s" => \$InDir, + "outdir|o=s" => \$OutDir, + "rrdtool=s" => \$RRDtool, + "help|h" => \&exit_usage) or exit_usage (); + +scan_dir ($InDir); + +# vim: set sw=2 sts=2 et fdm=marker : diff --git a/contrib/python/getsigchld.py b/contrib/python/getsigchld.py new file mode 100644 index 00000000..557adc09 --- /dev/null +++ b/contrib/python/getsigchld.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +############################################################################### +# WARNING! Importing this script will break the exec plugin! # +############################################################################### +# Use this if you want to create new processes from your python scripts. # +# Normally you will get a OSError exception when the new process terminates # +# because collectd will ignore the SIGCHLD python is waiting for. # +# This script will restore the default SIGCHLD behavior so python scripts can # +# create new processes without errors. # +############################################################################### +# WARNING! Importing this script will break the exec plugin! # +############################################################################### + +import signal +import collectd + +def init(): + signal.signal(signal.SIGCHLD, signal.SIG_DFL) + +collectd.register_init(init) diff --git a/contrib/redhat/init.d-collectd b/contrib/redhat/init.d-collectd index b7c085cd..a60acb39 100644 --- a/contrib/redhat/init.d-collectd +++ b/contrib/redhat/init.d-collectd @@ -1,7 +1,7 @@ #!/bin/bash # # collectd Startup script for the Collectd statistics gathering daemon -# chkconfig: - 86 15 +# chkconfig: - 99 01 # description: Collectd is a statistics gathering daemon used to collect \ # system information ie. cpu, memory, disk, network # processname: collectd @@ -15,6 +15,7 @@ RETVAL=0 ARGS="" prog="collectdmon" +service="collectd" CONFIG=/etc/collectd.conf COLLECTD=/usr/sbin/collectd COLLECTDMONPID=/var/run/collectdmon.pid @@ -30,7 +31,7 @@ start () { daemon $prog -P $COLLECTDMONPID -c $COLLECTD -- -C "$CONFIG" RETVAL=$? echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$service fi } stop () { @@ -38,7 +39,7 @@ stop () { killproc $prog RETVAL=$? echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$service } # See how we were called. case "$1" in diff --git a/src/Makefile.am b/src/Makefile.am index d928311a..57281440 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ AM_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"' AM_CPPFLAGS += -DPKGDATADIR='"${pkgdatadir}"' sbin_PROGRAMS = collectd collectdmon -bin_PROGRAMS = collectd-nagios +bin_PROGRAMS = collectd-nagios collectdctl collectd_SOURCES = collectd.c collectd.h \ common.c common.h \ @@ -40,7 +40,7 @@ collectd_SOURCES = collectd.c collectd.h \ utils_match.c utils_match.h \ utils_subst.c utils_subst.h \ utils_tail.c utils_tail.h \ - utils_threshold.c utils_threshold.h \ + utils_time.c utils_time.h \ types_list.c types_list.h collectd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) @@ -53,6 +53,9 @@ collectd_DEPENDENCIES = if BUILD_WITH_LIBRT collectd_LDADD += -lrt endif +if BUILD_WITH_LIBPOSIX4 +collectd_LDADD += -lposix4 +endif if BUILD_WITH_LIBSOCKET collectd_LDADD += -lsocket endif @@ -102,8 +105,36 @@ endif collectd_nagios_LDADD += libcollectdclient/libcollectdclient.la collectd_nagios_DEPENDENCIES = libcollectdclient/libcollectdclient.la + +collectdctl_SOURCES = collectdctl.c +collectdctl_LDADD = +if BUILD_WITH_LIBSOCKET +collectdctl_LDADD += -lsocket +endif +if BUILD_AIX +collectdctl_LDADD += -lm +endif +collectdctl_LDADD += libcollectdclient/libcollectdclient.la +collectdctl_DEPENDENCIES = libcollectdclient/libcollectdclient.la + + pkglib_LTLIBRARIES = +BUILT_SOURCES = +CLEANFILES = + +if BUILD_PLUGIN_AMQP +pkglib_LTLIBRARIES += amqp.la +amqp_la_SOURCES = amqp.c \ + utils_cmd_putval.c utils_cmd_putval.h \ + utils_format_json.c utils_format_json.h +amqp_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBRABBITMQ_LDFLAGS) +amqp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBRABBITMQ_CPPFLAGS) +amqp_la_LIBADD = $(BUILD_WITH_LIBRABBITMQ_LIBS) +collectd_LDADD += "-dlopen" amqp.la +collectd_DEPENDENCIES += amqp.la +endif + if BUILD_PLUGIN_APACHE pkglib_LTLIBRARIES += apache.la apache_la_SOURCES = apache.c @@ -257,6 +288,17 @@ collectd_LDADD += "-dlopen" curl_json.la collectd_DEPENDENCIES += curl_json.la endif +if BUILD_PLUGIN_CURL_XML +pkglib_LTLIBRARIES += curl_xml.la +curl_xml_la_SOURCES = curl_xml.c +curl_xml_la_LDFLAGS = -module -avoid-version +curl_xml_la_CFLAGS = $(AM_CFLAGS) \ + $(BUILD_WITH_LIBCURL_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS) +curl_xml_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBXML2_LIBS) +collectd_LDADD += "-dlopen" curl_xml.la +collectd_DEPENDENCIES += curl_xml.la +endif + if BUILD_PLUGIN_DBI pkglib_LTLIBRARIES += dbi.la dbi_la_SOURCES = dbi.c \ @@ -482,6 +524,15 @@ collectd_LDADD += "-dlopen" logfile.la collectd_DEPENDENCIES += logfile.la endif +if BUILD_PLUGIN_LPAR +pkglib_LTLIBRARIES += lpar.la +lpar_la_SOURCES = lpar.c +lpar_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" lpar.la +collectd_DEPENDENCIES += lpar.la +lpar_la_LIBADD = -lperfstat +endif + if BUILD_PLUGIN_MADWIFI pkglib_LTLIBRARIES += madwifi.la madwifi_la_SOURCES = madwifi.c madwifi.h @@ -587,6 +638,16 @@ memory_la_LIBADD += -lperfstat endif endif +if BUILD_PLUGIN_MODBUS +pkglib_LTLIBRARIES += modbus.la +modbus_la_SOURCES = modbus.c +modbus_la_LDFLAGS = -module -avoid-version +modbus_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMODBUS_CFLAGS) +modbus_la_LIBADD = $(BUILD_WITH_LIBMODBUS_LIBS) +collectd_LDADD += "-dlopen" modbus.la +collectd_DEPENDENCIES += modbus.la +endif + if BUILD_PLUGIN_MULTIMETER pkglib_LTLIBRARIES += multimeter.la multimeter_la_SOURCES = multimeter.c @@ -783,6 +844,17 @@ collectd_LDADD += "-dlopen" perl.la collectd_DEPENDENCIES += perl.la endif +if BUILD_PLUGIN_PINBA +BUILT_SOURCES += pinba.pb-c.c pinba.pb-c.h +CLEANFILES += pinba.pb-c.c pinba.pb-c.h +pkglib_LTLIBRARIES += pinba.la +pinba_la_SOURCES = pinba.c +pinba_la_LDFLAGS = -module -avoid-version +pinba_la_LIBADD = -lprotobuf-c +collectd_LDADD += "-dlopen" pinba.la +collectd_DEPENDENCIES += pinba.la +endif + if BUILD_PLUGIN_PING pkglib_LTLIBRARIES += ping.la ping_la_SOURCES = ping.c @@ -817,6 +889,10 @@ if BUILD_PLUGIN_PYTHON pkglib_LTLIBRARIES += python.la python_la_SOURCES = python.c pyconfig.c pyvalues.c cpython.h python_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_PYTHON_CPPFLAGS) +python_la_CFLAGS = $(AM_CFLAGS) +if COMPILER_IS_GCC +python_la_CFLAGS += -fno-strict-aliasing -Wno-strict-aliasing +endif python_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_PYTHON_LDFLAGS) python_la_LIBADD = $(BUILD_WITH_PYTHON_LIBS) collectd_LDADD += "-dlopen" python.la @@ -843,6 +919,16 @@ collectd_LDADD += "-dlopen" protocols.la collectd_DEPENDENCIES += protocols.la endif +if BUILD_PLUGIN_REDIS +pkglib_LTLIBRARIES += redis.la +redis_la_SOURCES = redis.c +redis_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBCREDIS_LDFLAGS) +redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCREDIS_CPPFLAGS) +redis_la_LIBADD = -lcredis +collectd_LDADD += "-dlopen" redis.la +collectd_DEPENDENCIES += redis.la +endif + if BUILD_PLUGIN_ROUTEROS pkglib_LTLIBRARIES += routeros.la routeros_la_SOURCES = routeros.c @@ -1000,6 +1086,14 @@ collectd_LDADD += "-dlopen" target_set.la collectd_DEPENDENCIES += target_set.la endif +if BUILD_PLUGIN_TARGET_V5UPGRADE +pkglib_LTLIBRARIES += target_v5upgrade.la +target_v5upgrade_la_SOURCES = target_v5upgrade.c +target_v5upgrade_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" target_v5upgrade.la +collectd_DEPENDENCIES += target_v5upgrade.la +endif + if BUILD_PLUGIN_TCPCONNS pkglib_LTLIBRARIES += tcpconns.la tcpconns_la_SOURCES = tcpconns.c @@ -1036,6 +1130,14 @@ collectd_LDADD += "-dlopen" thermal.la collectd_DEPENDENCIES += thermal.la endif +if BUILD_PLUGIN_THRESHOLD +pkglib_LTLIBRARIES += threshold.la +threshold_la_SOURCES = threshold.c +threshold_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" threshold.la +collectd_DEPENDENCIES += threshold.la +endif + if BUILD_PLUGIN_TOKYOTYRANT pkglib_LTLIBRARIES += tokyotyrant.la tokyotyrant_la_SOURCES = tokyotyrant.c @@ -1054,7 +1156,6 @@ pkglib_LTLIBRARIES += unixsock.la unixsock_la_SOURCES = unixsock.c \ utils_cmd_flush.h utils_cmd_flush.c \ utils_cmd_getval.h utils_cmd_getval.c \ - utils_cmd_getthreshold.h utils_cmd_getthreshold.c \ utils_cmd_listval.h utils_cmd_listval.c \ utils_cmd_putval.h utils_cmd_putval.c \ utils_cmd_putnotif.h utils_cmd_putnotif.c @@ -1101,6 +1202,16 @@ collectd_LDADD += "-dlopen" uuid.la collectd_DEPENDENCIES += uuid.la endif +if BUILD_PLUGIN_VARNISH +pkglib_LTLIBRARIES += varnish.la +varnish_la_SOURCES = varnish.c +varnish_la_LDFLAGS = -module -avoid-version +varnish_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBVARNISH_CFLAGS) +varnish_la_LIBADD = $(BUILD_WITH_LIBVARNISH_LIBS) +collectd_LDADD += "-dlopen" varnish.la +collectd_DEPENDENCIES += varnish.la +endif + if BUILD_PLUGIN_VMEM pkglib_LTLIBRARIES += vmem.la vmem_la_SOURCES = vmem.c @@ -1140,6 +1251,16 @@ endif collectd_DEPENDENCIES += write_http.la endif +if BUILD_PLUGIN_WRITE_REDIS +pkglib_LTLIBRARIES += write_redis.la +write_redis_la_SOURCES = write_redis.c +write_redis_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBCREDIS_LDFLAGS) +write_redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCREDIS_CPPFLAGS) +write_redis_la_LIBADD = -lcredis +collectd_LDADD += "-dlopen" write_redis.la +collectd_DEPENDENCIES += write_redis.la +endif + if BUILD_PLUGIN_XMMS pkglib_LTLIBRARIES += xmms.la xmms_la_SOURCES = xmms.c @@ -1160,27 +1281,29 @@ collectd_LDADD += "-dlopen" zfs_arc.la collectd_DEPENDENCIES += zfs_arc.la endif - dist_man_MANS = collectd.1 \ collectd.conf.5 \ collectd-email.5 \ collectd-exec.5 \ + collectdctl.1 \ collectd-java.5 \ collectdmon.1 \ collectd-nagios.1 \ collectd-perl.5 \ collectd-python.5 \ collectd-snmp.5 \ + collectd-threshold.5 \ collectd-unixsock.5 \ types.db.5 #collectd_1_SOURCES = collectd.pod -EXTRA_DIST = types.db +EXTRA_DIST = types.db pinba.proto EXTRA_DIST += collectd.conf.pod \ collectd-email.pod \ collectd-exec.pod \ + collectdctl.pod \ collectd-java.pod \ collectdmon.pod \ collectd-nagios.pod \ @@ -1188,6 +1311,7 @@ EXTRA_DIST += collectd.conf.pod \ collectd-python.pod \ collectd.pod \ collectd-snmp.pod \ + collectd-threshold.pod \ collectd-unixsock.pod \ postgresql_default.conf \ types.db.pod @@ -1208,6 +1332,9 @@ EXTRA_DIST += collectd.conf.pod \ echo "$@ has some POD errors!"; false; \ fi +pinba.pb-c.c pinba.pb-c.h: pinba.proto + protoc-c --c_out $(builddir) pinba.proto + install-exec-hook: $(mkinstalldirs) $(DESTDIR)$(sysconfdir) if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \ diff --git a/src/amqp.c b/src/amqp.c new file mode 100644 index 00000000..f0abd44b --- /dev/null +++ b/src/amqp.c @@ -0,0 +1,939 @@ +/** + * collectd - src/amqp.c + * Copyright (C) 2009 Sebastien Pahl + * Copyright (C) 2010 Florian Forster + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sebastien Pahl + * Florian Forster + **/ + +#include "collectd.h" +#include "common.h" +#include "plugin.h" +#include "utils_cmd_putval.h" +#include "utils_format_json.h" + +#include + +#include +#include + +/* Defines for the delivery mode. I have no idea why they're not defined by the + * library.. */ +#define CAMQP_DM_VOLATILE 1 +#define CAMQP_DM_PERSISTENT 2 + +#define CAMQP_FORMAT_COMMAND 1 +#define CAMQP_FORMAT_JSON 2 + +#define CAMQP_CHANNEL 1 + +/* + * Data types + */ +struct camqp_config_s +{ + _Bool publish; + char *name; + + char *host; + int port; + char *vhost; + char *user; + char *password; + + char *exchange; + char *routing_key; + + /* publish only */ + uint8_t delivery_mode; + _Bool store_rates; + int format; + + /* subscribe only */ + char *exchange_type; + char *queue; + + amqp_connection_state_t connection; + pthread_mutex_t lock; +}; +typedef struct camqp_config_s camqp_config_t; + +/* + * Global variables + */ +static const char *def_host = "localhost"; +static const char *def_vhost = "/"; +static const char *def_user = "guest"; +static const char *def_password = "guest"; +static const char *def_exchange = "amq.fanout"; + +static pthread_t *subscriber_threads = NULL; +static size_t subscriber_threads_num = 0; +static _Bool subscriber_threads_running = 1; + +#define CONF(c,f) (((c)->f != NULL) ? (c)->f : def_##f) + +/* + * Functions + */ +static void camqp_close_connection (camqp_config_t *conf) /* {{{ */ +{ + int sockfd; + + if ((conf == NULL) || (conf->connection == NULL)) + return; + + sockfd = amqp_get_sockfd (conf->connection); + amqp_channel_close (conf->connection, CAMQP_CHANNEL, AMQP_REPLY_SUCCESS); + amqp_connection_close (conf->connection, AMQP_REPLY_SUCCESS); + amqp_destroy_connection (conf->connection); + close (sockfd); + conf->connection = NULL; +} /* }}} void camqp_close_connection */ + +static void camqp_config_free (void *ptr) /* {{{ */ +{ + camqp_config_t *conf = ptr; + + if (conf == NULL) + return; + + camqp_close_connection (conf); + + sfree (conf->name); + sfree (conf->host); + sfree (conf->vhost); + sfree (conf->user); + sfree (conf->password); + sfree (conf->exchange); + sfree (conf->exchange_type); + sfree (conf->queue); + sfree (conf->routing_key); + + sfree (conf); +} /* }}} void camqp_config_free */ + +static char *camqp_bytes_cstring (amqp_bytes_t *in) /* {{{ */ +{ + char *ret; + + if ((in == NULL) || (in->bytes == NULL)) + return (NULL); + + ret = malloc (in->len + 1); + if (ret == NULL) + return (NULL); + + memcpy (ret, in->bytes, in->len); + ret[in->len] = 0; + + return (ret); +} /* }}} char *camqp_bytes_cstring */ + +static _Bool camqp_is_error (camqp_config_t *conf) /* {{{ */ +{ + amqp_rpc_reply_t r; + + r = amqp_get_rpc_reply (conf->connection); + if (r.reply_type == AMQP_RESPONSE_NORMAL) + return (0); + + return (1); +} /* }}} _Bool camqp_is_error */ + +static char *camqp_strerror (camqp_config_t *conf, /* {{{ */ + char *buffer, size_t buffer_size) +{ + amqp_rpc_reply_t r; + + r = amqp_get_rpc_reply (conf->connection); + switch (r.reply_type) + { + case AMQP_RESPONSE_NORMAL: + sstrncpy (buffer, "Success", sizeof (buffer)); + break; + + case AMQP_RESPONSE_NONE: + sstrncpy (buffer, "Missing RPC reply type", sizeof (buffer)); + break; + + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + if (r.library_errno) + return (sstrerror (r.library_errno, buffer, buffer_size)); + else + sstrncpy (buffer, "End of stream", sizeof (buffer)); + break; + + case AMQP_RESPONSE_SERVER_EXCEPTION: + if (r.reply.id == AMQP_CONNECTION_CLOSE_METHOD) + { + amqp_connection_close_t *m = r.reply.decoded; + char *tmp = camqp_bytes_cstring (&m->reply_text); + ssnprintf (buffer, buffer_size, "Server connection error %d: %s", + m->reply_code, tmp); + sfree (tmp); + } + else if (r.reply.id == AMQP_CHANNEL_CLOSE_METHOD) + { + amqp_channel_close_t *m = r.reply.decoded; + char *tmp = camqp_bytes_cstring (&m->reply_text); + ssnprintf (buffer, buffer_size, "Server channel error %d: %s", + m->reply_code, tmp); + sfree (tmp); + } + else + { + ssnprintf (buffer, buffer_size, "Server error method %#"PRIx32, + r.reply.id); + } + break; + + default: + ssnprintf (buffer, buffer_size, "Unknown reply type %i", + (int) r.reply_type); + } + + return (buffer); +} /* }}} char *camqp_strerror */ + +static int camqp_create_exchange (camqp_config_t *conf) /* {{{ */ +{ + amqp_exchange_declare_ok_t *ed_ret; + + if (conf->exchange_type == NULL) + return (0); + + ed_ret = amqp_exchange_declare (conf->connection, + /* channel = */ CAMQP_CHANNEL, + /* exchange = */ amqp_cstring_bytes (conf->exchange), + /* type = */ amqp_cstring_bytes (conf->exchange_type), + /* passive = */ 0, + /* durable = */ 0, + /* auto_delete = */ 1, + /* arguments = */ AMQP_EMPTY_TABLE); + if ((ed_ret == NULL) && camqp_is_error (conf)) + { + char errbuf[1024]; + ERROR ("amqp plugin: amqp_exchange_declare failed: %s", + camqp_strerror (conf, errbuf, sizeof (errbuf))); + camqp_close_connection (conf); + return (-1); + } + + INFO ("amqp plugin: Successfully created exchange \"%s\" " + "with type \"%s\".", + conf->exchange, conf->exchange_type); + + return (0); +} /* }}} int camqp_create_exchange */ + +static int camqp_setup_queue (camqp_config_t *conf) /* {{{ */ +{ + amqp_queue_declare_ok_t *qd_ret; + amqp_basic_consume_ok_t *cm_ret; + + qd_ret = amqp_queue_declare (conf->connection, + /* channel = */ CAMQP_CHANNEL, + /* queue = */ (conf->queue != NULL) + ? amqp_cstring_bytes (conf->queue) + : AMQP_EMPTY_BYTES, + /* passive = */ 0, + /* durable = */ 0, + /* exclusive = */ 0, + /* auto_delete = */ 1, + /* arguments = */ AMQP_EMPTY_TABLE); + if (qd_ret == NULL) + { + ERROR ("amqp plugin: amqp_queue_declare failed."); + camqp_close_connection (conf); + return (-1); + } + + if (conf->queue == NULL) + { + conf->queue = camqp_bytes_cstring (&qd_ret->queue); + if (conf->queue == NULL) + { + ERROR ("amqp plugin: camqp_bytes_cstring failed."); + camqp_close_connection (conf); + return (-1); + } + + INFO ("amqp plugin: Created queue \"%s\".", conf->queue); + } + DEBUG ("amqp plugin: Successfully created queue \"%s\".", conf->queue); + + /* bind to an exchange */ + if (conf->exchange != NULL) + { + amqp_queue_bind_ok_t *qb_ret; + + assert (conf->queue != NULL); + qb_ret = amqp_queue_bind (conf->connection, + /* channel = */ CAMQP_CHANNEL, + /* queue = */ amqp_cstring_bytes (conf->queue), + /* exchange = */ amqp_cstring_bytes (conf->exchange), + /* routing_key = */ (conf->routing_key != NULL) + ? amqp_cstring_bytes (conf->routing_key) + : AMQP_EMPTY_BYTES, + /* arguments = */ AMQP_EMPTY_TABLE); + if ((qb_ret == NULL) && camqp_is_error (conf)) + { + char errbuf[1024]; + ERROR ("amqp plugin: amqp_queue_bind failed: %s", + camqp_strerror (conf, errbuf, sizeof (errbuf))); + camqp_close_connection (conf); + return (-1); + } + + DEBUG ("amqp plugin: Successfully bound queue \"%s\" to exchange \"%s\".", + conf->queue, conf->exchange); + } /* if (conf->exchange != NULL) */ + + cm_ret = amqp_basic_consume (conf->connection, + /* channel = */ CAMQP_CHANNEL, + /* queue = */ amqp_cstring_bytes (conf->queue), + /* consumer_tag = */ AMQP_EMPTY_BYTES, + /* no_local = */ 0, + /* no_ack = */ 1, + /* exclusive = */ 0); + if ((cm_ret == NULL) && camqp_is_error (conf)) + { + char errbuf[1024]; + ERROR ("amqp plugin: amqp_basic_consume failed: %s", + camqp_strerror (conf, errbuf, sizeof (errbuf))); + camqp_close_connection (conf); + return (-1); + } + + return (0); +} /* }}} int camqp_setup_queue */ + +static int camqp_connect (camqp_config_t *conf) /* {{{ */ +{ + amqp_rpc_reply_t reply; + int sockfd; + int status; + + if (conf->connection != NULL) + return (0); + + conf->connection = amqp_new_connection (); + if (conf->connection == NULL) + { + ERROR ("amqp plugin: amqp_new_connection failed."); + return (ENOMEM); + } + + sockfd = amqp_open_socket (CONF(conf, host), conf->port); + if (sockfd < 0) + { + char errbuf[1024]; + status = (-1) * sockfd; + ERROR ("amqp plugin: amqp_open_socket failed: %s", + sstrerror (status, errbuf, sizeof (errbuf))); + amqp_destroy_connection (conf->connection); + conf->connection = NULL; + return (status); + } + amqp_set_sockfd (conf->connection, sockfd); + + reply = amqp_login (conf->connection, CONF(conf, vhost), + /* channel max = */ 0, + /* frame max = */ 131072, + /* heartbeat = */ 0, + /* authentication = */ AMQP_SASL_METHOD_PLAIN, + CONF(conf, user), CONF(conf, password)); + if (reply.reply_type != AMQP_RESPONSE_NORMAL) + { + ERROR ("amqp plugin: amqp_login (vhost = %s, user = %s) failed.", + CONF(conf, vhost), CONF(conf, user)); + amqp_destroy_connection (conf->connection); + close (sockfd); + conf->connection = NULL; + return (1); + } + + amqp_channel_open (conf->connection, /* channel = */ 1); + /* FIXME: Is checking "reply.reply_type" really correct here? How does + * it get set? --octo */ + if (reply.reply_type != AMQP_RESPONSE_NORMAL) + { + ERROR ("amqp plugin: amqp_channel_open failed."); + amqp_connection_close (conf->connection, AMQP_REPLY_SUCCESS); + amqp_destroy_connection (conf->connection); + close(sockfd); + conf->connection = NULL; + return (1); + } + + INFO ("amqp plugin: Successfully opened connection to vhost \"%s\" " + "on %s:%i.", CONF(conf, vhost), CONF(conf, host), conf->port); + + status = camqp_create_exchange (conf); + if (status != 0) + return (status); + + if (!conf->publish) + return (camqp_setup_queue (conf)); + return (0); +} /* }}} int camqp_connect */ + +static int camqp_shutdown (void) /* {{{ */ +{ + size_t i; + + DEBUG ("amqp plugin: Shutting down %zu subscriber threads.", + subscriber_threads_num); + + subscriber_threads_running = 0; + for (i = 0; i < subscriber_threads_num; i++) + { + /* FIXME: Sending a signal is not very elegant here. Maybe find out how + * to use a timeout in the thread and check for the variable in regular + * intervals. */ + pthread_kill (subscriber_threads[i], SIGTERM); + pthread_join (subscriber_threads[i], /* retval = */ NULL); + } + + subscriber_threads_num = 0; + sfree (subscriber_threads); + + DEBUG ("amqp plugin: All subscriber threads exited."); + + return (0); +} /* }}} int camqp_shutdown */ + +/* + * Subscribing code + */ +static int camqp_read_body (camqp_config_t *conf, /* {{{ */ + size_t body_size, const char *content_type) +{ + char body[body_size + 1]; + char *body_ptr; + size_t received; + amqp_frame_t frame; + int status; + + memset (body, 0, sizeof (body)); + body_ptr = &body[0]; + received = 0; + + while (received < body_size) + { + status = amqp_simple_wait_frame (conf->connection, &frame); + if (status < 0) + { + char errbuf[1024]; + status = (-1) * status; + ERROR ("amqp plugin: amqp_simple_wait_frame failed: %s", + sstrerror (status, errbuf, sizeof (errbuf))); + camqp_close_connection (conf); + return (status); + } + + if (frame.frame_type != AMQP_FRAME_BODY) + { + NOTICE ("amqp plugin: Unexpected frame type: %#"PRIx8, + frame.frame_type); + return (-1); + } + + if ((body_size - received) < frame.payload.body_fragment.len) + { + WARNING ("amqp plugin: Body is larger than indicated by header."); + return (-1); + } + + memcpy (body_ptr, frame.payload.body_fragment.bytes, + frame.payload.body_fragment.len); + body_ptr += frame.payload.body_fragment.len; + received += frame.payload.body_fragment.len; + } /* while (received < body_size) */ + + if (strcasecmp ("text/collectd", content_type) == 0) + { + status = handle_putval (stderr, body); + if (status != 0) + ERROR ("amqp plugin: handle_putval failed with status %i.", + status); + return (status); + } + else if (strcasecmp ("application/json", content_type) == 0) + { + ERROR ("amqp plugin: camqp_read_body: Parsing JSON data has not " + "been implemented yet. FIXME!"); + return (0); + } + else + { + ERROR ("amqp plugin: camqp_read_body: Unknown content type \"%s\".", + content_type); + return (EINVAL); + } + + /* not reached */ + return (0); +} /* }}} int camqp_read_body */ + +static int camqp_read_header (camqp_config_t *conf) /* {{{ */ +{ + int status; + amqp_frame_t frame; + amqp_basic_properties_t *properties; + char *content_type; + + status = amqp_simple_wait_frame (conf->connection, &frame); + if (status < 0) + { + char errbuf[1024]; + status = (-1) * status; + ERROR ("amqp plugin: amqp_simple_wait_frame failed: %s", + sstrerror (status, errbuf, sizeof (errbuf))); + camqp_close_connection (conf); + return (status); + } + + if (frame.frame_type != AMQP_FRAME_HEADER) + { + NOTICE ("amqp plugin: Unexpected frame type: %#"PRIx8, + frame.frame_type); + return (-1); + } + + properties = frame.payload.properties.decoded; + content_type = camqp_bytes_cstring (&properties->content_type); + if (content_type == NULL) + { + ERROR ("amqp plugin: Unable to determine content type."); + return (-1); + } + + status = camqp_read_body (conf, + (size_t) frame.payload.properties.body_size, + content_type); + + sfree (content_type); + return (status); +} /* }}} int camqp_read_header */ + +static void *camqp_subscribe_thread (void *user_data) /* {{{ */ +{ + camqp_config_t *conf = user_data; + int status; + + while (subscriber_threads_running) + { + amqp_frame_t frame; + + status = camqp_connect (conf); + if (status != 0) + { + ERROR ("amqp plugin: camqp_connect failed. " + "Will sleep for %i seconds.", interval_g); + sleep (interval_g); + continue; + } + + status = amqp_simple_wait_frame (conf->connection, &frame); + if (status < 0) + { + ERROR ("amqp plugin: amqp_simple_wait_frame failed. " + "Will sleep for %i seconds.", interval_g); + camqp_close_connection (conf); + sleep (interval_g); + continue; + } + + if (frame.frame_type != AMQP_FRAME_METHOD) + { + DEBUG ("amqp plugin: Unexpected frame type: %#"PRIx8, + frame.frame_type); + continue; + } + + if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD) + { + DEBUG ("amqp plugin: Unexpected method id: %#"PRIx32, + frame.payload.method.id); + continue; + } + + status = camqp_read_header (conf); + + amqp_maybe_release_buffers (conf->connection); + } /* while (subscriber_threads_running) */ + + camqp_config_free (conf); + pthread_exit (NULL); +} /* }}} void *camqp_subscribe_thread */ + +static int camqp_subscribe_init (camqp_config_t *conf) /* {{{ */ +{ + int status; + pthread_t *tmp; + + tmp = realloc (subscriber_threads, + sizeof (*subscriber_threads) * (subscriber_threads_num + 1)); + if (tmp == NULL) + { + ERROR ("amqp plugin: realloc failed."); + camqp_config_free (conf); + return (ENOMEM); + } + subscriber_threads = tmp; + tmp = subscriber_threads + subscriber_threads_num; + memset (tmp, 0, sizeof (*tmp)); + + status = pthread_create (tmp, /* attr = */ NULL, + camqp_subscribe_thread, conf); + if (status != 0) + { + char errbuf[1024]; + ERROR ("amqp plugin: pthread_create failed: %s", + sstrerror (status, errbuf, sizeof (errbuf))); + camqp_config_free (conf); + return (status); + } + + subscriber_threads_num++; + + return (0); +} /* }}} int camqp_subscribe_init */ + +/* + * Publishing code + */ +/* XXX: You must hold "conf->lock" when calling this function! */ +static int camqp_write_locked (camqp_config_t *conf, /* {{{ */ + const char *buffer, const char *routing_key) +{ + amqp_basic_properties_t props; + int status; + + status = camqp_connect (conf); + if (status != 0) + return (status); + + memset (&props, 0, sizeof (props)); + props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG + | AMQP_BASIC_DELIVERY_MODE_FLAG + | AMQP_BASIC_APP_ID_FLAG; + if (conf->format == CAMQP_FORMAT_COMMAND) + props.content_type = amqp_cstring_bytes("text/collectd"); + else if (conf->format == CAMQP_FORMAT_JSON) + props.content_type = amqp_cstring_bytes("application/json"); + else + assert (23 == 42); + props.delivery_mode = conf->delivery_mode; + props.app_id = amqp_cstring_bytes("collectd"); + + status = amqp_basic_publish(conf->connection, + /* channel = */ 1, + amqp_cstring_bytes(CONF(conf, exchange)), + amqp_cstring_bytes (routing_key), + /* mandatory = */ 0, + /* immediate = */ 0, + &props, + amqp_cstring_bytes(buffer)); + if (status != 0) + { + ERROR ("amqp plugin: amqp_basic_publish failed with status %i.", + status); + camqp_close_connection (conf); + } + + return (status); +} /* }}} int camqp_write_locked */ + +static int camqp_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */ + user_data_t *user_data) +{ + camqp_config_t *conf = user_data->data; + char routing_key[6 * DATA_MAX_NAME_LEN]; + char buffer[4096]; + int status; + + if ((ds == NULL) || (vl == NULL) || (conf == NULL)) + return (EINVAL); + + memset (buffer, 0, sizeof (buffer)); + + if (conf->routing_key != NULL) + { + sstrncpy (routing_key, conf->routing_key, sizeof (routing_key)); + } + else + { + size_t i; + ssnprintf (routing_key, sizeof (routing_key), "collectd/%s/%s/%s/%s/%s", + vl->host, + vl->plugin, vl->plugin_instance, + vl->type, vl->type_instance); + + /* Switch slashes (the only character forbidden by collectd) and dots + * (the separation character used by AMQP). */ + for (i = 0; routing_key[i] != 0; i++) + { + if (routing_key[i] == '.') + routing_key[i] = '/'; + else if (routing_key[i] == '/') + routing_key[i] = '.'; + } + } + + if (conf->format == CAMQP_FORMAT_COMMAND) + { + status = create_putval (buffer, sizeof (buffer), ds, vl); + if (status != 0) + { + ERROR ("amqp plugin: create_putval failed with status %i.", + status); + return (status); + } + } + else if (conf->format == CAMQP_FORMAT_JSON) + { + size_t bfree = sizeof (buffer); + size_t bfill = 0; + + format_json_initialize (buffer, &bfill, &bfree); + format_json_value_list (buffer, &bfill, &bfree, ds, vl, conf->store_rates); + format_json_finalize (buffer, &bfill, &bfree); + } + else + { + ERROR ("amqp plugin: Invalid format (%i).", conf->format); + return (-1); + } + + pthread_mutex_lock (&conf->lock); + status = camqp_write_locked (conf, buffer, routing_key); + pthread_mutex_unlock (&conf->lock); + + return (status); +} /* }}} int camqp_write */ + +/* + * Config handling + */ +static int camqp_config_set_format (oconfig_item_t *ci, /* {{{ */ + camqp_config_t *conf) +{ + char *string; + int status; + + string = NULL; + status = cf_util_get_string (ci, &string); + if (status != 0) + return (status); + + assert (string != NULL); + if (strcasecmp ("Command", string) == 0) + conf->format = CAMQP_FORMAT_COMMAND; + else if (strcasecmp ("JSON", string) == 0) + conf->format = CAMQP_FORMAT_JSON; + else + { + WARNING ("amqp plugin: Invalid format string: %s", + string); + } + + free (string); + + return (0); +} /* }}} int config_set_string */ + +static int camqp_config_connection (oconfig_item_t *ci, /* {{{ */ + _Bool publish) +{ + camqp_config_t *conf; + int status; + int i; + + conf = malloc (sizeof (*conf)); + if (conf == NULL) + { + ERROR ("amqp plugin: malloc failed."); + return (ENOMEM); + } + + /* Initialize "conf" {{{ */ + memset (conf, 0, sizeof (*conf)); + conf->publish = publish; + conf->name = NULL; + conf->format = CAMQP_FORMAT_COMMAND; + conf->host = NULL; + conf->port = 5672; + conf->vhost = NULL; + conf->user = NULL; + conf->password = NULL; + conf->exchange = NULL; + conf->routing_key = NULL; + /* publish only */ + conf->delivery_mode = CAMQP_DM_VOLATILE; + conf->store_rates = 0; + /* subscribe only */ + conf->exchange_type = NULL; + conf->queue = NULL; + /* general */ + conf->connection = NULL; + pthread_mutex_init (&conf->lock, /* attr = */ NULL); + /* }}} */ + + status = cf_util_get_string (ci, &conf->name); + if (status != 0) + { + sfree (conf); + return (status); + } + + for (i = 0; i < ci->children_num; i++) + { + oconfig_item_t *child = ci->children + i; + + if (strcasecmp ("Host", child->key) == 0) + status = cf_util_get_string (child, &conf->host); + else if (strcasecmp ("Port", child->key) == 0) + { + status = cf_util_get_port_number (child); + if (status > 0) + { + conf->port = status; + status = 0; + } + } + else if (strcasecmp ("VHost", child->key) == 0) + status = cf_util_get_string (child, &conf->vhost); + else if (strcasecmp ("User", child->key) == 0) + status = cf_util_get_string (child, &conf->user); + else if (strcasecmp ("Password", child->key) == 0) + status = cf_util_get_string (child, &conf->password); + else if (strcasecmp ("Exchange", child->key) == 0) + status = cf_util_get_string (child, &conf->exchange); + else if ((strcasecmp ("ExchangeType", child->key) == 0) && !publish) + status = cf_util_get_string (child, &conf->exchange_type); + else if ((strcasecmp ("Queue", child->key) == 0) && !publish) + status = cf_util_get_string (child, &conf->queue); + else if (strcasecmp ("RoutingKey", child->key) == 0) + status = cf_util_get_string (child, &conf->routing_key); + else if ((strcasecmp ("Persistent", child->key) == 0) && publish) + { + _Bool tmp = 0; + status = cf_util_get_boolean (child, &tmp); + if (tmp) + conf->delivery_mode = CAMQP_DM_PERSISTENT; + else + conf->delivery_mode = CAMQP_DM_VOLATILE; + } + else if ((strcasecmp ("StoreRates", child->key) == 0) && publish) + status = cf_util_get_boolean (child, &conf->store_rates); + else if ((strcasecmp ("Format", child->key) == 0) && publish) + status = camqp_config_set_format (child, conf); + else + WARNING ("amqp plugin: Ignoring unknown " + "configuration option \"%s\".", child->key); + + if (status != 0) + break; + } /* for (i = 0; i < ci->children_num; i++) */ + + if ((status == 0) && (conf->exchange == NULL)) + { + if (conf->exchange_type != NULL) + WARNING ("amqp plugin: The option \"ExchangeType\" was given " + "without the \"Exchange\" option. It will be ignored."); + + if (!publish && (conf->routing_key != NULL)) + WARNING ("amqp plugin: The option \"RoutingKey\" was given " + "without the \"Exchange\" option. It will be ignored."); + + } + + if (status != 0) + { + camqp_config_free (conf); + return (status); + } + + if (conf->exchange != NULL) + { + DEBUG ("amqp plugin: camqp_config_connection: exchange = %s;", + conf->exchange); + } + + if (publish) + { + char cbname[128]; + user_data_t ud = { conf, camqp_config_free }; + + ssnprintf (cbname, sizeof (cbname), "amqp/%s", conf->name); + + status = plugin_register_write (cbname, camqp_write, &ud); + if (status != 0) + { + camqp_config_free (conf); + return (status); + } + } + else + { + status = camqp_subscribe_init (conf); + if (status != 0) + { + camqp_config_free (conf); + return (status); + } + } + + return (0); +} /* }}} int camqp_config_connection */ + +static int camqp_config (oconfig_item_t *ci) /* {{{ */ +{ + int i; + + for (i = 0; i < ci->children_num; i++) + { + oconfig_item_t *child = ci->children + i; + + if (strcasecmp ("Publish", child->key) == 0) + camqp_config_connection (child, /* publish = */ 1); + else if (strcasecmp ("Subscribe", child->key) == 0) + camqp_config_connection (child, /* publish = */ 0); + else + WARNING ("amqp plugin: Ignoring unknown config option \"%s\".", + child->key); + } /* for (ci->children_num) */ + + return (0); +} /* }}} int camqp_config */ + +void module_register (void) +{ + plugin_register_complex_config ("amqp", camqp_config); + plugin_register_shutdown ("amqp", camqp_shutdown); +} /* void module_register */ + +/* vim: set sw=4 sts=4 et fdm=marker : */ diff --git a/src/apache.c b/src/apache.c index ad877b5f..9be32d16 100644 --- a/src/apache.c +++ b/src/apache.c @@ -1,6 +1,6 @@ /** * collectd - src/apache.c - * Copyright (C) 2006-2009 Florian octo Forster + * Copyright (C) 2006-2010 Florian octo Forster * Copyright (C) 2007 Florent EppO Monbillard * Copyright (C) 2009 Amit Gupta * @@ -144,6 +144,8 @@ static size_t apache_header_callback (void *buf, size_t size, size_t nmemb, st->server_type = APACHE; else if (strstr (buf, "lighttpd") != NULL) st->server_type = LIGHTTPD; + else if (strstr (buf, "IBM_HTTP_Server") != NULL) + st->server_type = APACHE; else { const char *hdr = buf; @@ -313,7 +315,8 @@ static int config_add (oconfig_item_t *ci) (st->host != NULL) ? st->host : hostname_g, (st->name != NULL) ? st->name : "default"), - status = plugin_register_complex_read (callback_name, + status = plugin_register_complex_read (/* group = */ NULL, + /* name = */ callback_name, /* callback = */ apache_read_host, /* interval = */ NULL, /* user_data = */ &ud); @@ -332,57 +335,22 @@ static int config (oconfig_item_t *ci) { int status = 0; int i; - oconfig_item_t *lci = NULL; /* legacy config */ for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; - if (strcasecmp ("Instance", child->key) == 0 && child->children_num > 0) + if (strcasecmp ("Instance", child->key) == 0) config_add (child); else - { - /* legacy mode - convert to config */ - if (lci == NULL) - { - lci = malloc (sizeof(*lci)); - if (lci == NULL) - { - ERROR ("apache plugin: malloc failed."); - return (-1); - } - memset (lci, '\0', sizeof (*lci)); - } - - lci->children_num++; - lci->children = - realloc (lci->children, - lci->children_num * sizeof (*child)); - if (lci->children == NULL) - { - ERROR ("apache plugin: realloc failed."); - return (-1); - } - memcpy (&lci->children[lci->children_num-1], child, sizeof (*child)); - } + WARNING ("apache plugin: The configuration option " + "\"%s\" is not allowed here. Did you " + "forget to add an block " + "around the configuration?", + child->key); } /* for (ci->children) */ - if (lci) - { - /* create a entry */ - lci->key = "Instance"; - lci->values_num = 1; - lci->values = (oconfig_value_t *) malloc (lci->values_num * sizeof (oconfig_value_t)); - lci->values[0].type = OCONFIG_TYPE_STRING; - lci->values[0].value.string = ""; - - status = config_add (lci); - sfree (lci->values); - sfree (lci->children); - sfree (lci); - } - - return status; + return (status); } /* int config */ /* initialize curl for each host */ @@ -419,6 +387,8 @@ static int init_host (apache_t *st) /* {{{ */ st->server_type = APACHE; else if (strcasecmp(st->server, "lighttpd") == 0) st->server_type = LIGHTTPD; + else if (strcasecmp(st->server, "ibm_http_server") == 0) + st->server_type = APACHE; else WARNING ("apache plugin: Unknown `Server' setting: %s", st->server); @@ -506,13 +476,13 @@ static void submit_value (const char *type, const char *type_instance, plugin_dispatch_values (&vl); } /* void submit_value */ -static void submit_counter (const char *type, const char *type_instance, - counter_t c, apache_t *st) +static void submit_derive (const char *type, const char *type_instance, + derive_t c, apache_t *st) { value_t v; - v.counter = c; + v.derive = c; submit_value (type, type_instance, v, st); -} /* void submit_counter */ +} /* void submit_derive */ static void submit_gauge (const char *type, const char *type_instance, gauge_t g, apache_t *st) @@ -674,11 +644,11 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ { if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0)) - submit_counter ("apache_requests", "", + submit_derive ("apache_requests", "", atoll (fields[2]), st); else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0)) - submit_counter ("apache_bytes", "", + submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st); } else if (fields_num == 2) @@ -688,6 +658,9 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ else if ((strcmp (fields[0], "BusyServers:") == 0) /* Apache 1.* */ || (strcmp (fields[0], "BusyWorkers:") == 0) /* Apache 2.* */) submit_gauge ("apache_connections", NULL, atol (fields[1]), st); + else if ((strcmp (fields[0], "IdleServers:") == 0) /* Apache 1.x */ + || (strcmp (fields[0], "IdleWorkers:") == 0) /* Apache 2.x */) + submit_gauge ("apache_idle_workers", NULL, atol (fields[1]), st); } } diff --git a/src/battery.c b/src/battery.c index b62ad81d..4178d8b5 100644 --- a/src/battery.c +++ b/src/battery.c @@ -514,7 +514,8 @@ static int battery_read (void) if (0 == access (battery_acpi_dir, R_OK)) walk_directory (battery_acpi_dir, battery_read_acpi, - /* user_data = */ NULL); + /* user_data = */ NULL, + /* include hidden */ 0); else { char errbuf[1024]; diff --git a/src/bind.c b/src/bind.c index 63887747..db8a891f 100644 --- a/src/bind.c +++ b/src/bind.c @@ -1,7 +1,7 @@ /** * collectd - src/bind.c - * Copyright (C) 2009 Bruno Prémont - * Copyright (C) 2009 Florian Forster + * Copyright (C) 2009 Bruno Prémont + * Copyright (C) 2009,2010 Florian 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 @@ -18,10 +18,22 @@ * * Authors: * Bruno Prémont - * Florian Forster + * Florian Forster **/ -#define _XOPEN_SOURCE 600 /* glibc2 needs this for strptime */ +#include "config.h" + +#if STRPTIME_NEEDS_STANDARDS +# ifndef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +# endif +# ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200112L +# endif +# ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 500 +# endif +#endif /* STRPTIME_NEEDS_STANDARDS */ #include "collectd.h" #include "common.h" @@ -237,7 +249,7 @@ static void submit (time_t ts, const char *plugin_instance, /* {{{ */ vl.values = values; vl.values_len = 1; - vl.time = ts; + vl.time = TIME_T_TO_CDTIME_T (ts); sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "bind", sizeof(vl.plugin)); if (plugin_instance) { @@ -333,36 +345,31 @@ static int bind_xml_list_callback (const char *name, /* {{{ */ return (0); } /* }}} int bind_xml_list_callback */ -static int bind_xml_read_counter (xmlDoc *doc, xmlNode *node, /* {{{ */ - counter_t *ret_value) +static int bind_xml_read_derive (xmlDoc *doc, xmlNode *node, /* {{{ */ + derive_t *ret_value) { - char *str_ptr, *end_ptr; - long long int value; + char *str_ptr; + value_t value; + int status; str_ptr = (char *) xmlNodeListGetString (doc, node->xmlChildrenNode, 1); if (str_ptr == NULL) { - ERROR ("bind plugin: bind_xml_read_counter: xmlNodeListGetString failed."); + ERROR ("bind plugin: bind_xml_read_derive: xmlNodeListGetString failed."); return (-1); } - errno = 0; - value = strtoll (str_ptr, &end_ptr, 10); - xmlFree(str_ptr); - if (str_ptr == end_ptr || errno) + status = parse_value (str_ptr, &value, DS_TYPE_DERIVE); + if (status != 0) { - if (errno && (value < 0)) - ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with underflow."); - else if (errno && (value > 0)) - ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with overflow."); - else - ERROR ("bind plugin: bind_xml_read_counter: strtoll failed."); + ERROR ("bind plugin: Parsing string \"%s\" to derive value failed.", + str_ptr); return (-1); } - *ret_value = value; + *ret_value = value.derive; return (0); -} /* }}} int bind_xml_read_counter */ +} /* }}} int bind_xml_read_derive */ static int bind_xml_read_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */ gauge_t *ret_value) @@ -523,7 +530,7 @@ static int bind_parse_generic_name_value (const char *xpath_expression, /* {{{ * if (ds_type == DS_TYPE_GAUGE) status = bind_xml_read_gauge (doc, counter, &value.gauge); else - status = bind_xml_read_counter (doc, counter, &value.counter); + status = bind_xml_read_derive (doc, counter, &value.derive); if (status != 0) continue; @@ -596,7 +603,7 @@ static int bind_parse_generic_value_list (const char *xpath_expression, /* {{{ * if (ds_type == DS_TYPE_GAUGE) status = bind_xml_read_gauge (doc, child, &value.gauge); else - status = bind_xml_read_counter (doc, child, &value.counter); + status = bind_xml_read_derive (doc, child, &value.derive); if (status != 0) continue; diff --git a/src/collectd-exec.pod b/src/collectd-exec.pod index 81b3a2ec..10f68290 100644 --- a/src/collectd-exec.pod +++ b/src/collectd-exec.pod @@ -273,6 +273,14 @@ to make use of collectd's more powerful interface. The user, the binary is executed as, may not have root privileges, i.Ee. must have an UID that is non-zero. This is for your own good. +=item + +Early versions of the plugin did not use a command but treated all lines as if +they were arguments to the I command. When the I command was +implemented, this behavior was kept for lines which start with an unknown +command for backwards compatibility. This compatibility code has been removed +in I5>. + =back =head1 SEE ALSO diff --git a/src/collectd-java.pod b/src/collectd-java.pod index 9c0c6eba..9e2f81aa 100644 --- a/src/collectd-java.pod +++ b/src/collectd-java.pod @@ -667,6 +667,14 @@ will be used. Use I to authenticate to the server. If not given, unauthenticated access is used. +=item B I + +Prefixes the generated I with I. If a second +I is specified in a referenced I block, the prefix +specified in the I block will appear at the beginning of the +I, the prefix specified in the I block will be appended +to it. + =item B I Configures which of the I blocks to use with this connection. May be diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 29e34a4c..af8744de 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -1,6 +1,6 @@ /** * collectd-nagios - src/collectd-nagios.c - * Copyright (C) 2008 Florian octo Forster + * Copyright (C) 2008-2010 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 @@ -35,14 +35,6 @@ #include #include -#include -#include - -#include "libcollectdclient/client.h" - -/* - * This is copied directly from collectd.h. Make changes there! - */ #if NAN_STATIC_DEFAULT # include /* #endif NAN_STATIC_DEFAULT*/ @@ -66,8 +58,16 @@ # ifndef isnan # define isnan(f) ((f) != (f)) # endif /* !defined(isnan) */ +# ifndef isfinite +# define isfinite(f) (((f) - (f)) == 0.0) +# endif +# ifndef isinf +# define isinf(f) (!isfinite(f) && !isnan(f)) +# endif #endif /* NAN_ZERO_ZERO */ +#include "libcollectdclient/client.h" + #define RET_OKAY 0 #define RET_WARNING 1 #define RET_CRITICAL 2 @@ -96,6 +96,7 @@ static char *hostname_g = NULL; static range_t range_critical_g; static range_t range_warning_g; static int consolitation_g = CON_NONE; +static _Bool nan_is_error_g = 0; static char **match_ds_g = NULL; static int match_ds_num_g = 0; @@ -254,6 +255,7 @@ static void usage (const char *name) " -H Hostname to query the values for.\n" " -c Critical range\n" " -w Warning range\n" + " -m Treat \"Not a Number\" (NaN) as critical (default: warning)\n" "\n" "Consolidation functions:\n" " none: Apply the warning- and critical-ranges to each data-source\n" @@ -280,7 +282,12 @@ static int do_check_con_none (size_t values_num, for (i = 0; i < values_num; i++) { if (isnan (values[i])) - num_warning++; + { + if (nan_is_error_g) + num_critical++; + else + num_warning++; + } else if (match_range (&range_critical_g, values[i]) != 0) num_critical++; else if (match_range (&range_warning_g, values[i]) != 0) @@ -316,7 +323,7 @@ static int do_check_con_none (size_t values_num, { printf (" |"); for (i = 0; i < values_num; i++) - printf (" %s=%g;;;;", values_names[i], values[i]); + printf (" %s=%f;;;;", values_names[i], values[i]); } printf ("\n"); @@ -337,11 +344,18 @@ static int do_check_con_average (size_t values_num, total_num = 0; for (i = 0; i < values_num; i++) { - if (!isnan (values[i])) + if (isnan (values[i])) { - total += values[i]; - total_num++; + if (!nan_is_error_g) + continue; + + printf ("CRITICAL: Data source \"%s\" is NaN\n", + values_names[i]); + return (RET_CRITICAL); } + + total += values[i]; + total_num++; } if (total_num == 0) @@ -370,7 +384,7 @@ static int do_check_con_average (size_t values_num, printf ("%s: %g average |", status_str, average); for (i = 0; i < values_num; i++) - printf (" %s=%g;;;;", values_names[i], values[i]); + printf (" %s=%f;;;;", values_names[i], values[i]); printf ("\n"); return (status_code); @@ -389,11 +403,18 @@ static int do_check_con_sum (size_t values_num, total_num = 0; for (i = 0; i < values_num; i++) { - if (!isnan (values[i])) + if (isnan (values[i])) { - total += values[i]; - total_num++; + if (!nan_is_error_g) + continue; + + printf ("CRITICAL: Data source \"%s\" is NaN\n", + values_names[i]); + return (RET_CRITICAL); } + + total += values[i]; + total_num++; } if (total_num == 0) @@ -420,7 +441,7 @@ static int do_check_con_sum (size_t values_num, printf ("%s: %g sum |", status_str, total); for (i = 0; i < values_num; i++) - printf (" %s=%g;;;;", values_names[i], values[i]); + printf (" %s=%f;;;;", values_names[i], values[i]); printf ("\n"); return (status_code); @@ -443,8 +464,19 @@ static int do_check_con_percentage (size_t values_num, } for (i = 0; i < values_num; i++) - if (!isnan (values[i])) - sum += values[i]; + { + if (isnan (values[i])) + { + if (!nan_is_error_g) + continue; + + printf ("CRITICAL: Data source \"%s\" is NaN\n", + values_names[i]); + return (RET_CRITICAL); + } + + sum += values[i]; + } if (sum == 0.0) { @@ -563,7 +595,7 @@ int main (int argc, char **argv) { int c; - c = getopt (argc, argv, "w:c:s:n:H:g:d:h"); + c = getopt (argc, argv, "w:c:s:n:H:g:d:hm"); if (c < 0) break; @@ -623,6 +655,9 @@ int main (int argc, char **argv) match_ds_num_g++; break; } + case 'm': + nan_is_error_g = 1; + break; default: usage (argv[0]); } /* switch (c) */ diff --git a/src/collectd-nagios.pod b/src/collectd-nagios.pod index c6347eac..d7c749cd 100644 --- a/src/collectd-nagios.pod +++ b/src/collectd-nagios.pod @@ -94,6 +94,12 @@ I (and the colon) may be omitted, I is then assumed to be zero. If I (but not the trailing colon) is omitted, I is assumed to be positive infinity. +=item B<-m> + +If this option is given, "Not a Number" (NaN) is treated as I. By +default, the I consolidation reports NaNs as I. Other +consolidations simply ignore NaN values. + =back =head1 RETURN VALUE diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod index 85e7a8a7..6b44722c 100644 --- a/src/collectd-perl.pod +++ b/src/collectd-perl.pod @@ -4,11 +4,13 @@ collectd-perl - Documentation of collectd's C =head1 SYNOPSIS - LoadPlugin perl + + Globals true + # ... IncludeDir "/path/to/perl/plugins" - BaseName "Collectd::Plugin" + BaseName "Collectd::Plugins" EnableDebugger "" LoadPlugin "FooBar" @@ -25,6 +27,12 @@ for collectd in Perl. This is a lot more efficient than executing a Perl-script every time you want to read a value with the C (see L) and provides a lot more functionality, too. +When loading the C, the B option should be enabled. +Else, the perl plugin will fail to load any Perl modules implemented in C, +which includes, amongst many others, the B module used by the plugin +itself. See the documentation of the B option in L +for details. + =head1 CONFIGURATION =over 4 @@ -38,7 +46,9 @@ causes the Perl-interpreter to be initialized. =item B I Prepends IB<::> to all plugin names loaded after this option. This is -provided for convenience to keep plugin names short. +provided for convenience to keep plugin names short. All Perl-based plugins +provided with the I distributions reside in the C +namespace. =item EB IE block @@ -366,11 +376,6 @@ is found (and the number of values matches the number of data-sources) then the type, data-set and value-list is passed to all write-callbacks that are registered with the daemon. -B: Prior to version 4.4 of collectd, the data-set type used to be passed -as the first argument to B. This syntax is still supported -for backwards compatibility but has been deprecated and will be removed in -some future version of collectd. - =item B ([B => I<...>][, B => I<...>], B => I<...>) @@ -395,23 +400,6 @@ argument has been specified, only named plugins will be flushed. The value of the B and B arguments may either be a string or a reference to an array of strings. -=item B (I, I) - -This is identical to using "plugin_flush (timeout =E I, plugins -=E I". - -B: Starting with version 4.5 of collectd, B has been -deprecated and will be removed in some future version of collectd. Use -B instead. - -=item B (I) - -This is identical to using "plugin_flush (timeout =E I)". - -B: Starting with version 4.5 of collectd, B has been -deprecated and will be removed in some future version of collectd. Use -B instead. - =item B (I) Submits a I to the daemon which will then pass it to all @@ -713,7 +701,7 @@ types used by the read, write and match functions. =item -Please feel free to send in new plugins to collectd's mailinglist at +Please feel free to send in new plugins to collectd's mailing list at EcollectdEatEverplant.orgE for review and, possibly, inclusion in the main distribution. In the latter case, we will take care of keeping the plugin up to date and adapting it to new versions of collectd. diff --git a/src/collectd-python.pod b/src/collectd-python.pod index 45a06d1d..267296cf 100644 --- a/src/collectd-python.pod +++ b/src/collectd-python.pod @@ -1,3 +1,13 @@ +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + =head1 NAME collectd-python - Documentation of collectd's C @@ -27,8 +37,7 @@ for collectd in Python. This is a lot more efficient than executing a Python-script every time you want to read a value with the C (see L) and provides a lot more functionality, too. -Currently only I is supported and at least I is -required. +At least python I is required. =head1 CONFIGURATION @@ -106,6 +115,15 @@ environment variable, e.g. I before starting collectd. Depending on your version of python this might or might not result in an B exception which can be ignored. +If you really need to spawn new processes from python you can register an init +callback and reset the action for SIGCHLD to the default behavior. Please note +that this I break the exec plugin. Do not even load the exec plugin if +you intend to do this! + +There is an example script located in B to do +this. If you import this from I SIGCHLD will be handled +normally and spawning processes from python will work as intended. + =back =item EB IE block @@ -119,6 +137,29 @@ The I identifies the callback. =back +=head1 STRINGS + +There are a lot of places where strings are send from collectd to python and +from python to collectd. How exactly this works depends on wheather byte or +unicode strings or python2 or python3 are used. + +Python2 has I, which is just bytes, and I. Python3 has I, +which is a unicode object, and I. + +When passing strings from python to collectd all of these object are supported +in all places, however I should be used if possible. These strings must +not contain a NUL byte. Ignoring this will result in a I exception. +If a byte string was used it will be used as is by collectd. If a unicode +object was used it will be encoded using the default encoding (see above). If +this is not possible python will raise a I exception. + +Wenn passing strings from collectd to python the behavior depends on the +python version used. Python2 will always receive a I object. Python3 will +usually receive a I object as well, however the original string will be +decoded to unicode using the default encoding. If this fails because the +string is not a valid sequence for this encoding a I object will be +returned instead. + =head1 WRITING YOUR OWN PLUGINS Writing your own plugins is quite simple. collectd manages plugins by means of @@ -209,6 +250,28 @@ collectd you're done. The following complex types are used to pass values between the Python plugin and collectd: +=head2 Signed + +The Signed class is just a long. It has all its methods and behaves exactly +like any other long object. It is used to indicate if an integer was or should +be stored as a signed or unsigned integer object. + + class Signed(long) + +This is a long by another name. Use it in meta data dicts +to choose the way it is stored in the meta data. + +=head2 Unsigned + +The Unsigned class is just a long. It has all its methods and behaves exactly +like any other long object. It is used to indicate if an integer was or should +be stored as a signed or unsigned integer object. + + class Unsigned(long) + +This is a long by another name. Use it in meta data dicts +to choose the way it is stored in the meta data. + =head2 Config The Config class is an object which keeps the information provided in the @@ -372,6 +435,16 @@ If the sequence does not have the correct size upon dispatch a I exception will be raised. If the content of the sequence is not a number, a I exception will be raised. +=item meta + +These are the meta data for this Value object. +It has to be a dictionary of numbers, strings or bools. All keys must be +strings. I and objects will be dispatched as signed integers unless +they are between 2**63 and 2**64-1, which will result in a unsigned integer. +You can force one of these storage classes by using the classes +B and B. A meta object received by a write +callback will always contain B or B objects. + =back =head2 Notification @@ -630,14 +703,8 @@ dispatched by the python plugin after upgrades. =item -This plugin is not compatible with python3. Trying to compile it with python3 -will fail because of the ways string, unicode and bytearray behavior was -changed. - -=item - Not all aspects of the collectd API are accessible from python. This includes -but is not limited to meta-data, filters and data sets. +but is not limited to filters and data sets. =back diff --git a/src/collectd-threshold.pod b/src/collectd-threshold.pod new file mode 100644 index 00000000..5d1a645c --- /dev/null +++ b/src/collectd-threshold.pod @@ -0,0 +1,194 @@ +=head1 NAME + +collectd-threshold - Documentation of collectd's I + +=head1 SYNOPSIS + + LoadPlugin "threshold" + + + WarningMin 0.00 + WarningMax 1000.00 + FailureMin 0.00 + FailureMax 1200.00 + Invert false + Instance "bar" + + + +=head1 DESCRIPTION + +Starting with version C<4.3.0> I has support for B. By +that we mean that the values are not only stored or sent somewhere, but that +they are judged and, if a problem is recognized, acted upon. The only action +the I takes itself is to generate and dispatch a +I. Other plugins can register to receive notifications and +perform appropriate further actions. + +Since systems and what you expect them to do differ a lot, you can configure +I for your values freely. This gives you a lot of flexibility but +also a lot of responsibility. + +Every time a value is out of range, a notification is dispatched. This means +that the idle percentage of your CPU needs to be less then the configured +threshold only once for a notification to be generated. There's no such thing +as a moving average or similar - at least not now. + +Also, all values that match a threshold are considered to be relevant or +"interesting". As a consequence collectd will issue a notification if they are +not received for B iterations. The B configuration option is +explained in section L. If, for example, +B is set to "2" (the default) and some hosts sends it's CPU statistics +to the server every 60 seconds, a notification will be dispatched after about +120 seconds. It may take a little longer because the timeout is checked only +once each B on the server. + +When a value comes within range again or is received after it was missing, an +"OKAY-notification" is dispatched. + +=head1 CONFIGURATION + +Here is a configuration example to get you started. Read below for more +information. + + LoadPlugin "threshold" + + + WarningMin 0.00 + WarningMax 1000.00 + FailureMin 0.00 + FailureMax 1200.00 + Invert false + Instance "bar" + + + + Instance "eth0" + + FailureMax 10000000 + DataSource "rx" + + + + + + Instance "idle" + FailureMin 10 + + + + + Instance "cached" + WarningMin 100000000 + + + + + DataSource "midterm" + FailureMax 4 + Hits 3 + Hysteresis 3 + + + + +There are basically two types of configuration statements: The C, +C, and C blocks select the value for which a threshold should be +configured. The C and C blocks may be specified further using the +C option. You can combine the block by nesting the blocks, though +they must be nested in the above order, i.e. C may contain either +C and C blocks, C may only contain C blocks and +C may not contain other blocks. If multiple blocks apply to the same +value the most specific block is used. + +The other statements specify the threshold to configure. They B be +included in a C block. Currently the following statements are recognized: + +=over 4 + +=item B I + +=item B I + +Sets the upper bound of acceptable values. If unset defaults to positive +infinity. If a value is greater than B a B notification +will be created. If the value is greater than B but less than (or +equal to) B a B notification will be created. + +=item B I + +=item B I + +Sets the lower bound of acceptable values. If unset defaults to negative +infinity. If a value is less than B a B notification will +be created. If the value is less than B but greater than (or equal +to) B a B notification will be created. + +=item B I + +Some data sets have more than one "data source". Interesting examples are the +C data set, which has received (C) and sent (C) bytes and +the C data set, which holds C and C operations. The +system load data set, C, even has three data sources: C, +C, and C. + +Normally, all data sources are checked against a configured threshold. If this +is undesirable, or if you want to specify different limits for each data +source, you can use the B option to have a threshold apply only to +one data source. + +=item B B|B + +If set to B the range of acceptable values is inverted, i.e. values +between B and B (B and B) are +not okay. Defaults to B. + +=item B B|B + +Sets how often notifications are generated. If set to B one notification +will be generated for each value that is out of the acceptable range. If set to +B (the default) then a notification is only generated if a value is out +of range but the previous value was okay. + +This applies to missing values, too: If set to B a notification about a +missing value is generated once every B seconds. If set to B +only one such notification is generated until the value appears again. + +=item B B|B + +If set to B, the minimum and maximum values given are interpreted as +percentage value, relative to the other data sources. This is helpful for +example for the "df" type, where you may want to issue a warning when less than +5E% of the total space is available. Defaults to B. + +=item B I + +Sets the number of occurrences which the threshold must be raised before to +dispatch any notification or, in other words, the number of Bs +that the threshold must be match before dispatch any notification. + +=item B I + +Sets the hysteresis value for threshold. The hysteresis is a method to prevent +flapping between states, until a new received value for a previously matched +threshold down below the threshold condition (B, B or +everything else) minus the hysteresis value, the failure (respectively warning) +state will be keep. + +=item B B|B + +If set to B (the default), the threshold must be treated as interesting +and, when a number of B values will lost, then a missing notification +will be dispatched. On the other hand, if set to B, the missing +notification will never dispatched for this threshold. + +=back + +=head1 SEE ALSO + +L, +L + +=head1 AUTHOR + +Florian Forster EoctoEatEcollectd.orgE diff --git a/src/collectd.c b/src/collectd.c index bc69a3b7..d33d1d66 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -40,7 +40,8 @@ * Global variables */ char hostname_g[DATA_MAX_NAME_LEN]; -int interval_g; +cdtime_t interval_g; +int timeout_g; #if HAVE_LIBKSTAT kstat_ctl_t *kc; #endif /* HAVE_LIBKSTAT */ @@ -50,7 +51,9 @@ static int loop = 0; static void *do_flush (void __attribute__((unused)) *arg) { INFO ("Flushing all data."); - plugin_flush (NULL, -1, NULL); + plugin_flush (/* plugin = */ NULL, + /* timeout = */ 0, + /* ident = */ NULL); INFO ("Finished flushing all data."); pthread_exit (NULL); return NULL; @@ -138,15 +141,37 @@ static int init_global_variables (void) str = global_option_get ("Interval"); if (str == NULL) - str = "10"; - interval_g = atoi (str); - if (interval_g <= 0) { - fprintf (stderr, "Cannot set the interval to a correct value.\n" + interval_g = TIME_T_TO_CDTIME_T (10); + } + else + { + double tmp; + + tmp = atof (str); + if (tmp <= 0.0) + { + fprintf (stderr, "Cannot set the interval to a " + "correct value.\n" + "Please check your settings.\n"); + return (-1); + } + + interval_g = DOUBLE_TO_CDTIME_T (tmp); + } + DEBUG ("interval_g = %.3f;", CDTIME_T_TO_DOUBLE (interval_g)); + + str = global_option_get ("Timeout"); + if (str == NULL) + str = "2"; + timeout_g = atoi (str); + if (timeout_g <= 1) + { + fprintf (stderr, "Cannot set the timeout to a correct value.\n" "Please check your settings.\n"); return (-1); } - DEBUG ("interval_g = %i;", interval_g); + DEBUG ("timeout_g = %i;", timeout_g); if (init_hostname () != 0) return (-1); @@ -259,9 +284,10 @@ static void exit_usage (int status) #endif " -h Display help (this message)\n" "\nBuiltin defaults:\n" - " Config-File "CONFIGFILE"\n" - " PID-File "PIDFILE"\n" - " Data-Directory "PKGLOCALSTATEDIR"\n" + " Config file "CONFIGFILE"\n" + " PID file "PIDFILE"\n" + " Plugin directory "PLUGINDIR"\n" + " Data directory "PKGLOCALSTATEDIR"\n" "\n"PACKAGE" "VERSION", http://collectd.org/\n" "by Florian octo Forster \n" "for contributions see `AUTHORS'\n"); @@ -297,22 +323,14 @@ static int do_init (void) static int do_loop (void) { - struct timeval tv_now; - struct timeval tv_next; - struct timeval tv_wait; - struct timespec ts_wait; + cdtime_t wait_until; + + wait_until = cdtime () + interval_g; while (loop == 0) { - if (gettimeofday (&tv_next, NULL) < 0) - { - char errbuf[1024]; - ERROR ("gettimeofday failed: %s", - sstrerror (errno, errbuf, - sizeof (errbuf))); - return (-1); - } - tv_next.tv_sec += interval_g; + struct timespec ts_wait = { 0, 0 }; + cdtime_t now; #if HAVE_LIBKSTAT update_kstat (); @@ -321,27 +339,20 @@ static int do_loop (void) /* Issue all plugins */ plugin_read_all (); - if (gettimeofday (&tv_now, NULL) < 0) - { - char errbuf[1024]; - ERROR ("gettimeofday failed: %s", - sstrerror (errno, errbuf, - sizeof (errbuf))); - return (-1); - } - - if (timeval_cmp (tv_next, tv_now, &tv_wait) <= 0) + now = cdtime (); + if (now >= wait_until) { WARNING ("Not sleeping because the next interval is " - "%i.%06i seconds in the past!", - (int) tv_wait.tv_sec, (int) tv_wait.tv_usec); + "%.3f seconds in the past!", + CDTIME_T_TO_DOUBLE (now - wait_until)); + wait_until = now + interval_g; continue; } - ts_wait.tv_sec = tv_wait.tv_sec; - ts_wait.tv_nsec = (long) (1000 * tv_wait.tv_usec); + CDTIME_T_TO_TIMESPEC (wait_until - now, &ts_wait); + wait_until = wait_until + interval_g; - while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1)) + while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) != 0)) { if (errno != EINTR) { @@ -354,7 +365,6 @@ static int do_loop (void) } } /* while (loop == 0) */ - DEBUG ("return (0);"); return (0); } /* int do_loop */ diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 594e8574..38b7c90f 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -11,12 +11,13 @@ ############################################################################## #Hostname "localhost" -FQDNLookup true +#FQDNLookup true #BaseDir "@prefix@/var/lib/@PACKAGE_NAME@" #PIDFile "@prefix@/var/run/@PACKAGE_NAME@.pid" #PluginDir "@prefix@/lib/@PACKAGE_NAME@" #TypesDB "@prefix@/share/@PACKAGE_NAME@/types.db" #Interval 10 +#Timeout 2 #ReadThreads 5 ############################################################################## @@ -34,6 +35,7 @@ FQDNLookup true # LogLevel @DEFAULT_LOG_LEVEL@ # File STDOUT # Timestamp true +# PrintSeverity false # # @@ -50,6 +52,7 @@ FQDNLookup true # to missing dependencies or because they have been deactivated explicitly. # ############################################################################## +#@BUILD_PLUGIN_AMQP_TRUE@LoadPlugin amqp #@BUILD_PLUGIN_APACHE_TRUE@LoadPlugin apache #@BUILD_PLUGIN_APCUPS_TRUE@LoadPlugin apcups #@BUILD_PLUGIN_APPLE_SENSORS_TRUE@LoadPlugin apple_sensors @@ -63,6 +66,7 @@ FQDNLookup true @LOAD_PLUGIN_CSV@LoadPlugin csv #@BUILD_PLUGIN_CURL_TRUE@LoadPlugin curl #@BUILD_PLUGIN_CURL_JSON_TRUE@LoadPlugin curl_json +#@BUILD_PLUGIN_CURL_XML_TRUE@LoadPlugin curl_xml #@BUILD_PLUGIN_DBI_TRUE@LoadPlugin dbi #@BUILD_PLUGIN_DF_TRUE@LoadPlugin df #@BUILD_PLUGIN_DISK_TRUE@LoadPlugin disk @@ -82,11 +86,13 @@ FQDNLookup true #@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_MADWIFI_TRUE@LoadPlugin madwifi #@BUILD_PLUGIN_MBMON_TRUE@LoadPlugin mbmon #@BUILD_PLUGIN_MEMCACHEC_TRUE@LoadPlugin memcachec #@BUILD_PLUGIN_MEMCACHED_TRUE@LoadPlugin memcached @BUILD_PLUGIN_MEMORY_TRUE@@BUILD_PLUGIN_MEMORY_TRUE@LoadPlugin memory +#@BUILD_PLUGIN_MODBUS_TRUE@LoadPlugin modbus #@BUILD_PLUGIN_MULTIMETER_TRUE@LoadPlugin multimeter #@BUILD_PLUGIN_MYSQL_TRUE@LoadPlugin mysql #@BUILD_PLUGIN_NETAPP_TRUE@LoadPlugin netapp @@ -103,12 +109,14 @@ FQDNLookup true #@BUILD_PLUGIN_OPENVPN_TRUE@LoadPlugin openvpn #@BUILD_PLUGIN_ORACLE_TRUE@LoadPlugin oracle #@BUILD_PLUGIN_PERL_TRUE@LoadPlugin perl +#@BUILD_PLUGIN_PINBA_TRUE@LoadPlugin pinba #@BUILD_PLUGIN_PING_TRUE@LoadPlugin ping #@BUILD_PLUGIN_POSTGRESQL_TRUE@LoadPlugin postgresql #@BUILD_PLUGIN_POWERDNS_TRUE@LoadPlugin powerdns #@BUILD_PLUGIN_PROCESSES_TRUE@LoadPlugin processes #@BUILD_PLUGIN_PROTOCOLS_TRUE@LoadPlugin protocols #@BUILD_PLUGIN_PYTHON_TRUE@LoadPlugin python +#@BUILD_PLUGIN_REDIS_TRUE@LoadPlugin redis #@BUILD_PLUGIN_ROUTEROS_TRUE@LoadPlugin routeros #@BUILD_PLUGIN_RRDCACHED_TRUE@LoadPlugin rrdcached @LOAD_PLUGIN_RRDTOOL@LoadPlugin rrdtool @@ -128,10 +136,12 @@ FQDNLookup true #@BUILD_PLUGIN_UPTIME_TRUE@LoadPlugin uptime #@BUILD_PLUGIN_USERS_TRUE@LoadPlugin users #@BUILD_PLUGIN_UUID_TRUE@LoadPlugin uuid +#@BUILD_PLUGIN_VARNISH_TRUE@LoadPlugin varnish #@BUILD_PLUGIN_VMEM_TRUE@LoadPlugin vmem #@BUILD_PLUGIN_VSERVER_TRUE@LoadPlugin vserver #@BUILD_PLUGIN_WIRELESS_TRUE@LoadPlugin wireless #@BUILD_PLUGIN_WRITE_HTTP_TRUE@LoadPlugin write_http +#@BUILD_PLUGIN_WRITE_REDIS_TRUE@LoadPlugin write_redis #@BUILD_PLUGIN_XMMS_TRUE@LoadPlugin xmms #@BUILD_PLUGIN_ZFS_ARC_TRUE@LoadPlugin zfs_arc @@ -142,11 +152,27 @@ FQDNLookup true # ription of those options is available in the collectd.conf(5) manual page. # ############################################################################## +# +# +# Host "localhost" +# Port "5672" +# VHost "/" +# User "guest" +# Password "guest" +# Exchange "amq.fanout" +# RoutingKey "collectd" +# Persistent false +# StoreRates false +# +# + # -# URL "http://localhost/status?auto" -# User "www-user" -# Password "secret" -# CACert "/etc/ssl/ca.crt" +# +# URL "http://localhost/status?auto" +# User "www-user" +# Password "secret" +# CACert "/etc/ssl/ca.crt" +# # # @@ -231,6 +257,25 @@ FQDNLookup true # # +# +# +# Host "my_host" +# Instance "some_instance" +# User "collectd" +# Password "thaiNg0I" +# VerifyPeer true +# VerifyHost true +# CACert "/path/to/ca.crt" +# +# +# Type "magic_level" +# #InstancePrefix "prefix-" +# InstanceFrom "td[1]" +# ValuesFrom "td[2]/span[@class=\"level\"]" +# +# +# + # # # Statement "SELECT 'customers' AS c_key, COUNT(*) AS c_value FROM customers_tbl" @@ -293,6 +338,7 @@ FQDNLookup true # MTime "-5m" # Size "+10k" # Recursive true +# IncludeHidden false # # @@ -313,13 +359,6 @@ FQDNLookup true # # Host "127.0.0.1" # Port "7634" -# -# #----------------------------------------------------------------# -# # `TranslateDevicename' enables backwards compatibility behavior # -# # and is enabled by default. Setting this option to `false' is # -# # highly recommended. # -# #----------------------------------------------------------------# -# TranslateDevicename false # # @@ -365,6 +404,12 @@ FQDNLookup true # InterfaceDevice "name:device" # IgnoreSelected false # HostnameFormat name +# InterfaceFormat name +# + +# +# CpuPoolStats false +# ReportBySerial false # # @@ -389,6 +434,7 @@ FQDNLookup true # Key "page_key" # # Regex "(\\d+) bytes sent" +# ExcludeRegex "" # DSType CounterAdd # Type "ipt_octets" # Instance "type_instance" @@ -401,6 +447,26 @@ FQDNLookup true # Port "11211" # +# +# +# RegisterBase 1234 +# RegisterType float +# Type gauge +# Instance "..." +# +# +# +# Address "addr" +# Port "1234" +# Interval 60 +# +# +# Instance "foobar" # optional +# Collect "data_name" +# +# +# + # # # Host "database.serv.er" @@ -480,14 +546,33 @@ FQDNLookup true # @LOAD_PLUGIN_NETWORK@ +# # client setup: @LOAD_PLUGIN_NETWORK@ Server "ff18::efc0:4a42" "25826" -@LOAD_PLUGIN_NETWORK@ Server "239.192.74.66" "25826" -# Listen "ff18::efc0:4a42" "25826" -# Listen "239.192.74.66" "25826" +@LOAD_PLUGIN_NETWORK@ +# SecurityLevel Encrypt +# Username "user" +# Password "secret" +# Interface "eth0" +@LOAD_PLUGIN_NETWORK@ # TimeToLive "128" -# Forward false -# CacheFlush 1800 +# +# # server setup: +# Listen "ff18::efc0:4a42" "25826" +# +# SecurityLevel Sign +# AuthFile "/etc/collectd/passwd" +# Interface "eth0" +# +# MaxPacketSize 1024 +# +# # proxy setup (client and server as above): +# Forward true +# +# # statistics about the network plugin itself # ReportStats false +# +# # "garbage collection" +# CacheFlush 1800 @LOAD_PLUGIN_NETWORK@ # @@ -541,6 +626,10 @@ FQDNLookup true # # StatusFile "/etc/openvpn/openvpn-status.log" +# ImprovedNamingSchema false +# CollectCompression true +# CollectIndividualUsers true +# CollectUserCount false # # @@ -562,7 +651,7 @@ FQDNLookup true # # IncludeDir "/my/include/path" -# BaseName "Collectd::Plugin" +# BaseName "Collectd::Plugins" # EnableDebugger "" # LoadPlugin Monitorus # LoadPlugin OpenVZ @@ -573,6 +662,16 @@ FQDNLookup true # # +# +# Address "::0" +# Port "30002" +# +# Host "host name" +# Server "server name" +# Script "script name" +# +# + # # Host "host.foo.bar" # Interval 1.0 @@ -617,6 +716,7 @@ FQDNLookup true # Query magic # # +# Interval 60 # Service "service_name" # Query backend # predefined # Query rt36_tickets @@ -657,6 +757,14 @@ FQDNLookup true # # +# +# +# Host "redis.example.com" +# Port "6379" +# Timeout 2000 +# +# + # # # Host "router.example.com" @@ -665,6 +773,10 @@ FQDNLookup true # Password "dozaiTh4" # CollectInterface true # CollectRegistrationTable true +# CollectCPULoad true +# CollectMemory true +# CollectDF true +# CollectDisk true # # @@ -800,12 +912,34 @@ FQDNLookup true # SocketFile "@prefix@/var/run/@PACKAGE_NAME@-unixsock" # SocketGroup "collectd" # SocketPerms "0660" +# DeleteSocket false # # # UUIDFile "/etc/uuid" # +# +# This tag support an argument if you want to +# monitor the local instance just use +# If you prefer defining another instance you can do +# so by using +# +# CollectCache true +# CollectBackend true +# CollectConnections true +# CollectSHM true +# CollectESI false +# CollectFetch false +# CollectHCB false +# CollectSMA false +# CollectSMS false +# CollectSM false +# CollectTotals false +# CollectWorkers false +# +# + # # Verbose false # @@ -814,9 +948,22 @@ FQDNLookup true # # User "collectd" # Password "weCh3ik0" +# VerifyPeer true +# VerifyHost true +# CACert "/etc/ssl/ca.crt" +# Format "Command" +# StoreRates false # # +# +# +# Host "localhost" +# Port "6379" +# Timeout 1000 +# +# + ############################################################################## # Filter configuration # #----------------------------------------------------------------------------# @@ -846,3 +993,52 @@ FQDNLookup true # # Target "write" # + +############################################################################## +# Threshold configuration # +#----------------------------------------------------------------------------# +# The following outlines how to configure collectd's threshold checking # +# plugin. The plugin and possible configuration options are documented in # +# the collectd-threshold(5) manual page. # +############################################################################## + +#@BUILD_PLUGIN_THRESHOLD_TRUE@LoadPlugin "threshold" +# +# +# WarningMin 0.00 +# WarningMax 1000.00 +# FailureMin 0.00 +# FailureMax 1200.00 +# Invert false +# Instance "bar" +# +# +# +# Instance "eth0" +# +# FailureMax 10000000 +# DataSource "rx" +# +# +# +# +# +# Instance "idle" +# FailureMin 10 +# +# +# +# +# Instance "cached" +# WarningMin 100000000 +# +# +# +# +# DataSource "midterm" +# FailureMax 4 +# Hits 3 +# Hysteresis 3 +# +# +# diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 75681ca1..b63f486b 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -57,6 +57,37 @@ directory for the daemon. Loads the plugin I. There must be at least one such line or B will be mostly useless. +Starting with collectd 4.9, this may also be a block in which further options +affecting the behavior of B may be specified. The following +options are allowed inside a B block: + + + Globals true + + +=over 4 + +=item B B + +If enabled, collectd will export all global symbols of the plugin (and of all +libraries loaded as dependencies of the plugin) and, thus, makes those symbols +available for resolving unresolved symbols in subsequently loaded plugins if +that is supported by your system. + +This is useful (or possibly even required), e.g., when loading a plugin that +embeds some scripting language into the daemon (e.g. the I and +I). Scripting languages usually provide means to load +extensions written in C. Those extensions require symbols provided by the +interpreter, which is loaded as a dependency of the respective collectd plugin. +See the documentation of those plugins (e.g., L or +L) for details. + +By default, this is disabled. As a special exception, if the plugin name is +either C or C, the default is changed to enabled in order to keep +the average user from ever having to deal with this low level linking stuff. + +=back + =item B I If I points to a file, includes that file. If I points to a @@ -102,6 +133,20 @@ Configures the interval in which to query the read plugins. Obviously smaller values lead to a higher system load produced by collectd, while higher values lead to more coarse statistics. +B You should set this once and then never touch it again. If you do, +I or know some serious RRDtool +magic! (Assuming you're using the I or I plugin.) + +=item B I + +Consider a value list "missing" when no update has been read or received for +I iterations. By default, I considers a value list +missing when no update has been received for twice the update interval. Since +this setting uses iterations, the maximum allowed time without update depends +on the I information contained in each value list. This is used in +the I configuration to dispatch notifications about missing values, +see L for details. + =item B I Number of threads to start for reading plugins. The default value is B<5>, but @@ -118,13 +163,8 @@ hostname will be determined using the L system call. If B is determined automatically this setting controls whether or not the daemon should try to figure out the "fully qualified domain name", FQDN. -This is done using a lookup of the name returned by C. - -Using this feature (i.Ee. setting this option to B) is recommended. -However, to preserve backwards compatibility the default is set to B. -The sample config file that is installed with Cinstall> includes a -line which sets this option, though, so that default installations will have -this setting enabled. +This is done using a lookup of the name returned by C. This option +is enabled by default. =item B I @@ -149,6 +189,143 @@ A list of all plugins and a short summary for each plugin can be found in the F file shipped with the sourcecode and hopefully binary packets as well. +=head2 Plugin C + +The I can be used to communicate with other instances of +I or third party applications using an AMQP message broker. Values +are sent to or received from the broker, which handles routing, queueing and +possibly filtering or messages. + + + # Send values to an AMQP broker + + Host "localhost" + Port "5672" + VHost "/" + User "guest" + Password "guest" + Exchange "amq.fanout" + # ExchangeType "fanout" + # RoutingKey "collectd" + # Persistent false + # Format "command" + # StoreRates false + + + # Receive values from an AMQP broker + + Host "localhost" + Port "5672" + VHost "/" + User "guest" + Password "guest" + Exchange "amq.fanout" + # ExchangeType "fanout" + # Queue "queue_name" + # RoutingKey "collectd.#" + + + +The plugin's configuration consists of a number of I and I +blocks, which configure sending and receiving of values respectively. The two +blocks are very similar, so unless otherwise noted, an option can be used in +either block. The name given in the blocks starting tag is only used for +reporting messages, but may be used to support I of certain +I blocks in the future. + +=over 4 + +=item B I + +Hostname or IP-address of the AMQP broker. Defaults to the default behavior of +the underlying communications library, I, which is "localhost". + +=item B I + +Service name or port number on which the AMQP broker accepts connections. This +argument must be a string, even if the numeric form is used. Defaults to +"5672". + +=item B I + +Name of the I on the AMQP broker to use. Defaults to "/". + +=item B I + +=item B I + +Credentials used to authenticate to the AMQP broker. By default "guest"/"guest" +is used. + +=item B I + +In I blocks, this option specifies the I to send values to. +By default, "amq.fanout" will be used. + +In I blocks this option is optional. If given, a I between +the given exchange and the I is created, using the I if +configured. See the B and B options below. + +=item B I + +If given, the plugin will try to create the configured I with this +I after connecting. When in a I block, the I will then +be bound to this exchange. + +=item B I (Subscribe only) + +Configures the I name to subscribe to. If no queue name was configures +explicitly, a unique queue name will be created by the broker. + +=item B I + +In I blocks, this configures the routing key to set on all outgoing +messages. If not given, the routing key will be computed from the I +of the value. The host, plugin, type and the two instances are concatenated +together using dots as the separator and all containing dots replaced with +slashes. For example "collectd.host/example/com.cpu.0.cpu.user". This makes it +possible to receive only specific values using a "topic" exchange. + +In I blocks, configures the I used when creating a +I between an I and the I. The usual wildcards can be +used to filter messages when using a "topic" exchange. If you're only +interested in CPU statistics, you could use the routing key "collectd.*.cpu.#" +for example. + +=item B B|B (Publish only) + +Selects the I to use. If set to B, the I +mode will be used, i.e. delivery is guaranteed. If set to B (the +default), the I delivery mode will be used, i.e. messages may be +lost due to high load, overflowing queues or similar issues. + +=item B B|B (Publish only) + +Selects the format in which messages are sent to the broker. If set to +B (the default), values are sent as C commands which are +identical to the syntax used by the I and I. In this +case, the C header field will be set to C. + +If set to B, the values are encoded in the I, +an easy and straight forward exchange format. The C header field +will be set to C. + +A subscribing client I use the C header field to +determine how to decode the values. Currently, the I itself can +only decode the B format. + +=item B B|B (Publish only) + +Determines whether or not C, C and C data sources +are converted to a I (i.e. a C value). If set to B (the +default), no conversion is performed. Otherwise the conversion is performed +using the internal value cache. + +Please note that currently this option is only used if the B option has +been set to B. + +=back + =head2 Plugin C To configure the C-plugin you first need to configure the Apache @@ -167,7 +344,25 @@ Since its C module is very similar to Apache's, B is also supported. It introduces a new field, called C, to count the number of currently connected clients. This field is also supported. -The following options are accepted by the C-plugin: +The configuration of the I plugin consists of one or more +CInstanceE/E> blocks. Each block requires one string argument +as the instance name. For example: + + + + URL "http://www1.example.com/mod_status?auto" + + + URL "http://www2.example.com/mod_status?auto" + + + +The instance name will be used as the I. To emulate the old +(versionE4) behavior, you can use an empty string (""). In order for the +plugin to work correctly, each instance name must be unique. This is not +enforced by the plugin and it is your responsibility to ensure it. + +The following options are accepted within each I block: =over 4 @@ -175,7 +370,7 @@ The following options are accepted by the C-plugin: Sets the URL of the C output. This needs to be the output generated by C and it needs to be the machine readable output -generated by appending the C argument. +generated by appending the C argument. This option is I. =item B I @@ -544,22 +739,6 @@ runtime statistics module of CouchDB -Another CouchDB example: -The following example will collect the status values from each database: - - - Instance "dbs" - - Type "gauge" - - - Type "counter" - - - Type "bytes" - - - In the B block, there may be one or more B blocks, each defining a URL to be fetched via HTTP (using libcurl) and one or more B blocks. The B string argument must be in a path format, which is used to collect a @@ -619,6 +798,110 @@ Type-instance to use. Defaults to the current map key or current string array el =back +=head2 Plugin C + +The B uses B (L) and B +(L) to retrieve XML data via cURL. + + + + Host "my_host" + Instance "some_instance" + User "collectd" + Password "thaiNg0I" + VerifyPeer true + VerifyHost true + CACert "/path/to/ca.crt" + + + Type "magic_level" + #InstancePrefix "prefix-" + InstanceFrom "td[1]" + ValuesFrom "td[2]/span[@class=\"level\"]" + + + + +In the B block, there may be one or more B blocks, each defining a +URL to be fetched via HTTP (using libcurl). Within each B block there are +options which specify the connection parameters, for example authentication +information, and one or more B blocks. + +Each B block specifies how to get one type of information. The +string argument must be a valid XPath expression which returns a list +of "base elements". One value is dispatched for each "base element". The +I and values are looked up using further I expressions +that should be relative to the base element. + +Within the B block the following options are accepted: + +=over 4 + +=item B I + +Use I as the host name when submitting values. Defaults to the global +host name setting. + +=item B I + +Use I as the plugin instance when submitting values. Defaults to an +empty string (no plugin instance). + +=item B I +=item B I +=item B B|B +=item B B|B +=item B I + +These options behave exactly equivalent to the appropriate options of the +I and I plugins. Please see there for a detailed description. + +=item EB IE + +Within each B block, there must be one or more B blocks. Each +B block specifies how to get one type of information. The string +argument must be a valid XPath expression which returns a list of "base +elements". One value is dispatched for each "base element". + +Within the B block the following options are accepted: + +=over 4 + +=item B I + +Specifies the I used for submitting patches. This determines the number +of values that are required / expected and whether the strings are parsed as +signed or unsigned integer or as double values. See L for details. +This option is required. + +=item B I + +Prefix the I with I. The values are simply +concatenated together without any separator. +This option is optional. + +=item B I + +Specifies a XPath expression to use for determining the I. The +XPath expression must return exactly one element. The element's value is then +used as I, possibly prefixed with I (see above). + +This value is required. As a special exception, if the "base XPath expression" +(the argument to the B block) returns exactly one argument, then this +option may be omitted. + +=item B I [I ...] + +Specifies one or more XPath expression to use for reading the values. The +number of XPath expressions must match the number of data sources in the +I specified with B (see above). Each XPath expression must return +exactly one element. The element's value is then parsed as a number and used as +value for the appropriate value in the value list dispatched to the daemon. + +=back + +=back + =head2 Plugin C This plugin uses the B library (L) to @@ -885,22 +1168,6 @@ Report using the device name rather than the mountpoint. i.e. with this I (the default), it will report a disk as "root", but with it I, it will be "sda1" (or whichever). -=item B B|B - -When enabled, the blocks reserved for root are reported separately. When -disabled (the default for backwards compatibility reasons) the reserved space -will be included in the "free" space. - -When disabled, the "df" type will be used to store "free" and "used" space. The -mount point or disk name (see option B) is used as type -instance in this case (again: backwards compatibility). - -When enabled, the type "df_complex" is used and three files are created. The -mount point or disk name is used as plugin instance and the type instance is -set to "free", "reserved" and "used" as appropriate. - -Enabling this option is recommended. - =item B B|B Enables or disables reporting of free, reserved and used inodes. Defaults to @@ -1104,6 +1371,12 @@ note that there are 1000 bytes in a kilobyte, not 1024. Controls whether or not to recurse into subdirectories. Enabled by default. +=item B I|I + +Controls whether or not to include "hidden" files and directories in the count. +"Hidden" files and directories are those, whose name begins with a dot. +Defaults to I, i.e. by default hidden files and directories are ignored. + =back =head2 Plugin C @@ -1214,13 +1487,6 @@ Hostname to connect to. Defaults to B<127.0.0.1>. TCP-Port to connect to. Defaults to B<7634>. -=item B I|I - -If enabled, translate the disk names to major/minor device numbers -(e.Eg. "8-0" for /dev/sda). For backwards compatibility this defaults to -I but it's recommended to disable it as it will probably be removed in -the next major version. - =back =head2 Plugin C @@ -1448,6 +1714,16 @@ 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. + =back =head2 Plugin C @@ -1466,19 +1742,51 @@ debugging support. Sets the file to write log messages to. The special strings B and B can be used to write to the standard output and standard error -channels, respectively. This, of course, only makes much sense when collectd is -running in foreground- or non-daemon-mode. +channels, respectively. This, of course, only makes much sense when I +is running in foreground- or non-daemon-mode. =item B B|B Prefix all lines printed by the current time. Defaults to B. +=item B B|B + +When enabled, all lines are prefixed by the severity of the log message, for +example "warning". Defaults to B. + =back B: There is no need to notify the daemon after moving or removing the log file (e.Eg. when rotating the logs). The plugin reopens the file for each line it writes. +=head2 Plugin C + +The I reads CPU statistics of I, a +virtualization technique for IBM POWER processors. It takes into account CPU +time stolen from or donated to a partition, in addition to the usual user, +system, I/O statistics. + +The following configuration options are available: + +=over 4 + +=item B B|B + +When enabled, statistics about the processor pool are read, too. The partition +needs to have pool authority in order to be able to acquire this information. +Defaults to false. + +=item B B|B + +If enabled, the serial of the physical machine the partition is currently +running on is reported as I and the logical hostname of the machine +is reported in the I. Otherwise, the logical hostname will be +used (just like other plugins) and the I will be empty. +Defaults to false. + +=back + =head2 Plugin C The C uses mbmon to retrieve temperature, voltage, etc. @@ -1573,12 +1881,138 @@ TCP-Port to connect to. Defaults to B<11211>. =back +=head2 Plugin C + +The B connects to a Modbus "slave" via Modbus/TCP and reads +register values. It supports reading single registers (unsigned 16Ebit +values), large integer values (unsigned 32Ebit values) and floating point +values (two registers interpreted as IEEE floats in big endian notation). + +Synopsis: + + + RegisterBase 0 + RegisterType float + Type voltage + Instance "input-1" + + + + RegisterBase 2 + RegisterType float + Type voltage + Instance "input-2" + + + + Address "192.168.0.42" + Port "502" + Interval 60 + + + Instance "power-supply" + Collect "voltage-input-1" + Collect "voltage-input-2" + + + +=over 4 + +=item EB IE blocks + +Data blocks define a mapping between register numbers and the "types" used by +I. + +Within EDataE/E blocks, the following options are allowed: + +=over 4 + +=item B I + +Configures the base register to read from the device. If the option +B has been set to B or B, this and the next +register will be read (the register number is increased by one). + +=item B B|B|B + +Specifies what kind of data is returned by the device. If the type is B +or B, two 16Ebit registers will be read and the data is combined +into one value. Defaults to B. + +=item B I + +Specifies the "type" (data set) to use when dispatching the value to +I. Currently, only data sets with exactly one data source are +supported. + +=item B I + +Sets the type instance to use when dispatching the value to I. If +unset, an empty string (no type instance) is used. + +=back + +=item EB IE blocks + +Host blocks are used to specify to which hosts to connect and what data to read +from their "slaves". The string argument I is used as hostname when +dispatching the values to I. + +Within EHostE/E blocks, the following options are allowed: + +=over 4 + +=item B
I + +Specifies the node name (the actual network address) used to connect to the +host. This may be an IP address or a hostname. Please note that the used +I library only supports IPv4 at the moment. + +=item B I + +Specifies the port used to connect to the host. The port can either be given as +a number or as a service name. Please note that the I argument must be +a string, even if ports are given in their numerical form. Defaults to "502". + +=item B I + +Sets the interval (in seconds) in which the values will be collected from this +host. By default the global B setting will be used. + +=item EB IE + +Over each TCP connection, multiple Modbus devices may be reached. The slave ID +is used to specify which device should be addressed. For each device you want +to query, one B block must be given. + +Within ESlaveE/E blocks, the following options are allowed: + +=over 4 + +=item B I + +Specify the plugin instance to use when dispatching the values to I. +By default "slave_I" is used. + +=item B I + +Specifies which data to retrieve from the device. I must be the same +string as the I argument passed to a B block. You can specify this +option multiple times to collect more than one value from a slave. At least one +B option is mandatory. + +=back + +=back + +=back + =head2 Plugin C The C requires B to be installed. It connects to one or more databases when started and keeps the connection up as long as possible. When the connection is interrupted for whatever reason it will try -to re-connect. The plugin will complaint loudly in case anything goes wrong. +to re-connect. The plugin will complain loudly in case anything goes wrong. This plugin issues the MySQL C / C command and collects information about MySQL network traffic, executed statements, @@ -2271,6 +2705,15 @@ B require this setting. This feature is only available if the I plugin was linked with I. +=item B I + +Set the outgoing interface for IP packets. This applies at least +to IPv6 packets and if possible to IPv4. If this option is not applicable, +undefined or a non-existent interface name is specified, the default +behavior is to let the kernel choose the appropriate interface. Be warned +that the manual selection of an interface for unicast traffic is only +necessary in rare cases. + =back =item BListen> I [I]B> @@ -2319,6 +2762,14 @@ Each time a packet is received, the modification time of the file is checked using L. If the file has been changed, the contents is re-read. While the file is being read, it is locked using L. +=item B I + +Set the incoming interface for IP packets explicitly. This applies at least +to IPv6 packets and if possible to IPv4. If this option is not applicable, +undefined or a non-existent interface name is specified, the default +behavior is, to let the kernel choose the appropriate interface. Thus incoming +traffic gets only accepted, if it arrives on the given interface. + =back =item B I<1-255> @@ -2331,7 +2782,7 @@ operating systems. =item B I<1024-65535> Set the maximum size for datagrams received over the network. Packets larger -than this will be truncated. +than this will be truncated. Defaults to 1452Ebytes. =item B I @@ -2342,16 +2793,6 @@ the same multicast group. While this results in more network traffic than necessary it's not a huge problem since the plugin has a duplicate detection, so the values will not loop. -=item B I - -For each host/plugin/type combination the C caches the time of -the last value being sent or received. Every I seconds the plugin -searches and removes all entries that are older than I seconds, thus -freeing the unused memory again. Since this process is somewhat expensive and -normally doesn't do much, this value should not be too small. The default is -1800 seconds, but setting this to 86400 seconds (one day) will not do much harm -either. - =item B B|B The network plugin cannot only receive and send statistics, it can also create @@ -2668,12 +3109,24 @@ and the client's "common name" will be used as type instance. This is required when reading multiple status files. Enabling this option is recommended, but to maintain backwards compatibility this option is disabled by default. -=item B B|B +=item B B|B Sets whether or not statistics about the compression used by OpenVPN should be collected. This information is only available in I mode. Enabled by default. +=item B B|B + +Sets whether or not traffic information is collected for each connected client +individually. If set to false, currently no traffic data is collected at all +because aggregating this data in a save manner is tricky. Defaults to B. + +=item B B|B + +When enabled, the number of currently connected clients or users is collected. +This is especially interesting when B is disabled, but +can be configured independently from that option. Defaults to B. + =back =head2 Plugin C @@ -2743,6 +3196,83 @@ refer to them from. This plugin embeds a Perl-interpreter into collectd and provides an interface to collectd's plugin system. See L for its documentation. +=head2 Plugin C + +The I receives profiling information from I, an extension +for the I interpreter. At the end of executing a script, i.e. after a +PHP-based webpage has been delivered, the extension will send a UDP packet +containing timing information, peak memory usage and so on. The plugin will +wait for such packets, parse them and account the provided information, which +is then dispatched to the daemon once per interval. + +Synopsis: + + + Address "::0" + Port "30002" + # Overall statistics for the website. + + Server "www.example.com" + + # Statistics for www-a only + + Host "www-a.example.com" + Server "www.example.com" + + # Statistics for www-b only + + Host "www-b.example.com" + Server "www.example.com" + + + +The plugin provides the following configuration options: + +=over 4 + +=item B
I + +Configures the address used to open a listening socket. By default, plugin will +bind to the I address C<::0>. + +=item B I + +Configures the port (service) to bind to. By default the default Pinba port +"30002" will be used. The option accepts service names in addition to port +numbers and thus requires a I argument. + +=item EB IE block + +The packets sent by the Pinba extension include the hostname of the server, the +server name (the name of the virtual host) and the script that was executed. +Using B blocks it is possible to separate the data into multiple groups +to get more meaningful statistics. Each packet is added to all matching groups, +so that a packet may be accounted for more than once. + +=over 4 + +=item B I + +Matches the hostname of the system the webserver / script is running on. This +will contain the result of the L system call. If not +configured, all hostnames will be accepted. + +=item B I + +Matches the name of the I, i.e. the contents of the +C<$_SERVER["SERVER_NAME"]> variable when within PHP. If not configured, all +server names will be accepted. + +=item B