bool getdata(struct iface *ifa, int cols) { static unsigned long long rx, tx; if (rx && tx) { if (!getcounters(ifa->ifname, &ifa->rx, &ifa->tx)) return false; memmove(ifa->rxs, ifa->rxs+1, sizeof(ifa->rxs) * (cols - 1)); memmove(ifa->txs, ifa->txs+1, sizeof(ifa->txs) * (cols - 1)); ifa->rxs[cols - 1] = (ifa->rx - rx) / delay; ifa->txs[cols - 1] = (ifa->tx - tx) / delay; if (globalmax) { ifa->rxmax = arraymax(ifa->rxs, cols, ifa->rxmax); ifa->txmax = arraymax(ifa->txs, cols, ifa->txmax); } else { ifa->rxmax = arraymax(ifa->rxs, cols, 0); ifa->txmax = arraymax(ifa->txs, cols, 0); } ifa->rxavg = arrayavg(ifa->rxs, cols); ifa->txavg = arrayavg(ifa->txs, cols); ifa->rxmin = arraymin(ifa->rxs, cols); ifa->txmin = arraymin(ifa->txs, cols); } if (!getcounters(ifa->ifname, &rx, &tx)) return false; return true; }
void getdata(struct iface *ifa, double delay, int cols) { static long long rx, tx; if (rx && tx && !resize) { getcounters(ifa->ifname, &ifa->rx, &ifa->tx); memmove(ifa->rxs, ifa->rxs+1, sizeof(long) * (cols-1)); memmove(ifa->txs, ifa->txs+1, sizeof(long) * (cols-1)); ifa->rxs[cols-1] = (ifa->rx - rx) / delay; ifa->txs[cols-1] = (ifa->tx - tx) / delay; ifa->rxavg = arrayavg(ifa->rxs, cols); ifa->txavg = arrayavg(ifa->txs, cols); ifa->rxmax = arraymax(ifa->rxs, cols); ifa->txmax = arraymax(ifa->txs, cols); } getcounters(ifa->ifname, &rx, &tx); }