rrd based system stats
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "configfile.h"
#include "logging.h"
#include "network.h"
#include "rrdtool.h"
#define BUFSIZE 512
#define SUBMIT_NET_ONLY 0x01
static int submit_flags;
int probe_init(void)
const char *fwd_only = config_get_string("global", "forward_only", "false");
if (fwd_only == NULL || strncmp(fwd_only, "true", 4))
submit_flags |= SUBMIT_NET_ONLY;
return 0;
int probe_submit(struct sammler_plugin *plugin, const char *filename, int ds_id, const char *fmt, ... )
static const char *hostname = NULL;
if (hostname == NULL)
hostname = config_get_string("global", "hostname", "localhost");
char *buffer = malloc(BUFSIZE);
if (buffer == NULL) {
log_print(LOG_ERROR, "probe_submit: out of memory");
return -1;
va_list az;
va_start(az, fmt);
int len = vsnprintf(buffer, BUFSIZE, fmt, az);
if (len < 0 || len >= BUFSIZE) {
log_print(LOG_ERROR, "probe_submit: %s arguments too long", plugin->name);
return -1;
net_submit(hostname, plugin->name, filename, ds_id, buffer);
if (!(submit_flags & SUBMIT_NET_ONLY))
rrd_submit(hostname, plugin->name, filename, ds_id, buffer);
return 0;