summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7acaf7b)
raw | patch | inline | side by side (parent: 7acaf7b)
author | octo <octo> | |
Wed, 26 Apr 2006 09:37:47 +0000 (09:37 +0000) | ||
committer | octo <octo> | |
Wed, 26 Apr 2006 09:37:47 +0000 (09:37 +0000) |
src/traffic.c | patch | blob | history |
diff --git a/src/traffic.c b/src/traffic.c
index 7bbc48141c630d2e3ded96bc13b5478c45104298..713b01a4158e41640baa04787e4f1c5d4289b055 100644 (file)
--- a/src/traffic.c
+++ b/src/traffic.c
static char *bytes_file = "traffic-%s.rrd";
static char *packets_file = "if_packets-%s.rrd";
static char *errors_file = "if_errors-%s.rrd";
+/* TODO: Maybe implement multicast and broadcast counters */
static char *bytes_ds_def[] =
{
plugin_submit (MODULE_NAME, device, buf);
}
-#if HAVE_GETIFADDRS
+#if HAVE_GETIFADDRS || HAVE_LIBKSTAT
static void packets_submit (char *dev,
unsigned long long rx,
unsigned long long tx)
return;
plugin_submit ("if_errors", dev, buf);
}
-#endif /* HAVE_GETIFADDRS */
+#endif /* HAVE_GETIFADDRS || HAVE_LIBKSTAT */
static void traffic_read (void)
{
fclose (fh);
/* #endif KERNEL_LINUX */
-#elif defined(HAVE_LIBKSTAT)
+#elif HAVE_LIBKSTAT
int i;
- unsigned long long incoming, outgoing;
+ unsigned long long rx;
+ unsigned long long tx;
if (kc == NULL)
return;
if (kstat_read (kc, ksp[i], NULL) == -1)
continue;
- if ((incoming = get_kstat_value (ksp[i], "rbytes")) == -1LL)
- continue;
- if ((outgoing = get_kstat_value (ksp[i], "obytes")) == -1LL)
- continue;
+ rx = get_kstat_value (ksp[i], "rbytes");
+ tx = get_kstat_value (ksp[i], "obytes");
+ if ((rx != -1LL) || (tx != -1LL))
+ bytes_submit (ksp[i]->ks_name, rx, tx);
+
+ rx = get_kstat_value (ksp[i], "ipackets");
+ tx = get_kstat_value (ksp[i], "opackets");
+ if ((rx != -1LL) || (tx != -1LL))
+ packets_submit (ksp[i]->ks_name, rx, tx);
- bytes_submit (ksp[i]->ks_name, incoming, outgoing);
+ rx = get_kstat_value (ksp[i], "ierrors");
+ tx = get_kstat_value (ksp[i], "oerrors");
+ if ((rx != -1LL) || (tx != -1LL))
+ errors_submit (ksp[i]->ks_name, rx, tx);
}
/* #endif HAVE_LIBKSTAT */