projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
utils_vl_lookup: Fixed a race when creating user objects.
[collectd.git]
/
src
/
vserver.c
diff --git
a/src/vserver.c
b/src/vserver.c
index
8fdae27
..
d80717c
100644
(file)
--- a/
src/vserver.c
+++ b/
src/vserver.c
@@
-1,6
+1,7
@@
/**
* collectd - src/vserver.c
* Copyright (C) 2006,2007 Sebastian Harl
/**
* collectd - src/vserver.c
* Copyright (C) 2006,2007 Sebastian Harl
+ * Copyright (C) 2007-2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@
-17,6
+18,7
@@
*
* Authors:
* Sebastian Harl <sh at tokkee.org>
*
* Authors:
* Sebastian Harl <sh at tokkee.org>
+ * Florian octo Forster <octo at verplant.org>
**/
#include "collectd.h"
**/
#include "collectd.h"
@@
-46,13
+48,13
@@
static int vserver_init (void)
} /* static void vserver_init(void) */
static void traffic_submit (const char *plugin_instance,
} /* static void vserver_init(void) */
static void traffic_submit (const char *plugin_instance,
- const char *type_instance,
counter_t rx, counter
_t tx)
+ const char *type_instance,
derive_t rx, derive
_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].
counter
= rx;
- values[1].
counter
= tx;
+ values[0].
derive
= rx;
+ values[1].
derive
= tx;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
@@
-105,14
+107,21
@@
static void submit_gauge (const char *plugin_instance, const char *type,
plugin_dispatch_values (&vl);
} /* void submit_gauge */
plugin_dispatch_values (&vl);
} /* void submit_gauge */
-static
inline long long _
_get_sock_bytes(const char *s)
+static
derive_t vserver
_get_sock_bytes(const char *s)
{
{
+ value_t v;
+ int status;
+
while (s[0] != '/')
++s;
/* Remove '/' */
++s;
while (s[0] != '/')
++s;
/* Remove '/' */
++s;
- return atoll(s);
+
+ status = parse_value (s, &v, DS_TYPE_DERIVE);
+ if (status != 0)
+ return (-1);
+ return (v.derive);
}
static int vserver_read (void)
}
static int vserver_read (void)
@@
-199,8
+208,8
@@
static int vserver_read (void)
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
-
counter
_t rx;
-
counter
_t tx;
+
derive
_t rx;
+
derive
_t tx;
char *type_instance;
if (strsplit (buffer, cols, 4) < 4)
char *type_instance;
if (strsplit (buffer, cols, 4) < 4)
@@
-219,8
+228,8
@@
static int vserver_read (void)
else
continue;
else
continue;
- rx =
_
_get_sock_bytes (cols[1]);
- tx =
_
_get_sock_bytes (cols[2]);
+ rx =
vserver
_get_sock_bytes (cols[1]);
+ tx =
vserver
_get_sock_bytes (cols[2]);
/* cols[3] == errors */
traffic_submit (dent->d_name, type_instance, rx, tx);
/* cols[3] == errors */
traffic_submit (dent->d_name, type_instance, rx, tx);