| 40 |
|
|
| 41 |
|
#ifdef HAVE_NCURSES_H |
| 42 |
|
#include <ncurses.h> |
| 43 |
+ |
#define COLOR_SUPPORT |
| 44 |
|
#else |
| 45 |
|
#include <curses.h> |
| 46 |
|
#endif |
| 311 |
|
move(4,33); |
| 312 |
|
if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_ALERT_CPU) { |
| 313 |
|
attron(A_STANDOUT); |
| 314 |
+ |
attron(A_BOLD); |
| 315 |
|
} |
| 316 |
|
else if (colors && stats.cpu_percents->user + stats.cpu_percents->nice > THRESHOLD_WARN_CPU) { |
| 317 |
|
attron(A_BOLD); |
| 331 |
|
move(2,74); |
| 332 |
|
if (colors && stats.process_count->zombie > THRESHOLD_WARN_ZMB) { |
| 333 |
|
attron(A_STANDOUT); |
| 334 |
+ |
attron(A_BOLD); |
| 335 |
|
} |
| 336 |
|
printw("%5d", stats.process_count->zombie); |
| 337 |
|
if(colors) { |
| 338 |
|
attroff(A_STANDOUT); |
| 339 |
< |
attron(COLOR_PAIR(6)); |
| 339 |
> |
attroff(A_BOLD); |
| 340 |
|
} |
| 341 |
|
move(3, 54); |
| 342 |
|
printw("%5d", stats.process_count->sleeping); |
| 379 |
|
float f = 100.00 * (float)(stats.mem_stats->used)/stats.mem_stats->total; |
| 380 |
|
if (colors && f > THRESHOLD_ALERT_MEM) { |
| 381 |
|
attron(A_STANDOUT); |
| 382 |
+ |
attron(A_BOLD); |
| 383 |
|
} |
| 384 |
|
else if (colors && f > THRESHOLD_WARN_MEM) { |
| 385 |
|
attron(A_BOLD); |
| 396 |
|
float f = 100.00 * (float)(stats.swap_stats->used)/stats.swap_stats->total; |
| 397 |
|
if (colors && f > THRESHOLD_ALERT_SWAP) { |
| 398 |
|
attron(A_STANDOUT); |
| 399 |
+ |
attron(A_BOLD); |
| 400 |
|
} |
| 401 |
|
else if (colors && f > THRESHOLD_WARN_SWAP) { |
| 402 |
|
attron(A_BOLD); |
| 515 |
|
move(line, 73); |
| 516 |
|
if(colors && 100.00 * ((float) disk_stat_ptr->used / (float) (disk_stat_ptr->used + disk_stat_ptr->avail)) > THRESHOLD_ALERT_DISK) { |
| 517 |
|
attron(A_STANDOUT); |
| 518 |
+ |
attron(A_BOLD); |
| 519 |
|
} else if (colors && 100.00 * ((float) disk_stat_ptr->used / (float) (disk_stat_ptr->used + disk_stat_ptr->avail)) > THRESHOLD_WARN_DISK) { |
| 520 |
|
attron(A_BOLD); |
| 521 |
|
} |
| 563 |
|
} |
| 564 |
|
|
| 565 |
|
void usage(char *progname){ |
| 566 |
+ |
#ifdef COLOR_SUPPORT |
| 567 |
|
fprintf(stderr, "Usage: %s [-d delay] [-c] [-v] [-h]\n\n", progname); |
| 568 |
+ |
#else |
| 569 |
+ |
fprintf(stderr, "Usage: %s [-d delay] [-v] [-h]\n\n", progname); |
| 570 |
+ |
#endif |
| 571 |
|
fprintf(stderr, " -d Sets the update time in seconds\n"); |
| 572 |
+ |
#ifdef COLOR_SUPPORT |
| 573 |
|
fprintf(stderr, " -c Enables coloured output\n"); |
| 574 |
+ |
#endif |
| 575 |
|
fprintf(stderr, " -v Prints version number\n"); |
| 576 |
|
fprintf(stderr, " -h Displays this help information.\n"); |
| 577 |
|
fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); |
| 597 |
|
return 1; |
| 598 |
|
} |
| 599 |
|
|
| 600 |
+ |
#ifdef COLOR_SUPPORT |
| 601 |
|
while ((c = getopt(argc, argv, "d:cvh")) != -1){ |
| 602 |
+ |
#else |
| 603 |
+ |
while ((c = getopt(argc, argv, "d:vh")) != -1){ |
| 604 |
+ |
#endif |
| 605 |
|
switch (c){ |
| 606 |
|
case 'd': |
| 607 |
|
delay = atoi(optarg); |
| 610 |
|
exit(1); |
| 611 |
|
} |
| 612 |
|
break; |
| 613 |
+ |
#ifdef COLOR_SUPPORT |
| 614 |
|
case 'c': |
| 615 |
|
colouron = 1; |
| 616 |
|
break; |
| 617 |
+ |
#endif |
| 618 |
|
case 'v': |
| 619 |
|
version_num(argv[0]); |
| 620 |
|
break; |
| 628 |
|
|
| 629 |
|
signal(SIGWINCH, sig_winch_handler); |
| 630 |
|
initscr(); |
| 631 |
+ |
#ifdef COLOR_SUPPORT |
| 632 |
|
/* turn on colour */ |
| 633 |
|
if (colouron) { |
| 634 |
|
if (has_colors()) { |
| 645 |
|
colouron = 0; |
| 646 |
|
} |
| 647 |
|
} |
| 648 |
+ |
#endif |
| 649 |
|
nonl(); |
| 650 |
|
cbreak(); |
| 651 |
|
noecho(); |