From: tokkee Date: Mon, 13 Mar 2006 11:00:53 +0000 (+0000) Subject: Redesigned the VServer DS's to be more consistent with the rest of collectd. X-Git-Tag: collectd-3.8.6^2~116 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5d32490be3b416a4e2c709a5d79bb6bce13db897;p=collectd.git Redesigned the VServer DS's to be more consistent with the rest of collectd. --- diff --git a/src/collectd.pod b/src/collectd.pod index b21f688a..0a3b91f4 100644 --- a/src/collectd.pod +++ b/src/collectd.pod @@ -387,18 +387,11 @@ The DS'es depend on the module creating the RRD files: DS:users:GAUGE:25:0:65535 -=item VServer socket msg. accounting (FxidE>/socket.rrd>) - - DS:unix_in:COUNTER:25:0:9223372036854775807 - DS:unix_out:COUNTER:25:0:9223372036854775807 - DS:inet_in:COUNTER:25:0:9223372036854775807 - DS:inet_out:COUNTER:25:0:9223372036854775807 - DS:inet6_in:COUNTER:25:0:9223372036854775807 - DS:inet6_out:COUNTER:25:0:9223372036854775807 - DS:other_in:COUNTER:25:0:9223372036854775807 - DS:other_out:COUNTER:25:0:9223372036854775807 - DS:unspec_in:COUNTER:25:0:9223372036854775807 - DS:unspec_out:COUNTER:25:0:9223372036854775807 +=item VServer load (FxidE>/load.rrd>) + + DS:shortterm:GAUGE:25:0:100 + DS:midterm:GAUGE:25:0:100 + DS:longterm:GAUGE:25:0:100 =item VServer threads (FxidE>/threads.rrd>) @@ -407,17 +400,17 @@ The DS'es depend on the module creating the RRD files: DS:uninterruptible:GAUGE:25:0:65535 DS:onhold:GAUGE:25:0:65535 -=item VServer load (FxidE>/load.rrd>) +=item VServer network traffic (FxidE>/traffic-InameE>.rrd>) - DS:avg1:GAUGE:25:0:100 - DS:avg5:GAUGE:25:0:100 - DS:avg15:GAUGE:25:0:100 + DS:incoming:COUNTER:25:0:9223372036854775807 + DS:outgoing:COUNTER:25:0:9223372036854775807 + DS:failed:COUNTER:25:0:9223372036854775807 -=item VServer processes (FxidE>/processes.rrd>) +=item VServer processes (FxidE>/vs_processes.rrd>) DS:total:GAUGE:25:0:65535 -=item VServer memory usage (FxidE>/memory.rrd>) +=item VServer memory usage (FxidE>/vs_memory.rrd>) DS:vm:GAUGE:25:0:9223372036854775807 DS:vml:GAUGE:25:0:9223372036854775807 diff --git a/src/vserver.c b/src/vserver.c index a6befa7e..90185bab 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -20,6 +20,8 @@ * Sebastian Harl **/ +#include "vserver.h" + #include "collectd.h" #include "common.h" #include "plugin.h" @@ -32,40 +34,71 @@ #include #include -#define BUFSIZE 512 - -#define MODULE_NAME "vserver" -#define PROCDIR "/proc/virtual" - #if defined(KERNEL_LINUX) # define VSERVER_HAVE_READ 1 #else # define VSERVER_HAVE_READ 0 #endif /* defined(KERNEL_LINUX) */ -static char *rrd_socket = "vserver-%s/socket.rrd"; +static char *rrd_unix = "vserver-%s/traffic-unix.rrd"; +static char *rrd_inet = "vserver-%s/traffic-inet.rrd"; +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_load = "vserver-%s/load.rrd"; -static char *rrd_procs = "vserver-%s/processes.rrd"; -static char *rrd_memory = "vserver-%s/memory.rrd"; + +static char *rrd_procs = "vserver-%s/vs_processes.rrd"; +static char *rrd_memory = "vserver-%s/vs_memory.rrd"; /* 9223372036854775807 == LLONG_MAX */ /* bytes transferred */ -static char *ds_def_socket[] = +static char *ds_def_unix[] = +{ + "DS:incoming:COUNTER:25:0:9223372036854775807", + "DS:outgoing:COUNTER:25:0:9223372036854775807", + "DS:failed:COUNTER:25: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", + 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", + NULL +}; +static int ds_num_inet6 = 3; + +static char *ds_def_other[] = { - "DS:unix_in:COUNTER:25:0:9223372036854775807", - "DS:unix_out:COUNTER:25:0:9223372036854775807", - "DS:inet_in:COUNTER:25:0:9223372036854775807", - "DS:inet_out:COUNTER:25:0:9223372036854775807", - "DS:inet6_in:COUNTER:25:0:9223372036854775807", - "DS:inet6_out:COUNTER:25:0:9223372036854775807", - "DS:other_in:COUNTER:25:0:9223372036854775807", - "DS:other_out:COUNTER:25:0:9223372036854775807", - "DS:unspec_in:COUNTER:25:0:9223372036854775807", - "DS:unspec_out:COUNTER:25:0:9223372036854775807", + "DS:incoming:COUNTER:25:0:9223372036854775807", + "DS:outgoing:COUNTER:25:0:9223372036854775807", + "DS:failed:COUNTER:25:0:9223372036854775807", NULL }; -static int ds_num_socket = 10; +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", + NULL +}; +static int ds_num_unspec = 3; static char *ds_def_threads[] = { @@ -79,9 +112,9 @@ static int ds_num_threads = 4; static char *ds_def_load[] = { - "DS:avg1:GAUGE:25:0:100", - "DS:avg5:GAUGE:25:0:100", - "DS:avg15:GAUGE:25:0:100", + "DS:shortterm:GAUGE:25:0:100", + "DS:midterm:GAUGE:25:0:100", + "DS:longterm:GAUGE:25:0:100", NULL }; static int ds_num_load = 3; @@ -115,16 +148,60 @@ static void vserver_init (void) return; } /* static void vserver_init(void) */ -static void vserver_socket_write (char *host, char *inst, char *val) +static void vserver_unix_write (char *host, char *inst, char *val) +{ + int len; + char filename[BUFSIZE]; + + len = snprintf (filename, BUFSIZE, rrd_unix, inst); + if ((len > 0) && (len < BUFSIZE)) + rrd_update_file (host, filename, val, ds_def_unix, ds_num_unix); + return; +} /* static void vserver_unix_write(char *host, char *inst, char *val) */ + +static void vserver_inet_write (char *host, char *inst, char *val) +{ + int len; + char filename[BUFSIZE]; + + len = snprintf (filename, BUFSIZE, rrd_inet, inst); + if ((len > 0) && (len < BUFSIZE)) + rrd_update_file (host, filename, val, ds_def_inet, ds_num_inet); + return; +} /* static void vserver_inet_write(char *host, char *inst, char *val) */ + +static void vserver_inet6_write (char *host, char *inst, char *val) +{ + int len; + char filename[BUFSIZE]; + + len = snprintf (filename, BUFSIZE, rrd_inet6, inst); + if ((len > 0) && (len < BUFSIZE)) + rrd_update_file (host, filename, val, ds_def_inet6, ds_num_inet6); + return; +} /* static void vserver_inet6_write(char *host, char *inst, char *val) */ + +static void vserver_other_write (char *host, char *inst, char *val) +{ + int len; + char filename[BUFSIZE]; + + len = snprintf (filename, BUFSIZE, rrd_other, inst); + if ((len > 0) && (len < BUFSIZE)) + rrd_update_file (host, filename, val, ds_def_other, ds_num_other); + return; +} /* static void vserver_other_write(char *host, char *inst, char *val) */ + +static void vserver_unspec_write (char *host, char *inst, char *val) { int len; char filename[BUFSIZE]; - len = snprintf (filename, BUFSIZE, rrd_socket, inst); + len = snprintf (filename, BUFSIZE, rrd_unspec, inst); if ((len > 0) && (len < BUFSIZE)) - rrd_update_file (host, filename, val, ds_def_socket, ds_num_socket); + rrd_update_file (host, filename, val, ds_def_unspec, ds_num_unspec); return; -} /* static void vserver_socket_write(char *host, char *inst, char *val) */ +} /* static void vserver_unspec_write(char *host, char *inst, char *val) */ static void vserver_threads_write (char *host, char *inst, char *val) { @@ -172,9 +249,11 @@ static void vserver_memory_write (char *host, char *inst, char *val) #if VSERVER_HAVE_READ static void vserver_submit (char *inst, long long unix_in, long long unix_out, - long long inet_in, long long inet_out, long long inet6_in, - long long inet6_out, long long other_in, long long other_out, - long long unspec_in, long long unspec_out, int t_total, int t_running, + long long unix_failed, long long inet_in, long long inet_out, + long long inet_failed, long long inet6_in, long long inet6_out, + long long inet6_failed, long long other_in, long long other_out, + long long other_failed, long long unspec_in, long long unspec_out, + long long unspec_failed, int t_total, int t_running, int t_uninterruptible, int t_onhold, double avg1, double avg5, double avg15, int p_total, long long vm, long long vml, long long rss, long long anon) @@ -183,12 +262,38 @@ static void vserver_submit (char *inst, long long unix_in, long long unix_out, char buffer[BUFSIZE]; len = snprintf (buffer, BUFSIZE, - "N:%lld:%lld:%lld:%lld:%lld:%lld:%lld:%lld:%lld:%lld", - unix_in, unix_out, inet_in, inet_out, inet6_in, inet6_out, - other_in, other_out, unspec_in, unspec_out); + "N:%lld:%lld:%lld", unix_in, unix_out, unix_failed); + + if ((len > 0) && (len < BUFSIZE)) + plugin_submit ("vserver_unix", inst, buffer); + + + len = snprintf (buffer, BUFSIZE, + "N:%lld:%lld:%lld", inet_in, inet_out, inet_failed); + + if ((len > 0) && (len < BUFSIZE)) + plugin_submit ("vserver_inet", inst, buffer); + + + len = snprintf (buffer, BUFSIZE, + "N:%lld:%lld:%lld", inet6_in, inet6_out, inet6_failed); + + if ((len > 0) && (len < BUFSIZE)) + plugin_submit ("vserver_inet6", inst, buffer); + + + len = snprintf (buffer, BUFSIZE, + "N:%lld:%lld:%lld", other_in, other_out, other_failed); + + if ((len > 0) && (len < BUFSIZE)) + plugin_submit ("vserver_other", inst, buffer); + + + len = snprintf (buffer, BUFSIZE, + "N:%lld:%lld:%lld", unspec_in, unspec_out, unspec_failed); if ((len > 0) && (len < BUFSIZE)) - plugin_submit ("vserver_socket", inst, buffer); + plugin_submit ("vserver_unspec", inst, buffer); len = snprintf (buffer, BUFSIZE, "N:%d:%d:%d:%d", @@ -250,7 +355,11 @@ static void vserver_read (void) char *cols[4]; - long long socket[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + long long unix_s[3] = {-1, -1, -1}; + long long inet[3] = {-1, -1, -1}; + long long inet6[3] = {-1, -1, -1}; + long long other[3] = {-1, -1, -1}; + long long unspec[3] = {-1, -1, -1}; int threads[4] = {-1, -1, -1, -1}; double load[3] = {-1, -1, -1}; /* Just to be consistent ;-) */ @@ -277,28 +386,33 @@ static void vserver_read (void) } while (NULL != fgets (buffer, BUFSIZE, fh)) { - if (strsplit (buffer, cols, 3) < 3) + if (strsplit (buffer, cols, 4) < 4) continue; if (0 == strcmp (cols[0], "UNIX:")) { - socket[0] = __get_sock_bytes (cols[1]); - socket[1] = __get_sock_bytes (cols[2]); + unix_s[0] = __get_sock_bytes (cols[1]); + unix_s[1] = __get_sock_bytes (cols[2]); + unix_s[2] = __get_sock_bytes (cols[3]); } else if (0 == strcmp (cols[0], "INET:")) { - socket[2] = __get_sock_bytes (cols[1]); - socket[3] = __get_sock_bytes (cols[2]); + inet[0] = __get_sock_bytes (cols[1]); + inet[1] = __get_sock_bytes (cols[2]); + inet[2] = __get_sock_bytes (cols[3]); } else if (0 == strcmp (cols[0], "INET6:")) { - socket[4] = __get_sock_bytes (cols[1]); - socket[5] = __get_sock_bytes (cols[2]); + inet6[0] = __get_sock_bytes (cols[1]); + inet6[1] = __get_sock_bytes (cols[2]); + inet6[2] = __get_sock_bytes (cols[3]); } else if (0 == strcmp (cols[0], "OTHER:")) { - socket[6] = __get_sock_bytes (cols[1]); - socket[7] = __get_sock_bytes (cols[2]); + other[0] = __get_sock_bytes (cols[1]); + other[1] = __get_sock_bytes (cols[2]); + other[2] = __get_sock_bytes (cols[3]); } else if (0 == strcmp (cols[0], "UNSPEC:")) { - socket[8] = __get_sock_bytes (cols[1]); - socket[9] = __get_sock_bytes (cols[2]); + unspec[0] = __get_sock_bytes (cols[1]); + unspec[1] = __get_sock_bytes (cols[2]); + unspec[2] = __get_sock_bytes (cols[3]); } } @@ -378,11 +492,12 @@ static void vserver_read (void) /* XXX What to do in case of an error (i.e. some value is * still -1)? */ - vserver_submit (dent->d_name, socket[0], socket[1], socket[2], - socket[3], socket[4], socket[5], socket[6], socket[7], - socket[8], socket[9], threads[0], threads[1], threads[2], - threads[3], load[0], load[1], load[2], procs[0], memory[0], - memory[1], memory[2], memory[3]); + vserver_submit (dent->d_name, unix_s[0], unix_s[1], unix_s[2], + inet[0], inet[1], inet[2], inet6[0], inet6[1], inet6[2], + other[0], other[1], other[2], unspec[0], unspec[1], unspec[2], + threads[0], threads[1], threads[2], threads[3], load[0], + load[1], load[2], procs[0], memory[0], memory[1], memory[2], + memory[3]); } closedir (proc); @@ -395,7 +510,11 @@ static void vserver_read (void) void module_register (void) { plugin_register (MODULE_NAME, vserver_init, vserver_read, NULL); - plugin_register ("vserver_socket", NULL, NULL, vserver_socket_write); + plugin_register ("vserver_unix", NULL, NULL, vserver_unix_write); + plugin_register ("vserver_inet", NULL, NULL, vserver_inet_write); + plugin_register ("vserver_inet6", NULL, NULL, vserver_inet6_write); + plugin_register ("vserver_other", NULL, NULL, vserver_other_write); + plugin_register ("vserver_unspec", NULL, NULL, vserver_unspec_write); plugin_register ("vserver_threads", NULL, NULL, vserver_threads_write); plugin_register ("vserver_load", NULL, NULL, vserver_load_write); plugin_register ("vserver_procs", NULL, NULL, vserver_procs_write); diff --git a/src/vserver.h b/src/vserver.h index c8da63a2..c0fa1e5a 100644 --- a/src/vserver.h +++ b/src/vserver.h @@ -23,6 +23,11 @@ #if !COLLECTD_VSERVER_H #define COLLECTD_VSERVER_H 1 +#define BUFSIZE 512 + +#define MODULE_NAME "vserver" +#define PROCDIR "/proc/virtual" + void module_register(void); #endif /* !COLLECTD_VSERVER_H */