Florian Forster [Sat, 25 Nov 2023 13:12:59 +0000 (14:12 +0100)]
SMART plugin: initialize struct passed to `ioctl(2)`.
Valgrind is complaining about a conditional jump based on uninitialized
memory:
```
==66462== Conditional jump or move depends on uninitialised value(s)
==66462== at 0x10C500: smart_read_nvme_intel_disk (in /__w/collectd/collectd/test_plugin_smart)
==66462== by 0x10D366: test_x (in /__w/collectd/collectd/test_plugin_smart)
==66462== by 0x10D638: main (in /__w/collectd/collectd/test_plugin_smart)
```
This may be due to the `struct nvme_additional_smart_log` being
uninitialized when it's being passed to `ioctl(2)`.
This there, this removed an unnecessary level of indentation.
Florian Forster [Sat, 25 Nov 2023 12:51:57 +0000 (13:51 +0100)]
Netlink plugin: complete initialize structs used for testing.
Valgrind complains about a conditional jump based on uninitialized
memory:
```
==66438== Conditional jump or move depends on uninitialised value(s)
==66438== at 0x10CA06: vf_info_submit (in /__w/collectd/collectd/test_plugin_netlink)
==66438== by 0x1110F2: test_vf_submit_test (in /__w/collectd/collectd/test_plugin_netlink)
==66438== by 0x112EAC: main (in /__w/collectd/collectd/test_plugin_netlink)
```
This is likely caused by the `vf_stats_t` being only partially
initialized. Using a struct initializer is not only cleaner, it also
ensures the remainder of the struct is initialized to zero.
Florian Forster [Fri, 24 Nov 2023 11:04:25 +0000 (12:04 +0100)]
Build workflow: remove old distros.
This removes old and unsupported Linux distros:
* Ubuntu 16 ("Xenial", support ended April 2021)
* Ubuntu 18 ("Bionic Beaver", support ended June 2023)
* Enterprise Linux 7 (technically still supported, but nine years old
at this point)
* Fedora 34 (support ended June 2022)
* Fedora 35 (support ended December 2022)
Fedora 36 is also unsupported. We will keep the builder until we have
never versions of Fedora available (or at least Rawhide builds again).
Florian Forster [Fri, 24 Nov 2023 13:14:05 +0000 (14:14 +0100)]
AMQP plugin: prefer the `rabbitmq-c/amqp.h` header if available.
At some point, RabbitMQ has moved their headers to the `rabbitmq-c/`
subdirectory. The old locations still exist but throw an error, saying
the old headers are "deprecated".
This adds appropriate checks for the new headers to the configure script
and uses those if present.
To simplify both the configure script and plugin, support for ancient
versions of the library is removed. This affects versions that don't
have the `amqp_tcp_socket_new()` function yet.
Florian Forster [Fri, 24 Nov 2023 08:15:04 +0000 (09:15 +0100)]
Write MongoDB plugin: fix format trunction errors.
When a `size_t` is a 64bit integer, the 16 byte buffer could potentially
overflow. Fix this by using a larger buffer and also collectd's own
`ssnprintf()` function which guarantees to result in a null terminated
string.
```
In function 'wm_create_bson',
inlined from 'wm_write' at src/write_mongodb.c:229:17:
src/write_mongodb.c:99:32: error: '%zu' directive output may be truncated writing between 1 and 20 bytes into a region of size 16 [-Werror=format-truncation=]
99 | snprintf(key, sizeof(key), "%" PRIsz, i);
| ^~~
src/write_mongodb.c: In function 'wm_write':
src/write_mongodb.c:99:33: note: format string is defined here
99 | snprintf(key, sizeof(key), "%" PRIsz, i);
```
Florian Forster [Fri, 24 Nov 2023 07:28:06 +0000 (08:28 +0100)]
curl_stats: fix compatibility with new versions of cURL.
Use integer based keys for metrics if available.
cURL ≥ 7.55.0 provides additional keys that allow getting certain
metrics as integers rather than doubles, e.g. content length. In some
newer versions of cURL, the original keys (using doubles) are marked as
deprecated.
ChangeLog: cURL, cURL-JSON, cURL-XML, Write HTTP plugins: fix compatibility with new versions of cURL.
Wolf480pl [Tue, 21 Nov 2023 10:53:59 +0000 (11:53 +0100)]
write_prometheus: don't use AI_ADDRCONFIG for resolving bind address
Fixes #4150
write_prometheus uses getaddrinfo to resolve the bind address.
The AI_ADDRCONFIG flag causes getaddrinfo to refuse to resolve
0.0.0.0 when the system has no non-loopback IPv4 addresses configured
and refuse to resolve :: when the system has no non-loopback IPv6 configured.
We want binding to a wildcard address (0.0.0.0 or ::) to always work,
even if the network is down.
To achieve that, don't pass the AI_ADDRCONFIG flag
when resolving a bind address.
Georg Gast [Sun, 27 Aug 2023 11:20:11 +0000 (13:20 +0200)]
contrib/postgresql: Second postgresql database layout.
Changelog: contrib/postgresql: Second postgresql database layout.
Motivation for that second possible postgresql layout:
------------------------------------------------------
The first layout from Sebastian 'tokkee' Harl is like that:
```
+-------------------+ +----------------+
|Identifiers | |values |
+-------------------+ +----------------+
|ID int <-- >ID int |
|plugin text | |tstamp time |
|plugin_inst text | |name text |
|type text | |value double|
|type_inst text | | |
+-------------------+ +----------------+
```
The ID connects the two tables. The plugin, plugin_inst, type and tpye_inst
create s so called identifier. The timestamp, name and value get inserted into
the value table.
collectd/postgresql calles the collectd_insert function.
```
collectd_insert(timestamp with time zone, -- tstamp
character varying, -- host
character varying, -- plugin
character varying, -- plugin_inst
character varying, -- type
character varying, -- type_inst
character varying[], -- value_name
character varying[], -- type_name
double precision[]) -- values
```
This seems to represents the user_data_t/notification_t structure.
https://github.com/collectd/collectd/blob/ef1e157de1a4f2cff10f6f902002066d0998232c/src/daemon/plugin.h#L172
Lets take the ping plugin as an example. It collects 3 values: ping, ping_stddev, ping_droprate.
The current structure creates 3 identifiers and 3 lines for each entry. The identifiers get reused. It reports "192.168.myping.ip" as type.
To draw a diagram with e.g. grafana i would like all 3 values near each other for that host that i am pinging. See the graph in the wiki. The current setup must join through all collected values to scrap the ping values out of it. Each value must do the same again because it has an other identifier.
This second setup creates two tables:
```
+--------------------+ +--------------------+
|Instance | |plugin_ping |
+--------------------+ +--------------------+
|ID int <-- >ID int |
|plugin text | |tstamp time |
|plugin_inst text | |ping double|
| | |ping_stddev double|
| | |ping_droprate double|
| | | |
+--------------------+ +--------------------+
```
The instance ID get reused. The plugin data get its own table. All relevant measurement values are on one line. Get out the data is much more easy.
What could get argued is that i must admit, maybe take the creation of the instance table, sequence out of the collectd_insert function.
The type, type_inst and value_name get used to create the name of the value volumn. The impl_location() function handles this "data anomalies" like the ping plugin.
Description:
------------
My development was done on postgresql 15.
It has some advantages: The data has much higher data locality as it stays in one table and much less unneeded text columns.
This leads to much smaller table spaces. In my case the first setup created about 300 MB per day. The new setup about 50 MB with the advantage of depending data near each other.
You can also think about changing the datatype of the plugin_$plugin table to real. Just think if you realy need the double precission that double vs real. This just cuts the needed space in half.
Sample configuration:
---------------------
```
<Plugin postgresql>
<Writer sqlstore>
Statement "SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);"
</Writer>
<Database collectd>
Host "127.0.0.1"
Port 5432
User collector
Password "mypassword"
SSLMode "prefer"
Writer sqlstore
</Database>
</Plugin>
```
Please make sure that your database user (in this collector) has the rights to create tables, insert and update. The user that drops data must have the delete right.
Function description:
---------------------
The function collectd_insert() creates all tables and columns by itself.
1. The instance table consists of host/plugin/plugin_inst
2. The plugin_$plugin table (e.g. plugin_apache) contain all data for that plugin. The function collectd_insert() inserts the value into the column that its type/type_inst/name determines. There is one sad thing about collectd. The times that are submitted dont match 100%, so there is a epsilon (0.5 sec) that is used to check to what row a value belongs. If the column is not yet present it is added by this function.
The function impl_location() removes some data anomalies that are there when the data get submitted. There is a default that matches most cases. The plugins cpufreq, ping and memory get their names, plugin_inst get adjusted.
The procedure collectd_cleanup() is the maintainance function. It has as an argument the number of days where to keep the data. It can be called by pgagent or a similar mechanism like "CALL collectd_cleanup(180)". This delete all data that is older than 180 days.
Chris Sibbitt [Fri, 25 Aug 2023 19:04:16 +0000 (15:04 -0400)]
Change AMQP queue drops from DEBUG to WARNING
Debug messages are only available if collectd is compiled with debug enabled, making it hard to troubleshoot the situation where the amqp queue is being overrun.
The way strptime is activated using feature macros, _DEFAULT_SOURCE
(successor to _BSD_SOURCE) is disabled implicitly, so timegm is
hidden. Defining _DEFAULT_SOURCE at the same time as the other
feature macros solves this, and removes the need for the
TIMEGM_NEEDS_BSD configure macro.
This avoids an implicit declaration of timegm in src/bind.c, and build
failures with future compilers.
tiozhang [Wed, 1 Mar 2023 06:19:15 +0000 (14:19 +0800)]
vmem: add metrics start with "pgscan_" in Kernel Linux
Some Linux Kernel versions have metrics start with "pgscan_"
in /proc/vmstat, for instance:
```
cat /proc/vmstat | grep pgscan
pgscan_kswapd 0
pgscan_direct 0
pgscan_direct_throttle 0
```
Yadnesh Kulkarni [Wed, 22 Feb 2023 12:27:55 +0000 (17:57 +0530)]
Hugepages plugin skips reading write-only file
Since 'demote' is a write-only file do not attempt to
to read it. This also prevents the plugin from generating
incessant logs about the failure to open it.
Thomas Renninger [Tue, 31 Jan 2023 15:40:42 +0000 (16:40 +0100)]
Fix compile issue if net-snmp has NETSNMP_DISABLE_MD5 set
Otherwise one gets:
src/snmp.c: In function 'csnmp_config_add_host_auth_protocol':
src/snmp.c:678:25: error: 'usmHMACMD5AuthProtocol' undeclared (first use in this function); did you mean 'usmHMACSHA1AuthProtocol'?
678 | hd->auth_protocol = usmHMACMD5AuthProtocol;
| ^~~~~~~~~~~~~~~~~~~~~~
| usmHMACSHA1AuthProtocol
Leonard Göhrs [Tue, 27 Sep 2022 06:03:14 +0000 (08:03 +0200)]
mmc: cache open file descriptors to block devices
Udev rules can contain a "watch" option, which is described in the man page as:
Watch the device node with inotify; when the node is closed after being
opened for writing, a change uevent is synthesized.
This watch option is enabled by default for all block devices[1].
The intention behind this is to be notified about changes to the partition
table. The mmc plugin does however also need to open the block device for
writing, even though it never modifies its content, in order to be able to
issue ioctls with vendor defined MMC-commands.
Reduce the amount of generated change events from one per read to one per
collectd runtime by caching the open file descriptor.