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