summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b84d1b)
raw | patch | inline | side by side (parent: 3b84d1b)
author | Fabian Schuh <mail@xeroc.org> | |
Thu, 18 Mar 2010 09:50:15 +0000 (10:50 +0100) | ||
committer | Fabian Schuh <mail@xeroc.org> | |
Thu, 18 Mar 2010 09:50:15 +0000 (10:50 +0100) |
src/openvpn.c | patch | blob | history |
diff --git a/src/openvpn.c b/src/openvpn.c
index 1ac50830ceea5fb8f7cc4bdc5c21f68a5781a104..a274537680172db762ecfaaa5f32c86759cd55ae 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 long long sum_rx = 0;
+static long long sum_tx = 0;
static const char *config_keys[] =
{
"StatusFile",
"Compression",
- "ImprovedNamingSchema"
+ "ImprovedNamingSchema",
+ "SumOverAllUsers"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
if (fields_num < 4)
continue;
- if (new_naming_schema)
+ if (sumover_allusers)
+ /* If so, sum over all users, ignore the individuals*/
{
- iostats_submit (fields[0], /* "Common Name" */
- NULL, /* unused when in multimode */
- atoll (fields[2]), /* "Bytes Received" */
- atoll (fields[3])); /* "Bytes Sent" */
+ sum_rx += atoll(fields[2]);
+ sum_tx += atoll(fields[3]);
}
else
{
- iostats_submit (name, /* vpn instance */
- fields[0], /* "Common Name" */
- atoll (fields[2]), /* "Bytes Received" */
- atoll (fields[3])); /* "Bytes Sent" */
+ 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" */
+ }
}
read = 1;
}
+ if (sumover_allusers)
+ {
+ iostats_submit (name, /* vpn instance */
+ "OverAllTraffic", /* "Common Name" */
+ sum_rx, /* "Bytes Received" */
+ sum_rx); /* "Bytes Sent" */
+ }
+
return (read);
} /* int multi1_read */
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
- if (new_naming_schema)
+ if (sumover_allusers)
+ /* If so, sum over all users, ignore the individuals*/
{
- /* 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" */
+ sum_rx += atoll(fields[2]);
+ sum_tx += atoll(fields[3]);
}
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" */
+ 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" */
+ }
}
-
read = 1;
}
+ if (sumover_allusers)
+ {
+ iostats_submit (name, /* vpn instance */
+ "OverAllTraffic", /* "Common Name" */
+ sum_rx, /* "Bytes Received" */
+ sum_rx); /* "Bytes Sent" */
+ }
+
return (read);
} /* int multi2_read */
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
- if (new_naming_schema)
+ if (sumover_allusers)
+ /* If so, sum over all users, ignore the individuals*/
{
- iostats_submit (name, /* vpn instance */
- fields[1], /* "Common Name" */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
+ sum_rx += atoll(fields[2]);
+ sum_tx += atoll(fields[3]);
}
else
{
- iostats_submit (fields[1], /* "Common Name" */
- NULL, /* unused when in multimode */
- atoll (fields[4]), /* "Bytes Received" */
- atoll (fields[5])); /* "Bytes Sent" */
+ 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" */
+ }
}
read = 1;
}
}
+ if (sumover_allusers)
+ {
+ iostats_submit (name, /* vpn instance */
+ "OverAllTraffic", /* "Common Name" */
+ sum_rx, /* "Bytes Received" */
+ sum_rx); /* "Bytes Sent" */
+ }
+
return (read);
} /* int multi3_read */
new_naming_schema = 0;
}
} /* if (strcasecmp ("ImprovedNamingSchema", key) == 0) */
+ else if (strcasecmp("SumOverAllUsers", key) == 0)
+ {
+ if (IS_TRUE(value))
+ {
+ DEBUG ("openvpn plugin: Summing up over all users");
+ sumover_allusers = 1;
+ }
+ else
+ {
+ sumover_allusers = 1;
+ }
+ } /* if (strcasecmp("SumOverAllUsers", key) == 0) */
else
{
return (-1);