aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/man1/stats.15
-rw-r--r--src/cmd/auxstats/Linux.c72
-rw-r--r--src/cmd/draw/stats.c7
3 files changed, 77 insertions, 7 deletions
diff --git a/man/man1/stats.1 b/man/man1/stats.1
index a6f5ba43..d5555deb 100644
--- a/man/man1/stats.1
+++ b/man/man1/stats.1
@@ -105,6 +105,11 @@ number of system calls per second.
number of valid pages on the swap device.
The swap is displayed as a
fraction of the number of swap pages configured by the machine.
+.TP
+.B "8 802.11b
+display the signal strength detected by the 802.11b wireless ether card; the value
+is usually below 50% unless the receiver is in the same room as the transmitter, so
+a midrange value represents a strong signal.
.PD
.PP
The graphs are plotted with time on the horizontal axis.
diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c
index 2592bc4e..09ca18f3 100644
--- a/src/cmd/auxstats/Linux.c
+++ b/src/cmd/auxstats/Linux.c
@@ -8,6 +8,8 @@ void xloadavg(int);
void xmeminfo(int);
void xnet(int);
void xstat(int);
+void xvmstat(int);
+void xwireless(int);
void (*statfn[])(int) =
{
@@ -16,6 +18,8 @@ void (*statfn[])(int) =
xmeminfo,
xnet,
xstat,
+ xvmstat,
+ xwireless,
0
};
@@ -77,6 +81,7 @@ xmeminfo(int first)
int i;
vlong tot, used;
vlong mtot, mfree;
+ vlong stot, sfree;
static int fd = -1;
if(first){
@@ -86,6 +91,9 @@ xmeminfo(int first)
readfile(fd);
mtot = 0;
+ stot = 0;
+ mfree = 0;
+ sfree = 0;
for(i=0; i<nline; i++){
tokens(i);
if(ntok < 3)
@@ -98,11 +106,22 @@ xmeminfo(int first)
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]);
+ else if(strcmp(tok[0], "MemFree:") == 0)
+ mfree += atoll(tok[1]);
+ else if(strcmp(tok[0], "Buffers:") == 0)
+ mfree += atoll(tok[1]);
+ else if(strcmp(tok[0], "Cached:") == 0){
+ mfree += atoll(tok[1]);
if(mtot < mfree)
continue;
Bprint(&bout, "mem =%lld %lld\n", mtot-mfree, mtot);
+ }else if(strcmp(tok[0], "SwapTotal:") == 0)
+ stot = atoll(tok[1]); /* kb */
+ else if(strcmp(tok[0], "SwapFree:") == 0){
+ sfree = atoll(tok[1]);
+ if(stot < sfree)
+ continue;
+ Bprint(&bout, "swap =%lld %lld\n", stot-sfree, stot);
}
}
}
@@ -135,7 +154,7 @@ xnet(int first)
tokens(i);
if(ntok < 8+8)
continue;
- if(strncmp(tok[0], "eth", 3) != 0)
+ if(strncmp(tok[0], "eth", 3) != 0 && strncmp(tok[0], "wlan", 4) != 0)
continue;
inb = atoll(tok[1]);
oub = atoll(tok[9]);
@@ -182,7 +201,7 @@ xstat(int first)
Bprint(&bout, "user %lld 100\n", atoll(tok[1]));
Bprint(&bout, "sys %lld 100\n", atoll(tok[3]));
Bprint(&bout, "cpu %lld 100\n", atoll(tok[1])+atoll(tok[3]));
- Bprint(&bout, "idle %lld\n", atoll(tok[4]));
+ Bprint(&bout, "idle %lld 100\n", atoll(tok[4]));
}
/*
if(strcmp(tok[0], "page") == 0 && ntok >= 3){
@@ -197,11 +216,52 @@ xstat(int first)
}
*/
if(strcmp(tok[0], "intr") == 0)
- Bprint(&bout, "interrupt %lld 1000\n", atoll(tok[1]));
+ Bprint(&bout, "intr %lld 1000\n", atoll(tok[1]));
if(strcmp(tok[0], "ctxt") == 0)
- Bprint(&bout, "context %lld 1000\n", atoll(tok[1]));
+ Bprint(&bout, "context %lld 10000\n", atoll(tok[1]));
if(strcmp(tok[0], "processes") == 0)
Bprint(&bout, "fork %lld 1000\n", atoll(tok[1]));
}
}
+void
+xvmstat(int first)
+{
+ static int fd = -1;
+ int i;
+
+ if(first){
+ fd = open("/proc/vmstat", OREAD);
+ return;
+ }
+
+ readfile(fd);
+ for(i=0; i<nline; i++){
+ tokens(i);
+ if(ntok < 2)
+ continue;
+ if(strcmp(tok[0], "pgfault") == 0)
+ Bprint(&bout, "fault %lld 100000\n", atoll(tok[1]));
+ }
+}
+
+void
+xwireless(int first)
+{
+ static int fd = -1;
+ int i;
+
+ if(first){
+ fd = open("/proc/net/wireless", OREAD);
+ return;
+ }
+
+ readfile(fd);
+ for(i=0; i<nline; i++){
+ tokens(i);
+ if(ntok < 3)
+ continue;
+ if(strcmp(tok[0], "wlan0:") == 0)
+ Bprint(&bout, "802.11 =%lld 100\n", atoll(tok[2]));
+ }
+}
diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c
index 75069e2b..74b8b76c 100644
--- a/src/cmd/draw/stats.c
+++ b/src/cmd/draw/stats.c
@@ -28,6 +28,7 @@ enum
enum
{
+ V80211,
Vbattery,
Vcontext,
Vcpu,
@@ -51,6 +52,7 @@ enum
char*
labels[Nvalue] =
{
+ "802.11",
"battery",
"context",
"cpu",
@@ -109,7 +111,7 @@ Machine *mach;
Font *mediumfont;
char *fontname;
char *mysysname;
-char argchars[] = "bcCeEfiIlmnsw";
+char argchars[] = "8bcCeEfiIlmnsw";
int pids[1024];
int parity; /* toggled to avoid patterns in textured background */
int nmach;
@@ -748,6 +750,9 @@ threadmain(int argc, char *argv[])
default:
fprint(2, "stats: internal error: unknown arg %c\n", args[i]);
usage();
+ case '8':
+ addgraph(V80211);
+ break;
case 'b':
addgraph(Vbattery);
break;