| 1 |
+ |
/* |
| 2 |
+ |
* i-scream central monitoring system |
| 3 |
+ |
* http://www.i-scream.org.uk |
| 4 |
+ |
* Copyright (C) 2000-2002 i-scream |
| 5 |
+ |
* |
| 6 |
+ |
* This program is free software; you can redistribute it and/or |
| 7 |
+ |
* modify it under the terms of the GNU General Public License |
| 8 |
+ |
* as published by the Free Software Foundation; either version 2 |
| 9 |
+ |
* of the License, or (at your option) any later version. |
| 10 |
+ |
* |
| 11 |
+ |
* This program is distributed in the hope that it will be useful, |
| 12 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
+ |
* GNU General Public License for more details. |
| 15 |
+ |
* |
| 16 |
+ |
* You should have received a copy of the GNU General Public License |
| 17 |
+ |
* along with this program; if not, write to the Free Software |
| 18 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
+ |
*/ |
| 20 |
+ |
|
| 21 |
+ |
#ifdef HAVE_CONFIG_H |
| 22 |
+ |
#include "config.h" |
| 23 |
+ |
#endif |
| 24 |
+ |
|
| 25 |
|
#include <stdio.h> |
| 26 |
|
#include <string.h> |
| 27 |
|
#include <sys/types.h> |
| 34 |
|
#include <libxml/parser.h> |
| 35 |
|
#include "genmergesort.h" |
| 36 |
|
|
| 37 |
+ |
#ifdef HAVE_NCURSES_H |
| 38 |
+ |
#include <ncurses.h> |
| 39 |
+ |
#else |
| 40 |
+ |
#include <curses.h> |
| 41 |
+ |
#endif |
| 42 |
+ |
|
| 43 |
|
struct host_line_t{ |
| 44 |
|
char *hostname; |
| 45 |
|
int line; |
| 122 |
|
network_data_list_t *network_data_list; |
| 123 |
|
long long network_io_total_tx; |
| 124 |
|
long long network_io_total_rx; |
| 125 |
+ |
long long network_io_total; |
| 126 |
|
|
| 127 |
|
diskio_data_list_t *diskio_data_list; |
| 128 |
|
long long disk_io_total_write; |
| 129 |
|
long long disk_io_total_read; |
| 130 |
+ |
long long disk_io_total; |
| 131 |
|
|
| 132 |
|
/* Maybe in the future */ |
| 133 |
|
/* |
| 140 |
|
|
| 141 |
|
typedef struct machine_data_t machine_data_list_t; |
| 142 |
|
|
| 143 |
+ |
#define SORTBYMAXNAME 128 |
| 144 |
|
typedef struct{ |
| 145 |
|
int cpu_user; |
| 146 |
|
int cpu_idle; |
| 182 |
|
|
| 183 |
|
int disk_total_used; |
| 184 |
|
int disk_all_stats; |
| 185 |
+ |
|
| 186 |
+ |
char sortby[SORTBYMAXNAME]; |
| 187 |
|
}display_config_t; |
| 188 |
|
|
| 189 |
|
GENERIC_MERGE_SORT(static, sort_machine_stats, machine_data_list_t, next) |
| 195 |
|
|
| 196 |
|
MKCMP(cpu_used) |
| 197 |
|
MKCMP(load_1) |
| 198 |
+ |
MKCMP(network_io_total) |
| 199 |
|
MKCMP(network_io_total_tx) |
| 200 |
|
MKCMP(network_io_total_rx) |
| 201 |
+ |
MKCMP(disk_io_total) |
| 202 |
|
MKCMP(disk_io_total_write) |
| 203 |
|
MKCMP(disk_io_total_read) |
| 204 |
|
MKCMP(memory_used_pecent) |
| 205 |
|
MKCMP(swap_used_pecent) |
| 206 |
|
|
| 207 |
+ |
#define CPU_USED "CPU used" |
| 208 |
+ |
#define LOAD "Load (1)" |
| 209 |
+ |
#define NETIORX "total Network RX for all interfaces" |
| 210 |
+ |
#define NETIOTX "total Network TX for all interfaces" |
| 211 |
+ |
#define NETIO "total Network IO for all interfaces (rx+tx)" |
| 212 |
+ |
#define MEM "Memory usage" |
| 213 |
+ |
#define SWAP "Swap usage" |
| 214 |
+ |
#define DISKIOR "DiskIO reads" |
| 215 |
+ |
#define DISKIOW "DiskIO writes" |
| 216 |
+ |
#define DISKIO "Total DiskIO (reads+writes)" |
| 217 |
+ |
|
| 218 |
+ |
|
| 219 |
|
/* |
| 220 |
|
int cmp_cpu(machine_data_list_t *a, machine_data_list_t *b){ |
| 221 |
|
|
| 583 |
|
machine_data_list->network_io_total_rx+=ndl_ptr->rx; |
| 584 |
|
ndl_ptr=ndl_ptr->next; |
| 585 |
|
} |
| 586 |
+ |
machine_data_list->network_io_total=machine_data_list->network_io_total_rx+machine_data_list->network_io_total_tx; |
| 587 |
|
|
| 588 |
|
didl_ptr=machine_data_list->diskio_data_list; |
| 589 |
|
machine_data_list->disk_io_total_read=0; |
| 593 |
|
machine_data_list->disk_io_total_write+=didl_ptr->write; |
| 594 |
|
didl_ptr=didl_ptr->next; |
| 595 |
|
} |
| 596 |
+ |
machine_data_list->disk_io_total=machine_data_list->disk_io_total_read+machine_data_list->disk_io_total_write; |
| 597 |
|
|
| 598 |
|
xmlFreeDoc(doc); |
| 599 |
|
|
| 604 |
|
|
| 605 |
|
void display(machine_data_list_t *machine_data_list, display_config_t *display_config, int num_lines, int *title){ |
| 606 |
|
int line_num=4; |
| 607 |
+ |
int counter; |
| 608 |
|
int x=1; |
| 609 |
|
|
| 610 |
|
if(*title){ |
| 611 |
< |
printf("\033[2J"); |
| 612 |
< |
// printf("\033[1;1HHostname CPU Load Page Page Mem Swap Net Net Disk Disk"); |
| 613 |
< |
// printf("\033[2;1H used%% (1m) ins outs used used rx tx read write"); |
| 614 |
< |
printf("\033[1;1H%-11s", "Hostname"); |
| 611 |
> |
clear(); |
| 612 |
> |
move (num_lines-3, 1); |
| 613 |
> |
printw("Sorting by %-64s", display_config->sortby); |
| 614 |
> |
|
| 615 |
> |
move(1,1); |
| 616 |
> |
printw("%-11s", "Hostname"); |
| 617 |
|
x=x+11+1; |
| 618 |
|
if(display_config->cpu_used){ |
| 619 |
< |
printf("\033[1;%dH%5s", x, "CPU"); |
| 620 |
< |
printf("\033[2;%dH%5s", x, "used%"); |
| 619 |
> |
move(1,x); |
| 620 |
> |
printw("%5s", "CPU"); |
| 621 |
> |
move(2,x); |
| 622 |
> |
printw("%5s", "used%"); |
| 623 |
|
x+=6; |
| 624 |
|
} |
| 625 |
|
if(display_config->load_1){ |
| 626 |
< |
printf("\033[1;%dH%5s", x, "Load"); |
| 627 |
< |
printf("\033[2;%dH%5s", x, "(1m)"); |
| 626 |
> |
move(1,x); |
| 627 |
> |
printw("%5s", "Load"); |
| 628 |
> |
move(2,x); |
| 629 |
> |
printw("%5s", "(1m)"); |
| 630 |
|
x+=6; |
| 631 |
|
} |
| 632 |
|
if(display_config->pages_in){ |
| 633 |
< |
printf("\033[1;%dH%5s", x, "Page"); |
| 634 |
< |
printf("\033[2;%dH%5s", x, "ins"); |
| 633 |
> |
move(1,x); |
| 634 |
> |
printw("%5s", "Page"); |
| 635 |
> |
move(2,x); |
| 636 |
> |
printw("%5s", "ins"); |
| 637 |
|
x+=6; |
| 638 |
|
} |
| 639 |
|
if(display_config->pages_out){ |
| 640 |
< |
printf("\033[1;%dH%5s", x, "Page"); |
| 641 |
< |
printf("\033[2;%dH%5s", x, "outs"); |
| 640 |
> |
move(1,x); |
| 641 |
> |
printw("%5s", "Page"); |
| 642 |
> |
move(2,x); |
| 643 |
> |
printw("%5s", "outs"); |
| 644 |
|
x+=6; |
| 645 |
|
} |
| 646 |
|
if(display_config->memory_used_pecent){ |
| 647 |
< |
printf("\033[1;%dH%5s", x, "Mem"); |
| 648 |
< |
printf("\033[2;%dH%5s", x, "used"); |
| 647 |
> |
move(1,x); |
| 648 |
> |
printw("%5s", "Mem"); |
| 649 |
> |
move(2,x); |
| 650 |
> |
printw("%5s", "used"); |
| 651 |
|
x+=6; |
| 652 |
|
} |
| 653 |
|
if(display_config->swap_used_pecent){ |
| 654 |
< |
printf("\033[1;%dH%5s", x, "Swap"); |
| 655 |
< |
printf("\033[2;%dH%5s", x, "used"); |
| 654 |
> |
move(1,x); |
| 655 |
> |
printw("%5s", "Swap"); |
| 656 |
> |
move(2,x); |
| 657 |
> |
printw("%5s", "used"); |
| 658 |
|
x+=6; |
| 659 |
|
} |
| 660 |
|
if(display_config->network_io_total_rx){ |
| 661 |
< |
printf("\033[1;%dH%8s", x, "Net"); |
| 662 |
< |
printf("\033[2;%dH%8s", x, "rx"); |
| 661 |
> |
move(1,x); |
| 662 |
> |
printw("%8s", "Net"); |
| 663 |
> |
move(2,x); |
| 664 |
> |
printw("%8s", "rx"); |
| 665 |
|
x+=9; |
| 666 |
|
} |
| 667 |
|
if(display_config->network_io_total_tx){ |
| 668 |
< |
printf("\033[1;%dH%8s", x, "Net"); |
| 669 |
< |
printf("\033[2;%dH%8s", x, "tx"); |
| 668 |
> |
move(1,x); |
| 669 |
> |
printw("%8s", "Net"); |
| 670 |
> |
move(2,x); |
| 671 |
> |
printw("%8s", "tx"); |
| 672 |
|
x+=9; |
| 673 |
|
} |
| 674 |
|
if(display_config->disk_io_total_read){ |
| 675 |
< |
printf("\033[1;%dH%9s", x, "Disk"); |
| 676 |
< |
printf("\033[2;%dH%9s", x, "read"); |
| 675 |
> |
move(1,x); |
| 676 |
> |
printw("%9s", "Disk"); |
| 677 |
> |
move(2,x); |
| 678 |
> |
printw("%9s", "read"); |
| 679 |
|
x+=10; |
| 680 |
|
} |
| 681 |
|
if(display_config->disk_io_total_read){ |
| 682 |
< |
printf("\033[1;%dH%9s", x, "Disk"); |
| 683 |
< |
printf("\033[2;%dH%9s", x, "write"); |
| 682 |
> |
move(1,x); |
| 683 |
> |
printw("%9s", "Disk"); |
| 684 |
> |
move(2,x); |
| 685 |
> |
printw("%9s", "write"); |
| 686 |
|
x+=10; |
| 687 |
|
} |
| 688 |
|
|
| 689 |
|
*title=0; |
| 690 |
|
} |
| 691 |
|
|
| 692 |
< |
for(;num_lines;num_lines--){ |
| 692 |
> |
/* Counter starts at 8, for padding (eg, headers, borders etc) */ |
| 693 |
> |
for(counter=8;counter<num_lines;counter++){ |
| 694 |
|
if(machine_data_list==NULL) break; |
| 695 |
+ |
move(line_num++, 1); |
| 696 |
+ |
printw("%-11s", machine_data_list->sysname); |
| 697 |
|
|
| 698 |
< |
printf("\033[%d;%dH%-11s", line_num++, 1, machine_data_list->sysname); |
| 698 |
> |
if(display_config->cpu_used) printw(" %5.1f", machine_data_list->cpu_used); |
| 699 |
> |
if(display_config->load_1) printw(" %5.1f", machine_data_list->load_1); |
| 700 |
> |
if(display_config->pages_in) printw(" %5d", machine_data_list->pages_in); |
| 701 |
> |
if(display_config->pages_out) printw(" %5d", machine_data_list->pages_out); |
| 702 |
> |
if(display_config->memory_used_pecent) printw(" %5.1f", machine_data_list->memory_used_pecent); |
| 703 |
> |
if(display_config->swap_used_pecent) printw(" %5.1f", machine_data_list->swap_used_pecent); |
| 704 |
> |
if(display_config->network_io_total_rx) printw(" %8lld", machine_data_list->network_io_total_rx); |
| 705 |
> |
if(display_config->network_io_total_tx) printw(" %8lld", machine_data_list->network_io_total_tx); |
| 706 |
> |
if(display_config->disk_io_total_read) printw(" %9lld", machine_data_list->disk_io_total_read); |
| 707 |
> |
if(display_config->disk_io_total_write) printw(" %9lld", machine_data_list->disk_io_total_write); |
| 708 |
|
|
| 623 |
– |
if(display_config->cpu_used) printf(" %5.1f", machine_data_list->cpu_used); |
| 624 |
– |
if(display_config->load_1) printf(" %5.1f", machine_data_list->load_1); |
| 625 |
– |
if(display_config->pages_in) printf(" %5d", machine_data_list->pages_in); |
| 626 |
– |
if(display_config->pages_out) printf(" %5d", machine_data_list->pages_out); |
| 627 |
– |
if(display_config->memory_used_pecent) printf(" %5.1f", machine_data_list->memory_used_pecent); |
| 628 |
– |
if(display_config->swap_used_pecent) printf(" %5.1f", machine_data_list->swap_used_pecent); |
| 629 |
– |
if(display_config->network_io_total_rx) printf(" %8lld", machine_data_list->network_io_total_rx); |
| 630 |
– |
if(display_config->network_io_total_tx) printf(" %8lld", machine_data_list->network_io_total_tx); |
| 631 |
– |
if(display_config->disk_io_total_read) printf(" %9lld", machine_data_list->disk_io_total_read); |
| 632 |
– |
if(display_config->disk_io_total_write) printf(" %9lld", machine_data_list->disk_io_total_write); |
| 633 |
– |
|
| 709 |
|
machine_data_list=machine_data_list->next; |
| 710 |
|
} |
| 711 |
|
|
| 712 |
|
|
| 713 |
< |
fflush(stdout); |
| 713 |
> |
refresh(); |
| 714 |
|
|
| 715 |
|
} |
| 716 |
|
|
| 717 |
|
int main(int argc, char **argv){ |
| 718 |
+ |
WINDOW *window; |
| 719 |
+ |
fd_set infds; |
| 720 |
+ |
int maxx, maxy; |
| 721 |
+ |
|
| 722 |
|
FILE *control; |
| 723 |
|
FILE *data; |
| 724 |
|
|
| 733 |
|
|
| 734 |
|
int num_hosts; |
| 735 |
|
int max_display=0; |
| 736 |
< |
int title; |
| 736 |
> |
int title=1; |
| 737 |
|
|
| 738 |
|
int cmdopt; |
| 739 |
|
extern int optind; |
| 740 |
|
extern char *optarg; |
| 662 |
– |
sortby_ptr=NULL; |
| 741 |
|
|
| 742 |
|
display_config_t display_config; |
| 743 |
+ |
char ch; |
| 744 |
|
|
| 745 |
+ |
int data_fileno, stdin_fileno, biggest_fileno; |
| 746 |
+ |
|
| 747 |
+ |
sortby_ptr=NULL; |
| 748 |
+ |
|
| 749 |
|
/* What to display defaults */ |
| 750 |
|
display_config.cpu_user=0; |
| 751 |
|
display_config.cpu_idle=0; |
| 779 |
|
|
| 780 |
|
display_config.network_io_total_tx=1; |
| 781 |
|
display_config.network_io_total_rx=1; |
| 782 |
< |
display_config.network_all_stats=1; |
| 782 |
> |
display_config.network_all_stats=0; |
| 783 |
|
|
| 784 |
|
display_config.disk_io_total_write=1; |
| 785 |
|
display_config.disk_io_total_read=1; |
| 788 |
|
display_config.disk_total_used=0; |
| 789 |
|
display_config.disk_all_stats=0; |
| 790 |
|
|
| 708 |
– |
|
| 791 |
|
while((cmdopt=getopt(argc, argv, "d:s:")) != -1){ |
| 792 |
|
switch(cmdopt){ |
| 793 |
|
case 'd': |
| 796 |
|
case 's': |
| 797 |
|
if(!strcmp(optarg, "cpu")){ |
| 798 |
|
sortby_ptr=cmp_cpu_used; |
| 799 |
+ |
strlcpy(display_config.sortby, CPU_USED, SORTBYMAXNAME); |
| 800 |
|
} |
| 801 |
|
if(!strcmp(optarg, "load")){ |
| 802 |
|
sortby_ptr=cmp_load_1; |
| 803 |
+ |
strlcpy(display_config.sortby, LOAD, SORTBYMAXNAME); |
| 804 |
|
} |
| 805 |
|
if(!strcmp(optarg, "mem")){ |
| 806 |
|
sortby_ptr=cmp_memory_used_pecent; |
| 807 |
+ |
strlcpy(display_config.sortby, MEM, SORTBYMAXNAME); |
| 808 |
|
} |
| 809 |
+ |
if(!strcmp(optarg, "swap")){ |
| 810 |
+ |
sortby_ptr=cmp_swap_used_pecent; |
| 811 |
+ |
strlcpy(display_config.sortby, SWAP, SORTBYMAXNAME); |
| 812 |
+ |
} |
| 813 |
|
if(sortby_ptr==NULL){ |
| 814 |
|
errf("Invalid sort type"); |
| 815 |
|
exit(1); |
| 818 |
|
} |
| 819 |
|
} |
| 820 |
|
|
| 821 |
< |
if(sortby_ptr==NULL) sortby_ptr=cmp_cpu_used; |
| 821 |
> |
if(sortby_ptr==NULL){ |
| 822 |
> |
sortby_ptr=cmp_cpu_used; |
| 823 |
> |
strlcpy(display_config.sortby, "CPU Used", SORTBYMAXNAME); |
| 824 |
> |
} |
| 825 |
|
|
| 826 |
|
if(argc<(optind+2)){ |
| 827 |
|
printf("Usage is %s <-d lines> hostname port <machine list>\n", argv[0]); |
| 884 |
|
printf("\033[1;1HHostname CPU Load Page Page Mem Swap Net Net Disk Disk"); |
| 885 |
|
printf("\033[2;1H used%% (1m) ins outs used used rx tx read write"); |
| 886 |
|
*/ |
| 887 |
< |
fflush(stdout); |
| 887 |
> |
|
| 888 |
> |
initscr(); |
| 889 |
> |
nonl(); |
| 890 |
> |
cbreak(); |
| 891 |
> |
echo(); |
| 892 |
> |
window=newwin(0, 0, 0, 0); |
| 893 |
> |
getmaxyx(window, maxy, maxx); |
| 894 |
> |
|
| 895 |
> |
stdin_fileno=fileno(stdin); |
| 896 |
> |
data_fileno=fileno(data); |
| 897 |
> |
biggest_fileno=(data_fileno>stdin_fileno) ? (data_fileno+1) : (stdin_fileno+1); |
| 898 |
> |
|
| 899 |
|
for(;;){ |
| 900 |
< |
response=fpgetline(data); |
| 901 |
< |
if (response==NULL){ |
| 902 |
< |
errf("Failed to read data (%m)"); |
| 903 |
< |
exit(1); |
| 900 |
> |
FD_ZERO(&infds); |
| 901 |
> |
FD_SET(stdin_fileno, &infds); |
| 902 |
> |
FD_SET(data_fileno, &infds); |
| 903 |
> |
select(biggest_fileno, &infds, NULL, NULL, NULL); |
| 904 |
> |
|
| 905 |
> |
if(FD_ISSET(stdin_fileno, &infds)){ |
| 906 |
> |
|
| 907 |
> |
ch=getc(stdin); |
| 908 |
> |
switch(ch){ |
| 909 |
> |
|
| 910 |
> |
/* Quit */ |
| 911 |
> |
case 'Q': |
| 912 |
> |
case 'q': |
| 913 |
> |
endwin(); |
| 914 |
> |
exit(0); |
| 915 |
> |
break; |
| 916 |
> |
|
| 917 |
> |
/* Sort by */ |
| 918 |
> |
case 'C': |
| 919 |
> |
sortby_ptr=cmp_cpu_used; |
| 920 |
> |
strlcpy(display_config.sortby, CPU_USED, SORTBYMAXNAME); |
| 921 |
> |
break; |
| 922 |
> |
|
| 923 |
> |
case 'M': |
| 924 |
> |
sortby_ptr=cmp_memory_used_pecent; |
| 925 |
> |
strlcpy(display_config.sortby, MEM, SORTBYMAXNAME); |
| 926 |
> |
break; |
| 927 |
> |
|
| 928 |
> |
case 'L': |
| 929 |
> |
sortby_ptr=cmp_load_1; |
| 930 |
> |
strlcpy(display_config.sortby, LOAD, SORTBYMAXNAME); |
| 931 |
> |
break; |
| 932 |
> |
|
| 933 |
> |
case 'S': |
| 934 |
> |
sortby_ptr=cmp_swap_used_pecent; |
| 935 |
> |
strlcpy(display_config.sortby, SWAP, SORTBYMAXNAME); |
| 936 |
> |
break; |
| 937 |
> |
|
| 938 |
> |
case 'N': |
| 939 |
> |
if(sortby_ptr==cmp_network_io_total){ |
| 940 |
> |
strlcpy(display_config.sortby, NETIORX, SORTBYMAXNAME); |
| 941 |
> |
sortby_ptr=cmp_network_io_total_rx; |
| 942 |
> |
}else if(sortby_ptr==cmp_network_io_total_rx){ |
| 943 |
> |
strlcpy(display_config.sortby, NETIOTX, SORTBYMAXNAME); |
| 944 |
> |
sortby_ptr=cmp_network_io_total_tx; |
| 945 |
> |
}else{ |
| 946 |
> |
strlcpy(display_config.sortby, NETIO, SORTBYMAXNAME); |
| 947 |
> |
sortby_ptr=cmp_network_io_total; |
| 948 |
> |
} |
| 949 |
> |
break; |
| 950 |
> |
case 'D': |
| 951 |
> |
if(sortby_ptr==cmp_disk_io_total){ |
| 952 |
> |
strlcpy(display_config.sortby, DISKIOR, SORTBYMAXNAME); |
| 953 |
> |
sortby_ptr=cmp_disk_io_total_read; |
| 954 |
> |
}else if(sortby_ptr==cmp_disk_io_total_read){ |
| 955 |
> |
strlcpy(display_config.sortby, DISKIOW, SORTBYMAXNAME); |
| 956 |
> |
sortby_ptr=cmp_disk_io_total_write; |
| 957 |
> |
}else{ |
| 958 |
> |
strlcpy(display_config.sortby, DISKIO, SORTBYMAXNAME); |
| 959 |
> |
sortby_ptr=cmp_disk_io_total; |
| 960 |
> |
} |
| 961 |
> |
break; |
| 962 |
> |
|
| 963 |
> |
/* Display */ |
| 964 |
> |
|
| 965 |
> |
case 'd': |
| 966 |
> |
if(display_config.disk_io_total_read){ |
| 967 |
> |
display_config.disk_io_total_read=0; |
| 968 |
> |
display_config.disk_io_total_write=0; |
| 969 |
> |
}else{ |
| 970 |
> |
display_config.disk_io_total_read=1; |
| 971 |
> |
display_config.disk_io_total_write=1; |
| 972 |
> |
} |
| 973 |
> |
break; |
| 974 |
> |
case 'n': |
| 975 |
> |
if(display_config.network_io_total_rx){ |
| 976 |
> |
display_config.network_io_total_rx=0; |
| 977 |
> |
display_config.network_io_total_tx=0; |
| 978 |
> |
}else{ |
| 979 |
> |
display_config.network_io_total_rx=1; |
| 980 |
> |
display_config.network_io_total_tx=1; |
| 981 |
> |
} |
| 982 |
> |
break; |
| 983 |
> |
case 'm': |
| 984 |
> |
if(display_config.memory_used_pecent){ |
| 985 |
> |
display_config.memory_used_pecent=0; |
| 986 |
> |
}else{ |
| 987 |
> |
display_config.memory_used_pecent=1; |
| 988 |
> |
} |
| 989 |
> |
break; |
| 990 |
> |
|
| 991 |
> |
case 's': |
| 992 |
> |
if(display_config.swap_used_pecent){ |
| 993 |
> |
display_config.swap_used_pecent=0; |
| 994 |
> |
}else{ |
| 995 |
> |
display_config.swap_used_pecent=1; |
| 996 |
> |
} |
| 997 |
> |
break; |
| 998 |
> |
case 'l': |
| 999 |
> |
if(display_config.load_1){ |
| 1000 |
> |
display_config.load_1=0; |
| 1001 |
> |
}else{ |
| 1002 |
> |
display_config.load_1=1; |
| 1003 |
> |
} |
| 1004 |
> |
break; |
| 1005 |
> |
case 'p': |
| 1006 |
> |
if(display_config.pages_in){ |
| 1007 |
> |
display_config.pages_in=0; |
| 1008 |
> |
display_config.pages_out=0; |
| 1009 |
> |
}else{ |
| 1010 |
> |
display_config.pages_in=1; |
| 1011 |
> |
display_config.pages_out=1; |
| 1012 |
> |
} |
| 1013 |
> |
break; |
| 1014 |
> |
case 'c': |
| 1015 |
> |
if(display_config.cpu_used){ |
| 1016 |
> |
display_config.cpu_used=0; |
| 1017 |
> |
}else{ |
| 1018 |
> |
display_config.cpu_used=1; |
| 1019 |
> |
} |
| 1020 |
> |
break; |
| 1021 |
> |
|
| 1022 |
> |
default: |
| 1023 |
> |
/* Invalid key.. Ignore.. Set Title to -1, as the |
| 1024 |
> |
* title++ will then make that "0" (false) so a |
| 1025 |
> |
* screen redraw will not happen */ |
| 1026 |
> |
title=-1; |
| 1027 |
> |
break; |
| 1028 |
> |
} |
| 1029 |
> |
|
| 1030 |
> |
/* Increment title so it becomes true (and making the screen update */ |
| 1031 |
> |
title++; |
| 1032 |
> |
|
| 1033 |
|
} |
| 1034 |
+ |
if(FD_ISSET(data_fileno, &infds)){ |
| 1035 |
+ |
response=fpgetline(data); |
| 1036 |
+ |
if (response==NULL){ |
| 1037 |
+ |
errf("Failed to read data (%m)"); |
| 1038 |
+ |
exit(1); |
| 1039 |
+ |
} |
| 1040 |
+ |
} |
| 1041 |
|
|
| 1042 |
+ |
|
| 1043 |
|
num_hosts=parse_xml(response, &machine_data_list); |
| 1044 |
|
if(num_hosts==-1) continue; |
| 1045 |
|
machine_data_list=sort_machine_stats(machine_data_list, num_hosts, sortby_ptr); |
| 1046 |
|
if(max_display==0){ |
| 1047 |
< |
display(machine_data_list, &display_config, num_hosts, &title); |
| 1047 |
> |
display(machine_data_list, &display_config, maxy, &title); |
| 1048 |
|
}else{ |
| 1049 |
|
display(machine_data_list, &display_config, max_display, &title); |
| 1050 |
|
} |