241 |
|
*response=fpgetline(f); |
242 |
|
fseek(f, 0, SEEK_CUR); |
243 |
|
|
244 |
< |
if(*response!=NULL) log_msg(LOG_DEBUG, "Recieved %s", *response); |
244 |
> |
if(*response!=NULL) log_msg(LOG_DEBUG, "Received %s", *response); |
245 |
|
|
246 |
|
if( (*response==NULL) || (strcmp(*response, "ERROR")==0) ) return -1; |
247 |
|
|
432 |
|
|
433 |
|
int get_system_stats(int seq_no, ihost_state_t *ihost_state, char *xml, int size){ |
434 |
|
char tmp[size]; |
435 |
< |
cpu_percent_t *cpu_percent; |
436 |
< |
mem_stat_t *mem_stats; |
437 |
< |
load_stat_t *load_stats; |
438 |
< |
user_stat_t *user_stats; |
439 |
< |
swap_stat_t *swap_stats; |
440 |
< |
general_stat_t *general_stats; |
441 |
< |
disk_stat_t *disk_stats; |
442 |
< |
diskio_stat_t *diskio_stats; |
443 |
< |
process_stat_t *process_stats; |
444 |
< |
network_stat_t *network_stats; |
445 |
< |
page_stat_t *page_stats; |
435 |
> |
sg_cpu_percents *cpu_percent; |
436 |
> |
sg_mem_stats *mem_stats; |
437 |
> |
sg_load_stats *load_stats; |
438 |
> |
sg_user_stats *user_stats; |
439 |
> |
sg_swap_stats *swap_stats; |
440 |
> |
sg_host_info *general_stats; |
441 |
> |
sg_fs_stats *disk_stats; |
442 |
> |
sg_disk_io_stats *diskio_stats; |
443 |
> |
sg_process_count *process_stats; |
444 |
> |
sg_network_io_stats *network_stats; |
445 |
> |
sg_page_stats *page_stats; |
446 |
|
int disk_entries=0; |
447 |
|
int diskio_entries=0; |
448 |
|
int network_entries=0; |
456 |
|
seq_no, ihost_state->host_fqdn, time(NULL), ihost_state->host_ip); |
457 |
|
|
458 |
|
/* Get cpu stats, check it is correct, then fill in its entry for the xml */ |
459 |
< |
if((cpu_percent=cpu_percent_usage())==NULL){ |
459 |
> |
if((cpu_percent=sg_get_cpu_percents())==NULL){ |
460 |
|
log_msg(LOG_CRIT, "Failed to get cpu statistics"); |
461 |
|
}else{ |
462 |
|
snprintf(tmp, size, \ |
472 |
|
|
473 |
|
|
474 |
|
/*Get mem stats, and fill in xml */ |
475 |
< |
if((mem_stats=get_memory_stats())==NULL){ |
475 |
> |
if((mem_stats=sg_get_mem_stats())==NULL){ |
476 |
|
log_msg(LOG_CRIT, "Failed to get memory statistics"); |
477 |
|
}else{ |
478 |
|
snprintf(tmp, size, \ |
487 |
|
|
488 |
|
|
489 |
|
/* Get load stats */ |
490 |
< |
if((load_stats=get_load_stats())==NULL){ |
490 |
> |
if((load_stats=sg_get_load_stats())==NULL){ |
491 |
|
log_msg(LOG_CRIT, "Failed to get load statistics"); |
492 |
|
}else{ |
493 |
|
snprintf(tmp, size, \ |
501 |
|
|
502 |
|
/* get user stats */ |
503 |
|
|
504 |
< |
if((user_stats=get_user_stats())==NULL){ |
504 |
> |
if((user_stats=sg_get_user_stats())==NULL){ |
505 |
|
log_msg(LOG_CRIT, "Failed to get user statistics"); |
506 |
|
}else{ |
507 |
|
|
515 |
|
|
516 |
|
|
517 |
|
/* swap stats */ |
518 |
< |
if((swap_stats=get_swap_stats())==NULL){ |
518 |
> |
if((swap_stats=sg_get_swap_stats())==NULL){ |
519 |
|
log_msg(LOG_CRIT, "Failed to get swap statistics"); |
520 |
|
}else{ |
521 |
|
snprintf(tmp, size, \ |
530 |
|
|
531 |
|
/* general stats */ |
532 |
|
|
533 |
< |
if((general_stats=get_general_stats())==NULL){ |
533 |
> |
if((general_stats=sg_get_host_info())==NULL){ |
534 |
|
log_msg(LOG_CRIT, "Failed to get general statistics"); |
535 |
|
}else{ |
536 |
|
snprintf(tmp, size, \ |
548 |
|
|
549 |
|
|
550 |
|
/* process stats */ |
551 |
< |
if((process_stats=get_process_stats())==NULL){ |
551 |
> |
if((process_stats=sg_get_process_count())==NULL){ |
552 |
|
log_msg(LOG_CRIT, "Failed to get general statistics"); |
553 |
|
}else{ |
554 |
|
snprintf(tmp, size, \ |
565 |
|
|
566 |
|
|
567 |
|
/* Get paging stats */ |
568 |
< |
if((page_stats=get_page_stats_diff())==NULL){ |
568 |
> |
if((page_stats=sg_get_page_stats_diff())==NULL){ |
569 |
|
log_msg(LOG_CRIT, "Failed to get paging statistics"); |
570 |
|
}else{ |
571 |
|
if(page_stats->systime!=0){ |
586 |
|
|
587 |
|
/* get diskio stats */ |
588 |
|
|
589 |
< |
if((diskio_stats=get_diskio_stats_diff(&diskio_entries))==NULL){ |
589 |
> |
if((diskio_stats=sg_get_disk_io_stats_diff(&diskio_entries))==NULL){ |
590 |
|
log_msg(LOG_CRIT, "Failed to get diskio statistics"); |
591 |
|
}else{ |
592 |
|
strlcat(xml, "<diskio>", size); |
619 |
|
|
620 |
|
/* get networks stats */ |
621 |
|
|
622 |
< |
if((network_stats=get_network_stats_diff(&network_entries))==NULL){ |
622 |
> |
if((network_stats=sg_get_network_io_stats_diff(&network_entries))==NULL){ |
623 |
|
log_msg(LOG_CRIT, "Failed to get network statistics"); |
624 |
|
}else{ |
625 |
|
strlcat(xml, "<net>", size); |
651 |
|
|
652 |
|
/* get disk stats */ |
653 |
|
|
654 |
< |
if((disk_stats=get_disk_stats(&disk_entries))==NULL){ |
654 |
> |
if((disk_stats=sg_get_fs_stats(&disk_entries))==NULL){ |
655 |
|
log_msg(LOG_CRIT, "Failed to get disk statistics"); |
656 |
|
}else{ |
657 |
|
strlcat(xml, "<disk>", size); |