X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Finterface.c;h=d68240e1d35f95d73ff659c007815f17c4543328;hb=f4523a21e913449db2dbf79de3568b396b179ca1;hp=1ba6c8c32b73199823134d1662d89975065dc1d9;hpb=9988d61c84dfff5d04ddf48f4b93f6c9449cdc41;p=collectd.git diff --git a/src/interface.c b/src/interface.c index 1ba6c8c3..d68240e1 100644 --- a/src/interface.c +++ b/src/interface.c @@ -141,11 +141,17 @@ static int interface_init (void) { if (strncmp (ksp_chain->ks_class, "net", 3)) continue; + /* Ignore kstat entry if not the regular statistic set. This + * avoids problems with "bogus" interfaces, such as + * "wrsmd" */ + if (strncmp (ksp_chain->ks_name, ksp_chain->ks_module, + strlen (ksp_chain->ks_module)) != 0) + continue; if (ksp_chain->ks_type != KSTAT_TYPE_NAMED) continue; if (kstat_read (kc, ksp_chain, NULL) == -1) continue; - if ((val = get_kstat_value (ksp_chain, "obytes")) == -1LL) + if ((val = get_kstat_value (ksp_chain, "ifspeed")) == -1LL) continue; ksp[numif++] = ksp_chain; } @@ -296,16 +302,29 @@ static int interface_read (void) 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))