| 63 |
|
sg_host_info *host_info; |
| 64 |
|
sg_user_stats *user_stats; |
| 65 |
|
}stats_t; |
| 66 |
< |
|
| 66 |
> |
|
| 67 |
|
stats_t stats; |
| 68 |
|
|
| 69 |
|
char *size_conv(long long number){ |
| 88 |
|
|
| 89 |
|
snprintf(string, 10, "%lld%c", number, type[x]); |
| 90 |
|
return string; |
| 91 |
< |
|
| 91 |
> |
|
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
char *hr_uptime(time_t time){ |
| 95 |
|
int day = 0, hour = 0, min = 0; |
| 96 |
|
static char uptime_str[25]; |
| 97 |
|
int sec = (int) time; |
| 98 |
< |
|
| 98 |
> |
|
| 99 |
|
day = sec / (24*60*60); |
| 100 |
|
sec = sec % (24*60*60); |
| 101 |
|
hour = sec / (60*60); |
| 187 |
|
move(10,15); |
| 188 |
|
printw("Read"); |
| 189 |
|
move(10,28); |
| 190 |
< |
printw("Write"); |
| 190 |
> |
printw("Write"); |
| 191 |
|
|
| 192 |
|
line = 10; |
| 193 |
|
if (stats.network_io_stats != NULL) { |
| 236 |
|
*/ |
| 237 |
|
if (ptr != NULL){ |
| 238 |
|
*ptr = '\0'; |
| 239 |
< |
} |
| 239 |
> |
} |
| 240 |
|
printw("%s", hostname); |
| 241 |
|
move(0,36); |
| 242 |
|
printw("%s", hr_uptime(stats.host_info->uptime)); |
| 288 |
|
if (stats.mem_stats != NULL) { |
| 289 |
|
/* Mem */ |
| 290 |
|
move(6, 12); |
| 291 |
< |
printw("%7s", size_conv(stats.mem_stats->total)); |
| 291 |
> |
printw("%7s", size_conv(stats.mem_stats->total)); |
| 292 |
|
move(7, 12); |
| 293 |
< |
printw("%7s", size_conv(stats.mem_stats->used)); |
| 293 |
> |
printw("%7s", size_conv(stats.mem_stats->used)); |
| 294 |
|
move(8, 12); |
| 295 |
|
printw("%7s", size_conv(stats.mem_stats->free)); |
| 296 |
|
} |
| 297 |
< |
|
| 298 |
< |
if (stats.swap_stats != NULL) { |
| 297 |
> |
|
| 298 |
> |
if (stats.swap_stats != NULL) { |
| 299 |
|
/* Swap */ |
| 300 |
|
move(6, 32); |
| 301 |
|
printw("%8s", size_conv(stats.swap_stats->total)); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
/* VM */ |
| 309 |
< |
if (stats.mem_stats != NULL && stats.mem_stats->total != 0) { |
| 309 |
> |
if (stats.mem_stats != NULL && stats.mem_stats->total != 0) { |
| 310 |
|
move(6, 54); |
| 311 |
|
printw("%5.2f%%", (100.00 * (float)(stats.mem_stats->used)/stats.mem_stats->total)); |
| 312 |
|
} |
| 313 |
< |
if (stats.swap_stats != NULL && stats.swap_stats->total != 0) { |
| 313 |
> |
if (stats.swap_stats != NULL && stats.swap_stats->total != 0) { |
| 314 |
|
move(7, 54); |
| 315 |
|
printw("%5.2f%%", (100.00 * (float)(stats.swap_stats->used)/stats.swap_stats->total)); |
| 316 |
|
} |
| 317 |
|
if (stats.mem_stats != NULL && stats.swap_stats != NULL && |
| 318 |
< |
stats.mem_stats->total != 0 && stats.swap_stats->total != 0) { |
| 318 |
> |
stats.mem_stats->total != 0 && stats.swap_stats->total != 0) { |
| 319 |
|
move(8, 54); |
| 320 |
|
printw("%5.2f%%", (100.00 * (float)(stats.mem_stats->used+stats.swap_stats->used)/(stats.mem_stats->total+stats.swap_stats->total))); |
| 321 |
|
} |
| 322 |
|
|
| 323 |
< |
if (stats.page_stats != NULL) { |
| 323 |
> |
if (stats.page_stats != NULL) { |
| 324 |
|
/* Paging */ |
| 325 |
|
move(6, 74); |
| 326 |
|
printw("%5d", (stats.page_stats->systime)? (stats.page_stats->pages_pagein / stats.page_stats->systime): stats.page_stats->pages_pagein); |
| 329 |
|
} |
| 330 |
|
|
| 331 |
|
line = 11; |
| 332 |
< |
if (stats.disk_io_stats != NULL) { |
| 332 |
> |
if (stats.disk_io_stats != NULL) { |
| 333 |
|
/* Disk IO */ |
| 334 |
|
disk_io_stat_ptr = stats.disk_io_stats; |
| 335 |
|
r=0; |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
line = 11; |
| 364 |
< |
if (stats.network_io_stats != NULL) { |
| 364 |
> |
if (stats.network_io_stats != NULL) { |
| 365 |
|
/* Network */ |
| 366 |
|
network_stat_ptr = stats.network_io_stats; |
| 367 |
|
for(counter=0;counter<stats.network_io_entries;counter++){ |
| 374 |
|
rt = (network_stat_ptr->systime)? (network_stat_ptr->rx / network_stat_ptr->systime): network_stat_ptr->rx; |
| 375 |
|
printw("%7s", size_conv(rt)); |
| 376 |
|
move(line, 72); |
| 377 |
< |
wt = (network_stat_ptr->systime)? (network_stat_ptr->tx / network_stat_ptr->systime): network_stat_ptr->tx; |
| 377 |
> |
wt = (network_stat_ptr->systime)? (network_stat_ptr->tx / network_stat_ptr->systime): network_stat_ptr->tx; |
| 378 |
|
printw("%7s", size_conv(wt)); |
| 379 |
|
network_stat_ptr++; |
| 380 |
|
line++; |
| 382 |
|
line += 2; |
| 383 |
|
} |
| 384 |
|
|
| 385 |
< |
if (stats.fs_stats != NULL) { |
| 385 |
> |
if (stats.fs_stats != NULL) { |
| 386 |
|
/* Disk */ |
| 387 |
|
disk_stat_ptr = stats.fs_stats; |
| 388 |
|
for(counter=0;counter<stats.fs_entries;counter++){ |
| 459 |
|
fprintf(stderr, "Failed to drop setuid/setgid privileges\n"); |
| 460 |
|
return 1; |
| 461 |
|
} |
| 462 |
< |
|
| 462 |
> |
|
| 463 |
|
while ((c = getopt(argc, argv, "vhd:")) != -1){ |
| 464 |
|
switch (c){ |
| 465 |
|
case 'd': |
| 470 |
|
} |
| 471 |
|
break; |
| 472 |
|
case 'v': |
| 473 |
< |
version_num(argv[0]); |
| 473 |
> |
version_num(argv[0]); |
| 474 |
|
break; |
| 475 |
|
case 'h': |
| 476 |
|
default: |
| 515 |
|
last_update = now; |
| 516 |
|
|
| 517 |
|
display_data(); |
| 518 |
< |
} |
| 518 |
> |
} |
| 519 |
|
|
| 520 |
|
endwin(); |
| 521 |
|
return 0; |
| 522 |
< |
} |
| 522 |
> |
} |