Use `server->os_version_code' instead of GLIBTOP_LINUX_VERSION_CODE.

1999-01-06  Martin Baulig  <martin@home-of-linux.org>

	* netload.c (glibtop_get_netload_s): Use `server->os_version_code'
	instead of GLIBTOP_LINUX_VERSION_CODE.
This commit is contained in:
Martin Baulig
1999-01-06 19:59:04 +00:00
committed by Martin Baulig
parent 3b270123eb
commit 8ba42b25e0
2 changed files with 51 additions and 47 deletions

View File

@@ -1,3 +1,8 @@
1999-01-06 Martin Baulig <martin@home-of-linux.org>
* netload.c (glibtop_get_netload_s): Use `server->os_version_code'
instead of GLIBTOP_LINUX_VERSION_CODE.
1999-01-06 Martin Baulig <martin@home-of-linux.org> 1999-01-06 Martin Baulig <martin@home-of-linux.org>
Unconditionally enable SMP support for linux. Unconditionally enable SMP support for linux.

View File

@@ -182,83 +182,82 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
* need IP accounting. * need IP accounting.
*/ */
#if GLIBTOP_LINUX_VERSION_CODE < 131442 if (server->os_version_code < 131442) {
/* If IP accounting is enabled in the kernel and it is /* If IP accounting is enabled in the kernel and it is
* enabled for the requested interface, we use it to * enabled for the requested interface, we use it to
* get the data. In this case, we don't use /proc/net/dev * get the data. In this case, we don't use /proc/net/dev
* to get errors and collisions. * to get errors and collisions.
*/ */
f = fopen ("/proc/net/ip_acct", "r"); f = fopen ("/proc/net/ip_acct", "r");
if (f) { if (f) {
int success = 0; int success = 0;
/* Skip over the header line. */ /* Skip over the header line. */
fgets (buffer, BUFSIZ-1, f); fgets (buffer, BUFSIZ-1, f);
while (fgets (buffer, BUFSIZ-1, f)) { while (fgets (buffer, BUFSIZ-1, f)) {
unsigned long flags, packets, bytes; unsigned long flags, packets, bytes;
char *p, *dev; char *p, *dev;
/* Skip over the network thing. */ /* Skip over the network thing. */
dev = skip_token (buffer) + 1; dev = skip_token (buffer) + 1;
p = skip_token (dev); p = skip_token (dev);
*p++ = 0; *p++ = 0;
if (strcmp (dev, interface)) if (strcmp (dev, interface))
continue; continue;
success = 1; success = 1;
p = skip_token (p); p = skip_token (p);
flags = strtoul (p, &p, 16); flags = strtoul (p, &p, 16);
p = skip_multiple_token (p, 2); p = skip_multiple_token (p, 2);
packets = strtoul (p, &p, 0); packets = strtoul (p, &p, 0);
bytes = strtoul (p, &p, 0); bytes = strtoul (p, &p, 0);
if (flags & _GLIBTOP_IP_FW_ACCTIN) { if (flags & _GLIBTOP_IP_FW_ACCTIN) {
/* Incoming packets only. */ /* Incoming packets only. */
buf->packets_total += packets; buf->packets_total += packets;
buf->packets_in += packets; buf->packets_in += packets;
buf->bytes_total += bytes; buf->bytes_total += bytes;
buf->bytes_in += bytes; buf->bytes_in += bytes;
buf->flags |= _glibtop_sysdeps_netload_in; buf->flags |= _glibtop_sysdeps_netload_in;
} else if (flags & _GLIBTOP_IP_FW_ACCTOUT) { } else if (flags & _GLIBTOP_IP_FW_ACCTOUT) {
/* Outgoing packets only. */ /* Outgoing packets only. */
buf->packets_total += packets; buf->packets_total += packets;
buf->packets_out += packets; buf->packets_out += packets;
buf->bytes_total += bytes; buf->bytes_total += bytes;
buf->bytes_out += bytes; buf->bytes_out += bytes;
buf->flags |= _glibtop_sysdeps_netload_out; buf->flags |= _glibtop_sysdeps_netload_out;
} else { } else {
/* Only have total values. */ /* Only have total values. */
buf->packets_total += packets; buf->packets_total += packets;
buf->bytes_total += bytes; buf->bytes_total += bytes;
buf->flags |= _glibtop_sysdeps_netload_total; buf->flags |= _glibtop_sysdeps_netload_total;
}
} }
fclose (f);
if (success) return;
} }
fclose (f);
if (success) return;
} }
#endif
/* Ok, either IP accounting is not enabled in the kernel or /* Ok, either IP accounting is not enabled in the kernel or
* it was not enabled for the requested interface. */ * it was not enabled for the requested interface. */