Exemple #1
0
static void
_sysstat (gchar **vols)
{
	GString *tmp = g_string_new("");
	for (;;) {
		g_string_set_size (tmp, 0);
		g_string_append_printf (tmp, "%lu %.03f",
				oio_ext_real_seconds (), 100.0 * oio_sys_cpu_idle ());
		for (gchar **pvol=vols; *pvol ;++pvol) {
			g_string_append_printf (tmp, " %s,%3.03f,%.03f", *pvol,
					100.0 * oio_sys_io_idle (*pvol),
					100.0 * oio_sys_space_idle (*pvol));
		}
		g_print ("%s\n", tmp->str);
		g_usleep (998 * G_TIME_SPAN_MILLISECOND);
	}
	g_string_free (tmp, TRUE);
}
Exemple #2
0
			break;
		default:
			g_assert_not_reached();
	}

	if (cs_expire_local_services > 0) {
		struct service_info_s *v = service_info_dup (si);
		v->score.timestamp = oio_ext_monotonic_seconds ();
		PUSH_DO(
			const struct service_info_s *si0 = lru_tree_get(srv_registered, k);
			if (si0) v->score.value = si0->score.value;
			lru_tree_insert (srv_registered, g_strdup(k), v);
		);
	}

	si->score.timestamp = oio_ext_real_seconds ();

	// TODO follow the DRY principle and factorize this!
	if (flag_cache_enabled) {
		GString *gstr = g_string_new ("");
		service_info_encode_json (gstr, si, TRUE);
		PUSH_DO(lru_tree_insert(push_queue, service_info_key(si), si));
		return _reply_success_json (args, gstr);
	} else {
		CSURL(cs);
		GSList l = {.data = si, .next = NULL};
		if (NULL != (err = conscience_remote_push_services (cs, &l))) {
			service_info_clean (si);
			return _reply_common_error (args, err);
		} else {
			GString *gstr = g_string_new ("");