7 #include "util/logging.h"
19 d->parent=d->inner=d->prev=d->next=NULL;
39 __clone_copy_me_fields(entity, orig);
43 entity->inner = __clone_monitored_entity(orig->inner);
49 entity->next = __clone_monitored_entity(orig->next);
62 __clone_copy_me_fields(root_dest,root_orig);
66 root_dest->inner = __clone_monitored_entity(root_orig->inner);
73 root_dest->next = __clone_monitored_entity(root_orig->next);
76 __monitoring_remove_monitored_entity(monitoring, root_dest->inner,
true);
90 if( !monitoring || ( (prev && parent) || (!prev && !parent) ) ){
96 if(prev && !prev->parent){
114 if(monitoring->rwlock)
119 entity->next = prev->next;
122 entity->parent = prev->parent;
126 entity->next = parent->inner;
127 entity->next->prev = entity;
128 parent->inner = entity;
129 entity->parent = parent;
131 parent->inner = entity;
132 entity->parent = parent;
137 monitoring->last_rev++;
139 if(monitoring->rwlock)
160 if(!lock_acquired && monitoring->rwlock)
165 inner_it = entity->inner;
167 next = inner_it->next;
168 __monitoring_remove_monitored_entity(monitoring, inner_it,
true);
177 entity->next->prev = NULL;
179 entity->parent->inner = entity->next;
183 entity->next->prev = entity->prev;
184 entity->prev->next = entity->next;
189 monitoring->last_rev++;
191 if(!lock_acquired && monitoring->rwlock)
195 if(entity != &monitoring->chassis){
213 monitoring->last_rev = 1;
216 monitoring->chassis.type = ME_TYPE_CHASSIS;
222 if(!monitoring->mutex || !monitoring->rwlock){
236 if(monitoring->rwlock)
240 __monitoring_remove_monitored_entity(monitoring, &monitoring->chassis,
true);
243 if(monitoring->rwlock)
245 if(monitoring->mutex)
248 if(monitoring->is_snapshot)
254 int indentation_=indentation;
259 for(;indentation_ > 0;indentation_--)
260 ROFL_PIPELINE_INFO_NO_PREFIX(
" ");
263 ROFL_PIPELINE_INFO_NO_PREFIX(
"[" );
266 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-OTHER");
268 case ME_TYPE_UNKNOWN:
269 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-UNKNOWN");
271 case ME_TYPE_CHASSIS:
272 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-CHASSIS");
274 case ME_TYPE_BACKPLANE:
275 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-BACKPLANE");
277 case ME_TYPE_CONTAINER:
278 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-CONTAINER");
280 case ME_TYPE_POWER_SUPPLY:
281 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-POWER_SUPPLY");
284 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-FAN");
287 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-SENSOR");
290 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-MODULE");
293 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-PORT");
296 ROFL_PIPELINE_INFO_NO_PREFIX(
"t-STACK");
304 ROFL_PIPELINE_INFO_NO_PREFIX(
" (%p)] {name: %s}\n", me, me->name);
309 __monitoring_dump_me(indentation+1, me->inner);
312 __monitoring_dump_me(indentation, me->next);
321 if(monitoring->rwlock)
324 ROFL_PIPELINE_INFO(
"\n");
325 ROFL_PIPELINE_INFO(
"Dumping %smonitoring state(%p). Last rev: %"PRIu64
"\n", monitoring->is_snapshot?
"!SNAPSHOT! ":
"", monitoring, monitoring->last_rev);
328 __monitoring_dump_me(0, &monitoring->chassis);
331 if(monitoring->rwlock)
334 ROFL_PIPELINE_INFO_NO_PREFIX(
"\n\n");
352 if(monitoring->rwlock)
359 sn->mutex = sn->rwlock = NULL;
362 if(__clone_root_monitored_entity(monitoring, &sn->chassis, &monitoring->chassis) != ROFL_SUCCESS){
369 if(monitoring->rwlock)
373 sn->is_snapshot =
true;
Defines the locking interface used by the library. The user of the library MUST provide an implementa...
Defines the memory management interface used by the library. The user of the library MUST provide an ...
monitoring_snapshot_state_t * monitoring_get_snapshot(monitoring_state_t *monitoring)
Get a snapshot of the current monitoring state.
Defines the atomic operations API, mostly atomic increments and addition operations.
Container of the monitoring state.
void monitoring_dump(monitoring_state_t *monitoring)
Dumps the monitoring state, only meaningful for debugging purposes.
Abstraction of a monitored entity data.
monitored_entity_t * monitoring_add_monitored_entity(monitoring_state_t *monitoring, enum monitored_entity_type type, monitored_entity_t *prev, monitored_entity_t *parent)
Creates a monitored entity object and links it to the linked-list, in the position of prev OR parent...
monitored_entity_type
Monitoring entity type enum, defined according to RFC2737.
ROFL_BEGIN_DECLS rofl_result_t __monitoring_init(monitoring_state_t *monitoring)
Initializes the monitoring state.
This file contains the abstractions to monitor particular elements of the platform, like sensors or other hardware state.