summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 68958b2)
raw | patch | inline | side by side (parent: 68958b2)
author | Fabian Schuh <mail@xeroc.org> | |
Thu, 18 Mar 2010 13:41:34 +0000 (14:41 +0100) | ||
committer | Fabian Schuh <mail@xeroc.org> | |
Thu, 18 Mar 2010 13:41:34 +0000 (14:41 +0100) |
src/openvpn.c | patch | blob | history |
diff --git a/src/openvpn.c b/src/openvpn.c
index 81c5343d171af7e3bf1b8295a224844af1b251c9..359410b8413aba190aa6479085a089c135e41e5d 100644 (file)
--- a/src/openvpn.c
+++ b/src/openvpn.c
return (i);
} /* int openvpn_strsplit */
+/* dispatches number of users */
+static void sumusers_submit (char *pinst, char *tinst, gauge_t value)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = value;
+
+ vl.values = values;
+ vl.values_len = STATIC_ARRAY_SIZE (values);
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "openvpn", sizeof (vl.plugin));
+ sstrncpy (vl.type, "users", sizeof (vl.type));
+ if (pinst != NULL)
+ sstrncpy (vl.plugin_instance, pinst, sizeof (vl.plugin_instance));
+ if (tinst != NULL)
+ sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* void sumusers_submit */
+
/* dispatches stats about traffic (TCP or UDP) generated by the tunnel per single endpoint */
static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx)
{
int fields_num, read = 0, found_header = 0;
long long sum_rx = 0;
long long sum_tx = 0;
+ long long sum_users = 0;
/* read the file until the "ROUTING TABLE" line is found (no more info after) */
while (fgets (buffer, sizeof (buffer), fh) != NULL)
if (sumover_allusers)
/* If so, sum over all users, ignore the individuals*/
{
+ sum_users += 1;
sum_rx += atoll(fields[2]);
sum_tx += atoll(fields[3]);
}
"OverAllTraffic", /* "Common Name" */
sum_rx, /* "Bytes Received" */
sum_tx); /* "Bytes Sent" */
+ sumusers_submit(name, name, sum_users);
}
return (read);
int fields_num, read = 0;
long long sum_rx = 0;
long long sum_tx = 0;
+ long long sum_users = 1;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
if (sumover_allusers)
/* If so, sum over all users, ignore the individuals*/
{
+ sum_users += 1;
sum_rx += atoll(fields[2]);
sum_tx += atoll(fields[3]);
}
iostats_submit (name, /* vpn instance */
"OverAllTraffic", /* "Common Name" */
sum_rx, /* "Bytes Received" */
- sum_rx); /* "Bytes Sent" */
+ sum_tx); /* "Bytes Sent" */
+ sumusers_submit(name, name, sum_users);
}
return (read);
int fields_num, read = 0;
long long sum_rx = 0;
long long sum_tx = 0;
+ long long sum_users = 0;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
if (sumover_allusers)
/* If so, sum over all users, ignore the individuals*/
{
+ sum_users += 1;
sum_rx += atoll(fields[2]);
sum_tx += atoll(fields[3]);
}
iostats_submit (name, /* vpn instance */
"OverAllTraffic", /* "Common Name" */
sum_rx, /* "Bytes Received" */
- sum_rx); /* "Bytes Sent" */
+ sum_tx); /* "Bytes Sent" */
+ sumusers_submit(name, name, sum_users);
}
return (read);