void populate_proc() { /* FIXME expose individual process info too */ sg_process_count *proc = sg_get_process_count(); if (proc != NULL) { add_stat(INT, &proc->total, "proc", "total", NULL); add_stat(INT, &proc->running, "proc", "running", NULL); add_stat(INT, &proc->sleeping, "proc", "sleeping", NULL); add_stat(INT, &proc->stopped, "proc", "stopped", NULL); add_stat(INT, &proc->zombie, "proc", "zombie", NULL); } }
int get_stats() { stats.cpu_percents = sg_get_cpu_percents(); stats.mem_stats = sg_get_mem_stats(); stats.swap_stats = sg_get_swap_stats(); stats.load_stats = sg_get_load_stats(); stats.process_count = sg_get_process_count(); stats.page_stats = sg_get_page_stats_diff(); stats.network_io_stats = sg_get_network_io_stats_diff(&(stats.network_io_entries)); stats.disk_io_stats = sg_get_disk_io_stats_diff(&(stats.disk_io_entries)); stats.fs_stats = sg_get_fs_stats(&(stats.fs_entries)); stats.host_info = sg_get_host_info(); stats.user_stats = sg_get_user_stats(); return 1; }
int *iteliec_get_process_info (SoapCtx *request) { sg_process_count *process_stat; process_stat = sg_get_process_count (); soap_env_push_item (request->env, "urn:ProcessSoap", "process"); soap_env_add_itemf (request->env, "xsd:integer", "running", "%d", process_stat->running); soap_env_add_itemf (request->env, "xsd:integer", "sleeping","%d", process_stat->sleeping); soap_env_add_itemf (request->env, "xsd:integer", "stopped", "%d", process_stat->stopped); soap_env_add_itemf (request->env, "xsd:integer", "zombie", "%d", process_stat->zombie); soap_env_add_itemf (request->env, "xsd:integer", "total", "%d", process_stat->total); soap_env_pop_item (request->env); return ITELIEC_OK; }
static void populate_proc(void) { /* FIXME expose individual process info too */ sg_process_count *proc = sg_get_process_count(); if (proc != NULL) { add_stat(UNSIGNED_LONG_LONG, &proc->total, "proc", "total", NULL); add_stat(UNSIGNED_LONG_LONG, &proc->running, "proc", "running", NULL); add_stat(UNSIGNED_LONG_LONG, &proc->sleeping, "proc", "sleeping", NULL); add_stat(UNSIGNED_LONG_LONG, &proc->stopped, "proc", "stopped", NULL); add_stat(UNSIGNED_LONG_LONG, &proc->zombie, "proc", "zombie", NULL); } else { char *errbuf; sg_error_details errdet; if( SG_ERROR_NONE != sg_get_error_details(&errdet) ) return; if( NULL == sg_strperror( &errbuf, &errdet ) ) return; fprintf( stderr, "%s\n", errbuf ); } }
/* * Brief process count for different states, * see <tt>sg_get_process_count(3)</tt> manpage. */ static VALUE statgrab_process_count(VALUE self) { sg_process_count *count; VALUE info; if ((count = sg_get_process_count()) == NULL) statgrab_handle_error(); info = rb_hash_new(); rb_hash_aset(info, ID2SYM(rb_intern("total")), INT2FIX(count->total)); rb_hash_aset(info, ID2SYM(rb_intern("running")), INT2FIX(count->running)); rb_hash_aset(info, ID2SYM(rb_intern("sleeping")), INT2FIX(count->sleeping)); rb_hash_aset(info, ID2SYM(rb_intern("stopped")), INT2FIX(count->stopped)); rb_hash_aset(info, ID2SYM(rb_intern("zombie")), INT2FIX(count->zombie)); return info; }