X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Finterface.c;h=c618af98c0016dacb5950aad50b017c3e0858c34;hb=affac33e83584e7538c358e3bd0a587d0c692bc3;hp=9501161ce87b4e6cfaeb65cb4c190d238125ffea;hpb=3dffa6fb50c66249fb3da7592c7a9385edb74677;p=collectd.git diff --git a/src/interface.c b/src/interface.c index 9501161c..c618af98 100644 --- a/src/interface.c +++ b/src/interface.c @@ -141,17 +141,11 @@ 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, "ifspeed")) == -1LL) + if ((val = get_kstat_value (ksp_chain, "obytes")) == -1LL) continue; ksp[numif++] = ksp_chain; } @@ -219,18 +213,19 @@ static int interface_read (void) for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next) { - if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL) - continue; + if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) { + if_data = (struct IFA_DATA *) if_ptr->ifa_data; - if_submit (if_ptr->ifa_name, "if_octets", + if_submit (if_ptr->ifa_name, "if_octets", if_data->IFA_RX_BYTES, if_data->IFA_TX_BYTES); - if_submit (if_ptr->ifa_name, "if_packets", + if_submit (if_ptr->ifa_name, "if_packets", if_data->IFA_RX_PACKT, if_data->IFA_TX_PACKT); - if_submit (if_ptr->ifa_name, "if_errors", + if_submit (if_ptr->ifa_name, "if_errors", if_data->IFA_RX_ERROR, if_data->IFA_TX_ERROR); + } } freeifaddrs (if_list);