From: Florian Forster Date: Sat, 21 Jan 2012 12:07:50 +0000 (+0100) Subject: Merge branch 'collectd-4.10' into collectd-5.0 X-Git-Tag: collectd-5.0.2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=488c2ca9e3f6f6082f192bdd5d737c6cd1298ba2;hp=-c;p=collectd.git Merge branch 'collectd-4.10' into collectd-5.0 Conflicts: ChangeLog src/df.c src/plugin.h version-gen.sh Change-Id: Id7a31088cdb3371534d5c1e6a690464f3343543d --- 488c2ca9e3f6f6082f192bdd5d737c6cd1298ba2 diff --combined AUTHORS index c57f90b2,f090840e..0e0a5fed --- a/AUTHORS +++ b/AUTHORS @@@ -34,10 -34,6 +34,10 @@@ Anthony Gialluca - 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, @@@ -67,6 -63,9 +67,9 @@@ Edward “Koko” Konetzko - Percentage aggregation for `collectd-nagios'. + Fabien Wernli + - Solaris improvements in the memory and interfaces plugin. + Flavio Stanchina - mbmon plugin. @@@ -76,9 -75,6 +79,9 @@@ Franck Lombard 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. @@@ -166,9 -162,6 +169,9 @@@ Rodolphe Quiédeville - tape plugin. +Sebastien Pahl + - AMQP plugin. + Simon Kuhnle - OpenBSD code for the cpu and memory plugins. diff --combined ChangeLog index f7444543,1f9be512..2c75b5da --- a/ChangeLog +++ b/ChangeLog @@@ -1,102 -1,24 +1,123 @@@ +2011-10-07, Version 5.0.1 + * collectd: A mutex leak has been fixed in the meta data code. Thanks + to Rafal Lesniak for his patch. + * collectd: Compatibility fixes for GCC 4.6 have been applied. Thanks + to Peter Green for his patch. + * csv plugin: The line buffer size has been increased. Thanks to Colin + McCabe for the patch. + * curl_json plugin: Don't use the "parent" node to build the type + instance, if it is empty. Compatibility with libyajl 2 has been + added. Thanks to "spupykin" of the Arch Linux project for the initial + code. Formatting of time has been fixed in the JSON module. + * exec plugin: Fix the timestamp value passed to notification scripts. + Thanks to Alexander Kovalenko for fixing this. + * iptables plugin: Fix linking with some versions of libiptc. + * irq plugin: Fix support for interrupts under Linux. The old code + assumed that interrupts have a numeric value -- this is no longer + true for Linux. Thanks to Bostjan Skufca for implementing this. + * notify_desktop plugin: Compatibility with libnotify 0.7 has been + added. Thanks to Samuli Suominen for his patch. + * processes plugin: Fix handling of regular expressions containing + spaces. Thanks for Sebastian Harl for fixing this. + * rrdtool, rrdcached plugins: Improve precision of the XFF parameter. + Previously, values like 0.999 would have been rounded to 1.0. Thanks + to Francois-Xavier Bourlet for fixing this. + * varnish plugin: Fix data type handling of some metrics. Some values + were submitted as gauge even though they were derives. + * Various plugin: Set a multi-threading flag in libcurl. Thanks to Mike + Flisher for the fix. + +2011-03-28, 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. + + 2012-01-21, Version 4.10.5 + * curl_xml plugin: Fix handling of file:// and other URLs (which don't + follow HTTP status codes). Thanks to Fabien Wernli for his patch! + * df plugin: Fix handling of negative "available" counts. This can + occur with some file systems, for example UFS. Thanks to Toni Ylenius + for his patch. + * interface plugin: "mac" interfaces are now ignored on Solaris. These + pseudo-interfaces occur multiple times, causing warnings. Also switch + to 64-bit counters on Solaris, improving overflow behavior for + high-speed interfaces. Thanks to Eddy Geez and Fabien Wernli for + their patches. + * memory plugin: Account kernel and unused memory under Solaris. Thanks + to Fabien Wernli for his patch. + * network plugin: A bug in the interaction between the Network plugin + and filter chains has been fixed: When a filter modified a field such + as the hostname, subsequent values in the same network packets could + have ended up using the modified name rather than the original name. + Thanks to Sebastian Harl for identifying the problem. + * python plugin: A memory leak has been fixed. Thanks to Sven Trenkel + for fixing this bug! + 2011-10-14, Version 4.10.4 * collectd: A mutex leak has been fixed in the meta data code. Thanks to Rafal Lesniak for his patch. diff --combined src/collectd.conf.pod index de3e5161,62374b62..3d811105 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@@ -72,19 -72,15 +72,19 @@@ options are allowed inside a Bg., when loading a plugin -that embeds some scripting language into the daemon (e.Eg. the C -or C plugins). Scripting languages usually provide means to load +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.Eg., -L or L) for details. +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 @@@ -145,7 -141,7 +145,7 @@@ missing when no update has been receive 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<"THRESHOLD CONFIGURATION"> below. +see L for details. =item B I @@@ -163,8 -159,13 +163,8 @@@ hostname will be determined using the L 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 @@@ -189,143 -190,6 +189,143 @@@ A list of all plugins and a short summa 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 @@@ -344,25 -208,7 +344,25 @@@ Since its C module is very 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 @@@ -370,7 -216,7 +370,7 @@@ 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 @@@ -739,6 -585,22 +739,6 @@@ runtime statistics module of CouchD -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 @@@ -823,7 -685,7 +823,7 @@@ The B uses B 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 + URL to be fetched using libcurl. Within each B block there are options which specify the connection parameters, for example authentication information, and one or more B blocks. @@@ -1168,6 -1030,22 +1168,6 @@@ Report using the device name rather tha (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 @@@ -1487,6 -1365,13 +1487,6 @@@ Hostname to connect to. Defaults to B<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 @@@ -1714,16 -1599,6 +1714,16 @@@ You can also specify combinations of th 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 @@@ -1742,8 -1617,8 +1742,8 @@@ 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 @@@ -1760,33 -1635,6 +1760,33 @@@ B: There is no need to notify th 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. @@@ -2012,7 -1860,7 +2012,7 @@@ B option is mandatory 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, @@@ -2786,7 -2634,7 +2786,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 @@@ -2797,6 -2645,16 +2797,6 @@@ the same multicast group. While this re 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 @@@ -3431,6 -3289,11 +3431,6 @@@ allowed as long as a single non-empty c The returned lines will be handled separately one after another. -=item B I - -This is a deprecated synonym for B. It will be removed in version 5 -of collectd. - =item B I|I|I|I Specify the parameters which should be passed to the SQL query. The parameters @@@ -3506,6 -3369,21 +3506,6 @@@ This option is required inside a B options are specified, the columns are read in the given order. -=item B I [I] - -This is a deprecated alternative to a B block. It will be removed in -version 5 of collectd. It is equivalent to the following B block: - - - Type I - InstancePrefix I - ValuesFrom I - - -The order of the B options defines which columns of the query result -should be used. The first option specifies the data found in the first column, -the second option that of the second column, and so on. - =item B I =item B I @@@ -3520,6 -3398,13 +3520,6 @@@ The I has to be specified as t and patch-level versions, each represented as two-decimal-digit numbers. For example, version 8.2.3 will become 80203. -=item B I - -=item B I - -These are deprecated synonyms for B and B -respectively. They will be removed in version 5 of collectd. - =back The following predefined queries are available (the definitions can be found @@@ -3930,52 -3815,6 +3930,52 @@@ Defaults to B =back +=head2 Plugin C + +The I connects to one or more Redis servers and gathers +information about each server's state. For each server there is a I block +which configures the connection parameters for this node. + + + + Host "localhost" + Port "6379" + Timeout 2000 + + + +The information shown in the synopsis above is the I +which is used by the plugin if no configuration is present. + +=over 4 + +=item B I + +The B block identifies a new Redis node, that is a new Redis instance +running in an specified host and port. The name for node is a canonical +identifier which is used as I. It is limited to +64Echaracters in length. + +=item B I + +The B option is the hostname or IP-address where the Redis instance is +running on. + +=item B I + +The B option is the TCP port on which the Redis instance accepts +connections. Either a service name of a port number may be given. Please note +that numerical port numbers must be given as a string, too. + +=item B I + +The B option set the socket timeout for node response. Since the Redis +read function is blocking, you should keep this value as low as possible. Keep +in mind that the sum of all B values for all B should be lower +than B defined globally. + +=back + =head2 Plugin C The C plugin uses the RRDtool accelerator daemon, L, @@@ -4139,7 -3978,7 +4139,7 @@@ because all values were added to the in =head2 Plugin C -The C uses B to retrieve sensor-values. This means +The I uses B to retrieve sensor-values. This means that all the needed modules have to be loaded and lm_sensors has to be configured (most likely by editing F. Read L for details. @@@ -4174,25 -4013,6 +4174,25 @@@ Since the configuration of the C. Please see there for details. +=head2 Plugin C + +The I collects information about used and available swap space. On +I, the following options are available: + +=over 4 + +=item B B|B + +Configures how to report physical swap devices. If set to B is used (the +default), the summary over all swap devices is reported only, i.e. the globally +used and available space over all devices. If B is configured, the used +and available space of each device will be reported separately. + +This option is only available if the I can use the L +mechanism under I. + +=back + =head2 Plugin C =over 4 @@@ -4542,7 -4362,7 +4542,7 @@@ port in numeric form =item B I|I -By default, the C plugin tries to read the statistics from the Linux +By default, the I tries to read the statistics from the Linux C interface. If that is not available, the plugin falls back to the C interface. By setting this option to I, you can force the plugin to use the latter. This option defaults to I. @@@ -4562,18 -4382,9 +4562,18 @@@ selection is configured at all, B =back +=head2 Plugin C + +The I checks values collected or received by I +against a configurable I and issues I if values are +out of bounds. + +Documentation for this plugin is available in the L +manual page. + =head2 Plugin C -The C connects to a TokyoTyrant server and collects a +The I connects to a TokyoTyrant server and collects a couple metrics: number of records, and database size on disk. =over 4 @@@ -4610,13 -4421,6 +4610,13 @@@ Change the file permissions of the UNIX permissions must be given as a numeric, octal value as you would pass to L. Defaults to B<0770>. +=item B B|B + +If set to B, delete the socket file before calling L, if a file +with the given name already exists. If I crashes a socket file may be +left over, preventing the daemon from opening a new socket when restarted. +Since this is potentially dangerous, this defaults to B. + =back =head2 Plugin C @@@ -4660,68 -4464,6 +4660,68 @@@ Take the UUID from the given file (defa =back +=head2 Plugin C + +The Varnish plugin collects information about Varnish, an HTTP accelerator. + +=over 4 + +=item B B|B + +Cache hits and misses. True by default. + +=item B B|B + +Number of client connections received, accepted and dropped. True by default. + +=item B B|B + +Back-end connection statistics, such as successful, reused, +and closed connections. True by default. + +=item B B|B + +Statistics about the shared memory log, a memory region to store +log messages which is flushed to disk when full. True by default. + +=item B B|B + +Edge Side Includes (ESI) parse statistics. False by default. + +=item B B|B + +Statistics about fetches (HTTP requests sent to the backend). False by default. + +=item B B|B + +Inserts and look-ups in the crit bit tree based hash. Look-ups are +divided into locked and unlocked look-ups. False by default. + +=item B B|B + +malloc or umem (umem_alloc(3MALLOC) based) storage statistics. +The umem storage component is Solaris specific. False by default. + +=item B B|B + +synth (synthetic content) storage statistics. This storage +component is used internally only. False by default. + +=item B B|B + +file (memory mapped file) storage statistics. False by default. + +=item B B|B + +Collects overview counters, such as the number of sessions created, +the number of requests and bytes transferred. False by default. + +=item B B|B + +Collect statistics about worker threads. False by default. + +=back + =head2 Plugin C The C plugin collects information about the usage of virtual memory. @@@ -4820,6 -4562,142 +4820,6 @@@ number =back -=head1 THRESHOLD CONFIGURATION - -Starting with version C<4.3.0> collectd 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 -collectd takes itself is to generate and dispatch a "notification". 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 -B 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<"GLOBAL OPTIONS">. 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. - -Here is a configuration example to get you started. Read below for more -information. - - - - 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 - - - - - -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.Ee. 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.Ee. -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. - -=back - =head1 FILTER CONFIGURATION Starting with collectd 4.6 there is a powerful filtering infrastructure diff --combined src/common.c index 7015c875,d2a1b362..e1f204b9 --- a/src/common.c +++ b/src/common.c @@@ -1,6 -1,6 +1,6 @@@ /** * collectd - src/common.c - * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2005-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 @@@ -16,7 -16,7 +16,7 @@@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Niki W. Waibel * Sebastian Harl * Michał Mirosław @@@ -29,7 -29,6 +29,7 @@@ #include "collectd.h" #include "common.h" #include "plugin.h" +#include "utils_cache.h" #if HAVE_PTHREAD_H # include @@@ -39,6 -38,11 +39,6 @@@ # include #endif -/* for ntohl and htonl */ -#if HAVE_ARPA_INET_H -# include -#endif - /* for getaddrinfo */ #include #include @@@ -48,11 -52,6 +48,11 @@@ # include #endif +/* for ntohl and htonl */ +#if HAVE_ARPA_INET_H +# include +#endif + #ifdef HAVE_LIBKSTAT extern kstat_ctl_t *kc; #endif @@@ -803,75 -802,6 +803,75 @@@ int format_name (char *ret, int ret_len return (0); } /* int format_name */ +int format_values (char *ret, size_t ret_len, /* {{{ */ + const data_set_t *ds, const value_list_t *vl, + _Bool store_rates) +{ + size_t offset = 0; + int status; + int i; + gauge_t *rates = NULL; + + assert (0 == strcmp (ds->type, vl->type)); + + memset (ret, 0, ret_len); + +#define BUFFER_ADD(...) do { \ + status = ssnprintf (ret + offset, ret_len - offset, \ + __VA_ARGS__); \ + if (status < 1) \ + { \ + sfree (rates); \ + return (-1); \ + } \ + else if (((size_t) status) >= (ret_len - offset)) \ + { \ + sfree (rates); \ + return (-1); \ + } \ + else \ + offset += ((size_t) status); \ +} while (0) + + BUFFER_ADD ("%.3f", CDTIME_T_TO_DOUBLE (vl->time)); + + for (i = 0; i < ds->ds_num; i++) + { + if (ds->ds[i].type == DS_TYPE_GAUGE) + BUFFER_ADD (":%f", vl->values[i].gauge); + else if (store_rates) + { + if (rates == NULL) + rates = uc_get_rate (ds, vl); + if (rates == NULL) + { + WARNING ("format_values: " + "uc_get_rate failed."); + return (-1); + } + BUFFER_ADD (":%g", rates[i]); + } + else if (ds->ds[i].type == DS_TYPE_COUNTER) + BUFFER_ADD (":%llu", vl->values[i].counter); + else if (ds->ds[i].type == DS_TYPE_DERIVE) + BUFFER_ADD (":%"PRIi64, vl->values[i].derive); + else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) + BUFFER_ADD (":%"PRIu64, vl->values[i].absolute); + else + { + ERROR ("format_values plugin: Unknown data source type: %i", + ds->ds[i].type); + sfree (rates); + return (-1); + } + } /* for ds->ds_num */ + +#undef BUFFER_ADD + + sfree (rates); + return (0); +} /* }}} int format_values */ + int parse_identifier (char *str, char **ret_host, char **ret_plugin, char **ret_plugin_instance, char **ret_type, char **ret_type_instance) @@@ -918,40 -848,6 +918,40 @@@ return (0); } /* int parse_identifier */ +int parse_identifier_vl (const char *str, value_list_t *vl) /* {{{ */ +{ + char str_copy[6 * DATA_MAX_NAME_LEN]; + char *host = NULL; + char *plugin = NULL; + char *plugin_instance = NULL; + char *type = NULL; + char *type_instance = NULL; + int status; + + if ((str == NULL) || (vl == NULL)) + return (EINVAL); + + sstrncpy (str_copy, str, sizeof (str_copy)); + + status = parse_identifier (str_copy, &host, + &plugin, &plugin_instance, + &type, &type_instance); + if (status != 0) + return (status); + + sstrncpy (vl->host, host, sizeof (vl->host)); + sstrncpy (vl->plugin, plugin, sizeof (vl->plugin)); + sstrncpy (vl->plugin_instance, + (plugin_instance != NULL) ? plugin_instance : "", + sizeof (vl->plugin_instance)); + sstrncpy (vl->type, type, sizeof (vl->type)); + sstrncpy (vl->type_instance, + (type_instance != NULL) ? type_instance : "", + sizeof (vl->type_instance)); + + return (0); +} /* }}} int parse_identifier_vl */ + int parse_value (const char *value, value_t *ret_value, int ds_type) { char *endptr = NULL; @@@ -980,12 -876,15 +980,15 @@@ } if (value == endptr) { - ERROR ("parse_value: Failed to parse string as number: %s.", value); + ERROR ("parse_value: Failed to parse string as %s: %s.", + DS_TYPE_TO_STRING (ds_type), value); return -1; } else if ((NULL != endptr) && ('\0' != *endptr)) - WARNING ("parse_value: Ignoring trailing garbage after number: %s.", - endptr); + INFO ("parse_value: Ignoring trailing garbage \"%s\" after %s value. " + "Input string was \"%s\".", + endptr, DS_TYPE_TO_STRING (ds_type), value); + return 0; } /* int parse_value */ @@@ -1013,22 -912,9 +1016,22 @@@ int parse_values (char *buffer, value_l if (i == -1) { if (strcmp ("N", ptr) == 0) - vl->time = time (NULL); + vl->time = cdtime (); else - vl->time = (time_t) atoi (ptr); + { + char *endptr = NULL; + double tmp; + + errno = 0; + tmp = strtod (ptr, &endptr); + if ((errno != 0) /* Overflow */ + || (endptr == ptr) /* Invalid string */ + || (endptr == NULL) /* This should not happen */ + || (*endptr != 0)) /* Trailing chars */ + return (-1); + + vl->time = DOUBLE_TO_CDTIME_T (tmp); + } } else { diff --combined src/df.c index 5391f50c,9d53b0b6..371a7fc3 --- a/src/df.c +++ b/src/df.c @@@ -62,8 -62,9 +62,8 @@@ static ignorelist_t *il_device = NULL static ignorelist_t *il_mountpoint = NULL; static ignorelist_t *il_fstype = NULL; -static _Bool by_device = false; -static _Bool report_reserved = false; -static _Bool report_inodes = false; +static _Bool by_device = 0; +static _Bool report_inodes = 0; static int df_init (void) { @@@ -118,16 -119,25 +118,16 @@@ static int df_config (const char *key, else if (strcasecmp (key, "ReportByDevice") == 0) { if (IS_TRUE (value)) - by_device = true; - - return (0); - } - else if (strcasecmp (key, "ReportReserved") == 0) - { - if (IS_TRUE (value)) - report_reserved = true; - else - report_reserved = false; + by_device = 1; return (0); } else if (strcasecmp (key, "ReportInodes") == 0) { if (IS_TRUE (value)) - report_inodes = true; + report_inodes = 1; else - report_inodes = false; + report_inodes = 0; return (0); } @@@ -136,6 -146,28 +136,6 @@@ return (-1); } -static void df_submit_two (char *df_name, - const char *type, - gauge_t df_used, - gauge_t df_free) -{ - value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; - - values[0].gauge = df_used; - values[1].gauge = df_free; - - vl.values = values; - vl.values_len = 2; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); - sstrncpy (vl.plugin, "df", sizeof (vl.plugin)); - sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - sstrncpy (vl.type, type, sizeof (vl.type)); - sstrncpy (vl.type_instance, df_name, sizeof (vl.type_instance)); - - plugin_dispatch_values (&vl); -} /* void df_submit_two */ - __attribute__ ((nonnull(2))) static void df_submit_one (char *plugin_instance, const char *type, const char *type_instance, @@@ -183,9 -215,6 +183,9 @@@ static int df_read (void { unsigned long long blocksize; char disk_name[256]; + uint64_t blk_free; + uint64_t blk_reserved; + uint64_t blk_used; if (ignorelist_match (il_device, (mnt_ptr->spec_device != NULL) @@@ -245,22 -274,54 +245,37 @@@ blocksize = BLOCKSIZE(statbuf); - /* Sanity-check for the values in the struct */ - if (report_reserved) - { - uint64_t blk_free; - uint64_t blk_reserved; - uint64_t blk_used; - - /* - * Sanity-check for the values in the struct - */ - /* Check for negative "available" byes. For example UFS can - * report negative free space for user. Notice. blk_reserved - * will start to diminish after this. */ ++ /* ++ * Sanity-check for the values in the struct ++ */ ++ /* Check for negative "available" byes. For example UFS can ++ * report negative free space for user. Notice. blk_reserved ++ * will start to diminish after this. */ + #if HAVE_STATVFS - /* Cast is needed to avoid compiler warnings. - * ((struct statvfs).f_bavail is unsigned (POSIX)) */ - if (((int64_t) statbuf.f_bavail) < 0) - statbuf.f_bavail = 0; ++ /* Cast is needed to avoid compiler warnings. ++ * ((struct statvfs).f_bavail is unsigned (POSIX)) */ ++ if (((int64_t) statbuf.f_bavail) < 0) ++ statbuf.f_bavail = 0; + #elif HAVE_STATFS - if (statbuf.f_bavail < 0) - statbuf.f_bavail = 0; ++ if (statbuf.f_bavail < 0) ++ statbuf.f_bavail = 0; + #endif - /* Make sure that f_blocks >= f_bfree >= f_bavail */ - if (statbuf.f_bfree < statbuf.f_bavail) - statbuf.f_bfree = statbuf.f_bavail; - if (statbuf.f_blocks < statbuf.f_bfree) - statbuf.f_blocks = statbuf.f_bfree; - - blk_free = (uint64_t) statbuf.f_bavail; - blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail); - blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree); - - df_submit_one (disk_name, "df_complex", "free", - (gauge_t) (blk_free * blocksize)); - df_submit_one (disk_name, "df_complex", "reserved", - (gauge_t) (blk_reserved * blocksize)); - df_submit_one (disk_name, "df_complex", "used", - (gauge_t) (blk_used * blocksize)); - } - else /* compatibility code */ - { - gauge_t df_free; - gauge_t df_used; - - df_free = statbuf.f_bfree * blocksize; - df_used = (statbuf.f_blocks - statbuf.f_bfree) * blocksize; - - df_submit_two (disk_name, "df", df_used, df_free); - } ++ /* Make sure that f_blocks >= f_bfree >= f_bavail */ + if (statbuf.f_bfree < statbuf.f_bavail) + statbuf.f_bfree = statbuf.f_bavail; + if (statbuf.f_blocks < statbuf.f_bfree) + statbuf.f_blocks = statbuf.f_bfree; + + blk_free = (uint64_t) statbuf.f_bavail; + blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail); + blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree); + + df_submit_one (disk_name, "df_complex", "free", + (gauge_t) (blk_free * blocksize)); + df_submit_one (disk_name, "df_complex", "reserved", + (gauge_t) (blk_reserved * blocksize)); + df_submit_one (disk_name, "df_complex", "used", + (gauge_t) (blk_used * blocksize)); /* inode handling */ if (report_inodes) diff --combined src/interface.c index c1e28e32,d68240e1..9501161c --- a/src/interface.c +++ b/src/interface.c @@@ -1,6 -1,6 +1,6 @@@ /** * collectd - src/interface.c - * Copyright (C) 2005-2008 Florian octo Forster + * Copyright (C) 2005-2010 Florian octo Forster * Copyright (C) 2009 Manuel Sanmartin * * This program is free software; you can redistribute it and/or modify it @@@ -128,7 -128,7 +128,7 @@@ static int interface_config (const cha static int interface_init (void) { kstat_t *ksp_chain; - unsigned long long val; + derive_t val; numif = 0; @@@ -141,11 -141,17 +141,17 @@@ { if (strncmp (ksp_chain->ks_class, "net", 3)) continue; + /* Ignore kstat entry if not the regular statistic set. This + * avoids problems with "bogus" interfaces, such as + * "wrsmd" */ + if (strncmp (ksp_chain->ks_name, ksp_chain->ks_module, + strlen (ksp_chain->ks_module)) != 0) + continue; if (ksp_chain->ks_type != KSTAT_TYPE_NAMED) continue; if (kstat_read (kc, ksp_chain, NULL) == -1) continue; - if ((val = get_kstat_value (ksp_chain, "obytes")) == -1LL) + if ((val = get_kstat_value (ksp_chain, "ifspeed")) == -1LL) continue; ksp[numif++] = ksp_chain; } @@@ -155,8 -161,8 +161,8 @@@ #endif /* HAVE_LIBKSTAT */ static void if_submit (const char *dev, const char *type, - unsigned long long rx, - unsigned long long tx) + derive_t rx, + derive_t tx) { value_t values[2]; value_list_t vl = VALUE_LIST_INIT; @@@ -164,15 -170,15 +170,15 @@@ if (ignorelist_match (ignorelist, dev) != 0) return; - values[0].counter = rx; - values[1].counter = tx; + values[0].derive = rx; + values[1].derive = tx; vl.values = values; vl.values_len = 2; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "interface", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance)); sstrncpy (vl.type, type, sizeof (vl.type)); - sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); } /* void if_submit */ @@@ -233,7 -239,7 +239,7 @@@ static int interface_read (void #elif KERNEL_LINUX FILE *fh; char buffer[1024]; - unsigned long long incoming, outgoing; + derive_t incoming, outgoing; char *device; char *dummy; @@@ -285,8 -291,8 +291,8 @@@ #elif HAVE_LIBKSTAT int i; - unsigned long long rx; - unsigned long long tx; + derive_t rx; + derive_t tx; if (kc == NULL) return (-1); @@@ -296,16 -302,29 +302,29 @@@ if (kstat_read (kc, ksp[i], NULL) == -1) continue; - rx = get_kstat_value (ksp[i], "rbytes"); - tx = get_kstat_value (ksp[i], "obytes"); + /* try to get 64bit counters */ + rx = get_kstat_value (ksp[i], "rbytes64"); + tx = get_kstat_value (ksp[i], "obytes64"); + /* or fallback to 32bit */ + if (rx == -1LL) + rx = get_kstat_value (ksp[i], "rbytes"); + if (tx == -1LL) + tx = get_kstat_value (ksp[i], "obytes"); if ((rx != -1LL) || (tx != -1LL)) if_submit (ksp[i]->ks_name, "if_octets", rx, tx); - rx = get_kstat_value (ksp[i], "ipackets"); - tx = get_kstat_value (ksp[i], "opackets"); + /* try to get 64bit counters */ + rx = get_kstat_value (ksp[i], "ipackets64"); + tx = get_kstat_value (ksp[i], "opackets64"); + /* or fallback to 32bit */ + if (rx == -1LL) + rx = get_kstat_value (ksp[i], "ipackets"); + if (tx == -1LL) + tx = get_kstat_value (ksp[i], "opackets"); if ((rx != -1LL) || (tx != -1LL)) if_submit (ksp[i]->ks_name, "if_packets", rx, tx); + /* no 64bit error counters yet */ rx = get_kstat_value (ksp[i], "ierrors"); tx = get_kstat_value (ksp[i], "oerrors"); if ((rx != -1LL) || (tx != -1LL)) diff --combined src/network.c index 38534264,8de557d2..840577f5 --- a/src/network.c +++ b/src/network.c @@@ -1,6 -1,6 +1,6 @@@ /** * collectd - src/network.c - * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2005-2010 Florian octo Forster * Copyright (C) 2009 Aman Gupta * * This program is free software; you can redistribute it and/or modify it @@@ -259,7 -259,7 +259,7 @@@ typedef struct receive_list_entry_s rec * Private variables */ static int network_config_ttl = 0; -static size_t network_config_packet_size = 1024; +static size_t network_config_packet_size = 1452; static int network_config_forward = 0; static int network_config_stats = 0; @@@ -296,14 -296,14 +296,14 @@@ static pthread_mutex_t send_buffer_loc * example). Only if neither is true, the stats_lock is acquired. The counters * are always read without holding a lock in the hope that writing 8 bytes to * memory is an atomic operation. */ -static uint64_t stats_octets_rx = 0; -static uint64_t stats_octets_tx = 0; -static uint64_t stats_packets_rx = 0; -static uint64_t stats_packets_tx = 0; -static uint64_t stats_values_dispatched = 0; -static uint64_t stats_values_not_dispatched = 0; -static uint64_t stats_values_sent = 0; -static uint64_t stats_values_not_sent = 0; +static derive_t stats_octets_rx = 0; +static derive_t stats_octets_tx = 0; +static derive_t stats_packets_rx = 0; +static derive_t stats_packets_tx = 0; +static derive_t stats_values_dispatched = 0; +static derive_t stats_values_not_dispatched = 0; +static derive_t stats_values_sent = 0; +static derive_t stats_values_not_sent = 0; static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER; /* @@@ -320,30 -320,30 +320,30 @@@ static _Bool check_receive_okay (const /* This is a value we already sent. Don't allow it to be received again in * order to avoid looping. */ if ((status == 0) && (time_sent >= ((uint64_t) vl->time))) - return (false); + return (0); - return (true); + return (1); } /* }}} _Bool check_receive_okay */ static _Bool check_send_okay (const value_list_t *vl) /* {{{ */ { - _Bool received = false; + _Bool received = 0; int status; if (network_config_forward != 0) - return (true); + return (1); if (vl->meta == NULL) - return (true); + return (1); status = meta_data_get_boolean (vl->meta, "network:received", &received); if (status == -ENOENT) - return (true); + return (1); else if (status != 0) { ERROR ("network plugin: check_send_okay: meta_data_get_boolean failed " "with status %i.", status); - return (true); + return (1); } /* By default, only *send* value lists that were not *received* by the @@@ -384,7 -384,7 +384,7 @@@ static int network_dispatch_values (val return (-ENOMEM); } - status = meta_data_add_boolean (vl->meta, "network:received", true); + status = meta_data_add_boolean (vl->meta, "network:received", 1); if (status != 0) { ERROR ("network plugin: meta_data_add_boolean failed."); @@@ -405,7 -405,7 +405,7 @@@ } } - plugin_dispatch_values (vl); + plugin_dispatch_values_secure (vl); stats_values_dispatched++; meta_data_destroy (vl->meta); @@@ -1379,19 -1379,8 +1379,19 @@@ static int parse_packet (sockent_t *se &tmp); if (status == 0) { - vl.time = (time_t) tmp; - n.time = (time_t) tmp; + vl.time = TIME_T_TO_CDTIME_T (tmp); + n.time = TIME_T_TO_CDTIME_T (tmp); + } + } + else if (pkg_type == TYPE_TIME_HR) + { + uint64_t tmp = 0; + status = parse_part_number (&buffer, &buffer_size, + &tmp); + if (status == 0) + { + vl.time = (cdtime_t) tmp; + n.time = (cdtime_t) tmp; } } else if (pkg_type == TYPE_INTERVAL) @@@ -1400,15 -1389,7 +1400,15 @@@ status = parse_part_number (&buffer, &buffer_size, &tmp); if (status == 0) - vl.interval = (int) tmp; + vl.interval = TIME_T_TO_CDTIME_T (tmp); + } + else if (pkg_type == TYPE_INTERVAL_HR) + { + uint64_t tmp = 0; + status = parse_part_number (&buffer, &buffer_size, + &tmp); + if (status == 0) + vl.interval = (cdtime_t) tmp; } else if (pkg_type == TYPE_HOST) { @@@ -2604,7 -2585,7 +2604,7 @@@ static int add_to_buffer (char *buffer if (vl_def->time != vl->time) { - if (write_part_number (&buffer, &buffer_size, TYPE_TIME, + if (write_part_number (&buffer, &buffer_size, TYPE_TIME_HR, (uint64_t) vl->time)) return (-1); vl_def->time = vl->time; @@@ -2612,7 -2593,7 +2612,7 @@@ if (vl_def->interval != vl->interval) { - if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL, + if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL_HR, (uint64_t) vl->interval)) return (-1); vl_def->interval = vl->interval; @@@ -3074,6 -3055,8 +3074,6 @@@ static int network_config (oconfig_item network_config_set_boolean (child, &network_config_forward); else if (strcasecmp ("ReportStats", child->key) == 0) network_config_set_boolean (child, &network_config_stats); - else if (strcasecmp ("CacheFlush", child->key) == 0) - /* no op for backwards compatibility only */; else { WARNING ("network plugin: Option `%s' is not allowed here.", @@@ -3094,7 -3077,8 +3094,7 @@@ static int network_notification (const memset (buffer, '\0', sizeof (buffer)); - - status = write_part_number (&buffer_ptr, &buffer_free, TYPE_TIME, + status = write_part_number (&buffer_ptr, &buffer_free, TYPE_TIME_HR, (uint64_t) n->time); if (status != 0) return (-1); @@@ -3199,15 -3183,15 +3199,15 @@@ static int network_shutdown (void static int network_stats_read (void) /* {{{ */ { - uint64_t copy_octets_rx; - uint64_t copy_octets_tx; - uint64_t copy_packets_rx; - uint64_t copy_packets_tx; - uint64_t copy_values_dispatched; - uint64_t copy_values_not_dispatched; - uint64_t copy_values_sent; - uint64_t copy_values_not_sent; - uint64_t copy_receive_list_length; + derive_t copy_octets_rx; + derive_t copy_octets_tx; + derive_t copy_packets_rx; + derive_t copy_packets_tx; + derive_t copy_values_dispatched; + derive_t copy_values_not_dispatched; + derive_t copy_values_sent; + derive_t copy_values_not_sent; + derive_t copy_receive_list_length; value_list_t vl = VALUE_LIST_INIT; value_t values[2]; @@@ -3230,16 -3214,16 +3230,16 @@@ sstrncpy (vl.plugin, "network", sizeof (vl.plugin)); /* Octets received / sent */ - vl.values[0].counter = (counter_t) copy_octets_rx; - vl.values[1].counter = (counter_t) copy_octets_tx; + vl.values[0].derive = (derive_t) copy_octets_rx; + vl.values[1].derive = (derive_t) copy_octets_tx; sstrncpy (vl.type, "if_octets", sizeof (vl.type)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); /* Packets received / send */ - vl.values[0].counter = (counter_t) copy_packets_rx; - vl.values[1].counter = (counter_t) copy_packets_tx; + vl.values[0].derive = (derive_t) copy_packets_rx; + vl.values[1].derive = (derive_t) copy_packets_tx; sstrncpy (vl.type, "if_packets", sizeof (vl.type)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); /* Values (not) dispatched and (not) send */ sstrncpy (vl.type, "total_values", sizeof (vl.type)); @@@ -3248,41 -3232,41 +3248,41 @@@ vl.values[0].derive = (derive_t) copy_values_dispatched; sstrncpy (vl.type_instance, "dispatch-accepted", sizeof (vl.type_instance)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); vl.values[0].derive = (derive_t) copy_values_not_dispatched; sstrncpy (vl.type_instance, "dispatch-rejected", sizeof (vl.type_instance)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); vl.values[0].derive = (derive_t) copy_values_sent; sstrncpy (vl.type_instance, "send-accepted", sizeof (vl.type_instance)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); vl.values[0].derive = (derive_t) copy_values_not_sent; sstrncpy (vl.type_instance, "send-rejected", sizeof (vl.type_instance)); - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); /* Receive queue length */ vl.values[0].gauge = (gauge_t) copy_receive_list_length; sstrncpy (vl.type, "queue_length", sizeof (vl.type)); vl.type_instance[0] = 0; - plugin_dispatch_values (&vl); + plugin_dispatch_values_secure (&vl); return (0); } /* }}} int network_stats_read */ static int network_init (void) { - static _Bool have_init = false; + static _Bool have_init = 0; /* Check if we were already initialized. If so, just return - there's * nothing more to do (for now, that is). */ if (have_init) return (0); - have_init = true; + have_init = 1; #if HAVE_LIBGCRYPT gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); @@@ -3368,9 -3352,9 +3368,9 @@@ * just send the buffer if `flush' is called - if the requested value was in * there, good. If not, well, then there is nothing to flush.. -octo */ -static int network_flush (int timeout, - const char __attribute__((unused)) *identifier, - user_data_t __attribute__((unused)) *user_data) +static int network_flush (__attribute__((unused)) cdtime_t timeout, + __attribute__((unused)) const char *identifier, + __attribute__((unused)) user_data_t *user_data) { pthread_mutex_lock (&send_buffer_lock); diff --combined src/plugin.c index a749d1e0,3c92df21..91c40b6b --- a/src/plugin.c +++ b/src/plugin.c @@@ -1,6 -1,6 +1,6 @@@ /** * collectd - src/plugin.c - * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2005-2011 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 @@@ -16,7 -16,7 +16,7 @@@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Sebastian Harl **/ @@@ -36,6 -36,7 +36,6 @@@ #include "utils_llist.h" #include "utils_heap.h" #include "utils_cache.h" -#include "utils_threshold.h" #include "filter_chain.h" /* @@@ -73,7 -74,6 +73,7 @@@ typedef struct read_func_s read_func_t static llist_t *list_init; static llist_t *list_write; static llist_t *list_flush; +static llist_t *list_missing; static llist_t *list_shutdown; static llist_t *list_log; static llist_t *list_notification; @@@ -346,7 -346,7 +346,7 @@@ static void *plugin_read_thread (void _ while (read_loop != 0) { read_func_t *rf; - struct timeval now; + cdtime_t now; int status; int rf_type; int rc; @@@ -357,9 -357,10 +357,9 @@@ { struct timespec abstime; - gettimeofday (&now, /* timezone = */ NULL); + now = cdtime (); - abstime.tv_sec = now.tv_sec + interval_g; - abstime.tv_nsec = 1000 * now.tv_usec; + CDTIME_T_TO_TIMESPEC (now + interval_g, &abstime); pthread_mutex_lock (&read_lock); pthread_cond_timedwait (&read_cond, &read_lock, @@@ -370,13 -371,15 +370,13 @@@ if ((rf->rf_interval.tv_sec == 0) && (rf->rf_interval.tv_nsec == 0)) { - gettimeofday (&now, /* timezone = */ NULL); + now = cdtime (); - rf->rf_interval.tv_sec = interval_g; - rf->rf_interval.tv_nsec = 0; + CDTIME_T_TO_TIMESPEC (interval_g, &rf->rf_interval); rf->rf_effective_interval = rf->rf_interval; - rf->rf_next_read.tv_sec = now.tv_sec; - rf->rf_next_read.tv_nsec = 1000 * now.tv_usec; + CDTIME_T_TO_TIMESPEC (now, &rf->rf_next_read); } /* sleep until this entry is due, @@@ -466,7 -469,7 +466,7 @@@ } /* update the ``next read due'' field */ - gettimeofday (&now, /* timezone = */ NULL); + now = cdtime (); DEBUG ("plugin_read_thread: Effective interval of the " "%s plugin is %i.%09i.", @@@ -483,12 -486,15 +483,12 @@@ NORMALIZE_TIMESPEC (rf->rf_next_read); /* Check, if `rf_next_read' is in the past. */ - if ((rf->rf_next_read.tv_sec < now.tv_sec) - || ((rf->rf_next_read.tv_sec == now.tv_sec) - && (rf->rf_next_read.tv_nsec < (1000 * now.tv_usec)))) + if (TIMESPEC_TO_CDTIME_T (&rf->rf_next_read) < now) { /* `rf_next_read' is in the past. Insert `now' * so this value doesn't trail off into the * past too much. */ - rf->rf_next_read.tv_sec = now.tv_sec; - rf->rf_next_read.tv_nsec = 1000 * now.tv_usec; + CDTIME_T_TO_TIMESPEC (now, &rf->rf_next_read); } DEBUG ("plugin_read_thread: Next read of the %s plugin at %i.%09i.", @@@ -738,17 -744,6 +738,17 @@@ static int plugin_insert_read (read_fun } } + le = llist_search (read_list, rf->rf_name); + if (le != NULL) + { + pthread_mutex_unlock (&read_lock); + WARNING ("The read function \"%s\" is already registered. " + "Check for duplicate \"LoadPlugin\" lines " + "in your configuration!", + rf->rf_name); + return (EINVAL); + } + le = llentry_create (rf->rf_name, rf); if (le == NULL) { @@@ -777,13 -772,14 +777,13 @@@ int plugin_register_read (const char *n int (*callback) (void)) { read_func_t *rf; + int status; - rf = (read_func_t *) malloc (sizeof (read_func_t)); + rf = malloc (sizeof (*rf)); if (rf == NULL) { - char errbuf[1024]; - ERROR ("plugin_register_read: malloc failed: %s", - sstrerror (errno, errbuf, sizeof (errbuf))); - return (-1); + ERROR ("plugin_register_read: malloc failed."); + return (ENOMEM); } memset (rf, 0, sizeof (read_func_t)); @@@ -797,11 -793,7 +797,11 @@@ rf->rf_interval.tv_nsec = 0; rf->rf_effective_interval = rf->rf_interval; - return (plugin_insert_read (rf)); + status = plugin_insert_read (rf); + if (status != 0) + sfree (rf); + + return (status); } /* int plugin_register_read */ int plugin_register_complex_read (const char *group, const char *name, @@@ -810,13 -802,12 +810,13 @@@ user_data_t *user_data) { read_func_t *rf; + int status; - rf = (read_func_t *) malloc (sizeof (read_func_t)); + rf = malloc (sizeof (*rf)); if (rf == NULL) { ERROR ("plugin_register_complex_read: malloc failed."); - return (-1); + return (ENOMEM); } memset (rf, 0, sizeof (read_func_t)); @@@ -844,11 -835,7 +844,11 @@@ rf->rf_udata = *user_data; } - return (plugin_insert_read (rf)); + status = plugin_insert_read (rf); + if (status != 0) + sfree (rf); + + return (status); } /* int plugin_register_complex_read */ int plugin_register_write (const char *name, @@@ -865,13 -852,6 +865,13 @@@ int plugin_register_flush (const char * (void *) callback, ud)); } /* int plugin_register_flush */ +int plugin_register_missing (const char *name, + plugin_missing_cb callback, user_data_t *ud) +{ + return (create_register_callback (&list_missing, name, + (void *) callback, ud)); +} /* int plugin_register_missing */ + int plugin_register_shutdown (const char *name, int (*callback) (void)) { @@@ -1058,11 -1038,6 +1058,11 @@@ int plugin_unregister_flush (const cha return (plugin_unregister (list_flush, name)); } +int plugin_unregister_missing (const char *name) +{ + return (plugin_unregister (list_missing, name)); +} + int plugin_unregister_shutdown (const char *name) { return (plugin_unregister (list_shutdown, name)); @@@ -1286,7 -1261,7 +1286,7 @@@ int plugin_write (const char *plugin, / return (status); } /* }}} int plugin_write */ -int plugin_flush (const char *plugin, int timeout, const char *identifier) +int plugin_flush (const char *plugin, cdtime_t timeout, const char *identifier) { llentry_t *le; @@@ -1331,8 -1306,7 +1331,8 @@@ void plugin_shutdown_all (void destroy_read_heap (); - plugin_flush (/* plugin = */ NULL, /* timeout = */ -1, + plugin_flush (/* plugin = */ NULL, + /* timeout = */ 0, /* identifier = */ NULL); le = NULL; @@@ -1362,7 -1336,6 +1362,7 @@@ * the real free function when registering the write callback. This way * the data isn't freed twice. */ destroy_all_callbacks (&list_flush); + destroy_all_callbacks (&list_missing); destroy_all_callbacks (&list_write); destroy_all_callbacks (&list_notification); @@@ -1370,44 -1343,6 +1370,44 @@@ destroy_all_callbacks (&list_log); } /* void plugin_shutdown_all */ +int plugin_dispatch_missing (const value_list_t *vl) /* {{{ */ +{ + llentry_t *le; + + if (list_missing == NULL) + return (0); + + le = llist_head (list_missing); + while (le != NULL) + { + callback_func_t *cf; + plugin_missing_cb callback; + int status; + + cf = le->value; + callback = cf->cf_callback; + + status = (*callback) (vl, &cf->cf_udata); + if (status != 0) + { + if (status < 0) + { + ERROR ("plugin_dispatch_missing: Callback function \"%s\" " + "failed with status %i.", + le->key, status); + return (status); + } + else + { + return (0); + } + } + + le = le->next; + } + return (0); +} /* int }}} plugin_dispatch_missing */ + int plugin_dispatch_values (value_list_t *vl) { int status; @@@ -1460,17 -1395,16 +1460,17 @@@ } if (vl->time == 0) - vl->time = time (NULL); + vl->time = cdtime (); if (vl->interval <= 0) vl->interval = interval_g; - DEBUG ("plugin_dispatch_values: time = %u; interval = %i; " + DEBUG ("plugin_dispatch_values: time = %.3f; interval = %.3f; " "host = %s; " "plugin = %s; plugin_instance = %s; " "type = %s; type_instance = %s;", - (unsigned int) vl->time, vl->interval, + CDTIME_T_TO_DOUBLE (vl->time), + CDTIME_T_TO_DOUBLE (vl->interval), vl->host, vl->plugin, vl->plugin_instance, vl->type, vl->type_instance); @@@ -1554,6 -1488,9 +1554,6 @@@ /* Update the value cache */ uc_update (ds, vl); - /* Initiate threshold checking */ - ut_check_threshold (ds, vl); - if (post_cache_chain != NULL) { status = fc_process_chain (ds, vl, post_cache_chain); @@@ -1586,15 -1523,61 +1586,61 @@@ return (0); } /* int plugin_dispatch_values */ + int plugin_dispatch_values_secure (const value_list_t *vl) + { + value_list_t vl_copy; + int status; + + if (vl == NULL) + return EINVAL; + + memcpy (&vl_copy, vl, sizeof (vl_copy)); + + /* Write callbacks must not change the values and meta pointers, so we can + * savely skip copying those and make this more efficient. */ + if ((pre_cache_chain == NULL) && (post_cache_chain == NULL)) + return (plugin_dispatch_values (&vl_copy)); + + /* Set pointers to NULL, just to be on the save side. */ + vl_copy.values = NULL; + vl_copy.meta = NULL; + + vl_copy.values = malloc (sizeof (*vl_copy.values) * vl->values_len); + if (vl_copy.values == NULL) + { + ERROR ("plugin_dispatch_values_secure: malloc failed."); + return (ENOMEM); + } + memcpy (vl_copy.values, vl->values, sizeof (*vl_copy.values) * vl->values_len); + + if (vl->meta != NULL) + { + vl_copy.meta = meta_data_clone (vl->meta); + if (vl_copy.meta == NULL) + { + ERROR ("plugin_dispatch_values_secure: meta_data_clone failed."); + free (vl_copy.values); + return (ENOMEM); + } + } /* if (vl->meta) */ + + status = plugin_dispatch_values (&vl_copy); + + meta_data_destroy (vl_copy.meta); + free (vl_copy.values); + + return (status); + } /* int plugin_dispatch_values_secure */ + int plugin_dispatch_notification (const notification_t *notif) { llentry_t *le; /* Possible TODO: Add flap detection here */ DEBUG ("plugin_dispatch_notification: severity = %i; message = %s; " - "time = %u; host = %s;", + "time = %.3f; host = %s;", notif->severity, notif->message, - (unsigned int) notif->time, notif->host); + CDTIME_T_TO_DOUBLE (notif->time), notif->host); /* Nobody cares for notifications */ if (list_notification == NULL) @@@ -1728,7 -1711,7 +1774,7 @@@ static int plugin_notification_meta_ad } case NM_TYPE_BOOLEAN: { - meta->nm_value.nm_boolean = *((bool *) value); + meta->nm_value.nm_boolean = *((_Bool *) value); break; } default: @@@ -1782,7 -1765,7 +1828,7 @@@ int plugin_notification_meta_add_doubl int plugin_notification_meta_add_boolean (notification_t *n, const char *name, - bool value) + _Bool value) { return (plugin_notification_meta_add (n, name, NM_TYPE_BOOLEAN, &value)); } diff --combined src/plugin.h index e8804728,0b34ab1d..86d40340 --- a/src/plugin.h +++ b/src/plugin.h @@@ -2,7 -2,7 +2,7 @@@ #define PLUGIN_H /** * collectd - src/plugin.h - * Copyright (C) 2005-2010 Florian octo Forster + * Copyright (C) 2005-2011 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 @@@ -18,14 -18,13 +18,14 @@@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Sebastian Harl **/ #include "collectd.h" #include "configfile.h" #include "meta_data.h" +#include "utils_time.h" #define PLUGIN_FLAGS_GLOBAL 0x0001 @@@ -86,8 -85,8 +86,8 @@@ struct value_list_ { value_t *values; int values_len; - time_t time; - int interval; + cdtime_t time; + cdtime_t interval; char host[DATA_MAX_NAME_LEN]; char plugin[DATA_MAX_NAME_LEN]; char plugin_instance[DATA_MAX_NAME_LEN]; @@@ -136,7 -135,7 +136,7 @@@ typedef struct notification_meta_ int64_t nm_signed_int; uint64_t nm_unsigned_int; double nm_double; - bool nm_boolean; + _Bool nm_boolean; } nm_value; struct notification_meta_s *next; } notification_meta_t; @@@ -144,7 -143,7 +144,7 @@@ typedef struct notification_s { int severity; - time_t time; + cdtime_t time; char message[NOTIF_MAX_MSG_LEN]; char host[DATA_MAX_NAME_LEN]; char plugin[DATA_MAX_NAME_LEN]; @@@ -168,12 -167,8 +168,12 @@@ typedef int (*plugin_init_cb) (void) typedef int (*plugin_read_cb) (user_data_t *); typedef int (*plugin_write_cb) (const data_set_t *, const value_list_t *, user_data_t *); -typedef int (*plugin_flush_cb) (int timeout, const char *identifier, +typedef int (*plugin_flush_cb) (cdtime_t timeout, const char *identifier, user_data_t *); +/* "missing" callback. Returns less than zero on failure, zero if other + * callbacks should be called, greater than zero if no more callbacks should be + * called. */ +typedef int (*plugin_missing_cb) (const value_list_t *, user_data_t *); typedef void (*plugin_log_cb) (int severity, const char *message, user_data_t *); typedef int (*plugin_shutdown_cb) (void); @@@ -253,7 -248,7 +253,7 @@@ void plugin_shutdown_all (void) int plugin_write (const char *plugin, const data_set_t *ds, const value_list_t *vl); -int plugin_flush (const char *plugin, int timeout, const char *identifier); +int plugin_flush (const char *plugin, cdtime_t timeout, const char *identifier); /* * The `plugin_register_*' functions are used to make `config', `init', @@@ -269,8 -264,6 +269,8 @@@ int plugin_register_init (const char *n plugin_init_cb callback); int plugin_register_read (const char *name, int (*callback) (void)); +/* "user_data" will be freed automatically, unless + * "plugin_register_complex_read" returns an error (non-zero). */ int plugin_register_complex_read (const char *group, const char *name, plugin_read_cb callback, const struct timespec *interval, @@@ -279,8 -272,6 +279,8 @@@ int plugin_register_write (const char * plugin_write_cb callback, user_data_t *user_data); int plugin_register_flush (const char *name, plugin_flush_cb callback, user_data_t *user_data); +int plugin_register_missing (const char *name, + plugin_missing_cb callback, user_data_t *user_data); int plugin_register_shutdown (const char *name, plugin_shutdown_cb callback); int plugin_register_data_set (const data_set_t *ds); @@@ -296,7 -287,6 +296,7 @@@ int plugin_unregister_read (const char int plugin_unregister_read_group (const char *group); int plugin_unregister_write (const char *name); int plugin_unregister_flush (const char *name); +int plugin_unregister_missing (const char *name); int plugin_unregister_shutdown (const char *name); int plugin_unregister_data_set (const char *name); int plugin_unregister_log (const char *name); @@@ -318,7 -308,7 +318,8 @@@ int plugin_unregister_notification (con * function. */ int plugin_dispatch_values (value_list_t *vl); + int plugin_dispatch_values_secure (const value_list_t *vl); +int plugin_dispatch_missing (const value_list_t *vl); int plugin_dispatch_notification (const notification_t *notif); @@@ -351,7 -341,7 +352,7 @@@ int plugin_notification_meta_add_doubl double value); int plugin_notification_meta_add_boolean (notification_t *n, const char *name, - bool value); + _Bool value); int plugin_notification_meta_copy (notification_t *dst, const notification_t *src); diff --combined src/pyvalues.c index 36a717e9,4a701d01..9d8760a5 --- a/src/pyvalues.c +++ b/src/pyvalues.c @@@ -91,7 -91,7 +91,7 @@@ static PyObject *cpy_common_repr(PyObje if (self->time != 0) { CPY_STRCAT(&ret, l_time); - tmp = PyInt_FromLong(self->time); + tmp = PyFloat_FromDouble(self->time); CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp); CPY_STRCAT_AND_DEL(&ret, tmp); } @@@ -351,13 -351,14 +351,13 @@@ static PyObject *Values_new(PyTypeObjec static int Values_init(PyObject *s, PyObject *args, PyObject *kwds) { Values *self = (Values *) s; - int interval = 0; - double time = 0; + double interval = 0, time = 0; PyObject *values = NULL, *meta = NULL, *tmp; const char *type = "", *plugin_instance = "", *type_instance = "", *plugin = "", *host = ""; static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance", "plugin", "host", "time", "interval", "meta", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist, NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin, NULL, &host, &time, &interval, &meta)) return -1; @@@ -408,8 -409,12 +408,12 @@@ static meta_data_t *cpy_build_meta(PyOb if (!meta) return NULL; + l = PyDict_Items(meta); /* New reference. */ + if (!l) { + cpy_log_exception("building meta data"); + return NULL; + } m = meta_data_create(); - l = PyDict_Items(meta); s = PyList_Size(l); for (i = 0; i < s; ++i) { const char *string, *keystring; @@@ -474,6 -479,7 +478,7 @@@ Py_XDECREF(value); Py_DECREF(key); } + Py_XDECREF(l); return m; } @@@ -484,7 -490,8 +489,7 @@@ static PyObject *Values_dispatch(Value value_t *value; value_list_t value_list = VALUE_LIST_INIT; PyObject *values = self->values, *meta = self->meta; - double time = self->data.time; - int interval = self->interval; + double time = self->data.time, interval = self->interval; const char *host = self->data.host; const char *plugin = self->data.plugin; const char *plugin_instance = self->data.plugin_instance; @@@ -493,7 -500,7 +498,7 @@@ static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance", "plugin", "host", "time", "interval", "meta", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist, NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin, NULL, &host, &time, &interval, &meta)) return NULL; @@@ -523,27 -530,35 +528,35 @@@ value = malloc(size * sizeof(*value)); for (i = 0; i < size; ++i) { PyObject *item, *num; - item = PySequence_GetItem(values, i); + item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */ if (ds->ds->type == DS_TYPE_COUNTER) { - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].counter = PyLong_AsUnsignedLongLong(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_GAUGE) { - num = PyNumber_Float(item); - if (num != NULL) + num = PyNumber_Float(item); /* New reference. */ + if (num != NULL) { value[i].gauge = PyFloat_AsDouble(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_DERIVE) { /* This might overflow without raising an exception. * Not much we can do about it */ - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].derive = PyLong_AsLongLong(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_ABSOLUTE) { /* This might overflow without raising an exception. * Not much we can do about it */ - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].absolute = PyLong_AsUnsignedLongLong(num); + Py_XDECREF(num); + } } else { free(value); PyErr_Format(PyExc_RuntimeError, "unknown data type %d for %s", ds->ds->type, type); @@@ -557,8 -572,8 +570,8 @@@ value_list.values = value; value_list.meta = cpy_build_meta(meta); value_list.values_len = size; - value_list.time = time; - value_list.interval = interval; + value_list.time = DOUBLE_TO_CDTIME_T(time); + value_list.interval = DOUBLE_TO_CDTIME_T(interval); sstrncpy(value_list.host, host, sizeof(value_list.host)); sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin)); sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance)); @@@ -571,11 -586,12 +584,12 @@@ Py_BEGIN_ALLOW_THREADS; ret = plugin_dispatch_values(&value_list); Py_END_ALLOW_THREADS; + meta_data_destroy(value_list.meta); + free(value); if (ret != 0) { PyErr_SetString(PyExc_RuntimeError, "error dispatching values, read the logs"); return NULL; } - free(value); Py_RETURN_NONE; } @@@ -586,7 -602,8 +600,7 @@@ static PyObject *Values_write(Values *s value_t *value; value_list_t value_list = VALUE_LIST_INIT; PyObject *values = self->values, *meta = self->meta; - double time = self->data.time; - int interval = self->interval; + double time = self->data.time, interval = self->interval; const char *host = self->data.host; const char *plugin = self->data.plugin; const char *plugin_instance = self->data.plugin_instance; @@@ -596,7 -613,7 +610,7 @@@ static char *kwlist[] = {"destination", "type", "values", "plugin_instance", "type_instance", "plugin", "host", "time", "interval", "meta", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetdiO", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etOetetetetddO", kwlist, NULL, &type, &values, NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin, NULL, &host, &time, &interval, &meta)) return NULL; @@@ -622,27 -639,35 +636,35 @@@ value = malloc(size * sizeof(*value)); for (i = 0; i < size; ++i) { PyObject *item, *num; - item = PySequence_GetItem(values, i); + item = PySequence_Fast_GET_ITEM(values, i); /* Borrowed reference. */ if (ds->ds->type == DS_TYPE_COUNTER) { - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].counter = PyLong_AsUnsignedLongLong(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_GAUGE) { - num = PyNumber_Float(item); - if (num != NULL) + num = PyNumber_Float(item); /* New reference. */ + if (num != NULL) { value[i].gauge = PyFloat_AsDouble(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_DERIVE) { /* This might overflow without raising an exception. * Not much we can do about it */ - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].derive = PyLong_AsLongLong(num); + Py_XDECREF(num); + } } else if (ds->ds->type == DS_TYPE_ABSOLUTE) { /* This might overflow without raising an exception. * Not much we can do about it */ - num = PyNumber_Long(item); - if (num != NULL) + num = PyNumber_Long(item); /* New reference. */ + if (num != NULL) { value[i].absolute = PyLong_AsUnsignedLongLong(num); + Py_XDECREF(num); + } } else { free(value); PyErr_Format(PyExc_RuntimeError, "unknown data type %d for %s", ds->ds->type, type); @@@ -655,8 -680,8 +677,8 @@@ } value_list.values = value; value_list.values_len = size; - value_list.time = time; - value_list.interval = interval; + value_list.time = DOUBLE_TO_CDTIME_T(time); + value_list.interval = DOUBLE_TO_CDTIME_T(interval); sstrncpy(value_list.host, host, sizeof(value_list.host)); sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin)); sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance)); @@@ -670,11 -695,12 +692,12 @@@ Py_BEGIN_ALLOW_THREADS; ret = plugin_write(dest, NULL, &value_list); Py_END_ALLOW_THREADS; + meta_data_destroy(value_list.meta); + free(value); if (ret != 0) { PyErr_SetString(PyExc_RuntimeError, "error dispatching values, read the logs"); return NULL; } - free(value); Py_RETURN_NONE; } @@@ -698,7 -724,7 +721,7 @@@ static PyObject *Values_repr(PyObject * ret = cpy_common_repr(s); if (self->interval != 0) { CPY_STRCAT(&ret, l_interval); - tmp = PyInt_FromLong(self->interval); + tmp = PyFloat_FromDouble(self->interval); CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp); CPY_STRCAT_AND_DEL(&ret, tmp); } @@@ -861,7 -887,7 +884,7 @@@ static PyObject *Notification_dispatch( return NULL; } - notification.time = t; + notification.time = DOUBLE_TO_CDTIME_T(t); notification.severity = severity; sstrncpy(notification.message, message, sizeof(notification.message)); sstrncpy(notification.host, host, sizeof(notification.host)); @@@ -870,8 -896,8 +893,8 @@@ sstrncpy(notification.type, type, sizeof(notification.type)); sstrncpy(notification.type_instance, type_instance, sizeof(notification.type_instance)); notification.meta = NULL; - if (notification.time < 1) - notification.time = time(0); + if (notification.time == 0) + notification.time = cdtime(); if (notification.host[0] == 0) sstrncpy(notification.host, hostname_g, sizeof(notification.host)); if (notification.plugin[0] == 0)