| 344 | } |
| 345 | |
| 346 | static void mem_update_stats_fn (void *data) |
| 347 | { |
| 348 | struct resource_instance * inst = (struct resource_instance *)data; |
| 349 | int32_t new_value; |
| 350 | uint64_t timestamp; |
| 351 | char key_name[ICMAP_KEYNAME_MAXLEN]; |
| 352 | |
| 353 | new_value = percent_mem_used_get(); |
| 354 | if (new_value > 0) { |
| 355 | snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "current"); |
| 356 | icmap_set_uint32(key_name, new_value); |
| 357 | |
| 358 | timestamp = cs_timestamp_get(); |
| 359 | |
| 360 | snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "last_updated"); |
| 361 | icmap_set_uint64(key_name, timestamp); |
| 362 | |
| 363 | if (new_value > inst->max.int32 && inst->fsm.curr_state != MON_S_FAILED) { |
| 364 | cs_fsm_process (&inst->fsm, MON_E_FAILURE, inst, mon_fsm_cb); |
| 365 | } |
| 366 | } |
| 367 | api->timer_add_duration(inst->period * MILLI_2_NANO_SECONDS, |
| 368 | inst, inst->update_stats_fn, &inst->timer_handle); |
| 369 | } |
| 370 | |
| 371 | static double min15_loadavg_get(void) |
| 372 | { |
nothing calls this directly
no test coverage detected