summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc8f6e1)
raw | patch | inline | side by side (parent: fc8f6e1)
author | Rinigus <rinigus.git@gmail.com> | |
Sat, 30 Jul 2016 21:11:30 +0000 (00:11 +0300) | ||
committer | Rinigus <rinigus.git@gmail.com> | |
Sat, 30 Jul 2016 21:11:30 +0000 (00:11 +0300) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/interface.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index bf9e8e6f3c267953fcd52bfc01d35269bfdb4d1c..b678c4254583aa273b2b1f14b4971412edd69d0e 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#<Plugin interface>
# Interface "eth0"
# IgnoreSelected false
-# ActiveInterfaceOnly false
+# ReportInactive true
# UniqueName false
#</Plugin>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 5bbbf5db1c4ebed6f7c18e2aa5be6849cc893f82..32738dc6db2abc51c9568c5e1ebd29b853d4a27d 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
with I<veth> and all interfaces with names starting with I<tun> followed by
at least one digit.
-=item B<ActiveInterfaceOnly> I<true>|I<false>
+=item B<ReportInactive> I<true>|I<false>
-When set to I<true>, only interfaces with non-zero traffic will be
+When set to I<false>, only interfaces with non-zero traffic will be
reported. Note that the check is done by looking into whether a
package was sent at any time from boot and the corresponding counter
is non-zero. So, if the interface has been sending data in the past
since boot, but not during the reported time-interval, it will still
be reported.
-The default value is I<false> and results in collection of the data
+The default value is I<true> and results in collection of the data
from all interfaces that are selected by B<Interface> and
B<IgnoreSelected> options.
diff --git a/src/interface.c b/src/interface.c
index a91c13bec9b46f25b94afb10c8ca623155529103..539df588d16cc0f794f4f094a1e818054a3e6827 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
{
"Interface",
"IgnoreSelected",
- "ActiveInterfaceOnly",
+ "ReportInactive",
NULL
};
-static int config_keys_num = 3;
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static ignorelist_t *ignorelist = NULL;
-static _Bool active_interface_only = 0;
+static _Bool report_inactive = 1;
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
invert = 0;
ignorelist_set_invert (ignorelist, invert);
}
- else if (strcasecmp (key, "ActiveInterfaceOnly") == 0)
- {
- if (IS_TRUE (value))
- active_interface_only = 1;
- else
- active_interface_only = 0;
- }
+ else if (strcasecmp (key, "ReportInactive") == 0)
+ report_inactive = IS_TRUE (value);
else if (strcasecmp (key, "UniqueName") == 0)
{
#ifdef HAVE_LIBKSTAT
if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
if_data = (struct IFA_DATA *) if_ptr->ifa_data;
- if ( active_interface_only && if_data->IFA_RX_PACKT == 0 && if_data->IFA_TX_PACKT == 0 )
+ if (!report_inactive && if_data->IFA_RX_PACKT == 0 && if_data->IFA_TX_PACKT == 0)
continue;
if_submit (if_ptr->ifa_name, "if_octets",
incoming = atoll (fields[1]);
outgoing = atoll (fields[9]);
- if ( active_interface_only && incoming == 0 && outgoing == 0 )
+ if (!report_inactive && incoming == 0 && outgoing == 0)
continue;
if_submit (device, "if_packets", incoming, outgoing);
rx = get_kstat_value (ksp[i], "ipackets");
if (tx == -1LL)
tx = get_kstat_value (ksp[i], "opackets");
- if ( active_interface_only && rx == 0 && tx == 0 )
+ if (!report_inactive && rx == 0 && tx == 0)
continue;
if ((rx != -1LL) || (tx != -1LL))
if_submit (iname, "if_packets", rx, tx);
ios = sg_get_network_io_stats (&num);
for (i = 0; i < num; i++) {
- if ( active_interface_only && ios[i].rx == 0 && ios[i].tx == 0 )
+ if (!report_inactive && ios[i].rx == 0 && ios[i].tx == 0)
continue;
if_submit (ios[i].interface_name, "if_octets", ios[i].rx, ios[i].tx);
}
for (i = 0; i < ifs; i++)
{
- if ( active_interface_only && ifstat[i].ipackets == 0 && ifstat[i].opackets == 0 )
+ if (!report_inactive && ifstat[i].ipackets == 0 && ifstat[i].opackets == 0)
continue;
if_submit (ifstat[i].name, "if_octets", ifstat[i].ibytes, ifstat[i].obytes);