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));
}
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
// 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,
#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;
},
// Methods
- .collect = conntrack_collect,
+ .heartbeat = conntrack_heartbeat,
};
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;
},
// Methods
- .init = contextswitches_init,
- .free = contextswitches_free,
- .collect = contextswitches_collect,
+ .init = contextswitches_init,
+ .free = contextswitches_free,
+ .heartbeat = contextswitches_heartbeat,
};
#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;
},
// Methods
- .collect = df_collect,
+ .heartbeat = df_heartbeat,
};
#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;
},
// Methods
- .collect = ipfrag4_collect,
+ .heartbeat = ipfrag4_heartbeat,
};
#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;
},
// Methods
- .collect = loadavg_collect,
+ .heartbeat = loadavg_heartbeat,
};
#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;
},
// Methods
- .collect = memory_collect,
+ .heartbeat = memory_heartbeat,
};
#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;
},
// Methods
- .collect = pressure_cpu_collect,
+ .heartbeat = pressure_cpu_heartbeat,
};
#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;
},
// Methods
- .collect = pressure_io_collect,
+ .heartbeat = pressure_io_heartbeat,
};
#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;
},
// Methods
- .collect = pressure_memory_collect,
+ .heartbeat = pressure_memory_heartbeat,
};
// /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;
},
// Methods
- .collect = processor_collect,
+ .heartbeat = processor_heartbeat,
};
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);
}
},
// Methods
- .collect = softirq_collect,
+ .heartbeat = softirq_heartbeat,
};
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;
}
.name = "test-error",
// Methods
- .collect = test_error_collect,
+ .heartbeat = test_error_heartbeat,
};
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
},
// Methods
- .collect = test_flapping_collect,
+ .heartbeat = test_flapping_heartbeat,
};
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));
}
.name = "test-stall",
// Methods
- .collect = test_stall_collect,
+ .heartbeat = test_stall_heartbeat,
};
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;
},
// Methods
- .collect = unbound_collect,
+ .heartbeat = unbound_heartbeat,
};
#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;
},
// Methods
- .collect = uptime_collect,
+ .heartbeat = uptime_heartbeat,
};