diff --git a/src/traffic.c b/src/traffic.c
index c7f71103852ee73421668dcfc3d3fff683085290..14b7dc32b1c6ac9ca33caab29466f5b2a16fd3c2 100644 (file)
--- a/src/traffic.c
+++ b/src/traffic.c
*/
/* TODO: Move this to `interface-%s/<blah>.rrd' in version 4. */
static char *bytes_file = "traffic-%s.rrd";
*/
/* TODO: Move this to `interface-%s/<blah>.rrd' in version 4. */
static char *bytes_file = "traffic-%s.rrd";
-static char *packets_file = "if_packets-%s.rrd";
-static char *errors_file = "if_errors-%s.rrd";
+static char *packets_file = "interface-%s/if_packets.rrd";
+static char *errors_file = "interface-%s/if_errors.rrd";
/* TODO: Maybe implement multicast and broadcast counters */
static char *config_keys[] =
{
/* TODO: Maybe implement multicast and broadcast counters */
static char *config_keys[] =
{
- "Ignore",
+ "Interface",
+ "IgnoreSelected",
NULL
};
NULL
};
-static int config_keys_num = 1;
+static int config_keys_num = 2;
static char *bytes_ds_def[] =
{
static char *bytes_ds_def[] =
{
};
static int errors_ds_num = 2;
};
static int errors_ds_num = 2;
-static char **if_ignore_list = NULL;
-static int if_ignore_list_num = 0;
+static char **if_list = NULL;
+static int if_list_num = 0;
+/*
+ * if_list_action:
+ * 0 => default is to collect selected interface
+ * 1 => ignore selcted interfaces
+ */
+static int if_list_action = 0;
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
#ifdef HAVE_LIBKSTAT
#define MAX_NUMIF 256
{
char **temp;
{
char **temp;
- if (strcasecmp (key, "Ignore") != 0)
- return (-1);
+ if (strcasecmp (key, "Interface") == 0)
+ {
+ temp = (char **) realloc (if_list, (if_list_num + 1) * sizeof (char *));
+ if (temp == NULL)
+ {
+ syslog (LOG_EMERG, "Cannot allocate more memory.");
+ return (1);
+ }
+ if_list = temp;
- temp = (char **) realloc (if_ignore_list, (if_ignore_list_num + 1) * sizeof (char *));
- if (temp == NULL)
+ if ((if_list[if_list_num] = strdup (value)) == NULL)
+ {
+ syslog (LOG_EMERG, "Cannot allocate memory.");
+ return (1);
+ }
+ if_list_num++;
+ }
+ else if (strcasecmp (key, "IgnoreSelected") == 0)
{
{
- syslog (LOG_EMERG, "Cannot allocate more memory.");
- return (1);
+ if ((strcasecmp (value, "True") == 0)
+ || (strcasecmp (value, "Yes") == 0)
+ || (strcasecmp (value, "On") == 0))
+ if_list_action = 1;
+ else
+ if_list_action = 0;
}
}
- if_ignore_list = temp;
-
- if ((if_ignore_list[if_ignore_list_num] = strdup (value)) == NULL)
+ else
{
{
- syslog (LOG_EMERG, "Cannot allocate memory.");
- return (1);
+ return (-1);
}
}
- if_ignore_list_num++;
-
- syslog (LOG_NOTICE, "traffic: Ignoring interface `%s'", value);
return (0);
}
return (0);
}
/*
* Check if this interface/instance should be ignored. This is called from
/*
* Check if this interface/instance should be ignored. This is called from
- * both, `submit' and `write' to give client and server the ability to ignore
- * certain stuff..
+ * both, `submit' and `write' to give client and server the ability to
+ * ignore certain stuff..
*/
static int check_ignore_if (const char *interface)
{
int i;
*/
static int check_ignore_if (const char *interface)
{
int i;
- for (i = 0; i < if_ignore_list_num; i++)
- if (strcasecmp (interface, if_ignore_list[i]) == 0)
- return (1);
- return (0);
+ /* If no interfaces are given collect all interfaces. Mostly to be
+ * backwards compatible, but also because this is much easier. */
+ if (if_list_num < 1)
+ return (0);
+
+ for (i = 0; i < if_list_num; i++)
+ if (strcasecmp (interface, if_list[i]) == 0)
+ return (if_list_action);
+ return (1 - if_list_action);
}
static void generic_write (char *host, char *inst, char *val,
}
static void generic_write (char *host, char *inst, char *val,
bytes_submit (device, incoming, outgoing);
incoming = atoll (fields[1]);
bytes_submit (device, incoming, outgoing);
incoming = atoll (fields[1]);
- incoming = atoll (fields[9]);
+ outgoing = atoll (fields[9]);
packets_submit (device, incoming, outgoing);
incoming = atoll (fields[2]);
packets_submit (device, incoming, outgoing);
incoming = atoll (fields[2]);
- incoming = atoll (fields[10]);
+ outgoing = atoll (fields[10]);
errors_submit (device, incoming, outgoing);
}
errors_submit (device, incoming, outgoing);
}