mon.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * Copyright (c) 2010 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Angus Salkeld <asalkeld@redhat.com>
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <config.h>
  35. #include <unistd.h>
  36. #if defined(HAVE_LIBSTATGRAB)
  37. #include <statgrab.h>
  38. #endif
  39. #include <corosync/corotypes.h>
  40. #include <corosync/corodefs.h>
  41. #include <corosync/lcr/lcr_comp.h>
  42. #include <corosync/engine/coroapi.h>
  43. #include <corosync/list.h>
  44. #include <corosync/engine/logsys.h>
  45. #include "../exec/fsm.h"
  46. LOGSYS_DECLARE_SUBSYS ("MON");
  47. /*
  48. * Service Interfaces required by service_message_handler struct
  49. */
  50. static int mon_exec_init_fn (
  51. struct corosync_api_v1 *corosync_api);
  52. static struct corosync_api_v1 *api;
  53. static hdb_handle_t resources_obj;
  54. #define MON_DEFAULT_PERIOD 3000
  55. #define MON_MIN_PERIOD 500
  56. #define MON_MAX_PERIOD (120 * CS_TIME_MS_IN_SEC)
  57. struct corosync_service_engine mon_service_engine = {
  58. .name = "corosync resource monitoring service",
  59. .id = MON_SERVICE,
  60. .priority = 1,
  61. .private_data_size = 0,
  62. .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED,
  63. .lib_init_fn = NULL,
  64. .lib_exit_fn = NULL,
  65. .lib_engine = NULL,
  66. .lib_engine_count = 0,
  67. .exec_engine = NULL,
  68. .exec_engine_count = 0,
  69. .confchg_fn = NULL,
  70. .exec_init_fn = mon_exec_init_fn,
  71. .exec_dump_fn = NULL,
  72. .sync_mode = CS_SYNC_V2
  73. };
  74. static DECLARE_LIST_INIT (confchg_notify);
  75. struct resource_instance {
  76. hdb_handle_t handle;
  77. const char *name;
  78. corosync_timer_handle_t timer_handle;
  79. void (*update_stats_fn) (void *data);
  80. struct cs_fsm fsm;
  81. uint64_t period;
  82. objdb_value_types_t max_type;
  83. union {
  84. int32_t int32;
  85. double dbl;
  86. } max;
  87. };
  88. static void mem_update_stats_fn (void *data);
  89. static void load_update_stats_fn (void *data);
  90. static struct resource_instance memory_used_inst = {
  91. .name = "memory_used",
  92. .update_stats_fn = mem_update_stats_fn,
  93. .max_type = OBJDB_VALUETYPE_INT32,
  94. .max.int32 = INT32_MAX,
  95. .period = MON_DEFAULT_PERIOD,
  96. };
  97. static struct resource_instance load_15min_inst = {
  98. .name = "load_15min",
  99. .update_stats_fn = load_update_stats_fn,
  100. .max_type = OBJDB_VALUETYPE_DOUBLE,
  101. .max.dbl = INT32_MAX,
  102. .period = MON_DEFAULT_PERIOD,
  103. };
  104. /*
  105. * F S M
  106. */
  107. static void mon_config_changed (struct cs_fsm* fsm, int32_t event, void * data);
  108. static void mon_resource_failed (struct cs_fsm* fsm, int32_t event, void * data);
  109. const char * mon_running_str = "running";
  110. const char * mon_failed_str = "failed";
  111. const char * mon_failure_str = "failure";
  112. const char * mon_stopped_str = "stopped";
  113. const char * mon_config_changed_str = "config_changed";
  114. enum mon_resource_state {
  115. MON_S_STOPPED,
  116. MON_S_RUNNING,
  117. MON_S_FAILED
  118. };
  119. enum mon_resource_event {
  120. MON_E_CONFIG_CHANGED,
  121. MON_E_FAILURE
  122. };
  123. struct cs_fsm_entry mon_fsm_table[] = {
  124. { MON_S_STOPPED, MON_E_CONFIG_CHANGED, mon_config_changed, {MON_S_STOPPED, MON_S_RUNNING, -1} },
  125. { MON_S_STOPPED, MON_E_FAILURE, NULL, {-1} },
  126. { MON_S_RUNNING, MON_E_CONFIG_CHANGED, mon_config_changed, {MON_S_RUNNING, MON_S_STOPPED, -1} },
  127. { MON_S_RUNNING, MON_E_FAILURE, mon_resource_failed, {MON_S_FAILED, -1} },
  128. { MON_S_FAILED, MON_E_CONFIG_CHANGED, mon_config_changed, {MON_S_RUNNING, MON_S_STOPPED, -1} },
  129. { MON_S_FAILED, MON_E_FAILURE, NULL, {-1} },
  130. };
  131. /*
  132. * Dynamic loading descriptor
  133. */
  134. static struct corosync_service_engine *mon_get_service_engine_ver0 (void);
  135. static struct corosync_service_engine_iface_ver0 mon_service_engine_iface = {
  136. .corosync_get_service_engine_ver0 = mon_get_service_engine_ver0
  137. };
  138. static struct lcr_iface corosync_mon_ver0[1] = {
  139. {
  140. .name = "corosync_mon",
  141. .version = 0,
  142. .versions_replace = 0,
  143. .versions_replace_count = 0,
  144. .dependencies = 0,
  145. .dependency_count = 0,
  146. .constructor = NULL,
  147. .destructor = NULL,
  148. .interfaces = NULL,
  149. }
  150. };
  151. static struct lcr_comp mon_comp_ver0 = {
  152. .iface_count = 1,
  153. .ifaces = corosync_mon_ver0
  154. };
  155. static struct corosync_service_engine *mon_get_service_engine_ver0 (void)
  156. {
  157. return (&mon_service_engine);
  158. }
  159. #ifdef COROSYNC_SOLARIS
  160. void corosync_lcr_component_register (void);
  161. void corosync_lcr_component_register (void) {
  162. #else
  163. __attribute__ ((constructor)) static void corosync_lcr_component_register (void) {
  164. #endif
  165. lcr_interfaces_set (&corosync_mon_ver0[0], &mon_service_engine_iface);
  166. lcr_component_register (&mon_comp_ver0);
  167. }
  168. static const char * mon_res_state_to_str(struct cs_fsm* fsm,
  169. int32_t state)
  170. {
  171. switch (state) {
  172. case MON_S_STOPPED:
  173. return mon_stopped_str;
  174. break;
  175. case MON_S_RUNNING:
  176. return mon_running_str;
  177. break;
  178. case MON_S_FAILED:
  179. return mon_failed_str;
  180. break;
  181. }
  182. return NULL;
  183. }
  184. static const char * mon_res_event_to_str(struct cs_fsm* fsm,
  185. int32_t event)
  186. {
  187. switch (event) {
  188. case MON_E_CONFIG_CHANGED:
  189. return mon_config_changed_str;
  190. break;
  191. case MON_E_FAILURE:
  192. return mon_failure_str;
  193. break;
  194. }
  195. return NULL;
  196. }
  197. static cs_error_t str_to_uint64_t(const char* str, uint64_t *out_value, uint64_t min, uint64_t max)
  198. {
  199. char *endptr;
  200. errno = 0;
  201. *out_value = strtol(str, &endptr, 0);
  202. /* Check for various possible errors */
  203. if (errno != 0 || endptr == str) {
  204. return CS_ERR_INVALID_PARAM;
  205. }
  206. if (*out_value > max || *out_value < min) {
  207. return CS_ERR_INVALID_PARAM;
  208. }
  209. return CS_OK;
  210. }
  211. static void mon_fsm_state_set (struct cs_fsm* fsm,
  212. enum mon_resource_state next_state, struct resource_instance* inst)
  213. {
  214. enum mon_resource_state prev_state = fsm->curr_state;
  215. const char *state_str;
  216. ENTER();
  217. cs_fsm_state_set(fsm, next_state, inst);
  218. if (prev_state == fsm->curr_state) {
  219. return;
  220. }
  221. state_str = mon_res_state_to_str(fsm, fsm->curr_state);
  222. api->object_key_replace (inst->handle,
  223. "state", strlen ("state"),
  224. state_str, strlen (state_str));
  225. }
  226. static void mon_config_changed (struct cs_fsm* fsm, int32_t event, void * data)
  227. {
  228. struct resource_instance * inst = (struct resource_instance *)data;
  229. char *str;
  230. size_t str_len;
  231. objdb_value_types_t type;
  232. uint64_t tmp_value;
  233. int32_t res;
  234. char str_copy[256];
  235. ENTER();
  236. res = api->object_key_get_typed (inst->handle,
  237. "poll_period",
  238. (void**)&str, &str_len,
  239. &type);
  240. if (res == 0) {
  241. memcpy(str_copy, str, str_len);
  242. str_copy[str_len] = '\0';
  243. if (str_to_uint64_t(str_copy, &tmp_value, MON_MIN_PERIOD, MON_MAX_PERIOD) == CS_OK) {
  244. log_printf (LOGSYS_LEVEL_DEBUG,
  245. "poll_period changing from:%"PRIu64" to %"PRIu64".",
  246. inst->period, tmp_value);
  247. inst->period = tmp_value;
  248. } else {
  249. log_printf (LOGSYS_LEVEL_WARNING,
  250. "Could NOT use poll_period:%s ms for resource %s",
  251. str, inst->name);
  252. }
  253. }
  254. if (inst->timer_handle) {
  255. api->timer_delete(inst->timer_handle);
  256. inst->timer_handle = 0;
  257. }
  258. res = api->object_key_get_typed (inst->handle, "max",
  259. (void**)&str, &str_len, &type);
  260. if (res != 0) {
  261. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  262. inst->max.int32 = INT32_MAX;
  263. } else
  264. if (inst->max_type == OBJDB_VALUETYPE_DOUBLE) {
  265. inst->max.dbl = INT32_MAX;
  266. }
  267. mon_fsm_state_set (fsm, MON_S_STOPPED, inst);
  268. } else {
  269. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  270. inst->max.int32 = strtol (str, NULL, 0);
  271. } else
  272. if (inst->max_type == OBJDB_VALUETYPE_DOUBLE) {
  273. inst->max.dbl = strtod (str, NULL);
  274. }
  275. mon_fsm_state_set (fsm, MON_S_RUNNING, inst);
  276. /*
  277. * run the updater, incase the period has shortened
  278. * and to start the timer.
  279. */
  280. inst->update_stats_fn (inst);
  281. }
  282. }
  283. void mon_resource_failed (struct cs_fsm* fsm, int32_t event, void * data)
  284. {
  285. struct resource_instance * inst = (struct resource_instance *)data;
  286. ENTER();
  287. mon_fsm_state_set (fsm, MON_S_FAILED, inst);
  288. }
  289. static int32_t percent_mem_used_get(void)
  290. {
  291. #if defined(HAVE_LIBSTATGRAB)
  292. sg_mem_stats *mem_stats;
  293. sg_swap_stats *swap_stats;
  294. long long total, freemem;
  295. mem_stats = sg_get_mem_stats();
  296. swap_stats = sg_get_swap_stats();
  297. if (mem_stats == NULL || swap_stats != NULL) {
  298. log_printf (LOGSYS_LEVEL_ERROR, "Unable to get memory stats: %s\n",
  299. sg_str_error(sg_get_error()));
  300. return -1;
  301. }
  302. total = mem_stats->total + swap_stats->total;
  303. freemem = mem_stats->free + swap_stats->free;
  304. return ((total - freemem) * 100) / total;
  305. #else
  306. #if defined(COROSYNC_LINUX)
  307. char *line_ptr;
  308. char line[512];
  309. unsigned long long value;
  310. FILE *f;
  311. long long total = 0;
  312. long long freemem = 0;
  313. if ((f = fopen("/proc/meminfo", "r")) == NULL) {
  314. return -1;
  315. }
  316. while ((line_ptr = fgets(line, sizeof(line), f)) != NULL) {
  317. if (sscanf(line_ptr, "%*s %llu kB", &value) != 1) {
  318. continue;
  319. }
  320. value *= 1024;
  321. if (strncmp(line_ptr, "MemTotal:", 9) == 0) {
  322. total += value;
  323. } else if (strncmp(line_ptr, "MemFree:", 8) == 0) {
  324. freemem += value;
  325. } else if (strncmp(line_ptr, "SwapTotal:", 10) == 0) {
  326. total += value;
  327. } else if (strncmp(line_ptr, "SwapFree:", 9) == 0) {
  328. freemem += value;
  329. }
  330. }
  331. fclose(f);
  332. return ((total - freemem) * 100) / total;
  333. #else
  334. #error need libstatgrab or linux.
  335. #endif /* COROSYNC_LINUX */
  336. #endif /* HAVE_LIBSTATGRAB */
  337. }
  338. static void mem_update_stats_fn (void *data)
  339. {
  340. struct resource_instance * inst = (struct resource_instance *)data;
  341. int32_t new_value;
  342. uint64_t timestamp;
  343. new_value = percent_mem_used_get();
  344. if (new_value > 0) {
  345. api->object_key_replace (inst->handle,
  346. "current", strlen("current"),
  347. &new_value, sizeof(new_value));
  348. timestamp = cs_timestamp_get();
  349. api->object_key_replace (inst->handle,
  350. "last_updated", strlen("last_updated"),
  351. &timestamp, sizeof(uint64_t));
  352. if (new_value > inst->max.int32 && inst->fsm.curr_state != MON_S_FAILED) {
  353. cs_fsm_process (&inst->fsm, MON_E_FAILURE, inst);
  354. }
  355. }
  356. api->timer_add_duration(inst->period * MILLI_2_NANO_SECONDS,
  357. inst, inst->update_stats_fn, &inst->timer_handle);
  358. }
  359. static double min15_loadavg_get(void)
  360. {
  361. #if defined(HAVE_LIBSTATGRAB)
  362. sg_load_stats *load_stats;
  363. load_stats = sg_get_load_stats ();
  364. if (load_stats == NULL) {
  365. log_printf (LOGSYS_LEVEL_ERROR, "Unable to get load stats: %s\n",
  366. sg_str_error (sg_get_error()));
  367. return -1;
  368. }
  369. return load_stats->min15;
  370. #else
  371. #if defined(COROSYNC_LINUX)
  372. double loadav[3];
  373. if (getloadavg(loadav,3) < 0) {
  374. return -1;
  375. }
  376. return loadav[2];
  377. #else
  378. #error need libstatgrab or linux.
  379. #endif /* COROSYNC_LINUX */
  380. #endif /* HAVE_LIBSTATGRAB */
  381. }
  382. static void load_update_stats_fn (void *data)
  383. {
  384. struct resource_instance * inst = (struct resource_instance *)data;
  385. uint64_t timestamp;
  386. int32_t res = 0;
  387. double min15 = min15_loadavg_get();
  388. if (min15 > 0) {
  389. res = api->object_key_replace (inst->handle,
  390. "current", strlen("current"),
  391. &min15, sizeof (min15));
  392. if (res != 0) {
  393. log_printf (LOGSYS_LEVEL_ERROR, "replace current failed: %d", res);
  394. }
  395. timestamp = cs_timestamp_get();
  396. res = api->object_key_replace (inst->handle,
  397. "last_updated", strlen("last_updated"),
  398. &timestamp, sizeof(uint64_t));
  399. if (res != 0) {
  400. log_printf (LOGSYS_LEVEL_ERROR, "replace last_updated failed: %d", res);
  401. }
  402. if (min15 > inst->max.dbl && inst->fsm.curr_state != MON_S_FAILED) {
  403. cs_fsm_process (&inst->fsm, MON_E_FAILURE, &inst);
  404. }
  405. }
  406. api->timer_add_duration(inst->period * MILLI_2_NANO_SECONDS,
  407. inst, inst->update_stats_fn, &inst->timer_handle);
  408. }
  409. static int object_find_or_create (
  410. hdb_handle_t parent_object_handle,
  411. hdb_handle_t *object_handle,
  412. const void *object_name,
  413. size_t object_name_len)
  414. {
  415. hdb_handle_t obj_finder;
  416. hdb_handle_t obj;
  417. int ret = -1;
  418. api->object_find_create (
  419. parent_object_handle,
  420. object_name,
  421. object_name_len,
  422. &obj_finder);
  423. if (api->object_find_next (obj_finder, &obj) == 0) {
  424. /* found it */
  425. *object_handle = obj;
  426. ret = 0;
  427. }
  428. else {
  429. ret = api->object_create (parent_object_handle,
  430. object_handle,
  431. object_name, object_name_len);
  432. }
  433. api->object_find_destroy (obj_finder);
  434. return ret;
  435. }
  436. static void mon_object_destroyed(
  437. hdb_handle_t parent_object_handle,
  438. const void *name_pt, size_t name_len,
  439. void *priv_data_pt)
  440. {
  441. struct resource_instance* inst = (struct resource_instance*)priv_data_pt;
  442. if (inst) {
  443. log_printf (LOGSYS_LEVEL_WARNING,
  444. "resource \"%s\" deleted from objdb!",
  445. inst->name);
  446. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  447. }
  448. }
  449. static void mon_key_change_notify (object_change_type_t change_type,
  450. hdb_handle_t parent_object_handle,
  451. hdb_handle_t object_handle,
  452. const void *object_name_pt, size_t object_name_len,
  453. const void *key_name_pt, size_t key_len,
  454. const void *key_value_pt, size_t key_value_len,
  455. void *priv_data_pt)
  456. {
  457. struct resource_instance* inst = (struct resource_instance*)priv_data_pt;
  458. if ((strncmp ((char*)key_name_pt, "max", key_len) == 0) ||
  459. (strncmp ((char*)key_name_pt, "poll_period", key_len) == 0)) {
  460. ENTER();
  461. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  462. }
  463. }
  464. static void mon_instance_init (hdb_handle_t parent, struct resource_instance* inst)
  465. {
  466. int32_t res;
  467. char mon_period_str[32];
  468. char *str;
  469. size_t mon_period_len;
  470. objdb_value_types_t mon_period_type;
  471. uint64_t tmp_value;
  472. int32_t zero_32 = 0;
  473. time_t zero_64 = 0;
  474. double zero_double = 0;
  475. object_find_or_create (parent,
  476. &inst->handle,
  477. inst->name, strlen (inst->name));
  478. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  479. api->object_key_create_typed (inst->handle,
  480. "current", &zero_32,
  481. sizeof (zero_32), inst->max_type);
  482. } else {
  483. api->object_key_create_typed (inst->handle,
  484. "current", &zero_double,
  485. sizeof (zero_double), inst->max_type);
  486. }
  487. api->object_key_create_typed (inst->handle,
  488. "last_updated", &zero_64,
  489. sizeof (uint64_t), OBJDB_VALUETYPE_UINT64);
  490. api->object_key_create_typed (inst->handle,
  491. "state", mon_stopped_str, strlen (mon_stopped_str),
  492. OBJDB_VALUETYPE_STRING);
  493. inst->fsm.name = inst->name;
  494. inst->fsm.curr_entry = 0;
  495. inst->fsm.curr_state = MON_S_STOPPED;
  496. inst->fsm.table = mon_fsm_table;
  497. inst->fsm.entries = sizeof(mon_fsm_table) / sizeof(struct cs_fsm_entry);
  498. inst->fsm.state_to_str = mon_res_state_to_str;
  499. inst->fsm.event_to_str = mon_res_event_to_str;
  500. res = api->object_key_get_typed (inst->handle,
  501. "poll_period",
  502. (void**)&str, &mon_period_len,
  503. &mon_period_type);
  504. if (res != 0) {
  505. mon_period_len = snprintf (mon_period_str, 32, "%"PRIu64"",
  506. inst->period);
  507. api->object_key_create_typed (inst->handle,
  508. "poll_period", &mon_period_str,
  509. mon_period_len,
  510. OBJDB_VALUETYPE_STRING);
  511. }
  512. else {
  513. if (str_to_uint64_t(str, &tmp_value, MON_MIN_PERIOD, MON_MAX_PERIOD) == CS_OK) {
  514. inst->period = tmp_value;
  515. } else {
  516. log_printf (LOGSYS_LEVEL_WARNING,
  517. "Could NOT use poll_period:%s ms for resource %s",
  518. str, inst->name);
  519. }
  520. }
  521. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  522. api->object_track_start (inst->handle, OBJECT_TRACK_DEPTH_RECURSIVE,
  523. mon_key_change_notify,
  524. NULL, mon_object_destroyed, NULL, inst);
  525. }
  526. static int mon_exec_init_fn (
  527. struct corosync_api_v1 *corosync_api)
  528. {
  529. hdb_handle_t obj;
  530. hdb_handle_t parent;
  531. #ifdef HAVE_LIBSTATGRAB
  532. sg_init();
  533. #endif /* HAVE_LIBSTATGRAB */
  534. #ifdef COROSYNC_SOLARIS
  535. logsys_subsys_init();
  536. #endif
  537. api = corosync_api;
  538. object_find_or_create (OBJECT_PARENT_HANDLE,
  539. &resources_obj,
  540. "resources", strlen ("resources"));
  541. object_find_or_create (resources_obj,
  542. &obj,
  543. "system", strlen ("system"));
  544. parent = obj;
  545. mon_instance_init (parent, &memory_used_inst);
  546. mon_instance_init (parent, &load_15min_inst);
  547. return 0;
  548. }