diff --git a/src/interface.c b/src/interface.c
index 3e5a3d05e3efa17849c60d6dd4692215979db033..ea820399ca0652bc7299d2b24ee4dde9c5569ecd 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
/**
* collectd - src/interface.c
- * Copyright (C) 2005-2008 Florian octo Forster
+ * Copyright (C) 2005-2010 Florian octo Forster
* Copyright (C) 2009 Manuel Sanmartin
*
* This program is free software; you can redistribute it and/or modify it
static int interface_init (void)
{
kstat_t *ksp_chain;
- unsigned long long val;
+ derive_t val;
numif = 0;
#endif /* HAVE_LIBKSTAT */
static void if_submit (const char *dev, const char *type,
- unsigned long long rx,
- unsigned long long tx)
+ derive_t rx,
+ derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
if (ignorelist_match (ignorelist, dev) != 0)
return;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
vl.values = values;
vl.values_len = 2;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
- sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance));
plugin_dispatch_values (&vl);
} /* void if_submit */
#elif KERNEL_LINUX
FILE *fh;
char buffer[1024];
- unsigned long long incoming, outgoing;
+ derive_t incoming, outgoing;
char *device;
-
+
char *dummy;
char *fields[16];
int numfields;
if (device[0] == '\0')
continue;
-
+
numfields = strsplit (dummy, fields, 16);
if (numfields < 11)
#elif HAVE_LIBKSTAT
int i;
- unsigned long long rx;
- unsigned long long tx;
+ derive_t rx;
+ derive_t tx;
if (kc == NULL)
return (-1);
if (kstat_read (kc, ksp[i], NULL) == -1)
continue;
- rx = get_kstat_value (ksp[i], "rbytes");
- tx = get_kstat_value (ksp[i], "obytes");
+ /* try to get 64bit counters */
+ rx = get_kstat_value (ksp[i], "rbytes64");
+ tx = get_kstat_value (ksp[i], "obytes64");
+ /* or fallback to 32bit */
+ if (rx == -1LL)
+ rx = get_kstat_value (ksp[i], "rbytes");
+ if (tx == -1LL)
+ tx = get_kstat_value (ksp[i], "obytes");
if ((rx != -1LL) || (tx != -1LL))
if_submit (ksp[i]->ks_name, "if_octets", rx, tx);
- rx = get_kstat_value (ksp[i], "ipackets");
- tx = get_kstat_value (ksp[i], "opackets");
+ /* try to get 64bit counters */
+ rx = get_kstat_value (ksp[i], "ipackets64");
+ tx = get_kstat_value (ksp[i], "opackets64");
+ /* or fallback to 32bit */
+ if (rx == -1LL)
+ rx = get_kstat_value (ksp[i], "ipackets");
+ if (tx == -1LL)
+ tx = get_kstat_value (ksp[i], "opackets");
if ((rx != -1LL) || (tx != -1LL))
if_submit (ksp[i]->ks_name, "if_packets", rx, tx);
+ /* no 64bit error counters yet */
rx = get_kstat_value (ksp[i], "ierrors");
tx = get_kstat_value (ksp[i], "oerrors");
if ((rx != -1LL) || (tx != -1LL))