aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/auxstats
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-24 04:52:49 +0000
committerrsc <devnull@localhost>2004-04-24 04:52:49 +0000
commit78802e6993a0f44d7ac7ff7d0922d55d1b089dac (patch)
tree2131829fda5ff9ee9f8ef8c88695c361cc4ba335 /src/cmd/auxstats
parent272fd660b41d7ec793bc9d8972878510f3b66055 (diff)
downloadplan9port-78802e6993a0f44d7ac7ff7d0922d55d1b089dac.tar.gz
plan9port-78802e6993a0f44d7ac7ff7d0922d55d1b089dac.tar.bz2
plan9port-78802e6993a0f44d7ac7ff7d0922d55d1b089dac.zip
various bug fixes
Diffstat (limited to 'src/cmd/auxstats')
-rw-r--r--src/cmd/auxstats/Linux.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c
index 06e9d422..d4c2a29c 100644
--- a/src/cmd/auxstats/Linux.c
+++ b/src/cmd/auxstats/Linux.c
@@ -55,6 +55,7 @@ xmeminfo(int first)
{
int i;
vlong tot, used;
+ vlong mtot, mfree;
static int fd = -1;
if(first){
@@ -63,9 +64,10 @@ xmeminfo(int first)
}
readfile(fd);
+ mtot = 0;
for(i=0; i<nline; i++){
tokens(i);
- if(ntok < 4)
+ if(ntok < 3)
continue;
tot = atoll(tok[1]);
used = atoll(tok[2]);
@@ -73,6 +75,14 @@ xmeminfo(int first)
Bprint(&bout, "mem =%lld %lld\n", used/1024, tot/1024);
else if(strcmp(tok[0], "Swap:") == 0)
Bprint(&bout, "swap =%lld %lld\n", used/1024, tot/1024);
+ else if(strcmp(tok[0], "MemTotal:") == 0)
+ mtot = atoll(tok[1]); /* kb */
+ else if(strcmp(tok[0], "MemFree:") == 0){
+ mfree = atoll(tok[1]);
+ if(mtot < mfree)
+ continue;
+ Bprint(&bout, "mem =%lld %lld\n", mtot-mfree, mtot);
+ }
}
}