zzzyhtheonly [Fri, 19 Jan 2024 08:51:17 +0000 (16:51 +0800)]
disk: add /proc/diskstats fields 15 to 20 in KERNEL_LINUX
Kernel 4.18+ appends four more fields for discard tracking putting
the total at 18.
Kernel 5.5+ appends two more fields for flush requests.
This patch makes collectd available for those fields.
Eero Tamminen [Wed, 17 Jan 2024 15:19:16 +0000 (17:19 +0200)]
Pass strcmp() to c_avl_create() as function pointer, not data one
Matches how strcmp() is passed to c_avl_create() elsewhere.
Reported by -Wpendantic:
------------------------------------
write_prometheus.c: In function ‘prom_init’:
write_prometheus.c:900:28: error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic]
900 | metrics = c_avl_create((void *)strcmp);
| ^
write_prometheus.c:900:28: error: ISO C forbids passing argument 1 of ‘c_avl_create’ between function pointer and ‘void *’ [-Werror=pedantic]
900 | metrics = c_avl_create((void *)strcmp);
| ^~~~~~~~~~~~~~
In file included from write_prometheus.c:30:
utils/avltree/avltree.h:54:34: note: expected ‘int (*)(const void *, const void *)’ but argument is of type ‘void *’
54 | c_avl_tree_t *c_avl_create(int (*compare)(const void *, const void *));
|
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------
Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
Florian Forster [Thu, 11 Jan 2024 19:35:30 +0000 (20:35 +0100)]
write_riemann plugin: Terminate `riemann_event_set` arguments with `RIEMANN_EVENT_FIELD_NONE`.
`riemann_event_set` is a variadic function, that means it accepts a variable
number of arguments. That means it needs some way to determine – at runtime
– how many arguments there are. It appears to be doing so by using
`RIEMANN_EVENT_FIELD_NONE` to indicate the last element in the argument
list. Unfortunately I was unable to find the library's documentation and
code and could not verify this.
That means that the argument list passed to `riemann_event_set` was not
always terminated, causing it to read past where it was supposed to and
adding random crap into the message it crafted.
Takuro Ashie [Mon, 26 Oct 2020 02:22:29 +0000 (11:22 +0900)]
lua: Use a global lock to call Lua's API
Since vanilla Lua isn't multi-thread-safe, a global lock should be used
when calling their functions. The previous code causes unstable behavior
especially on loading Lua's C modules with both read & write threads.
Kentaro Hayashi [Mon, 8 Feb 2021 12:26:16 +0000 (21:26 +0900)]
collection3: Fix inappropriate usage of CGI:param
When using collection3 as a CGI, the following error is sent to logs
repeatedly.
FastCGI sent in stderr: "CGI::param called in list context from
/usr/share/doc/collectd-core/examples/collection3/lib/Collectd/Graph/Common.pm
line 529, this can lead to vulnerabilities. See the warning in
"Fetching the value or values of a single named parameter" at
/usr/share/perl5/CGI.pm line 412"
This is caused inappropriate usage of param(), it should be handled as
a scalar or should be treated by multi_param() explicitly.
Florian Forster [Thu, 21 Dec 2023 11:05:45 +0000 (12:05 +0100)]
common: Fix compiler warning in unit test.
Some compilers complained about using a value that depends on the input for the
size argument passed to `strncpy`. They missed that the size of `buf` also
depends on the source argument and therefore this use is fine.
```
CC src/utils/common/common_test.o
../../src/utils/common/common_test.c: In function 'test_parse_values':
../../src/utils/common/common_test.c:316:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
316 | strncpy(buf, cases[i].buffer, buf_sz);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/utils/common/common_test.c:314:21: note: length computed here
314 | size_t buf_sz = strlen(cases[i].buffer) + 1;
| ^~~~~~~~~~~~~~~~~~~~~~~
```
Florian Forster [Tue, 28 Nov 2023 18:31:11 +0000 (19:31 +0100)]
procevent plugin: remove use of a nested flexible array member.
The previous code used an ad-hoc struct to construct or parse a Netlink
message. This relied on allocating a field _after_ the struct with the
flexible array member, which is prohibited by the C standard, leading to
compiler warnings.
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.