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);