summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e70f2e)
raw | patch | inline | side by side (parent: 5e70f2e)
author | tokkee <tokkee> | |
Mon, 13 Mar 2006 11:00:53 +0000 (11:00 +0000) | ||
committer | tokkee <tokkee> | |
Mon, 13 Mar 2006 11:00:53 +0000 (11:00 +0000) |
src/collectd.pod | patch | blob | history | |
src/vserver.c | patch | blob | history | |
src/vserver.h | patch | blob | history |
diff --git a/src/collectd.pod b/src/collectd.pod
index b21f688a2f38ae26ba15e49dbe118da8214c6fff..0a3b91f46050dbef95fc48402607be20e5c446a5 100644 (file)
--- a/src/collectd.pod
+++ b/src/collectd.pod
DS:users:GAUGE:25:0:65535
-=item VServer socket msg. accounting (F<vserver-I<E<lt>xidE<gt>>/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 (F<vserver-I<E<lt>xidE<gt>>/load.rrd>)
+
+ DS:shortterm:GAUGE:25:0:100
+ DS:midterm:GAUGE:25:0:100
+ DS:longterm:GAUGE:25:0:100
=item VServer threads (F<vserver-I<E<lt>xidE<gt>>/threads.rrd>)
DS:uninterruptible:GAUGE:25:0:65535
DS:onhold:GAUGE:25:0:65535
-=item VServer load (F<vserver-I<E<lt>xidE<gt>>/load.rrd>)
+=item VServer network traffic (F<vserver-I<E<lt>xidE<gt>>/traffic-I<E<lt>nameE<gt>>.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 (F<vserver-I<E<lt>xidE<gt>>/processes.rrd>)
+=item VServer processes (F<vserver-I<E<lt>xidE<gt>>/vs_processes.rrd>)
DS:total:GAUGE:25:0:65535
-=item VServer memory usage (F<vserver-I<E<lt>xidE<gt>>/memory.rrd>)
+=item VServer memory usage (F<vserver-I<E<lt>xidE<gt>>/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 a6befa7eef2bfbbaf69c82608eb02f354587306b..90185babc4cc1986257cffa48b9c8636f0814894 100644 (file)
--- a/src/vserver.c
+++ b/src/vserver.c
* Sebastian Harl <sh at tokkee.org>
**/
+#include "vserver.h"
+
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include <sys/types.h>
#include <unistd.h>
-#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[] =
{
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;
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)
{
#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",
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 ;-) */
}
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]);
}
}
/* 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);
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 c8da63a2c82a14833a205868a25ebf2f6b44e7fa..c0fa1e5aa507f9da6855f405edb402a5eb75d43c 100644 (file)
--- a/src/vserver.h
+++ b/src/vserver.h
#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 */