mon.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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. ENTER();
  235. res = api->object_key_get_typed (inst->handle,
  236. "poll_period",
  237. (void**)&str, &str_len,
  238. &type);
  239. if (res == 0) {
  240. if (str_to_uint64_t(str, &tmp_value, MON_MIN_PERIOD, MON_MAX_PERIOD) == CS_OK) {
  241. log_printf (LOGSYS_LEVEL_DEBUG,
  242. "poll_period changing from:%"PRIu64" to %"PRIu64".",
  243. inst->period, tmp_value);
  244. inst->period = tmp_value;
  245. } else {
  246. log_printf (LOGSYS_LEVEL_WARNING,
  247. "Could NOT use poll_period:%s ms for resource %s",
  248. str, inst->name);
  249. }
  250. }
  251. if (inst->timer_handle) {
  252. api->timer_delete(inst->timer_handle);
  253. inst->timer_handle = 0;
  254. }
  255. res = api->object_key_get_typed (inst->handle, "max",
  256. (void**)&str, &str_len, &type);
  257. if (res != 0) {
  258. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  259. inst->max.int32 = INT32_MAX;
  260. } else
  261. if (inst->max_type == OBJDB_VALUETYPE_DOUBLE) {
  262. inst->max.dbl = INT32_MAX;
  263. }
  264. mon_fsm_state_set (fsm, MON_S_STOPPED, inst);
  265. } else {
  266. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  267. inst->max.int32 = strtol (str, NULL, 0);
  268. } else
  269. if (inst->max_type == OBJDB_VALUETYPE_DOUBLE) {
  270. inst->max.dbl = strtod (str, NULL);
  271. }
  272. mon_fsm_state_set (fsm, MON_S_RUNNING, inst);
  273. /*
  274. * run the updater, incase the period has shortened
  275. * and to start the timer.
  276. */
  277. inst->update_stats_fn (inst);
  278. }
  279. }
  280. void mon_resource_failed (struct cs_fsm* fsm, int32_t event, void * data)
  281. {
  282. struct resource_instance * inst = (struct resource_instance *)data;
  283. ENTER();
  284. mon_fsm_state_set (fsm, MON_S_FAILED, inst);
  285. }
  286. static int32_t percent_mem_used_get(void)
  287. {
  288. #if defined(HAVE_LIBSTATGRAB)
  289. sg_mem_stats *mem_stats;
  290. sg_swap_stats *swap_stats;
  291. long long total, freemem;
  292. mem_stats = sg_get_mem_stats();
  293. swap_stats = sg_get_swap_stats();
  294. if (mem_stats == NULL || swap_stats != NULL) {
  295. log_printf (LOGSYS_LEVEL_ERROR, "Unable to get memory stats: %s\n",
  296. sg_str_error(sg_get_error()));
  297. return -1;
  298. }
  299. total = mem_stats->total + swap_stats->total;
  300. freemem = mem_stats->free + swap_stats->free;
  301. return ((total - freemem) * 100) / total;
  302. #else
  303. #if defined(COROSYNC_LINUX)
  304. char *line_ptr;
  305. char line[512];
  306. unsigned long long value;
  307. FILE *f;
  308. long long total = 0;
  309. long long freemem = 0;
  310. if ((f = fopen("/proc/meminfo", "r")) == NULL) {
  311. return -1;
  312. }
  313. while ((line_ptr = fgets(line, sizeof(line), f)) != NULL) {
  314. if (sscanf(line_ptr, "%*s %llu kB", &value) != 1) {
  315. continue;
  316. }
  317. value *= 1024;
  318. if (strncmp(line_ptr, "MemTotal:", 9) == 0) {
  319. total += value;
  320. } else if (strncmp(line_ptr, "MemFree:", 8) == 0) {
  321. freemem += value;
  322. } else if (strncmp(line_ptr, "SwapTotal:", 10) == 0) {
  323. total += value;
  324. } else if (strncmp(line_ptr, "SwapFree:", 9) == 0) {
  325. freemem += value;
  326. }
  327. }
  328. fclose(f);
  329. return ((total - freemem) * 100) / total;
  330. #else
  331. #error need libstatgrab or linux.
  332. #endif /* COROSYNC_LINUX */
  333. #endif /* HAVE_LIBSTATGRAB */
  334. }
  335. static void mem_update_stats_fn (void *data)
  336. {
  337. struct resource_instance * inst = (struct resource_instance *)data;
  338. int32_t new_value;
  339. uint64_t timestamp;
  340. new_value = percent_mem_used_get();
  341. if (new_value > 0) {
  342. api->object_key_replace (inst->handle,
  343. "current", strlen("current"),
  344. &new_value, sizeof(new_value));
  345. timestamp = cs_timestamp_get();
  346. api->object_key_replace (inst->handle,
  347. "last_updated", strlen("last_updated"),
  348. &timestamp, sizeof(uint64_t));
  349. if (new_value > inst->max.int32 && inst->fsm.curr_state != MON_S_FAILED) {
  350. cs_fsm_process (&inst->fsm, MON_E_FAILURE, inst);
  351. }
  352. }
  353. api->timer_add_duration(inst->period * MILLI_2_NANO_SECONDS,
  354. inst, inst->update_stats_fn, &inst->timer_handle);
  355. }
  356. static double min15_loadavg_get(void)
  357. {
  358. #if defined(HAVE_LIBSTATGRAB)
  359. sg_load_stats *load_stats;
  360. load_stats = sg_get_load_stats ();
  361. if (load_stats == NULL) {
  362. log_printf (LOGSYS_LEVEL_ERROR, "Unable to get load stats: %s\n",
  363. sg_str_error (sg_get_error()));
  364. return -1;
  365. }
  366. return load_stats->min15;
  367. #else
  368. #if defined(COROSYNC_LINUX)
  369. double loadav[3];
  370. if (getloadavg(loadav,3) < 0) {
  371. return -1;
  372. }
  373. return loadav[2];
  374. #else
  375. #error need libstatgrab or linux.
  376. #endif /* COROSYNC_LINUX */
  377. #endif /* HAVE_LIBSTATGRAB */
  378. }
  379. static void load_update_stats_fn (void *data)
  380. {
  381. struct resource_instance * inst = (struct resource_instance *)data;
  382. uint64_t timestamp;
  383. int32_t res = 0;
  384. double min15 = min15_loadavg_get();
  385. if (min15 > 0) {
  386. res = api->object_key_replace (inst->handle,
  387. "current", strlen("current"),
  388. &min15, sizeof (min15));
  389. if (res != 0) {
  390. log_printf (LOGSYS_LEVEL_ERROR, "replace current failed: %d", res);
  391. }
  392. timestamp = cs_timestamp_get();
  393. res = api->object_key_replace (inst->handle,
  394. "last_updated", strlen("last_updated"),
  395. &timestamp, sizeof(uint64_t));
  396. if (res != 0) {
  397. log_printf (LOGSYS_LEVEL_ERROR, "replace last_updated failed: %d", res);
  398. }
  399. if (min15 > inst->max.dbl && inst->fsm.curr_state != MON_S_FAILED) {
  400. cs_fsm_process (&inst->fsm, MON_E_FAILURE, &inst);
  401. }
  402. }
  403. api->timer_add_duration(inst->period * MILLI_2_NANO_SECONDS,
  404. inst, inst->update_stats_fn, &inst->timer_handle);
  405. }
  406. static int object_find_or_create (
  407. hdb_handle_t parent_object_handle,
  408. hdb_handle_t *object_handle,
  409. const void *object_name,
  410. size_t object_name_len)
  411. {
  412. hdb_handle_t obj_finder;
  413. hdb_handle_t obj;
  414. int ret = -1;
  415. api->object_find_create (
  416. parent_object_handle,
  417. object_name,
  418. object_name_len,
  419. &obj_finder);
  420. if (api->object_find_next (obj_finder, &obj) == 0) {
  421. /* found it */
  422. *object_handle = obj;
  423. ret = 0;
  424. }
  425. else {
  426. ret = api->object_create (parent_object_handle,
  427. object_handle,
  428. object_name, object_name_len);
  429. }
  430. api->object_find_destroy (obj_finder);
  431. return ret;
  432. }
  433. static void mon_object_destroyed(
  434. hdb_handle_t parent_object_handle,
  435. const void *name_pt, size_t name_len,
  436. void *priv_data_pt)
  437. {
  438. struct resource_instance* inst = (struct resource_instance*)priv_data_pt;
  439. if (inst) {
  440. log_printf (LOGSYS_LEVEL_WARNING,
  441. "resource \"%s\" deleted from objdb!",
  442. inst->name);
  443. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  444. }
  445. }
  446. static void mon_key_change_notify (object_change_type_t change_type,
  447. hdb_handle_t parent_object_handle,
  448. hdb_handle_t object_handle,
  449. const void *object_name_pt, size_t object_name_len,
  450. const void *key_name_pt, size_t key_len,
  451. const void *key_value_pt, size_t key_value_len,
  452. void *priv_data_pt)
  453. {
  454. struct resource_instance* inst = (struct resource_instance*)priv_data_pt;
  455. if ((strncmp ((char*)key_name_pt, "max", key_len) == 0) ||
  456. (strncmp ((char*)key_name_pt, "poll_period", key_len) == 0)) {
  457. ENTER();
  458. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  459. }
  460. }
  461. static void mon_instance_init (hdb_handle_t parent, struct resource_instance* inst)
  462. {
  463. int32_t res;
  464. char mon_period_str[32];
  465. char *str;
  466. size_t mon_period_len;
  467. objdb_value_types_t mon_period_type;
  468. uint64_t tmp_value;
  469. int32_t zero_32 = 0;
  470. time_t zero_64 = 0;
  471. double zero_double = 0;
  472. object_find_or_create (parent,
  473. &inst->handle,
  474. inst->name, strlen (inst->name));
  475. if (inst->max_type == OBJDB_VALUETYPE_INT32) {
  476. api->object_key_create_typed (inst->handle,
  477. "current", &zero_32,
  478. sizeof (zero_32), inst->max_type);
  479. } else {
  480. api->object_key_create_typed (inst->handle,
  481. "current", &zero_double,
  482. sizeof (zero_double), inst->max_type);
  483. }
  484. api->object_key_create_typed (inst->handle,
  485. "last_updated", &zero_64,
  486. sizeof (uint64_t), OBJDB_VALUETYPE_UINT64);
  487. api->object_key_create_typed (inst->handle,
  488. "state", mon_stopped_str, strlen (mon_stopped_str),
  489. OBJDB_VALUETYPE_STRING);
  490. inst->fsm.name = inst->name;
  491. inst->fsm.curr_entry = 0;
  492. inst->fsm.curr_state = MON_S_STOPPED;
  493. inst->fsm.table = mon_fsm_table;
  494. inst->fsm.entries = sizeof(mon_fsm_table) / sizeof(struct cs_fsm_entry);
  495. inst->fsm.state_to_str = mon_res_state_to_str;
  496. inst->fsm.event_to_str = mon_res_event_to_str;
  497. res = api->object_key_get_typed (inst->handle,
  498. "poll_period",
  499. (void**)&str, &mon_period_len,
  500. &mon_period_type);
  501. if (res != 0) {
  502. mon_period_len = snprintf (mon_period_str, 32, "%"PRIu64"",
  503. inst->period);
  504. api->object_key_create_typed (inst->handle,
  505. "poll_period", &mon_period_str,
  506. mon_period_len,
  507. OBJDB_VALUETYPE_STRING);
  508. }
  509. else {
  510. if (str_to_uint64_t(str, &tmp_value, MON_MIN_PERIOD, MON_MAX_PERIOD) == CS_OK) {
  511. inst->period = tmp_value;
  512. } else {
  513. log_printf (LOGSYS_LEVEL_WARNING,
  514. "Could NOT use poll_period:%s ms for resource %s",
  515. str, inst->name);
  516. }
  517. }
  518. cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst);
  519. api->object_track_start (inst->handle, OBJECT_TRACK_DEPTH_RECURSIVE,
  520. mon_key_change_notify,
  521. NULL, mon_object_destroyed, NULL, inst);
  522. }
  523. static int mon_exec_init_fn (
  524. struct corosync_api_v1 *corosync_api)
  525. {
  526. hdb_handle_t obj;
  527. hdb_handle_t parent;
  528. #ifdef HAVE_LIBSTATGRAB
  529. sg_init();
  530. #endif /* HAVE_LIBSTATGRAB */
  531. #ifdef COROSYNC_SOLARIS
  532. logsys_subsys_init();
  533. #endif
  534. api = corosync_api;
  535. object_find_or_create (OBJECT_PARENT_HANDLE,
  536. &resources_obj,
  537. "resources", strlen ("resources"));
  538. object_find_or_create (resources_obj,
  539. &obj,
  540. "system", strlen ("system"));
  541. parent = obj;
  542. mon_instance_init (parent, &memory_used_inst);
  543. mon_instance_init (parent, &load_15min_inst);
  544. return 0;
  545. }