| 29 | 
   | 
 #include <unistd.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | 
   | 
 #include <stdlib.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
 #include <ukcprog.h> | 
 
 
 
 
 
 
 
 
 | 32 | 
 + | 
 #include <netinet/in.h> | 
 
 
 
 
 
 
 
 
 | 33 | 
 + | 
 #include <netdb.h> | 
 
 
 
 
 
 
 
 
 | 34 | 
 + | 
 #include <sys/termios.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | 
   | 
 #include <libxml/xmlmemory.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 | 
   | 
 #include <libxml/parser.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 238 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 239 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 240 | 
   | 
 */ | 
 
 
 
 
 
 
 
 
 | 241 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 242 | 
 + | 
 #ifndef HAVE_ATOLL | 
 
 
 
 
 
 
 
 
 | 243 | 
 + | 
 long long int atoll (const char *nptr){ | 
 
 
 
 
 
 
 
 
 | 244 | 
 + | 
   return strtoll (nptr, (char **) NULL, 10); | 
 
 
 
 
 
 
 
 
 | 245 | 
 + | 
 } | 
 
 
 
 
 
 
 
 
 | 246 | 
 + | 
 #endif | 
 
 
 
 
 
 
 
 
 | 247 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 248 | 
 + | 
 #ifndef HAVE_STRLCPY | 
 
 
 
 
 
 
 
 
 | 249 | 
 + | 
 /* | 
 
 
 
 
 
 
 
 
 | 250 | 
 + | 
  * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 
 
 
 
 
 
 
 
 
 | 251 | 
 + | 
  * All rights reserved. | 
 
 
 
 
 
 
 
 
 | 252 | 
 + | 
  * | 
 
 
 
 
 
 
 
 
 | 253 | 
 + | 
  * Redistribution and use in source and binary forms, with or without | 
 
 
 
 
 
 
 
 
 | 254 | 
 + | 
  * modification, are permitted provided that the following conditions | 
 
 
 
 
 
 
 
 
 | 255 | 
 + | 
  * are met: | 
 
 
 
 
 
 
 
 
 | 256 | 
 + | 
  * 1. Redistributions of source code must retain the above copyright | 
 
 
 
 
 
 
 
 
 | 257 | 
 + | 
  *    notice, this list of conditions and the following disclaimer. | 
 
 
 
 
 
 
 
 
 | 258 | 
 + | 
  * 2. Redistributions in binary form must reproduce the above copyright | 
 
 
 
 
 
 
 
 
 | 259 | 
 + | 
  *    notice, this list of conditions and the following disclaimer in the | 
 
 
 
 
 
 
 
 
 | 260 | 
 + | 
  *    documentation and/or other materials provided with the distribution. | 
 
 
 
 
 
 
 
 
 | 261 | 
 + | 
  * 3. The name of the author may not be used to endorse or promote products | 
 
 
 
 
 
 
 
 
 | 262 | 
 + | 
  *    derived from this software without specific prior written permission. | 
 
 
 
 
 
 
 
 
 | 263 | 
 + | 
  * | 
 
 
 
 
 
 
 
 
 | 264 | 
 + | 
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | 
 
 
 
 
 
 
 
 
 | 265 | 
 + | 
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | 
 
 
 
 
 
 
 
 
 | 266 | 
 + | 
  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL | 
 
 
 
 
 
 
 
 
 | 267 | 
 + | 
  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
 
 
 
 
 
 
 
 
 | 268 | 
 + | 
  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 
 
 
 
 
 
 
 
 
 | 269 | 
 + | 
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 
 
 
 
 
 
 
 
 
 | 270 | 
 + | 
  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 
 
 
 
 
 
 
 
 
 | 271 | 
 + | 
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 
 
 
 
 
 
 
 
 
 | 272 | 
 + | 
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 
 
 
 
 
 
 
 
 
 | 273 | 
 + | 
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
 
 
 
 
 
 
 
 
 | 274 | 
 + | 
  */ | 
 
 
 
 
 
 
 
 
 | 275 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 276 | 
 + | 
 /* | 
 
 
 
 
 
 
 
 
 | 277 | 
 + | 
  * Copy src to string dst of size siz.  At most siz-1 characters | 
 
 
 
 
 
 
 
 
 | 278 | 
 + | 
  * will be copied.  Always NUL terminates (unless siz == 0). | 
 
 
 
 
 
 
 
 
 | 279 | 
 + | 
  * Returns strlen(src); if retval >= siz, truncation occurred. | 
 
 
 
 
 
 
 
 
 | 280 | 
 + | 
  */ | 
 
 
 
 
 
 
 
 
 | 281 | 
 + | 
 size_t | 
 
 
 
 
 
 
 
 
 | 282 | 
 + | 
 strlcpy(dst, src, siz) | 
 
 
 
 
 
 
 
 
 | 283 | 
 + | 
         char *dst; | 
 
 
 
 
 
 
 
 
 | 284 | 
 + | 
         const char *src; | 
 
 
 
 
 
 
 
 
 | 285 | 
 + | 
         size_t siz; | 
 
 
 
 
 
 
 
 
 | 286 | 
 + | 
 { | 
 
 
 
 
 
 
 
 
 | 287 | 
 + | 
         register char *d = dst; | 
 
 
 
 
 
 
 
 
 | 288 | 
 + | 
         register const char *s = src; | 
 
 
 
 
 
 
 
 
 | 289 | 
 + | 
         register size_t n = siz; | 
 
 
 
 
 
 
 
 
 | 290 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 291 | 
 + | 
         /* Copy as many bytes as will fit */ | 
 
 
 
 
 
 
 
 
 | 292 | 
 + | 
         if (n != 0 && --n != 0) { | 
 
 
 
 
 
 
 
 
 | 293 | 
 + | 
                 do { | 
 
 
 
 
 
 
 
 
 | 294 | 
 + | 
                         if ((*d++ = *s++) == 0) | 
 
 
 
 
 
 
 
 
 | 295 | 
 + | 
                                 break; | 
 
 
 
 
 
 
 
 
 | 296 | 
 + | 
                 } while (--n != 0); | 
 
 
 
 
 
 
 
 
 | 297 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 | 298 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 299 | 
 + | 
         /* Not enough room in dst, add NUL and traverse rest of src */ | 
 
 
 
 
 
 
 
 
 | 300 | 
 + | 
         if (n == 0) { | 
 
 
 
 
 
 
 
 
 | 301 | 
 + | 
                 if (siz != 0) | 
 
 
 
 
 
 
 
 
 | 302 | 
 + | 
                         *d = '\0';              /* NUL-terminate dst */ | 
 
 
 
 
 
 
 
 
 | 303 | 
 + | 
                 while (*s++) | 
 
 
 
 
 
 
 
 
 | 304 | 
 + | 
                         ; | 
 
 
 
 
 
 
 
 
 | 305 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 | 306 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 307 | 
 + | 
         return(s - src - 1);    /* count does not include NUL */ | 
 
 
 
 
 
 
 
 
 | 308 | 
 + | 
 } | 
 
 
 
 
 
 
 
 
 | 309 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 310 | 
 + | 
 #endif | 
 
 
 
 
 
 
 
 
 | 311 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 312 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 313 | 
   | 
 FILE *create_tcp_connection(char *hostname, int port){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 314 | 
   | 
         int sock; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 682 | 
   | 
         int x=1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 683 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 684 | 
   | 
         if(*title){ | 
 
 
 
 
 
 
 
 
 | 685 | 
 + | 
                 clear(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 686 | 
   | 
                 move (num_lines-3, 1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 687 | 
   | 
                 printw("Sorting by %-64s", display_config->sortby); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 688 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 792 | 
   | 
         WINDOW *window; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 793 | 
   | 
         fd_set infds; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 794 | 
   | 
         int maxx, maxy; | 
 
 
 
 
 
 
 
 
 | 795 | 
 + | 
         struct winsize size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 796 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 797 | 
   | 
         FILE *control; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 798 | 
   | 
         FILE *data; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 854 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 855 | 
   | 
         display_config.network_io_total_tx=1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 856 | 
   | 
         display_config.network_io_total_rx=1; | 
 
 
 
 
 
 
 
 
 
 
 
 | 857 | 
 < | 
         display_config.network_all_stats=1; | 
 
 
 
 
 
 
 
 
 
 | 857 | 
 > | 
         display_config.network_all_stats=0; | 
 
 
 
 
 
 
 
 
 
 
 
 | 858 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 859 | 
 < | 
         display_config.disk_io_total_write=0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 860 | 
 < | 
         display_config.disk_io_total_read=0; | 
 
 
 
 
 
 
 
 
 
 | 859 | 
 > | 
         display_config.disk_io_total_write=1; | 
 
 
 
 
 
 | 860 | 
 > | 
         display_config.disk_io_total_read=1; | 
 
 
 
 
 
 
 
 
 
 
 
 | 861 | 
   | 
         display_config.disk_io_all_stats=0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 862 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 863 | 
   | 
         display_config.disk_total_used=0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 909 | 
   | 
         control=create_tcp_connection(servername, server_control_port); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 910 | 
   | 
         if(control==NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 911 | 
   | 
                 errf("Failed to connect (%m)"); | 
 
 
 
 
 
 
 
 
 | 912 | 
 + | 
                 exit(1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 913 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 914 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 915 | 
   | 
         if(argc==4){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 953 | 
   | 
         data=create_tcp_connection(servername, server_data_port); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 954 | 
   | 
         if(data==NULL){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 955 | 
   | 
                 errf("Failed to connect to host %s on port %d (%m)",servername, server_data_port); | 
 
 
 
 
 
 
 
 
 | 956 | 
 + | 
                 exit(1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 957 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 958 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 959 | 
   | 
         /*       | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 977 | 
   | 
                 FD_ZERO(&infds); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 978 | 
   | 
                 FD_SET(stdin_fileno, &infds); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 979 | 
   | 
                 FD_SET(data_fileno, &infds); | 
 
 
 
 
 
 
 
 
 
 
 
 | 980 | 
 < | 
                 select(biggest_fileno, &infds, NULL, NULL, NULL); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 980 | 
 > | 
                 if((select(biggest_fileno, &infds, NULL, NULL, NULL))==-1){ | 
 
 
 
 
 
 | 981 | 
 > | 
                         if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) { | 
 
 
 
 
 
 | 982 | 
 > | 
                                 resizeterm(size.ws_row, size.ws_col); | 
 
 
 
 
 
 | 983 | 
 > | 
                                 wrefresh(curscr); | 
 
 
 
 
 
 | 984 | 
 > | 
                         } | 
 
 
 
 
 
 | 985 | 
 > | 
                         getmaxyx(window, maxy, maxx); | 
 
 
 
 
 
 | 986 | 
 > | 
                         title=1; | 
 
 
 
 
 
 | 987 | 
 > | 
                         display(machine_data_list, &display_config, maxy, &title); | 
 
 
 
 
 
 | 988 | 
 > | 
                         refresh(); | 
 
 
 
 
 
 | 989 | 
 > | 
                         continue; | 
 
 
 
 
 
 | 990 | 
 > | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 | 991 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 992 | 
   | 
                 if(FD_ISSET(stdin_fileno, &infds)){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 993 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 994 | 
   | 
                         ch=getc(stdin); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 995 | 
   | 
                         switch(ch){ | 
 
 
 
 
 
 
 
 
 | 996 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 997 | 
 + | 
                                 /* Quit */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 998 | 
   | 
                                 case 'Q': | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 999 | 
   | 
                                 case 'q': | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1000 | 
   | 
                                         endwin(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1001 | 
   | 
                                         exit(0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1002 | 
   | 
                                         break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1003 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 1004 | 
 + | 
                                 /* Sort by */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1005 | 
   | 
                                 case 'C': | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1006 | 
   | 
                                         sortby_ptr=cmp_cpu_used; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1007 | 
   | 
                                         strlcpy(display_config.sortby, CPU_USED, SORTBYMAXNAME); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1034 | 
   | 
                                                 sortby_ptr=cmp_network_io_total; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1035 | 
   | 
                                         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1036 | 
   | 
                                         break; | 
 
 
 
 
 
 
 
 
 | 1037 | 
 + | 
                                 case 'D': | 
 
 
 
 
 
 
 
 
 | 1038 | 
 + | 
                                         if(sortby_ptr==cmp_disk_io_total){ | 
 
 
 
 
 
 
 
 
 | 1039 | 
 + | 
                                                 strlcpy(display_config.sortby, DISKIOR, SORTBYMAXNAME); | 
 
 
 
 
 
 
 
 
 | 1040 | 
 + | 
                                                 sortby_ptr=cmp_disk_io_total_read; | 
 
 
 
 
 
 
 
 
 | 1041 | 
 + | 
                                         }else if(sortby_ptr==cmp_disk_io_total_read){ | 
 
 
 
 
 
 
 
 
 | 1042 | 
 + | 
                                                 strlcpy(display_config.sortby, DISKIOW, SORTBYMAXNAME); | 
 
 
 
 
 
 
 
 
 | 1043 | 
 + | 
                                                 sortby_ptr=cmp_disk_io_total_write; | 
 
 
 
 
 
 
 
 
 | 1044 | 
 + | 
                                         }else{ | 
 
 
 
 
 
 
 
 
 | 1045 | 
 + | 
                                                 strlcpy(display_config.sortby, DISKIO, SORTBYMAXNAME); | 
 
 
 
 
 
 
 
 
 | 1046 | 
 + | 
                                                 sortby_ptr=cmp_disk_io_total; | 
 
 
 
 
 
 
 
 
 | 1047 | 
 + | 
                                         } | 
 
 
 
 
 
 
 
 
 | 1048 | 
 + | 
                                         break; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1049 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 1050 | 
 < | 
                         } | 
 
 
 
 
 
 
 
 
 
 | 1050 | 
 > | 
                                 /* Display */ | 
 
 
 
 
 
 
 
 
 
 
 
 | 1051 | 
   | 
                          | 
 
 
 
 
 
 
 
 
 
 
 
 | 1052 | 
 < | 
                         title=1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1052 | 
 > | 
                                 case 'd': | 
 
 
 
 
 
 | 1053 | 
 > | 
                                         if(display_config.disk_io_total_read){ | 
 
 
 
 
 
 | 1054 | 
 > | 
                                                 display_config.disk_io_total_read=0; | 
 
 
 
 
 
 | 1055 | 
 > | 
                                                 display_config.disk_io_total_write=0; | 
 
 
 
 
 
 | 1056 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1057 | 
 > | 
                                                 display_config.disk_io_total_read=1; | 
 
 
 
 
 
 | 1058 | 
 > | 
                                                 display_config.disk_io_total_write=1; | 
 
 
 
 
 
 | 1059 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1060 | 
 > | 
                                         break;   | 
 
 
 
 
 
 | 1061 | 
 > | 
                                 case 'n': | 
 
 
 
 
 
 | 1062 | 
 > | 
                                         if(display_config.network_io_total_rx){ | 
 
 
 
 
 
 | 1063 | 
 > | 
                                                 display_config.network_io_total_rx=0; | 
 
 
 
 
 
 | 1064 | 
 > | 
                                                 display_config.network_io_total_tx=0; | 
 
 
 
 
 
 | 1065 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1066 | 
 > | 
                                                 display_config.network_io_total_rx=1; | 
 
 
 
 
 
 | 1067 | 
 > | 
                                                 display_config.network_io_total_tx=1; | 
 
 
 
 
 
 | 1068 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1069 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1070 | 
 > | 
                                 case 'm': | 
 
 
 
 
 
 | 1071 | 
 > | 
                                         if(display_config.memory_used_pecent){ | 
 
 
 
 
 
 | 1072 | 
 > | 
                                                 display_config.memory_used_pecent=0; | 
 
 
 
 
 
 | 1073 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1074 | 
 > | 
                                                 display_config.memory_used_pecent=1; | 
 
 
 
 
 
 | 1075 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1076 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1077 | 
 > | 
                                  | 
 
 
 
 
 
 | 1078 | 
 > | 
                                 case 's': | 
 
 
 
 
 
 | 1079 | 
 > | 
                                         if(display_config.swap_used_pecent){ | 
 
 
 
 
 
 | 1080 | 
 > | 
                                                 display_config.swap_used_pecent=0; | 
 
 
 
 
 
 | 1081 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1082 | 
 > | 
                                                 display_config.swap_used_pecent=1; | 
 
 
 
 
 
 | 1083 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1084 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1085 | 
 > | 
                                 case 'l': | 
 
 
 
 
 
 | 1086 | 
 > | 
                                         if(display_config.load_1){ | 
 
 
 
 
 
 | 1087 | 
 > | 
                                                 display_config.load_1=0; | 
 
 
 
 
 
 | 1088 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1089 | 
 > | 
                                                 display_config.load_1=1; | 
 
 
 
 
 
 | 1090 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1091 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1092 | 
 > | 
                                 case 'p': | 
 
 
 
 
 
 | 1093 | 
 > | 
                                         if(display_config.pages_in){ | 
 
 
 
 
 
 | 1094 | 
 > | 
                                                 display_config.pages_in=0; | 
 
 
 
 
 
 | 1095 | 
 > | 
                                                 display_config.pages_out=0; | 
 
 
 
 
 
 | 1096 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1097 | 
 > | 
                                                 display_config.pages_in=1; | 
 
 
 
 
 
 | 1098 | 
 > | 
                                                 display_config.pages_out=1; | 
 
 
 
 
 
 | 1099 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1100 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1101 | 
 > | 
                                 case 'c': | 
 
 
 
 
 
 | 1102 | 
 > | 
                                         if(display_config.cpu_used){ | 
 
 
 
 
 
 | 1103 | 
 > | 
                                                 display_config.cpu_used=0; | 
 
 
 
 
 
 | 1104 | 
 > | 
                                         }else{ | 
 
 
 
 
 
 | 1105 | 
 > | 
                                                 display_config.cpu_used=1; | 
 
 
 
 
 
 | 1106 | 
 > | 
                                         } | 
 
 
 
 
 
 | 1107 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1108 | 
 > | 
  | 
 
 
 
 
 
 | 1109 | 
 > | 
                                 default: | 
 
 
 
 
 
 | 1110 | 
 > | 
                                         /* Invalid key.. Ignore.. Set Title to -1, as the | 
 
 
 
 
 
 | 1111 | 
 > | 
                                          * title++ will then make that "0" (false) so a  | 
 
 
 
 
 
 | 1112 | 
 > | 
                                          * screen redraw will not happen */ | 
 
 
 
 
 
 | 1113 | 
 > | 
                                         title=-1; | 
 
 
 
 
 
 | 1114 | 
 > | 
                                         break; | 
 
 
 
 
 
 | 1115 | 
 > | 
                         } | 
 
 
 
 
 
 | 1116 | 
 > | 
  | 
 
 
 
 
 
 | 1117 | 
 > | 
                         /* Increment title so it becomes true (and making the screen update */   | 
 
 
 
 
 
 | 1118 | 
 > | 
                         title++; | 
 
 
 
 
 
 
 
 
 
 
 
 | 1119 | 
   | 
                          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1120 | 
   | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1121 | 
   | 
                 if(FD_ISSET(data_fileno, &infds)){ |