enum
{
- /* old /dev/swap */
+ /* /dev/swap */
Mem = 0,
Maxmem,
Swap,
Maxswap,
-
+ Reclaim,
+ Maxreclaim,
Kern,
Maxkern,
Draw,
Load,
Idle,
InIntr,
+
/* /net/ether0/stats */
In = 0,
Link,
int tempfd;
int disable;
- uvlong devswap[8];
+ uvlong devswap[10];
uvlong devsysstat[10];
uvlong prevsysstat[10];
int nproc;
Mload,
Mmem,
Mswap,
+ Mreclaim,
Mkern,
Mdraw,
Msyscall,
"add load ",
"add mem ",
"add swap ",
+ "add reclaim ",
"add kern ",
"add draw ",
"add syscall ",
idleval(Machine*, uvlong*, uvlong*, int),
memval(Machine*, uvlong*, uvlong*, int),
swapval(Machine*, uvlong*, uvlong*, int),
+ reclaimval(Machine*, uvlong*, uvlong*, int),
kernval(Machine*, uvlong*, uvlong*, int),
drawval(Machine*, uvlong*, uvlong*, int),
syscallval(Machine*, uvlong*, uvlong*, int),
loadval,
memval,
swapval,
+ reclaimval,
kernval,
drawval,
syscallval,
Graph *graph;
Machine *mach;
char *mysysname;
-char argchars[] = "8bcdeEfiIkmlnpstwz";
+char argchars[] = "8bcdeEfiIkmlnprstwz";
int pids[NPROC];
int parity; /* toggled to avoid patterns in textured background */
int nmach;
int
readswap(Machine *m, uvlong *a)
{
+ static int xxx = 0;
+
if(strstr(m->buf, "memory\n")){
/* new /dev/swap - skip first 3 numbers */
if(!readnums(m, 7, a, 1))
return 0;
- a[0] = a[3];
- a[1] = a[4];
- a[2] = a[5];
- a[3] = a[6];
- a[4] = 0;
- a[5] = 0;
+ a[Mem] = a[3];
+ a[Maxmem] = a[4];
+ a[Swap] = a[5];
+ a[Maxswap] = a[6];
+
+ a[Reclaim] = 0;
+ a[Maxreclaim] = 0;
+ if(m->bufp = strstr(m->buf, "reclaim")){
+ while(m->bufp > m->buf && m->bufp[-1] != '\n')
+ m->bufp--;
+ a[Reclaim] = strtoull(m->bufp, &m->bufp, 10);
+ while(*m->bufp++ == '/')
+ a[Maxreclaim] = strtoull(m->bufp, &m->bufp, 10);
+ }
+
+ a[Kern] = 0;
+ a[Maxkern] = 0;
if(m->bufp = strstr(m->buf, "kernel malloc")){
while(m->bufp > m->buf && m->bufp[-1] != '\n')
m->bufp--;
- a[4] = strtoull(m->bufp, &m->bufp, 10);
+ a[Kern] = strtoull(m->bufp, &m->bufp, 10);
while(*m->bufp++ == '/')
- a[5] = strtoull(m->bufp, &m->bufp, 10);
+ a[Maxkern] = strtoull(m->bufp, &m->bufp, 10);
}
- a[6] = 0;
- a[7] = 0;
+ a[Draw] = 0;
+ a[Maxdraw] = 0;
if(m->bufp = strstr(m->buf, "kernel draw")){
while(m->bufp > m->buf && m->bufp[-1] != '\n')
m->bufp--;
- a[6] = strtoull(m->bufp, &m->bufp, 10);
+ a[Draw] = strtoull(m->bufp, &m->bufp, 10);
while(*m->bufp++ == '/')
- a[7] = strtoull(m->bufp, &m->bufp, 10);
+ a[Maxdraw] = strtoull(m->bufp, &m->bufp, 10);
}
return 1;
}
- a[4] = 0;
- a[5] = 0;
- a[6] = 0;
- a[7] = 0;
+ a[Reclaim] = 0;
+ a[Maxreclaim] = 0;
+ a[Kern] = 0;
+ a[Maxkern] = 0;
+ a[Draw] = 0;
+ a[Maxdraw] = 0;
+
return readnums(m, 4, a, 0);
}
int pid;
snprint(mpt, sizeof mpt, "/n/%s", p);
- snprint(buf, sizeof buf, "rimport %q / %q || import %q / %q", name, mpt, name, mpt);
pid = fork();
switch(pid){
fprint(2, "can't fork: %r\n");
return 0;
case 0:
- execl("/bin/rc", "rc", "-c", buf, nil);
+ execl("/bin/rimport", "rimport", name, "/", mpt, nil);
fprint(2, "can't exec: %r\n");
exits("exec");
}
snprint(buf, sizeof buf, "%s/mnt/apm/battery", mpt);
m->batteryfd = open(buf, OREAD);
+ if(m->batteryfd < 0){
+ snprint(buf, sizeof buf, "%s/mnt/acpi/battery", mpt);
+ m->batteryfd = open(buf, OREAD);
+ }
m->bitsybatfd = -1;
if(m->batteryfd >= 0){
if(loadbuf(m, &m->batteryfd) && readnums(m, nelem(m->batterystats), a, 0))
}
snprint(buf, sizeof buf, "%s/dev/cputemp", mpt);
m->tempfd = open(buf, OREAD);
+ if(m->tempfd < 0){
+ snprint(buf, sizeof buf, "%s/mnt/acpi/cputemp", mpt);
+ m->tempfd = open(buf, OREAD);
+ }
if(loadbuf(m, &m->tempfd))
for(n=0; n < nelem(m->temp) && readnums(m, 2, a, 0); n++)
m->temp[n] = a[0];
int
needswap(int init)
{
- return init | present[Mmem] | present[Mswap] | present[Mkern] | present[Mdraw];
+ return init | present[Mmem] | present[Mswap] | present[Mreclaim] | present[Mkern] | present[Mdraw];
}
*vmax = 1;
}
+void
+reclaimval(Machine *m, uvlong *v, uvlong *vmax, int)
+{
+ *v = m->devswap[Reclaim];
+ *vmax = m->devswap[Maxreclaim];
+ if(*vmax == 0)
+ *vmax = 1;
+}
+
void
kernval(Machine *m, uvlong *v, uvlong *vmax, int)
{
}
void
-etherval(Machine *m, uvlong *v, uvlong *vmax, int init)
+etherval(Machine *m, uvlong *v, uvlong *vmax, int)
{
*v = m->netetherstats[In]-m->prevetherstats[In] + m->netetherstats[Out]-m->prevetherstats[Out];
- *vmax = sleeptime*m->nproc;
- if(init)
- *vmax = sleeptime;
+ *vmax = sleeptime;
}
void
-etherinval(Machine *m, uvlong *v, uvlong *vmax, int init)
+etherinval(Machine *m, uvlong *v, uvlong *vmax, int)
{
*v = m->netetherstats[In]-m->prevetherstats[In];
- *vmax = sleeptime*m->nproc;
- if(init)
- *vmax = sleeptime;
+ *vmax = sleeptime;
}
void
-etheroutval(Machine *m, uvlong *v, uvlong *vmax, int init)
+etheroutval(Machine *m, uvlong *v, uvlong *vmax, int)
{
*v = m->netetherstats[Out]-m->prevetherstats[Out];
- *vmax = sleeptime*m->nproc;
- if(init)
- *vmax = sleeptime;
+ *vmax = sleeptime;
}
void
-ethererrval(Machine *m, uvlong *v, uvlong *vmax, int init)
+ethererrval(Machine *m, uvlong *v, uvlong *vmax, int)
{
int i;
*v = 0;
for(i=Err0; i<nelem(m->netetherstats); i++)
- *v += m->netetherstats[i];
- *vmax = (sleeptime/1000)*10*m->nproc;
- if(init)
- *vmax = (sleeptime/1000)*10;
+ *v += m->netetherstats[i]-m->prevetherstats[i];
+ *vmax = (sleeptime/1000)*10;
}
void
{
ulong l;
- *vmax = sleeptime;
+ *vmax = 100;
l = m->temp[0];
if(l == ~0 || l == 0)
*v = 0;
else
- *v = (l-20)*27;
+ *v = l;
}
void
/* label right, if requested */
if(ylabels && dy>Nlab*(font->height+1)){
wid = labelwidth();
- if(wid < (maxx-startx)-30){
+ if(wid < dx-10){
/* else there's not enough room */
maxx -= 1+Lx+wid;
draw(screen, Rect(maxx, starty, maxx+1, screen->r.max.y), display->black, nil, ZP);
/* create graphs */
for(i=0; i<nmach; i++){
- machr = Rect(startx+i*dx, starty, maxx, screen->r.max.y);
- if(i < nmach-1)
- machr.max.x = startx+(i+1)*dx - 1;
+ machr = Rect(startx+i*dx, starty, startx+(i+1)*dx - 1, screen->r.max.y);
+ if(i == nmach-1)
+ machr.max.x = maxx;
y = starty;
for(j=0; j<ngraph; j++, y+=dy){
g = &graph[i*ngraph+j];
if(r.max.x <= g->r.max.x)
g->overtmp = allocimage(display, r, screen->chan, 0, -1);
g->newvalue(g->mach, &v, &vmax, 0);
+ if(vmax == 0)
+ vmax = 1;
redraw(g, vmax);
}
}
case 'p':
addgraph(Mtlbpurge);
break;
+ case 'r':
+ addgraph(Mreclaim);
+ break;
case 's':
addgraph(Msyscall);
break;
fprint(2, "stats: initdraw failed: %r\n");
exits("initdraw");
}
+ display->locking = 1; /* tell library we're using the display lock */
colinit();
einit(Emouse|Ekeyboard);
startproc(inputproc, Inputproc);
pids[Mainproc] = getpid();
- display->locking = 1; /* tell library we're using the display lock */
resize();
parity = 1-parity;
for(i=0; i<nmach*ngraph; i++){
graph[i].newvalue(graph[i].mach, &v, &vmax, 0);
+ if(vmax == 0)
+ vmax = 1;
graph[i].update(&graph[i], v, vmax);
}
flushimage(display, 1);