X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fvserver.c;h=3a77961bbb3089ff6bb259593c671f46f81a1592;hb=2cea8075c666a6c6c7d6e1b4f95e1bee6f3803ac;hp=90185babc4cc1986257cffa48b9c8636f0814894;hpb=5d32490be3b416a4e2c709a5d79bb6bce13db897;p=collectd.git diff --git a/src/vserver.c b/src/vserver.c index 90185bab..3a77961b 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -20,8 +20,6 @@ * Sebastian Harl **/ -#include "vserver.h" - #include "collectd.h" #include "common.h" #include "plugin.h" @@ -34,6 +32,11 @@ #include #include +#define BUFSIZE 512 + +#define MODULE_NAME "vserver" +#define PROCDIR "/proc/virtual" + #if defined(KERNEL_LINUX) # define VSERVER_HAVE_READ 1 #else @@ -46,7 +49,7 @@ static char *rrd_inet6 = "vserver-%s/traffic-inet6.rrd"; static char *rrd_other = "vserver-%s/traffic-other.rrd"; static char *rrd_unspec = "vserver-%s/traffic-unspec.rrd"; -static char *rrd_thread = "vserver-%s/threads.rrd"; +static char *rrd_thread = "vserver-%s/vs_threads.rrd"; static char *rrd_load = "vserver-%s/load.rrd"; @@ -57,71 +60,71 @@ static char *rrd_memory = "vserver-%s/vs_memory.rrd"; /* bytes transferred */ static char *ds_def_unix[] = { - "DS:incoming:COUNTER:25:0:9223372036854775807", - "DS:outgoing:COUNTER:25:0:9223372036854775807", - "DS:failed:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_unix = 3; static char *ds_def_inet[] = { - "DS:incoming:COUNTER:25:0:9223372036854775807", - "DS:outgoing:COUNTER:25:0:9223372036854775807", - "DS:failed:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_inet = 3; static char *ds_def_inet6[] = { - "DS:incoming:COUNTER:25:0:9223372036854775807", - "DS:outgoing:COUNTER:25:0:9223372036854775807", - "DS:failed:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_inet6 = 3; static char *ds_def_other[] = { - "DS:incoming:COUNTER:25:0:9223372036854775807", - "DS:outgoing:COUNTER:25:0:9223372036854775807", - "DS:failed:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_other = 3; static char *ds_def_unspec[] = { - "DS:incoming:COUNTER:25:0:9223372036854775807", - "DS:outgoing:COUNTER:25:0:9223372036854775807", - "DS:failed:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:outgoing:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:failed:COUNTER:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_unspec = 3; static char *ds_def_threads[] = { - "DS:total:GAUGE:25:0:65535", - "DS:running:GAUGE:25:0:65535", - "DS:uninterruptible:GAUGE:25:0:65535", - "DS:onhold:GAUGE:25:0:65535", + "DS:total:GAUGE:"COLLECTD_HEARTBEAT":0:65535", + "DS:running:GAUGE:"COLLECTD_HEARTBEAT":0:65535", + "DS:uninterruptible:GAUGE:"COLLECTD_HEARTBEAT":0:65535", + "DS:onhold:GAUGE:"COLLECTD_HEARTBEAT":0:65535", NULL }; static int ds_num_threads = 4; static char *ds_def_load[] = { - "DS:shortterm:GAUGE:25:0:100", - "DS:midterm:GAUGE:25:0:100", - "DS:longterm:GAUGE:25:0:100", + "DS:shortterm:GAUGE:"COLLECTD_HEARTBEAT":0:100", + "DS:midterm:GAUGE:"COLLECTD_HEARTBEAT":0:100", + "DS:longterm:GAUGE:"COLLECTD_HEARTBEAT":0:100", NULL }; static int ds_num_load = 3; static char *ds_def_procs[] = { - "DS:total:GAUGE:25:0:65535", + "DS:total:GAUGE:"COLLECTD_HEARTBEAT":0:65535", NULL }; static int ds_num_procs = 1; @@ -130,10 +133,10 @@ static int ds_num_procs = 1; /* bytes */ static char *ds_def_memory[] = { - "DS:vm:GAUGE:25:0:9223372036854775807", - "DS:vml:GAUGE:25:0:9223372036854775807", - "DS:rss:GAUGE:25:0:9223372036854775807", - "DS:anon:GAUGE:25:0:9223372036854775807", + "DS:vm:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:vml:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:rss:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", + "DS:anon:GAUGE:"COLLECTD_HEARTBEAT":0:9223372036854775807", NULL }; static int ds_num_memory = 4; @@ -340,11 +343,17 @@ static void vserver_read (void) DIR *proc; struct dirent *dent; /* 42 */ + static complain_t complain_obj; + errno = 0; - if (NULL == (proc = opendir (PROCDIR))) { - syslog (LOG_ERR, "Cannot open '%s': %s", PROCDIR, strerror (errno)); + if (NULL == (proc = opendir (PROCDIR))) + { + plugin_complain (LOG_ERR, &complain_obj, "vserver plugin: " + "fopen (%s) failed: %s", PROCDIR, strerror (errno)); return; } + plugin_relief (LOG_NOTICE, &complain_obj, "vserver plugin: " + "fopen (%s) succeeded.", PROCDIR); while (NULL != (dent = readdir (proc))) { int len;