ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/saidar/saidar.c
(Generate patch)

Comparing projects/libstatgrab/src/saidar/saidar.c (file contents):
Revision 1.36 by tdb, Thu Nov 30 23:42:43 2006 UTC vs.
Revision 1.41 by tdb, Fri Jan 5 13:30:36 2007 UTC

# Line 39 | Line 39
39   #include <math.h>
40  
41   #ifdef HAVE_NCURSES_H
42 < #include <ncurses.h>
43 < #else
44 < #include <curses.h>
42 > #define COLOR_SUPPORT
43   #endif
44 + #include CURSES_HEADER_FILE
45  
46   #define THRESHOLD_LOAD 1.0
47  
# Line 60 | Line 59
59   #define THRESHOLD_WARN_DISK 75.0
60   #define THRESHOLD_ALERT_DISK 90.0
61  
62 + int sig_winch_flag = 0;
63 +
64   typedef struct{
65          sg_cpu_percents *cpu_percents;
66          sg_mem_stats *mem_stats;
# Line 310 | Line 311 | void display_data(int colors){
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);
# Line 329 | Line 331 | void display_data(int colors){
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);
# Line 376 | Line 379 | void display_data(int colors){
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);
# Line 392 | Line 396 | void display_data(int colors){
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);
# Line 510 | Line 515 | void display_data(int colors){
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                          }
# Line 528 | Line 534 | void display_data(int colors){
534   }
535  
536   void sig_winch_handler(int dummy){
537 <        clear();
532 <        display_headings();
533 <        display_data(0);
537 >        sig_winch_flag = 1;
538          signal(SIGWINCH, sig_winch_handler);
539   }
540  
# Line 557 | Line 561 | void version_num(char *progname){
561   }
562  
563   void usage(char *progname){
564 + #ifdef COLOR_SUPPORT
565          fprintf(stderr, "Usage: %s [-d delay] [-c] [-v] [-h]\n\n", progname);
566 + #else
567 +        fprintf(stderr, "Usage: %s [-d delay] [-v] [-h]\n\n", progname);
568 + #endif
569          fprintf(stderr, "  -d    Sets the update time in seconds\n");
570 + #ifdef COLOR_SUPPORT
571          fprintf(stderr, "  -c    Enables coloured output\n");
572 + #endif
573          fprintf(stderr, "  -v    Prints version number\n");
574          fprintf(stderr, "  -h    Displays this help information.\n");
575          fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT);
# Line 585 | Line 595 | int main(int argc, char **argv){
595                  return 1;
596          }
597  
598 + #ifdef COLOR_SUPPORT
599          while ((c = getopt(argc, argv, "d:cvh")) != -1){
600 + #else
601 +        while ((c = getopt(argc, argv, "d:vh")) != -1){
602 + #endif
603                  switch (c){
604                          case 'd':
605                                  delay = atoi(optarg);
# Line 594 | Line 608 | int main(int argc, char **argv){
608                                          exit(1);
609                                  }
610                                  break;
611 + #ifdef COLOR_SUPPORT
612                          case 'c':
613                                  colouron = 1;
614                                  break;
615 + #endif
616                          case 'v':
617                                  version_num(argv[0]);
618                                  break;
# Line 610 | Line 626 | int main(int argc, char **argv){
626  
627          signal(SIGWINCH, sig_winch_handler);
628          initscr();
629 + #ifdef COLOR_SUPPORT
630          /* turn on colour */
631          if (colouron) {
632                  if (has_colors()) {
# Line 626 | Line 643 | int main(int argc, char **argv){
643                          colouron = 0;
644                  }
645          }
646 + #endif
647          nonl();
648 +        curs_set(0);
649          cbreak();
650          noecho();
651          timeout(delay * 1000);
# Line 657 | Line 676 | int main(int argc, char **argv){
676                          get_stats();
677                  }
678                  last_update = now;
679 +
680 +                if(sig_winch_flag) {
681 +                        clear();
682 +                        display_headings();
683 +                        sig_winch_flag = 0;
684 +                }
685  
686                  display_data(colouron);
687          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines