From 61e623c41ee80167091c40a6e107614500599e7c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 8 Oct 2025 09:43:26 +0000 Subject: [PATCH] sources: Rename collect() to heartbeat() Signed-off-by: Michael Tremer --- src/daemon/source.c | 10 +++++----- src/daemon/source.h | 4 ++-- src/daemon/sources/conntrack.c | 4 ++-- src/daemon/sources/contextswitches.c | 8 ++++---- src/daemon/sources/df.c | 4 ++-- src/daemon/sources/ipfrag4.c | 4 ++-- src/daemon/sources/loadavg.c | 4 ++-- src/daemon/sources/memory.c | 4 ++-- src/daemon/sources/pressure-cpu.c | 4 ++-- src/daemon/sources/pressure-io.c | 4 ++-- src/daemon/sources/pressure-memory.c | 4 ++-- src/daemon/sources/processor.c | 4 ++-- src/daemon/sources/softirq.c | 4 ++-- src/daemon/sources/test-error.c | 4 ++-- src/daemon/sources/test-flapping.c | 4 ++-- src/daemon/sources/test-stall.c | 4 ++-- src/daemon/sources/unbound.c | 4 ++-- src/daemon/sources/uptime.c | 4 ++-- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/daemon/source.c b/src/daemon/source.c index 04678de..5000da2 100644 --- a/src/daemon/source.c +++ b/src/daemon/source.c @@ -281,10 +281,10 @@ static int collecty_source_heartbeat(sd_event_source* source, uint64_t usec, voi collecty_source_name(self), USEC_TO_MSEC((double)t_delay)); } - // Call the collect method - r = self->impl->collect(self->ctx, self); + // Call the heartbeat method + r = self->impl->heartbeat(self->ctx, self); if (r < 0) { - ERROR(self->ctx, "collect() failed for %s: %s\n", + ERROR(self->ctx, "heartbeat() failed for %s: %s\n", collecty_source_name(self), strerror(-r)); } @@ -332,8 +332,8 @@ static int collecty_source_register_heartbeat(collecty_source* self) { uint64_t heartbeat = 0; int r; - // No need to do this if we don't have a collect method - if (!self->impl->collect) + // No need to do this if we don't have a heartbeat method + if (!self->impl->heartbeat) return 0; // To avoid any load peaks, stagger sources diff --git a/src/daemon/source.h b/src/daemon/source.h index dfe34e4..2898501 100644 --- a/src/daemon/source.h +++ b/src/daemon/source.h @@ -67,8 +67,8 @@ typedef struct collecty_source_impl { // Free int (*free)(collecty_ctx* ctx); - // Collect - int (*collect)(collecty_ctx* ctx, collecty_source* source); + // Heartbeat + int (*heartbeat)(collecty_ctx* ctx, collecty_source* source); } collecty_source_impl; int collecty_source_create(collecty_source** source, diff --git a/src/daemon/sources/conntrack.c b/src/daemon/sources/conntrack.c index e3dd418..033b46b 100644 --- a/src/daemon/sources/conntrack.c +++ b/src/daemon/sources/conntrack.c @@ -25,7 +25,7 @@ #include "../util.h" #include "conntrack.h" -static int conntrack_collect(collecty_ctx* ctx, collecty_source* source) { +static int conntrack_heartbeat(collecty_ctx* ctx, collecty_source* source) { uint64_t count = 0; uint64_t max = 0; int r; @@ -61,5 +61,5 @@ const collecty_source_impl conntrack_source = { }, // Methods - .collect = conntrack_collect, + .heartbeat = conntrack_heartbeat, }; diff --git a/src/daemon/sources/contextswitches.c b/src/daemon/sources/contextswitches.c index 6dd891f..09987be 100644 --- a/src/daemon/sources/contextswitches.c +++ b/src/daemon/sources/contextswitches.c @@ -88,7 +88,7 @@ static int contextswitches_free(collecty_ctx* ctx) { return 0; } -static int contextswitches_collect(collecty_ctx* ctx, collecty_source* source) { +static int contextswitches_heartbeat(collecty_ctx* ctx, collecty_source* source) { long long total = 0; uint64_t count = 0; int fd = -EBADF; @@ -127,7 +127,7 @@ const collecty_source_impl contextswitches_source = { }, // Methods - .init = contextswitches_init, - .free = contextswitches_free, - .collect = contextswitches_collect, + .init = contextswitches_init, + .free = contextswitches_free, + .heartbeat = contextswitches_heartbeat, }; diff --git a/src/daemon/sources/df.c b/src/daemon/sources/df.c index ce4040f..8d3c596 100644 --- a/src/daemon/sources/df.c +++ b/src/daemon/sources/df.c @@ -26,7 +26,7 @@ #include "../source.h" #include "df.h" -static int df_collect(collecty_ctx* ctx, collecty_source* source) { +static int df_heartbeat(collecty_ctx* ctx, collecty_source* source) { struct mntent* mountpoint = NULL; struct statvfs stat = {}; FILE* f = NULL; @@ -97,5 +97,5 @@ const collecty_source_impl df_source = { }, // Methods - .collect = df_collect, + .heartbeat = df_heartbeat, }; diff --git a/src/daemon/sources/ipfrag4.c b/src/daemon/sources/ipfrag4.c index ca96dee..4907fef 100644 --- a/src/daemon/sources/ipfrag4.c +++ b/src/daemon/sources/ipfrag4.c @@ -23,7 +23,7 @@ #include "../source.h" #include "ipfrag4.h" -static int ipfrag4_collect(collecty_ctx* ctx, collecty_source* source) { +static int ipfrag4_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_proto* proto = NULL; uint64_t frags_oks; uint64_t frags_fails; @@ -113,5 +113,5 @@ const collecty_source_impl ipfrag4_source = { }, // Methods - .collect = ipfrag4_collect, + .heartbeat = ipfrag4_heartbeat, }; diff --git a/src/daemon/sources/loadavg.c b/src/daemon/sources/loadavg.c index b14d16f..d96044a 100644 --- a/src/daemon/sources/loadavg.c +++ b/src/daemon/sources/loadavg.c @@ -24,7 +24,7 @@ #include "../source.h" #include "loadavg.h" -static int loadavg_collect(collecty_ctx* ctx, collecty_source* source) { +static int loadavg_heartbeat(collecty_ctx* ctx, collecty_source* source) { double loadavg[3]; int r; @@ -50,5 +50,5 @@ const collecty_source_impl loadavg_source = { }, // Methods - .collect = loadavg_collect, + .heartbeat = loadavg_heartbeat, }; diff --git a/src/daemon/sources/memory.c b/src/daemon/sources/memory.c index dd06f1b..d74099d 100644 --- a/src/daemon/sources/memory.c +++ b/src/daemon/sources/memory.c @@ -23,7 +23,7 @@ #include "../source.h" #include "memory.h" -static int memory_collect(collecty_ctx* ctx, collecty_source* source) { +static int memory_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_proc_meminfo meminfo = {}; int r; @@ -71,5 +71,5 @@ const collecty_source_impl memory_source = { }, // Methods - .collect = memory_collect, + .heartbeat = memory_heartbeat, }; diff --git a/src/daemon/sources/pressure-cpu.c b/src/daemon/sources/pressure-cpu.c index 8bcbcca..5afcd27 100644 --- a/src/daemon/sources/pressure-cpu.c +++ b/src/daemon/sources/pressure-cpu.c @@ -23,7 +23,7 @@ #include "../source.h" #include "pressure-cpu.h" -static int pressure_cpu_collect(collecty_ctx* ctx, collecty_source* source) { +static int pressure_cpu_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_pressure_stats stats = {}; int r; @@ -58,5 +58,5 @@ const collecty_source_impl pressure_cpu_source = { }, // Methods - .collect = pressure_cpu_collect, + .heartbeat = pressure_cpu_heartbeat, }; diff --git a/src/daemon/sources/pressure-io.c b/src/daemon/sources/pressure-io.c index a005c28..2e21c77 100644 --- a/src/daemon/sources/pressure-io.c +++ b/src/daemon/sources/pressure-io.c @@ -23,7 +23,7 @@ #include "../source.h" #include "pressure-io.h" -static int pressure_io_collect(collecty_ctx* ctx, collecty_source* source) { +static int pressure_io_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_pressure_stats stats = {}; int r; @@ -58,5 +58,5 @@ const collecty_source_impl pressure_io_source = { }, // Methods - .collect = pressure_io_collect, + .heartbeat = pressure_io_heartbeat, }; diff --git a/src/daemon/sources/pressure-memory.c b/src/daemon/sources/pressure-memory.c index 13e0456..89dc484 100644 --- a/src/daemon/sources/pressure-memory.c +++ b/src/daemon/sources/pressure-memory.c @@ -23,7 +23,7 @@ #include "../source.h" #include "pressure-memory.h" -static int pressure_memory_collect(collecty_ctx* ctx, collecty_source* source) { +static int pressure_memory_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_pressure_stats stats = {}; int r; @@ -58,5 +58,5 @@ const collecty_source_impl pressure_memory_source = { }, // Methods - .collect = pressure_memory_collect, + .heartbeat = pressure_memory_heartbeat, }; diff --git a/src/daemon/sources/processor.c b/src/daemon/sources/processor.c index 1617870..d85ac61 100644 --- a/src/daemon/sources/processor.c +++ b/src/daemon/sources/processor.c @@ -26,7 +26,7 @@ // /proc/stat currently carries 10 fields #define MAX_FIELDS 10 -static int processor_collect(collecty_ctx* ctx, collecty_source* source) { +static int processor_heartbeat(collecty_ctx* ctx, collecty_source* source) { unsigned long usage[MAX_FIELDS] = {}; int r; @@ -61,5 +61,5 @@ const collecty_source_impl processor_source = { }, // Methods - .collect = processor_collect, + .heartbeat = processor_heartbeat, }; diff --git a/src/daemon/sources/softirq.c b/src/daemon/sources/softirq.c index 55cdff5..7a2fe66 100644 --- a/src/daemon/sources/softirq.c +++ b/src/daemon/sources/softirq.c @@ -30,7 +30,7 @@ static int callback(collecty_ctx* ctx, const char* key, uint64_t value, void* da return collecty_source_submit(source, key, "%lu", value); } -static int softirq_collect(collecty_ctx* ctx, collecty_source* source) { +static int softirq_heartbeat(collecty_ctx* ctx, collecty_source* source) { return collecty_proc_read_softirq(ctx, callback, source); } @@ -44,5 +44,5 @@ const collecty_source_impl softirq_source = { }, // Methods - .collect = softirq_collect, + .heartbeat = softirq_heartbeat, }; diff --git a/src/daemon/sources/test-error.c b/src/daemon/sources/test-error.c index bd6b864..58b95de 100644 --- a/src/daemon/sources/test-error.c +++ b/src/daemon/sources/test-error.c @@ -28,7 +28,7 @@ This is a test source which always fails. */ -static int test_error_collect(collecty_ctx* ctx, collecty_source* source) { +static int test_error_heartbeat(collecty_ctx* ctx, collecty_source* source) { return -ENOSPC; } @@ -36,5 +36,5 @@ const collecty_source_impl test_error_source = { .name = "test-error", // Methods - .collect = test_error_collect, + .heartbeat = test_error_heartbeat, }; diff --git a/src/daemon/sources/test-flapping.c b/src/daemon/sources/test-flapping.c index 860e563..f4decd5 100644 --- a/src/daemon/sources/test-flapping.c +++ b/src/daemon/sources/test-flapping.c @@ -29,7 +29,7 @@ This is a test source which fails with a certain probability. */ -static int test_flapping_collect(collecty_ctx* ctx, collecty_source* source) { +static int test_flapping_heartbeat(collecty_ctx* ctx, collecty_source* source) { int r; // Fetch some random value @@ -53,5 +53,5 @@ const collecty_source_impl test_flapping_source = { }, // Methods - .collect = test_flapping_collect, + .heartbeat = test_flapping_heartbeat, }; diff --git a/src/daemon/sources/test-stall.c b/src/daemon/sources/test-stall.c index 8730653..fba82d8 100644 --- a/src/daemon/sources/test-stall.c +++ b/src/daemon/sources/test-stall.c @@ -27,7 +27,7 @@ This is a test stalls the event loop. */ -static int test_stall_collect(collecty_ctx* ctx, collecty_source* source) { +static int test_stall_heartbeat(collecty_ctx* ctx, collecty_source* source) { // Sleep for 500ms return usleep(MSEC_TO_USEC(500)); } @@ -36,5 +36,5 @@ const collecty_source_impl test_stall_source = { .name = "test-stall", // Methods - .collect = test_stall_collect, + .heartbeat = test_stall_heartbeat, }; diff --git a/src/daemon/sources/unbound.c b/src/daemon/sources/unbound.c index b326bd3..df53aad 100644 --- a/src/daemon/sources/unbound.c +++ b/src/daemon/sources/unbound.c @@ -97,7 +97,7 @@ static int unbound_on_success(collecty_ctx* ctx, stats.rec_replies, stats.rec_time_avg, stats.rec_time_median); } -static int unbound_collect(collecty_ctx* ctx, collecty_source* source) { +static int unbound_heartbeat(collecty_ctx* ctx, collecty_source* source) { collecty_command* command = NULL; int r; @@ -138,5 +138,5 @@ const collecty_source_impl unbound_source = { }, // Methods - .collect = unbound_collect, + .heartbeat = unbound_heartbeat, }; diff --git a/src/daemon/sources/uptime.c b/src/daemon/sources/uptime.c index 69e64bb..1a3f9e1 100644 --- a/src/daemon/sources/uptime.c +++ b/src/daemon/sources/uptime.c @@ -25,7 +25,7 @@ #include "../source.h" #include "uptime.h" -static int uptime_collect(collecty_ctx* ctx, collecty_source* source) { +static int uptime_heartbeat(collecty_ctx* ctx, collecty_source* source) { struct sysinfo info = {}; int r; @@ -48,5 +48,5 @@ const collecty_source_impl uptime_source = { }, // Methods - .collect = uptime_collect, + .heartbeat = uptime_heartbeat, }; -- 2.47.3