summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 94a30ec)
raw | patch | inline | side by side (parent: 94a30ec)
author | Fabian Schuh <mail@xeroc.org> | |
Fri, 19 Mar 2010 09:07:50 +0000 (10:07 +0100) | ||
committer | Fabian Schuh <mail@xeroc.org> | |
Fri, 19 Mar 2010 09:07:50 +0000 (10:07 +0100) |
src/openvpn.c | patch | blob | history |
diff --git a/src/openvpn.c b/src/openvpn.c
index 359410b8413aba190aa6479085a089c135e41e5d..b03ae96444d53b5c932e2ece3ee4f5610e11304f 100644 (file)
--- a/src/openvpn.c
+++ b/src/openvpn.c
static int store_compression = 1;
static int new_naming_schema = 0;
-static int sumover_allusers = 0;
+static int number_connectedusers = 0;
static const char *config_keys[] =
{
"StatusFile",
"Compression",
"ImprovedNamingSchema",
- "SumOverAllUsers"
+ "AggregateUsers"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
} /* int openvpn_strsplit */
/* dispatches number of users */
-static void sumusers_submit (char *pinst, char *tinst, gauge_t value)
+static void numusers_submit (char *pinst, char *tinst, gauge_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
-} /* void sumusers_submit */
+} /* void numusers_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)
char buffer[1024];
char *fields[10];
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) */
if (fields_num < 4)
continue;
- if (sumover_allusers)
- /* If so, sum over all users, ignore the individuals*/
+ if (number_connectedusers)
+ /* If so, sum all users, ignore the individuals*/
{
sum_users += 1;
- sum_rx += atoll(fields[2]);
- sum_tx += atoll(fields[3]);
+ }
+
+ if (new_naming_schema)
+ {
+ iostats_submit (fields[0], /* "Common Name" */
+ NULL, /* unused when in multimode */
+ atoll (fields[2]), /* "Bytes Received" */
+ atoll (fields[3])); /* "Bytes Sent" */
}
else
{
- if (new_naming_schema)
- {
- iostats_submit (fields[0], /* "Common Name" */
- NULL, /* unused when in multimode */
- atoll (fields[2]), /* "Bytes Received" */
- atoll (fields[3])); /* "Bytes Sent" */
- }
- else
- {
- iostats_submit (name, /* vpn instance */
- fields[0], /* "Common Name" */
- atoll (fields[2]), /* "Bytes Received" */
- atoll (fields[3])); /* "Bytes Sent" */
- }
+ iostats_submit (name, /* vpn instance */
+ fields[0], /* "Common Name" */
+ atoll (fields[2]), /* "Bytes Received" */
+ atoll (fields[3])); /* "Bytes Sent" */
}
read = 1;
}
- if (sumover_allusers)
+ if (number_connectedusers && read == 1)
{
- iostats_submit (name, /* vpn instance */
- "OverAllTraffic", /* "Common Name" */
- sum_rx, /* "Bytes Received" */
- sum_tx); /* "Bytes Sent" */
- sumusers_submit(name, name, sum_users);
- }
+ numusers_submit(name, name, sum_users);
+ }
return (read);
} /* int multi1_read */
char *fields[10];
const int max_fields = STATIC_ARRAY_SIZE (fields);
int fields_num, read = 0;
- long long sum_rx = 0;
- long long sum_tx = 0;
- long long sum_users = 1;
+ long long sum_users = 0;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
- if (sumover_allusers)
- /* If so, sum over all users, ignore the individuals*/
+ if (number_connectedusers)
+ /* If so, sum all users, ignore the individuals*/
{
sum_users += 1;
- sum_rx += atoll(fields[2]);
- sum_tx += atoll(fields[3]);
+ }
+
+ if (new_naming_schema)
+ {
+ /* plugin inst = file name, type inst = fields[1] */
+ iostats_submit (name, /* vpn instance */
+ fields[1], /* "Common Name" */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
}
else
{
- if (new_naming_schema)
- {
- /* plugin inst = file name, type inst = fields[1] */
- iostats_submit (name, /* vpn instance */
- fields[1], /* "Common Name" */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
- }
- else
- {
- /* plugin inst = fields[1], type inst = "" */
- iostats_submit (fields[1], /* "Common Name" */
- NULL, /* unused when in multimode */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
- }
+ /* plugin inst = fields[1], type inst = "" */
+ iostats_submit (fields[1], /* "Common Name" */
+ NULL, /* unused when in multimode */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
}
+
read = 1;
}
- if (sumover_allusers)
+ if (number_connectedusers && read == 1)
{
- iostats_submit (name, /* vpn instance */
- "OverAllTraffic", /* "Common Name" */
- sum_rx, /* "Bytes Received" */
- sum_tx); /* "Bytes Sent" */
- sumusers_submit(name, name, sum_users);
+ numusers_submit(name, name, sum_users);
}
return (read);
char *fields[15];
const int max_fields = STATIC_ARRAY_SIZE (fields);
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 (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
- if (sumover_allusers)
- /* If so, sum over all users, ignore the individuals*/
+ if (number_connectedusers)
+ /* If so, sum all users, ignore the individuals*/
{
sum_users += 1;
- sum_rx += atoll(fields[2]);
- sum_tx += atoll(fields[3]);
+ }
+
+ if (new_naming_schema)
+ {
+ iostats_submit (name, /* vpn instance */
+ fields[1], /* "Common Name" */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
}
else
{
- if (new_naming_schema)
- {
- iostats_submit (name, /* vpn instance */
- fields[1], /* "Common Name" */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
- }
- else
- {
- iostats_submit (fields[1], /* "Common Name" */
- NULL, /* unused when in multimode */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
- }
+ iostats_submit (fields[1], /* "Common Name" */
+ NULL, /* unused when in multimode */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
}
- read = 1;
+ read = 1;
}
}
- if (sumover_allusers)
+ if (number_connectedusers && read == 1)
{
- iostats_submit (name, /* vpn instance */
- "OverAllTraffic", /* "Common Name" */
- sum_rx, /* "Bytes Received" */
- sum_tx); /* "Bytes Sent" */
- sumusers_submit(name, name, sum_users);
- }
+ numusers_submit(name, name, sum_users);
+ }
return (read);
} /* int multi3_read */
new_naming_schema = 0;
}
} /* if (strcasecmp ("ImprovedNamingSchema", key) == 0) */
- else if (strcasecmp("SumOverAllUsers", key) == 0)
+ else if (strcasecmp("AggregateUsers", key) == 0)
{
if (IS_TRUE(value))
{
- DEBUG ("openvpn plugin: Summing up over all users");
- sumover_allusers = 1;
+ DEBUG ("openvpn plugin: Summing up all users");
+ number_connectedusers = 1;
}
else
{
- sumover_allusers = 1;
+ number_connectedusers = 0;
}
- } /* if (strcasecmp("SumOverAllUsers", key) == 0) */
+ } /* if (strcasecmp("AggregateUsers", key) == 0) */
else
{
return (-1);