| 295 |
|
printw("%8s", size_conv(stats.swap_stats->free)); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
< |
if (stats.mem_stats != NULL && stats.swap_stats != NULL) { |
| 299 |
< |
/* VM */ |
| 298 |
> |
/* VM */ |
| 299 |
> |
if (stats.mem_stats != NULL && stats.mem_stats->total != 0) { |
| 300 |
|
move(6, 54); |
| 301 |
|
printw("%5.2f%%", (100.00 * (float)(stats.mem_stats->used)/stats.mem_stats->total)); |
| 302 |
+ |
} |
| 303 |
+ |
if (stats.swap_stats != NULL && stats.swap_stats->total != 0) { |
| 304 |
|
move(7, 54); |
| 305 |
|
printw("%5.2f%%", (100.00 * (float)(stats.swap_stats->used)/stats.swap_stats->total)); |
| 306 |
+ |
} |
| 307 |
+ |
if (stats.mem_stats != NULL && stats.swap_stats != NULL && |
| 308 |
+ |
stats.mem_stats->total != 0 && stats.swap_stats->total != 0) { |
| 309 |
|
move(8, 54); |
| 310 |
|
printw("%5.2f%%", (100.00 * (float)(stats.mem_stats->used+stats.swap_stats->used)/(stats.mem_stats->total+stats.swap_stats->total))); |
| 311 |
|
} |
| 430 |
|
|
| 431 |
|
WINDOW *window; |
| 432 |
|
|
| 428 |
– |
int stdin_fileno; |
| 429 |
– |
fd_set infds; |
| 430 |
– |
struct timeval timeout; |
| 431 |
– |
|
| 433 |
|
extern int errno; |
| 434 |
|
char ch; |
| 435 |
|
|
| 472 |
|
nonl(); |
| 473 |
|
cbreak(); |
| 474 |
|
noecho(); |
| 475 |
+ |
timeout(delay * 1000); |
| 476 |
|
window=newwin(0, 0, 0, 0); |
| 477 |
|
clear(); |
| 478 |
|
|
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
display_headings(); |
| 484 |
– |
stdin_fileno=fileno(stdin); |
| 486 |
|
|
| 487 |
|
for(;;){ |
| 488 |
< |
|
| 489 |
< |
FD_ZERO(&infds); |
| 490 |
< |
FD_SET(stdin_fileno, &infds); |
| 491 |
< |
timeout.tv_sec = delay; |
| 491 |
< |
timeout.tv_usec = 0; |
| 492 |
< |
|
| 493 |
< |
if((select((stdin_fileno+1), &infds, NULL, NULL, &timeout)) == -1){ |
| 494 |
< |
if(errno!=EINTR){ |
| 495 |
< |
perror("select failed"); |
| 496 |
< |
exit(1); |
| 497 |
< |
} |
| 498 |
< |
} |
| 499 |
< |
|
| 500 |
< |
if(FD_ISSET(stdin_fileno, &infds)){ |
| 501 |
< |
ch=getch(); |
| 502 |
< |
if (ch == 'q'){ |
| 503 |
< |
endwin(); |
| 504 |
< |
return 0; |
| 505 |
< |
} |
| 488 |
> |
ch = getch(); |
| 489 |
> |
if (ch == 'q'){ |
| 490 |
> |
endwin(); |
| 491 |
> |
return 0; |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
get_stats(); |