Example #1
0
/*
 * General operating system statistics,
 * see <tt>sg_get_host_info(3)</tt> manpage.
 */
static VALUE
statgrab_host_info(VALUE self)
{
	sg_host_info *host;
	VALUE info, time_now;

	if ((host = sg_get_host_info()) == NULL)
		statgrab_handle_error();

	info = rb_hash_new();
	rb_hash_aset(info, ID2SYM(rb_intern("os_name")),
			rb_str_new2(host->os_name));
	rb_hash_aset(info, ID2SYM(rb_intern("os_release")),
			rb_str_new2(host->os_release));
	rb_hash_aset(info, ID2SYM(rb_intern("os_version")),
			rb_str_new2(host->os_version));
	rb_hash_aset(info, ID2SYM(rb_intern("platform")),
			rb_str_new2(host->platform));
	rb_hash_aset(info, ID2SYM(rb_intern("hostname")),
			rb_str_new2(host->hostname));
	rb_hash_aset(info, ID2SYM(rb_intern("uptime")),
			INT2NUM(host->uptime));

	time_now = rb_funcall(rb_cTime, rb_intern("now"), 0);
	rb_hash_aset(info, ID2SYM(rb_intern("booted")),
			rb_funcall(time_now, rb_intern("-"), 1,
				INT2NUM(host->uptime)));

	return info;
}
Example #2
0
int get_stats(void)
{
  st.cpu = sg_get_cpu_percents();
  if (!st.cpu) { LOG(LOG_INFO, "could not sg_get_cpu_stats"); }
  st.mem = sg_get_mem_stats();
  if (!st.mem) { LOG(LOG_INFO, "could not sg_get_mem_stats"); }
  st.swap = sg_get_swap_stats();
  if (!st.swap) { LOG(LOG_INFO, "could not get_swap_stats"); }
  st.load = sg_get_load_stats();
  if (!st.load) { LOG(LOG_INFO, "could not get_load_stats"); }
  st.process = sg_get_process_stats(&st.process_entries);
  if (!st.process) { LOG(LOG_INFO, "could not get_process_stats"); }
  st.paging = sg_get_page_stats_diff();
  if (!st.paging) { LOG(LOG_INFO, "could not get_page_stats_diff"); }
  st.network = sg_get_network_io_stats_diff(&(st.network_entries));
  if (!st.network) { LOG(LOG_INFO, "could not get_network_stats_diff"); }
  st.diskio = sg_get_disk_io_stats_diff(&(st.diskio_entries));
  if (!st.diskio) { LOG(LOG_INFO, "could not get_diskio_stats_diff"); }
  st.disk = sg_get_fs_stats(&(st.disk_entries));
  if (!st.disk) { LOG(LOG_INFO, "could not get_disk_stats"); }
  st.hostinfo = sg_get_host_info();
  if (!st.hostinfo) { LOG(LOG_INFO, "could not get_host_info"); }
  st.user = sg_get_user_stats();
  if (!st.user) { LOG(LOG_INFO, "could not get get_user_stats"); }

  return 1;
}
Example #3
0
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;
}
Example #4
0
void populate_general() {
	/* FIXME this should be renamed to host. */
	sg_host_info *host = sg_get_host_info();

	if (host != NULL) {
		add_stat(STRING, &host->os_name,
			 "general", "os_name", NULL);
		add_stat(STRING, &host->os_release,
			 "general", "os_release", NULL);
		add_stat(STRING, &host->os_version,
			 "general", "os_version", NULL);
		add_stat(STRING, &host->platform, "general", "platform", NULL);
		add_stat(STRING, &host->hostname, "general", "hostname", NULL);
		add_stat(TIME_T, &host->uptime, "general", "uptime", NULL);
	}
}
Example #5
0
int *iteliec_get_host_info (SoapCtx *request) {
	sg_host_info *general_stats;

	general_stats = sg_get_host_info ();

    soap_env_push_item (request->env, "urn:HostSoap", "host");

    soap_env_add_item  (request->env, "xsd:string", "os_name", general_stats->os_name);
    soap_env_add_item  (request->env, "xsd:string", "platform", general_stats->platform);
    soap_env_add_item  (request->env, "xsd:string", "hostname", general_stats->hostname);
    soap_env_add_itemf (request->env, "xsd:integer", "uptime", "%lu", general_stats->uptime);

    soap_env_pop_item (request->env);

    return 0;
}
Example #6
0
static void
populate_general(void) {
	/* FIXME this should be renamed to host. */
	sg_host_info *host = sg_get_host_info(NULL);

	if (host != NULL) {
		add_stat(STRING, &host->os_name,
			 "general", "os_name", NULL);
		add_stat(STRING, &host->os_release,
			 "general", "os_release", NULL);
		add_stat(STRING, &host->os_version,
			 "general", "os_version", NULL);
		add_stat(STRING, &host->platform, "general", "platform", NULL);
		add_stat(STRING, &host->hostname, "general", "hostname", NULL);
		add_stat(UNSIGNED, &host->ncpus, "general", "ncpus", NULL);
		add_stat(UNSIGNED, &host->maxcpus, "general", "ncpus_cfg", NULL);
		add_stat(UNSIGNED, &host->bitwidth, "general", "bitwidth", NULL);
		add_stat(STRING, ((size_t)host->host_state) > (lengthof(host_states) - 1)
		                 ? &unexpected_host_state
		                 : &host_states[host->host_state], "general", "hoststate", NULL);
		add_stat(TIME_T, &host->uptime, "general", "uptime", NULL);
	}
}