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