f1b38e3ca4834d587aa75e93da97a86fc6289d33
[demo.git] / vnfs / VES5.0 / evel / evel-library / code / evel_library / evel_scaling_measurement.c
1 /*************************************************************************//**
2  *
3  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and 
14  * limitations under the License.
15  *
16  ****************************************************************************/
17 /**************************************************************************//**
18  * @file
19  * Implementation of EVEL functions relating to the Measurement.
20  *
21  ****************************************************************************/
22
23 #include <string.h>
24 #include <assert.h>
25 #include <stdlib.h>
26
27 #include "evel.h"
28 #include "evel_internal.h"
29 #include "evel_throttle.h"
30
31 /**************************************************************************//**
32  * Create a new Measurement event.
33  *
34  * @note    The mandatory fields on the Measurement must be supplied to this
35  *          factory function and are immutable once set.  Optional fields have
36  *          explicit setter functions, but again values may only be set once so
37  *          that the Measurement has immutable properties.
38  *
39  * @param   measurement_interval
40  *
41  * @returns pointer to the newly manufactured ::EVENT_MEASUREMENT.  If the
42  *          event is not used (i.e. posted) it must be released using
43  *          ::evel_free_event.
44  * @retval  NULL  Failed to create the event.
45  *****************************************************************************/
46 EVENT_MEASUREMENT * evel_new_measurement(double measurement_interval)
47 {
48   EVENT_MEASUREMENT * measurement = NULL;
49
50   EVEL_ENTER();
51
52   /***************************************************************************/
53   /* Check preconditions.                                                    */
54   /***************************************************************************/
55   assert(measurement_interval >= 0.0);
56
57   /***************************************************************************/
58   /* Allocate the measurement.                                               */
59   /***************************************************************************/
60   measurement = malloc(sizeof(EVENT_MEASUREMENT));
61   if (measurement == NULL)
62   {
63     log_error_state("Out of memory for Measurement");
64     goto exit_label;
65   }
66   memset(measurement, 0, sizeof(EVENT_MEASUREMENT));
67   EVEL_DEBUG("New measurement is at %lp", measurement);
68
69   /***************************************************************************/
70   /* Initialize the header & the measurement fields.                         */
71   /***************************************************************************/
72   evel_init_header(&measurement->header,"vnfScalingMeasurement");
73   measurement->header.event_domain = EVEL_DOMAIN_MEASUREMENT;
74   measurement->measurement_interval = measurement_interval;
75   dlist_initialize(&measurement->additional_info);
76   dlist_initialize(&measurement->additional_measurements);
77   dlist_initialize(&measurement->additional_objects);
78   dlist_initialize(&measurement->cpu_usage);
79   dlist_initialize(&measurement->disk_usage);
80   dlist_initialize(&measurement->mem_usage);
81   dlist_initialize(&measurement->filesystem_usage);
82   dlist_initialize(&measurement->latency_distribution);
83   dlist_initialize(&measurement->vnic_usage);
84   dlist_initialize(&measurement->codec_usage);
85   dlist_initialize(&measurement->feature_usage);
86   evel_init_option_double(&measurement->mean_request_latency);
87   evel_init_option_int(&measurement->vnfc_scaling_metric);
88   evel_init_option_int(&measurement->concurrent_sessions);
89   evel_init_option_int(&measurement->configured_entities);
90   evel_init_option_int(&measurement->media_ports_in_use);
91   evel_init_option_int(&measurement->request_rate);
92   measurement->major_version = EVEL_MEASUREMENT_MAJOR_VERSION;
93   measurement->minor_version = EVEL_MEASUREMENT_MINOR_VERSION;
94
95 exit_label:
96   EVEL_EXIT();
97   return measurement;
98 }
99
100 /**************************************************************************//**
101  * Set the Event Type property of the Measurement.
102  *
103  * @note  The property is treated as immutable: it is only valid to call
104  *        the setter once.  However, we don't assert if the caller tries to
105  *        overwrite, just ignoring the update instead.
106  *
107  * @param measurement Pointer to the Measurement.
108  * @param type        The Event Type to be set. ASCIIZ string. The caller
109  *                    does not need to preserve the value once the function
110  *                    returns.
111  *****************************************************************************/
112 void evel_measurement_type_set(EVENT_MEASUREMENT * measurement,
113                                const char * const type)
114 {
115   EVEL_ENTER();
116
117   /***************************************************************************/
118   /* Check preconditions and call evel_header_type_set.                      */
119   /***************************************************************************/
120   assert(measurement != NULL);
121   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
122   evel_header_type_set(&measurement->header, type);
123
124   EVEL_EXIT();
125 }
126
127 /**************************************************************************//**
128  * Add an additional value name/value pair to the Measurement.
129  *
130  * The name and value are null delimited ASCII strings.  The library takes
131  * a copy so the caller does not have to preserve values after the function
132  * returns.
133  *
134  * @param measurement     Pointer to the measurement.
135  * @param name      ASCIIZ string with the attribute's name.  The caller
136  *                  does not need to preserve the value once the function
137  *                  returns.
138  * @param value     ASCIIZ string with the attribute's value.  The caller
139  *                  does not need to preserve the value once the function
140  *                  returns.
141  *****************************************************************************/
142 void evel_measurement_addl_info_add(EVENT_MEASUREMENT * measurement, char * name, char * value)
143 {
144   OTHER_FIELD * addl_info = NULL;
145   EVEL_ENTER();
146
147   /***************************************************************************/
148   /* Check preconditions.                                                    */
149   /***************************************************************************/
150   assert(measurement != NULL);
151   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
152   assert(name != NULL);
153   assert(value != NULL);
154   
155   EVEL_DEBUG("Adding name=%s value=%s", name, value);
156   addl_info = malloc(sizeof(OTHER_FIELD));
157   assert(addl_info != NULL);
158   memset(addl_info, 0, sizeof(OTHER_FIELD));
159   addl_info->name = strdup(name);
160   addl_info->value = strdup(value);
161   assert(addl_info->name != NULL);
162   assert(addl_info->value != NULL);
163
164   dlist_push_last(&measurement->additional_info, addl_info);
165
166   EVEL_EXIT();
167 }
168
169 /**************************************************************************//**
170  * Set the Concurrent Sessions property of the Measurement.
171  *
172  * @note  The property is treated as immutable: it is only valid to call
173  *        the setter once.  However, we don't assert if the caller tries to
174  *        overwrite, just ignoring the update instead.
175  *
176  * @param measurement         Pointer to the Measurement.
177  * @param concurrent_sessions The Concurrent Sessions to be set.
178  *****************************************************************************/
179 void evel_measurement_conc_sess_set(EVENT_MEASUREMENT * measurement,
180                                     int concurrent_sessions)
181 {
182   EVEL_ENTER();
183
184   /***************************************************************************/
185   /* Check preconditions.                                                    */
186   /***************************************************************************/
187   assert(measurement != NULL);
188   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
189   assert(concurrent_sessions >= 0);
190
191   evel_set_option_int(&measurement->concurrent_sessions,
192                       concurrent_sessions,
193                       "Concurrent Sessions");
194   EVEL_EXIT();
195 }
196
197 /**************************************************************************//**
198  * Set the Configured Entities property of the Measurement.
199  *
200  * @note  The property is treated as immutable: it is only valid to call
201  *        the setter once.  However, we don't assert if the caller tries to
202  *        overwrite, just ignoring the update instead.
203  *
204  * @param measurement         Pointer to the Measurement.
205  * @param configured_entities The Configured Entities to be set.
206  *****************************************************************************/
207 void evel_measurement_cfg_ents_set(EVENT_MEASUREMENT * measurement,
208                                    int configured_entities)
209 {
210   EVEL_ENTER();
211
212   /***************************************************************************/
213   /* Check preconditions.                                                    */
214   /***************************************************************************/
215   assert(measurement != NULL);
216   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
217   assert(configured_entities >= 0);
218
219   evel_set_option_int(&measurement->configured_entities,
220                       configured_entities,
221                       "Configured Entities");
222   EVEL_EXIT();
223 }
224
225 /**************************************************************************//**
226  * Add an additional set of Errors to the Measurement.
227  *
228  * @note  The property is treated as immutable: it is only valid to call
229  *        the setter once.  However, we don't assert if the caller tries to
230  *        overwrite, just ignoring the update instead.
231  *
232  * @param measurement       Pointer to the measurement.
233  * @param receive_discards  The number of receive discards.
234  * @param receive_errors    The number of receive errors.
235  * @param transmit_discards The number of transmit discards.
236  * @param transmit_errors   The number of transmit errors.
237  *****************************************************************************/
238 void evel_measurement_errors_set(EVENT_MEASUREMENT * measurement,
239                                  int receive_discards,
240                                  int receive_errors,
241                                  int transmit_discards,
242                                  int transmit_errors)
243 {
244   MEASUREMENT_ERRORS * errors = NULL;
245   EVEL_ENTER();
246
247   /***************************************************************************/
248   /* Check preconditions.                                                      */
249   /***************************************************************************/
250   assert(measurement != NULL);
251   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
252   assert(receive_discards >= 0);
253   assert(receive_errors >= 0);
254   assert(transmit_discards >= 0);
255   assert(transmit_errors >= 0);
256
257   if (measurement->errors == NULL)
258   {
259     EVEL_DEBUG("Adding Errors: %d, %d; %d, %d",
260                receive_discards,
261                receive_errors,
262                transmit_discards,
263                transmit_errors);
264     errors = malloc(sizeof(MEASUREMENT_ERRORS));
265     assert(errors != NULL);
266     memset(errors, 0, sizeof(MEASUREMENT_ERRORS));
267     errors->receive_discards = receive_discards;
268     errors->receive_errors = receive_errors;
269     errors->transmit_discards = transmit_discards;
270     errors->transmit_errors = transmit_errors;
271     measurement->errors = errors;
272   }
273   else
274   {
275     errors = measurement->errors;
276     EVEL_DEBUG("Ignoring attempt to add Errors: %d, %d; %d, %d\n"
277                "Errors already set: %d, %d; %d, %d",
278                receive_discards,
279                receive_errors,
280                transmit_discards,
281                transmit_errors,
282                errors->receive_discards,
283                errors->receive_errors,
284                errors->transmit_discards,
285                errors->transmit_errors);
286   }
287
288   EVEL_EXIT();
289 }
290
291 /**************************************************************************//**
292  * Set the Mean Request Latency property of the Measurement.
293  *
294  * @note  The property is treated as immutable: it is only valid to call
295  *        the setter once.  However, we don't assert if the caller tries to
296  *        overwrite, just ignoring the update instead.
297  *
298  * @param measurement          Pointer to the Measurement.
299  * @param mean_request_latency The Mean Request Latency to be set.
300  *****************************************************************************/
301 void evel_measurement_mean_req_lat_set(EVENT_MEASUREMENT * measurement,
302                                        double mean_request_latency)
303 {
304   EVEL_ENTER();
305
306   /***************************************************************************/
307   /* Check preconditions.                                                    */
308   /***************************************************************************/
309   assert(measurement != NULL);
310   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
311   assert(mean_request_latency >= 0.0);
312
313   evel_set_option_double(&measurement->mean_request_latency,
314                          mean_request_latency,
315                          "Mean Request Latency");
316   EVEL_EXIT();
317 }
318
319
320 /**************************************************************************//**
321  * Set the Request Rate property of the Measurement.
322  *
323  * @note  The property is treated as immutable: it is only valid to call
324  *        the setter once.  However, we don't assert if the caller tries to
325  *        overwrite, just ignoring the update instead.
326  *
327  * @param measurement  Pointer to the Measurement.
328  * @param request_rate The Request Rate to be set.
329  *****************************************************************************/
330 void evel_measurement_request_rate_set(EVENT_MEASUREMENT * measurement,
331                                        int request_rate)
332 {
333   EVEL_ENTER();
334
335   /***************************************************************************/
336   /* Check preconditions.                                                    */
337   /***************************************************************************/
338   assert(measurement != NULL);
339   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
340   assert(request_rate >= 0);
341
342   evel_set_option_int(&measurement->request_rate,
343                       request_rate,
344                       "Request Rate");
345   EVEL_EXIT();
346 }
347
348 /**************************************************************************//**
349  * Add an additional CPU usage value name/value pair to the Measurement.
350  *
351  * The name and value are null delimited ASCII strings.  The library takes
352  * a copy so the caller does not have to preserve values after the function
353  * returns.
354  *
355  * @param measurement   Pointer to the measurement.
356  * @param id            ASCIIZ string with the CPU's identifier.
357  * @param usage         CPU utilization.
358  *****************************************************************************/
359 MEASUREMENT_CPU_USE *evel_measurement_new_cpu_use_add(EVENT_MEASUREMENT * measurement,
360                                  char * id, double usage)
361 {
362   MEASUREMENT_CPU_USE * cpu_use = NULL;
363   EVEL_ENTER();
364
365   /***************************************************************************/
366   /* Check assumptions.                                                      */
367   /***************************************************************************/
368   assert(measurement != NULL);
369   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
370   assert(id != NULL);
371   assert(usage >= 0.0);
372
373   /***************************************************************************/
374   /* Allocate a container for the value and push onto the list.              */
375   /***************************************************************************/
376   EVEL_DEBUG("Adding id=%s usage=%lf", id, usage);
377   cpu_use = malloc(sizeof(MEASUREMENT_CPU_USE));
378   assert(cpu_use != NULL);
379   memset(cpu_use, 0, sizeof(MEASUREMENT_CPU_USE));
380   cpu_use->id    = strdup(id);
381   cpu_use->usage = usage;
382   evel_init_option_double(&cpu_use->idle);
383   evel_init_option_double(&cpu_use->intrpt);
384   evel_init_option_double(&cpu_use->nice);
385   evel_init_option_double(&cpu_use->softirq);
386   evel_init_option_double(&cpu_use->steal);
387   evel_init_option_double(&cpu_use->sys);
388   evel_init_option_double(&cpu_use->user);
389   evel_init_option_double(&cpu_use->wait);
390
391   dlist_push_last(&measurement->cpu_usage, cpu_use);
392
393   EVEL_EXIT();
394   return cpu_use;
395 }
396
397 /**************************************************************************//**
398  * Set the CPU Idle value in measurement interval
399  *   percentage of CPU time spent in the idle task
400  *
401  * @note  The property is treated as immutable: it is only valid to call
402  *        the setter once.  However, we don't assert if the caller tries to
403  *        overwrite, just ignoring the update instead.
404  *
405  * @param cpu_use      Pointer to the CPU Use.
406  * @param val          double
407  *****************************************************************************/
408 void evel_measurement_cpu_use_idle_set(MEASUREMENT_CPU_USE *const cpu_use,
409                                     const double val)
410 {
411   EVEL_ENTER();
412   evel_set_option_double(&cpu_use->idle, val, "CPU idle time");
413   EVEL_EXIT();
414 }
415
416 /**************************************************************************//**
417  * Set the percentage of time spent servicing interrupts
418  *
419  * @note  The property is treated as immutable: it is only valid to call
420  *        the setter once.  However, we don't assert if the caller tries to
421  *        overwrite, just ignoring the update instead.
422  *
423  * @param cpu_use      Pointer to the CPU Use.
424  * @param val          double
425  *****************************************************************************/
426 void evel_measurement_cpu_use_interrupt_set(MEASUREMENT_CPU_USE * const cpu_use,
427                                     const double val)
428 {
429   EVEL_ENTER();
430   evel_set_option_double(&cpu_use->intrpt, val, "CPU interrupt value");
431   EVEL_EXIT();
432 }
433
434
435 /**************************************************************************//**
436  * Set the percentage of time spent running user space processes that have been niced
437  *
438  * @note  The property is treated as immutable: it is only valid to call
439  *        the setter once.  However, we don't assert if the caller tries to
440  *        overwrite, just ignoring the update instead.
441  *
442  * @param cpu_use      Pointer to the CPU Use.
443  * @param val          double
444  *****************************************************************************/
445 void evel_measurement_cpu_use_nice_set(MEASUREMENT_CPU_USE * const cpu_use,
446                                     const double val)
447 {
448   EVEL_ENTER();
449   evel_set_option_double(&cpu_use->nice, val, "CPU nice value");
450   EVEL_EXIT();
451 }
452
453
454 /**************************************************************************//**
455  * Set the percentage of time spent handling soft irq interrupts
456  *
457  * @note  The property is treated as immutable: it is only valid to call
458  *        the setter once.  However, we don't assert if the caller tries to
459  *        overwrite, just ignoring the update instead.
460  *
461  * @param cpu_use      Pointer to the CPU Use.
462  * @param val          double
463  *****************************************************************************/
464 void evel_measurement_cpu_use_softirq_set(MEASUREMENT_CPU_USE * const cpu_use,
465                                     const double val)
466 {
467   EVEL_ENTER();
468   evel_set_option_double(&cpu_use->softirq, val, "CPU Soft IRQ value");
469   EVEL_EXIT();
470 }
471
472 /**************************************************************************//**
473  * Set the percentage of time spent in involuntary wait
474  *
475  * @note  The property is treated as immutable: it is only valid to call
476  *        the setter once.  However, we don't assert if the caller tries to
477  *        overwrite, just ignoring the update instead.
478  *
479  * @param cpu_use      Pointer to the CPU Use.
480  * @param val          double
481  *****************************************************************************/
482 void evel_measurement_cpu_use_steal_set(MEASUREMENT_CPU_USE * const cpu_use,
483                                     const double val)
484 {
485   EVEL_ENTER();
486   evel_set_option_double(&cpu_use->steal, val, "CPU involuntary wait");
487   EVEL_EXIT();
488 }
489
490 /**************************************************************************//**
491  * Set the percentage of time spent on system tasks running the kernel
492  *
493  * @note  The property is treated as immutable: it is only valid to call
494  *        the setter once.  However, we don't assert if the caller tries to
495  *        overwrite, just ignoring the update instead.
496  *
497  * @param cpu_use      Pointer to the CPU Use.
498  * @param val          double
499  *****************************************************************************/
500 void evel_measurement_cpu_use_system_set(MEASUREMENT_CPU_USE * const cpu_use,
501                                     const double val)
502 {
503   EVEL_ENTER();
504   evel_set_option_double(&cpu_use->sys, val, "CPU System load");
505   EVEL_EXIT();
506 }
507
508
509 /**************************************************************************//**
510  * Set the percentage of time spent running un-niced user space processes
511  *
512  * @note  The property is treated as immutable: it is only valid to call
513  *        the setter once.  However, we don't assert if the caller tries to
514  *        overwrite, just ignoring the update instead.
515  *
516  * @param cpu_use      Pointer to the CPU Use.
517  * @param val          double
518  *****************************************************************************/
519 void evel_measurement_cpu_use_usageuser_set(MEASUREMENT_CPU_USE * const cpu_use,
520                                     const double val)
521 {
522   EVEL_ENTER();
523   evel_set_option_double(&cpu_use->user, val, "CPU User load value");
524   EVEL_EXIT();
525 }
526
527 /**************************************************************************//**
528  * Set the percentage of CPU time spent waiting for I/O operations to complete
529  *
530  * @note  The property is treated as immutable: it is only valid to call
531  *        the setter once.  However, we don't assert if the caller tries to
532  *        overwrite, just ignoring the update instead.
533  *
534  * @param cpu_use      Pointer to the CPU Use.
535  * @param val          double
536  *****************************************************************************/
537 void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE * const cpu_use,
538                                     const double val)
539 {
540   EVEL_ENTER();
541   evel_set_option_double(&cpu_use->wait, val, "CPU Wait IO value");
542   EVEL_EXIT();
543 }
544
545
546 /**************************************************************************//**
547  * Add an additional Memory usage value name/value pair to the Measurement.
548  *
549  * The name and value are null delimited ASCII strings.  The library takes
550  * a copy so the caller does not have to preserve values after the function
551  * returns.
552  *
553  * @param measurement   Pointer to the measurement.
554  * @param id            ASCIIZ string with the Memory identifier.
555  * @param vmidentifier  ASCIIZ string with the VM's identifier.
556  * @param membuffsz     Memory Size.
557  *
558  * @return  Returns pointer to memory use structure in measurements
559  *****************************************************************************/
560 MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add(EVENT_MEASUREMENT * measurement,
561                                  char * id,  char *vmidentifier,  double membuffsz)
562 {
563   MEASUREMENT_MEM_USE * mem_use = NULL;
564   EVEL_ENTER();
565
566   /***************************************************************************/
567   /* Check assumptions.                                                      */
568   /***************************************************************************/
569   assert(measurement != NULL);
570   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
571   assert(id != NULL);
572   assert(membuffsz >= 0.0);
573
574   /***************************************************************************/
575   /* Allocate a container for the value and push onto the list.              */
576   /***************************************************************************/
577   EVEL_DEBUG("Adding id=%s buffer size=%lf", id, membuffsz);
578   mem_use = malloc(sizeof(MEASUREMENT_MEM_USE));
579   assert(mem_use != NULL);
580   memset(mem_use, 0, sizeof(MEASUREMENT_MEM_USE));
581   mem_use->id    = strdup(id);
582   mem_use->vmid  = strdup(vmidentifier);
583   mem_use->membuffsz = membuffsz;
584   evel_init_option_double(&mem_use->memcache);
585   evel_init_option_double(&mem_use->memconfig);
586   evel_init_option_double(&mem_use->memfree);
587   evel_init_option_double(&mem_use->slabrecl);
588   evel_init_option_double(&mem_use->slabunrecl);
589   evel_init_option_double(&mem_use->memused);
590
591   assert(mem_use->id != NULL);
592
593   dlist_push_last(&measurement->mem_usage, mem_use);
594
595   EVEL_EXIT();
596   return mem_use;
597 }
598
599 /**************************************************************************//**
600  * Set kilobytes of memory used for cache
601  *
602  * @note  The property is treated as immutable: it is only valid to call
603  *        the setter once.  However, we don't assert if the caller tries to
604  *        overwrite, just ignoring the update instead.
605  *
606  * @param mem_use      Pointer to the Memory Use.
607  * @param val          double
608  *****************************************************************************/
609 void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE * const mem_use,
610                                     const double val)
611 {
612   EVEL_ENTER();
613   evel_set_option_double(&mem_use->memcache, val, "Memory cache value");
614   EVEL_EXIT();
615 }
616
617 /**************************************************************************//**
618  * Set kilobytes of memory configured in the virtual machine on which the VNFC reporting
619  *
620  * @note  The property is treated as immutable: it is only valid to call
621  *        the setter once.  However, we don't assert if the caller tries to
622  *        overwrite, just ignoring the update instead.
623  *
624  * @param mem_use      Pointer to the Memory Use.
625  * @param val          double
626  *****************************************************************************/
627 void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use,
628                                     const double val)
629 {
630   EVEL_ENTER();
631   evel_set_option_double(&mem_use->memconfig, val, "Memory configured value");
632   EVEL_EXIT();
633 }
634
635 /**************************************************************************//**
636  * Set kilobytes of physical RAM left unused by the system
637  *
638  * @note  The property is treated as immutable: it is only valid to call
639  *        the setter once.  However, we don't assert if the caller tries to
640  *        overwrite, just ignoring the update instead.
641  *
642  * @param mem_use      Pointer to the Memory Use.
643  * @param val          double
644  *****************************************************************************/
645 void evel_measurement_mem_use_memfree_set(MEASUREMENT_MEM_USE * const mem_use,
646                                     const double val)
647 {
648   EVEL_ENTER();
649   evel_set_option_double(&mem_use->memfree, val, "Memory freely available value");
650   EVEL_EXIT();
651 }
652
653 /**************************************************************************//**
654  * Set the part of the slab that can be reclaimed such as caches measured in kilobytes
655  *
656  * @note  The property is treated as immutable: it is only valid to call
657  *        the setter once.  However, we don't assert if the caller tries to
658  *        overwrite, just ignoring the update instead.
659  *
660  * @param mem_use      Pointer to the Memory Use.
661  * @param val          double
662  *****************************************************************************/
663 void evel_measurement_mem_use_slab_reclaimed_set(MEASUREMENT_MEM_USE * const mem_use,
664                                     const double val)
665 {
666   EVEL_ENTER();
667   evel_set_option_double(&mem_use->slabrecl, val, "Memory reclaimable slab set");
668   EVEL_EXIT();
669 }
670
671 /**************************************************************************//**
672  * Set the part of the slab that cannot be reclaimed such as caches measured in kilobytes
673  *
674  * @note  The property is treated as immutable: it is only valid to call
675  *        the setter once.  However, we don't assert if the caller tries to
676  *        overwrite, just ignoring the update instead.
677  *
678  * @param mem_use      Pointer to the Memory Use.
679  * @param val          double
680  *****************************************************************************/
681 void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE * const mem_use,
682                                     const double val)
683 {
684   EVEL_ENTER();
685   evel_set_option_double(&mem_use->slabunrecl, val, "Memory unreclaimable slab set");
686   EVEL_EXIT();
687 }
688
689 /**************************************************************************//**
690  * Set the total memory minus the sum of free, buffered, cached and slab memory in kilobytes
691  *
692  * @note  The property is treated as immutable: it is only valid to call
693  *        the setter once.  However, we don't assert if the caller tries to
694  *        overwrite, just ignoring the update instead.
695  *
696  * @param mem_use      Pointer to the Memory Use.
697  * @param val          double
698  *****************************************************************************/
699 void evel_measurement_mem_use_usedup_set(MEASUREMENT_MEM_USE * const mem_use,
700                                     const double val)
701 {
702   EVEL_ENTER();
703   evel_set_option_double(&mem_use->memused, val, "Memory usedup total set");
704   EVEL_EXIT();
705 }
706
707 /**************************************************************************//**
708  * Add an additional Disk usage value name/value pair to the Measurement.
709  *
710  * The name and value are null delimited ASCII strings.  The library takes
711  * a copy so the caller does not have to preserve values after the function
712  * returns.
713  *
714  * @param measurement   Pointer to the measurement.
715  * @param id            ASCIIZ string with the CPU's identifier.
716  * @param usage         Disk utilization.
717  *****************************************************************************/
718 MEASUREMENT_DISK_USE * evel_measurement_new_disk_use_add(EVENT_MEASUREMENT * measurement, char * id)
719 {
720   MEASUREMENT_DISK_USE * disk_use = NULL;
721   EVEL_ENTER();
722
723   /***************************************************************************/
724   /* Check assumptions.                                                      */
725   /***************************************************************************/
726   assert(measurement != NULL);
727   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
728   assert(id != NULL);
729
730   /***************************************************************************/
731   /* Allocate a container for the value and push onto the list.              */
732   /***************************************************************************/
733   EVEL_DEBUG("Adding id=%s disk usage", id);
734   disk_use = malloc(sizeof(MEASUREMENT_DISK_USE));
735   assert(disk_use != NULL);
736   memset(disk_use, 0, sizeof(MEASUREMENT_DISK_USE));
737   disk_use->id    = strdup(id);
738   assert(disk_use->id != NULL);
739   dlist_push_last(&measurement->disk_usage, disk_use);
740
741   evel_init_option_double(&disk_use->iotimeavg );
742   evel_init_option_double(&disk_use->iotimelast );
743   evel_init_option_double(&disk_use->iotimemax );
744   evel_init_option_double(&disk_use->iotimemin );
745   evel_init_option_double(&disk_use->mergereadavg );
746   evel_init_option_double(&disk_use->mergereadlast );
747   evel_init_option_double(&disk_use->mergereadmax );
748   evel_init_option_double(&disk_use->mergereadmin );
749   evel_init_option_double(&disk_use->mergewriteavg );
750   evel_init_option_double(&disk_use->mergewritelast );
751   evel_init_option_double(&disk_use->mergewritemax );
752   evel_init_option_double(&disk_use->mergewritemin );
753   evel_init_option_double(&disk_use->octetsreadavg );
754   evel_init_option_double(&disk_use->octetsreadlast );
755   evel_init_option_double(&disk_use->octetsreadmax );
756   evel_init_option_double(&disk_use->octetsreadmin );
757   evel_init_option_double(&disk_use->octetswriteavg );
758   evel_init_option_double(&disk_use->octetswritelast );
759   evel_init_option_double(&disk_use->octetswritemax );
760   evel_init_option_double(&disk_use->octetswritemin );
761   evel_init_option_double(&disk_use->opsreadavg );
762   evel_init_option_double(&disk_use->opsreadlast );
763   evel_init_option_double(&disk_use->opsreadmax );
764   evel_init_option_double(&disk_use->opsreadmin );
765   evel_init_option_double(&disk_use->opswriteavg );
766   evel_init_option_double(&disk_use->opswritelast );
767   evel_init_option_double(&disk_use->opswritemax );
768   evel_init_option_double(&disk_use->opswritemin );
769   evel_init_option_double(&disk_use->pendingopsavg );
770   evel_init_option_double(&disk_use->pendingopslast );
771   evel_init_option_double(&disk_use->pendingopsmax );
772   evel_init_option_double(&disk_use->pendingopsmin );
773   evel_init_option_double(&disk_use->timereadavg );
774   evel_init_option_double(&disk_use->timereadlast );
775   evel_init_option_double(&disk_use->timereadmax );
776   evel_init_option_double(&disk_use->timereadmin );
777   evel_init_option_double(&disk_use->timewriteavg );
778   evel_init_option_double(&disk_use->timewritelast );
779   evel_init_option_double(&disk_use->timewritemax );
780   evel_init_option_double(&disk_use->timewritemin );
781
782   EVEL_EXIT();
783   return disk_use;
784 }
785
786 /**************************************************************************//**
787  * Set milliseconds spent doing input/output operations over 1 sec; treat
788  * this metric as a device load percentage where 1000ms  matches 100% load;
789  * provide the average over the measurement interval
790  *
791  * @note  The property is treated as immutable: it is only valid to call
792  *        the setter once.  However, we don't assert if the caller tries to
793  *        overwrite, just ignoring the update instead.
794  *
795  * @param disk_use     Pointer to the Disk Use.
796  * @param val          double
797  *****************************************************************************/
798 void evel_measurement_disk_use_iotimeavg_set(MEASUREMENT_DISK_USE * const disk_use,
799                                     const double val) 
800 {
801   EVEL_ENTER();
802   evel_set_option_double(&disk_use->iotimeavg, val, "Disk ioload set");
803   EVEL_EXIT();
804 }
805
806 /**************************************************************************//**
807  * Set milliseconds spent doing input/output operations over 1 sec; treat
808  * this metric as a device load percentage where 1000ms  matches 100% load;
809  * provide the last value within the measurement interval
810  *
811  * @note  The property is treated as immutable: it is only valid to call
812  *        the setter once.  However, we don't assert if the caller tries to
813  *        overwrite, just ignoring the update instead.
814  *
815  * @param disk_use     Pointer to the Disk Use.
816  * @param val          double
817  *****************************************************************************/
818 void evel_measurement_disk_use_iotimelast_set(MEASUREMENT_DISK_USE * const disk_use,
819                                     const double val)
820 {
821   EVEL_ENTER();
822   evel_set_option_double(&disk_use->iotimelast, val, "Disk ioloadlast set");
823   EVEL_EXIT();
824 }
825
826 /**************************************************************************//**
827  * Set milliseconds spent doing input/output operations over 1 sec; treat
828  * this metric as a device load percentage where 1000ms  matches 100% load;
829  * provide the maximum value within the measurement interval
830  *
831  * @note  The property is treated as immutable: it is only valid to call
832  *        the setter once.  However, we don't assert if the caller tries to
833  *        overwrite, just ignoring the update instead.
834  *
835  * @param disk_use     Pointer to the Disk Use.
836  * @param val          double
837  *****************************************************************************/
838 void evel_measurement_disk_use_iotimemax_set(MEASUREMENT_DISK_USE * const disk_use,
839                                     const double val)
840 {
841   EVEL_ENTER();
842   evel_set_option_double(&disk_use->iotimemax, val, "Disk ioloadmax set");
843   EVEL_EXIT();
844 }
845
846 /**************************************************************************//**
847  * Set milliseconds spent doing input/output operations over 1 sec; treat
848  * this metric as a device load percentage where 1000ms  matches 100% load;
849  * provide the minimum value within the measurement interval
850  *
851  * @note  The property is treated as immutable: it is only valid to call
852  *        the setter once.  However, we don't assert if the caller tries to
853  *        overwrite, just ignoring the update instead.
854  *
855  * @param disk_use     Pointer to the Disk Use.
856  * @param val          double
857  *****************************************************************************/
858 void evel_measurement_disk_use_iotimemin_set(MEASUREMENT_DISK_USE * const disk_use,
859                                     const double val)
860 {
861   EVEL_ENTER();
862   evel_set_option_double(&disk_use->iotimemin, val, "Disk ioloadmin set");
863   EVEL_EXIT();
864 }
865
866 /**************************************************************************//**
867  * Set number of logical read operations that were merged into physical read
868  * operations, e.g., two logical reads were served by one physical disk access;
869  * provide the average measurement within the measurement interval
870  *
871  * @note  The property is treated as immutable: it is only valid to call
872  *        the setter once.  However, we don't assert if the caller tries to
873  *        overwrite, just ignoring the update instead.
874  *
875  * @param disk_use     Pointer to the Disk Use.
876  * @param val          double
877  *****************************************************************************/
878 void evel_measurement_disk_use_mergereadavg_set(MEASUREMENT_DISK_USE * const disk_use,
879                                     const double val)
880 {
881   EVEL_ENTER();
882   evel_set_option_double(&disk_use->mergereadavg, val, "Disk Merged read average set");
883   EVEL_EXIT();
884 }
885 /**************************************************************************//**
886  * Set number of logical read operations that were merged into physical read
887  * operations, e.g., two logical reads were served by one physical disk access;
888  * provide the last measurement within the measurement interval
889  *
890  * @note  The property is treated as immutable: it is only valid to call
891  *        the setter once.  However, we don't assert if the caller tries to
892  *        overwrite, just ignoring the update instead.
893  *
894  * @param disk_use     Pointer to the Disk Use.
895  * @param val          double
896  *****************************************************************************/
897 void evel_measurement_disk_use_mergereadlast_set(MEASUREMENT_DISK_USE * const disk_use,
898                                     const double val)
899 {
900   EVEL_ENTER();
901   evel_set_option_double(&disk_use->mergereadlast, val, "Disk mergedload last set");
902   EVEL_EXIT();
903 }
904 /**************************************************************************//**
905  * Set number of logical read operations that were merged into physical read
906  * operations, e.g., two logical reads were served by one physical disk access;
907  * provide the maximum measurement within the measurement interval
908  *
909  * @note  The property is treated as immutable: it is only valid to call
910  *        the setter once.  However, we don't assert if the caller tries to
911  *        overwrite, just ignoring the update instead.
912  *
913  * @param disk_use     Pointer to the Disk Use.
914  * @param val          double
915  *****************************************************************************/
916 void evel_measurement_disk_use_mergereadmax_set(MEASUREMENT_DISK_USE * const disk_use,
917                                     const double val)
918 {
919   EVEL_ENTER();
920   evel_set_option_double(&disk_use->mergereadmax, val, "Disk merged loadmax set");
921   EVEL_EXIT();
922 }
923
924 /**************************************************************************//**
925  * Set number of logical read operations that were merged into physical read
926  * operations, e.g., two logical reads were served by one physical disk access;
927  * provide the minimum measurement within the measurement interval
928  *
929  * @note  The property is treated as immutable: it is only valid to call
930  *        the setter once.  However, we don't assert if the caller tries to
931  *        overwrite, just ignoring the update instead.
932  *
933  * @param disk_use     Pointer to the Disk Use.
934  * @param val          double
935  *****************************************************************************/
936 void evel_measurement_disk_use_mergereadmin_set(MEASUREMENT_DISK_USE * const disk_use,
937                                     const double val)
938 {
939   EVEL_ENTER();
940   evel_set_option_double(&disk_use->mergereadmin, val, "Disk merged loadmin set");
941   EVEL_EXIT();
942 }
943 /**************************************************************************//**
944  * Set number of logical write operations that were merged into physical read
945  * operations, e.g., two logical writes were served by one physical disk access;
946  * provide the last measurement within the measurement interval
947  *
948  * @note  The property is treated as immutable: it is only valid to call
949  *        the setter once.  However, we don't assert if the caller tries to
950  *        overwrite, just ignoring the update instead.
951  *
952  * @param disk_use     Pointer to the Disk Use.
953  * @param val          double
954  *****************************************************************************/
955 void evel_measurement_disk_use_mergewritelast_set(MEASUREMENT_DISK_USE * const disk_use,
956                                     const double val)
957 {
958   EVEL_ENTER();
959   evel_set_option_double(&disk_use->mergewritelast, val, "Disk merged writelast set");
960   EVEL_EXIT();
961 }
962 /**************************************************************************//**
963  * Set number of logical write operations that were merged into physical read
964  * operations, e.g., two logical writes were served by one physical disk access;
965  * provide the maximum measurement within the measurement interval
966  *
967  * @note  The property is treated as immutable: it is only valid to call
968  *        the setter once.  However, we don't assert if the caller tries to
969  *        overwrite, just ignoring the update instead.
970  *
971  * @param disk_use     Pointer to the Disk Use.
972  * @param val          double
973  *****************************************************************************/
974 void evel_measurement_disk_use_mergewritemax_set(MEASUREMENT_DISK_USE * const disk_use,
975                                     const double val)
976 {
977   EVEL_ENTER();
978   evel_set_option_double(&disk_use->mergewritemax, val, "Disk writemax set");
979   EVEL_EXIT();
980 }
981 /**************************************************************************//**
982  * Set number of logical write operations that were merged into physical read
983  * operations, e.g., two logical writes were served by one physical disk access;
984  * provide the maximum measurement within the measurement interval
985  *
986  * @note  The property is treated as immutable: it is only valid to call
987  *        the setter once.  However, we don't assert if the caller tries to
988  *        overwrite, just ignoring the update instead.
989  *
990  * @param disk_use     Pointer to the Disk Use.
991  * @param val          double
992  *****************************************************************************/
993 void evel_measurement_disk_use_mergewritemin_set(MEASUREMENT_DISK_USE * const disk_use,
994                                     const double val)
995 {
996   EVEL_ENTER();
997   evel_set_option_double(&disk_use->mergewritemin, val, "Disk writemin set");
998   EVEL_EXIT();
999 }
1000
1001 /**************************************************************************//**
1002  * Set number of octets per second read from a disk or partition;
1003  * provide the average measurement within the measurement interval
1004  *
1005  * @note  The property is treated as immutable: it is only valid to call
1006  *        the setter once.  However, we don't assert if the caller tries to
1007  *        overwrite, just ignoring the update instead.
1008  *
1009  * @param disk_use     Pointer to the Disk Use.
1010  * @param val          double
1011  *****************************************************************************/
1012 void evel_measurement_disk_use_octetsreadavg_set(MEASUREMENT_DISK_USE * const disk_use,
1013                                     const double val)
1014 {
1015   EVEL_ENTER();
1016   evel_set_option_double(&disk_use->octetsreadavg, val, "Octets readavg set");
1017   EVEL_EXIT();
1018 }
1019
1020 /**************************************************************************//**
1021  * Set number of octets per second read from a disk or partition;
1022  * provide the last measurement within the measurement interval
1023  *
1024  * @note  The property is treated as immutable: it is only valid to call
1025  *        the setter once.  However, we don't assert if the caller tries to
1026  *        overwrite, just ignoring the update instead.
1027  *
1028  * @param disk_use     Pointer to the Disk Use.
1029  * @param val          double
1030  *****************************************************************************/
1031 void evel_measurement_disk_use_octetsreadlast_set(MEASUREMENT_DISK_USE * const disk_use,
1032                                     const double val)
1033 {
1034   EVEL_ENTER();
1035   evel_set_option_double(&disk_use->octetsreadlast, val, "Octets readlast set");
1036   EVEL_EXIT();
1037 }
1038
1039 /**************************************************************************//**
1040  * Set number of octets per second read from a disk or partition;
1041  * provide the maximum measurement within the measurement interval
1042  *
1043  * @note  The property is treated as immutable: it is only valid to call
1044  *        the setter once.  However, we don't assert if the caller tries to
1045  *        overwrite, just ignoring the update instead.
1046  *
1047  * @param disk_use     Pointer to the Disk Use.
1048  * @param val          double
1049  *****************************************************************************/
1050 void evel_measurement_disk_use_octetsreadmax_set(MEASUREMENT_DISK_USE * const disk_use,
1051                                     const double val)
1052 {
1053   EVEL_ENTER();
1054   evel_set_option_double(&disk_use->octetsreadmax, val, "Octets readmax set");
1055   EVEL_EXIT();
1056 }
1057 /**************************************************************************//**
1058  * Set number of octets per second read from a disk or partition;
1059  * provide the minimum measurement within the measurement interval
1060  *
1061  * @note  The property is treated as immutable: it is only valid to call
1062  *        the setter once.  However, we don't assert if the caller tries to
1063  *        overwrite, just ignoring the update instead.
1064  *
1065  * @param disk_use     Pointer to the Disk Use.
1066  * @param val          double
1067  *****************************************************************************/
1068 void evel_measurement_disk_use_octetsreadmin_set(MEASUREMENT_DISK_USE * const disk_use,
1069                                     const double val)
1070 {
1071   EVEL_ENTER();
1072   evel_set_option_double(&disk_use->octetsreadmin, val, "Octets readmin set");
1073   EVEL_EXIT();
1074 }
1075 /**************************************************************************//**
1076  * Set number of octets per second written to a disk or partition;
1077  * provide the average measurement within the measurement interval
1078  *
1079  * @note  The property is treated as immutable: it is only valid to call
1080  *        the setter once.  However, we don't assert if the caller tries to
1081  *        overwrite, just ignoring the update instead.
1082  *
1083  * @param disk_use     Pointer to the Disk Use.
1084  * @param val          double
1085  *****************************************************************************/
1086 void evel_measurement_disk_use_octetswriteavg_set(MEASUREMENT_DISK_USE * const disk_use,
1087                                     const double val)
1088 {
1089   EVEL_ENTER();
1090   evel_set_option_double(&disk_use->octetswriteavg, val, "Octets writeavg set");
1091   EVEL_EXIT();
1092 }
1093 /**************************************************************************//**
1094  * Set number of octets per second written to a disk or partition;
1095  * provide the last measurement within the measurement interval
1096  *
1097  * @note  The property is treated as immutable: it is only valid to call
1098  *        the setter once.  However, we don't assert if the caller tries to
1099  *        overwrite, just ignoring the update instead.
1100  *
1101  * @param disk_use     Pointer to the Disk Use.
1102  * @param val          double
1103  *****************************************************************************/
1104 void evel_measurement_disk_use_octetswritelast_set(MEASUREMENT_DISK_USE * const disk_use,
1105                                     const double val)
1106 {
1107   EVEL_ENTER();
1108   evel_set_option_double(&disk_use->octetswritelast, val, "Octets writelast set");
1109   EVEL_EXIT();
1110 }
1111 /**************************************************************************//**
1112  * Set number of octets per second written to a disk or partition;
1113  * provide the maximum measurement within the measurement interval
1114  *
1115  * @note  The property is treated as immutable: it is only valid to call
1116  *        the setter once.  However, we don't assert if the caller tries to
1117  *        overwrite, just ignoring the update instead.
1118  *
1119  * @param disk_use     Pointer to the Disk Use.
1120  * @param val          double
1121  *****************************************************************************/
1122 void evel_measurement_disk_use_octetswritemax_set(MEASUREMENT_DISK_USE * const disk_use,
1123                                     const double val)
1124 {
1125   EVEL_ENTER();
1126   evel_set_option_double(&disk_use->octetswritemax, val, "Octets writemax set");
1127   EVEL_EXIT();
1128 }
1129 /**************************************************************************//**
1130  * Set number of octets per second written to a disk or partition;
1131  * provide the minimum measurement within the measurement interval
1132  *
1133  * @note  The property is treated as immutable: it is only valid to call
1134  *        the setter once.  However, we don't assert if the caller tries to
1135  *        overwrite, just ignoring the update instead.
1136  *
1137  * @param disk_use     Pointer to the Disk Use.
1138  * @param val          double
1139  *****************************************************************************/
1140 void evel_measurement_disk_use_octetswritemin_set(MEASUREMENT_DISK_USE * const disk_use,
1141                                     const double val)
1142 {
1143   EVEL_ENTER();
1144   evel_set_option_double(&disk_use->octetswritemin, val, "Octets writemin set");
1145   EVEL_EXIT();
1146 }
1147
1148 /**************************************************************************//**
1149  * Set number of read operations per second issued to the disk;
1150  * provide the average measurement within the measurement interval
1151  *
1152  * @note  The property is treated as immutable: it is only valid to call
1153  *        the setter once.  However, we don't assert if the caller tries to
1154  *        overwrite, just ignoring the update instead.
1155  *
1156  * @param disk_use     Pointer to the Disk Use.
1157  * @param val          double
1158  *****************************************************************************/
1159 void evel_measurement_disk_use_opsreadavg_set(MEASUREMENT_DISK_USE * const disk_use,
1160                                     const double val)
1161 {
1162   EVEL_ENTER();
1163   evel_set_option_double(&disk_use->opsreadavg, val, "Disk read operation average set");
1164   EVEL_EXIT();
1165 }
1166 /**************************************************************************//**
1167  * Set number of read operations per second issued to the disk;
1168  * provide the last measurement within the measurement interval
1169  *
1170  * @note  The property is treated as immutable: it is only valid to call
1171  *        the setter once.  However, we don't assert if the caller tries to
1172  *        overwrite, just ignoring the update instead.
1173  *
1174  * @param disk_use     Pointer to the Disk Use.
1175  * @param val          double
1176  *****************************************************************************/
1177 void evel_measurement_disk_use_opsreadlast_set(MEASUREMENT_DISK_USE * const disk_use,
1178                                     const double val)
1179 {
1180   EVEL_ENTER();
1181   evel_set_option_double(&disk_use->opsreadlast, val, "Disk read operation last set");
1182   EVEL_EXIT();
1183 }
1184 /**************************************************************************//**
1185  * Set number of read operations per second issued to the disk;
1186  * provide the maximum measurement within the measurement interval
1187  *
1188  * @note  The property is treated as immutable: it is only valid to call
1189  *        the setter once.  However, we don't assert if the caller tries to
1190  *        overwrite, just ignoring the update instead.
1191  *
1192  * @param disk_use     Pointer to the Disk Use.
1193  * @param val          double
1194  *****************************************************************************/
1195 void evel_measurement_disk_use_opsreadmax_set(MEASUREMENT_DISK_USE * const disk_use,
1196                                     const double val)
1197 {
1198   EVEL_ENTER();
1199   evel_set_option_double(&disk_use->opsreadmax, val, "Disk read operation maximum set");
1200   EVEL_EXIT();
1201 }
1202 /**************************************************************************//**
1203  * Set number of read operations per second issued to the disk;
1204  * provide the minimum measurement within the measurement interval
1205  *
1206  * @note  The property is treated as immutable: it is only valid to call
1207  *        the setter once.  However, we don't assert if the caller tries to
1208  *        overwrite, just ignoring the update instead.
1209  *
1210  * @param disk_use     Pointer to the Disk Use.
1211  * @param val          double
1212  *****************************************************************************/
1213 void evel_measurement_disk_use_opsreadmin_set(MEASUREMENT_DISK_USE * const disk_use,
1214                                     const double val)
1215 {
1216   EVEL_ENTER();
1217   evel_set_option_double(&disk_use->opsreadmin, val, "Disk read operation minimum set");
1218   EVEL_EXIT();
1219 }
1220 /**************************************************************************//**
1221  * Set number of write operations per second issued to the disk;
1222  * provide the average measurement within the measurement interval
1223  *
1224  * @note  The property is treated as immutable: it is only valid to call
1225  *        the setter once.  However, we don't assert if the caller tries to
1226  *        overwrite, just ignoring the update instead.
1227  *
1228  * @param disk_use     Pointer to the Disk Use.
1229  * @param val          double
1230  *****************************************************************************/
1231 void evel_measurement_disk_use_opswriteavg_set(MEASUREMENT_DISK_USE * const disk_use,
1232                                     const double val)
1233 {
1234   EVEL_ENTER();
1235   evel_set_option_double(&disk_use->opswriteavg, val, "Disk write operation average set");
1236   EVEL_EXIT();
1237 }
1238 /**************************************************************************//**
1239  * Set number of write operations per second issued to the disk;
1240  * provide the last measurement within the measurement interval
1241  *
1242  * @note  The property is treated as immutable: it is only valid to call
1243  *        the setter once.  However, we don't assert if the caller tries to
1244  *        overwrite, just ignoring the update instead.
1245  *
1246  * @param disk_use     Pointer to the Disk Use.
1247  * @param val          double
1248  *****************************************************************************/
1249 void evel_measurement_disk_use_opswritelast_set(MEASUREMENT_DISK_USE * const disk_use,
1250                                     const double val)
1251 {
1252   EVEL_ENTER();
1253   evel_set_option_double(&disk_use->opswritelast, val, "Disk write operation last set");
1254   EVEL_EXIT();
1255 }
1256
1257 /**************************************************************************//**
1258  * Set number of write operations per second issued to the disk;
1259  * provide the maximum measurement within the measurement interval
1260  *
1261  * @note  The property is treated as immutable: it is only valid to call
1262  *        the setter once.  However, we don't assert if the caller tries to
1263  *        overwrite, just ignoring the update instead.
1264  *
1265  * @param disk_use     Pointer to the Disk Use.
1266  * @param val          double
1267  *****************************************************************************/
1268 void evel_measurement_disk_use_opswritemax_set(MEASUREMENT_DISK_USE * const disk_use,
1269                                     const double val)
1270 {
1271   EVEL_ENTER();
1272   evel_set_option_double(&disk_use->opswritemax, val, "Disk write operation maximum set");
1273   EVEL_EXIT();
1274 }
1275 /**************************************************************************//**
1276  * Set number of write operations per second issued to the disk;
1277  * provide the average measurement within the measurement interval
1278  *
1279  * @note  The property is treated as immutable: it is only valid to call
1280  *        the setter once.  However, we don't assert if the caller tries to
1281  *        overwrite, just ignoring the update instead.
1282  *
1283  * @param disk_use     Pointer to the Disk Use.
1284  * @param val          double
1285  *****************************************************************************/
1286 void evel_measurement_disk_use_opswritemin_set(MEASUREMENT_DISK_USE * const disk_use,
1287                                     const double val)
1288 {
1289   EVEL_ENTER();
1290   evel_set_option_double(&disk_use->opswritemin, val, "Disk write operation minimum set");
1291   EVEL_EXIT();
1292 }
1293
1294 /**************************************************************************//**
1295  * Set queue size of pending I/O operations per second;
1296  * provide the average measurement within the measurement interval
1297  *
1298  * @note  The property is treated as immutable: it is only valid to call
1299  *        the setter once.  However, we don't assert if the caller tries to
1300  *        overwrite, just ignoring the update instead.
1301  *
1302  * @param disk_use     Pointer to the Disk Use.
1303  * @param val          double
1304  *****************************************************************************/
1305 void evel_measurement_disk_use_pendingopsavg_set(MEASUREMENT_DISK_USE * const disk_use,
1306                                     const double val)
1307 {
1308   EVEL_ENTER();
1309   evel_set_option_double(&disk_use->pendingopsavg, val, "Disk pending operation average set");
1310   EVEL_EXIT();
1311 }
1312 /**************************************************************************//**
1313  * Set queue size of pending I/O operations per second;
1314  * provide the last measurement within the measurement interval
1315  *
1316  * @note  The property is treated as immutable: it is only valid to call
1317  *        the setter once.  However, we don't assert if the caller tries to
1318  *        overwrite, just ignoring the update instead.
1319  *
1320  * @param disk_use     Pointer to the Disk Use.
1321  * @param val          double
1322  *****************************************************************************/
1323 void evel_measurement_disk_use_pendingopslast_set(MEASUREMENT_DISK_USE * const disk_use,
1324                                     const double val)
1325 {
1326   EVEL_ENTER();
1327   evel_set_option_double(&disk_use->pendingopslast, val, "Disk pending operation last set");
1328   EVEL_EXIT();
1329 }
1330 /**************************************************************************//**
1331  * Set queue size of pending I/O operations per second;
1332  * provide the maximum measurement within the measurement interval
1333  *
1334  * @note  The property is treated as immutable: it is only valid to call
1335  *        the setter once.  However, we don't assert if the caller tries to
1336  *        overwrite, just ignoring the update instead.
1337  *
1338  * @param disk_use     Pointer to the Disk Use.
1339  * @param val          double
1340  *****************************************************************************/
1341 void evel_measurement_disk_use_pendingopsmax_set(MEASUREMENT_DISK_USE * const disk_use,
1342                                     const double val)
1343 {
1344   EVEL_ENTER();
1345   evel_set_option_double(&disk_use->pendingopsmax, val, "Disk pending operation maximum set");
1346   EVEL_EXIT();
1347 }
1348 /**************************************************************************//**
1349  * Set queue size of pending I/O operations per second;
1350  * provide the minimum measurement within the measurement interval
1351  *
1352  * @note  The property is treated as immutable: it is only valid to call
1353  *        the setter once.  However, we don't assert if the caller tries to
1354  *        overwrite, just ignoring the update instead.
1355  *
1356  * @param disk_use     Pointer to the Disk Use.
1357  * @param val          double
1358  *****************************************************************************/
1359 void evel_measurement_disk_use_pendingopsmin_set(MEASUREMENT_DISK_USE * const disk_use,
1360                                     const double val)
1361 {
1362   EVEL_ENTER();
1363   evel_set_option_double(&disk_use->pendingopsmin, val, "Disk pending operation min set");
1364   EVEL_EXIT();
1365 }
1366
1367 /**************************************************************************//**
1368  * Set milliseconds a read operation took to complete;
1369  * provide the average measurement within the measurement interval
1370  *
1371  * @note  The property is treated as immutable: it is only valid to call
1372  *        the setter once.  However, we don't assert if the caller tries to
1373  *        overwrite, just ignoring the update instead.
1374  *
1375  * @param disk_use     Pointer to the Disk Use.
1376  * @param val          double
1377  *****************************************************************************/
1378 void evel_measurement_disk_use_timereadavg_set(MEASUREMENT_DISK_USE * const disk_use,
1379                                     const double val)
1380 {
1381   EVEL_ENTER();
1382   evel_set_option_double(&disk_use->timereadavg, val, "Disk read time average set");
1383   EVEL_EXIT();
1384 }
1385 /**************************************************************************//**
1386  * Set milliseconds a read operation took to complete;
1387  * provide the last measurement within the measurement interval
1388  *
1389  * @note  The property is treated as immutable: it is only valid to call
1390  *        the setter once.  However, we don't assert if the caller tries to
1391  *        overwrite, just ignoring the update instead.
1392  *
1393  * @param disk_use     Pointer to the Disk Use.
1394  * @param val          double
1395  *****************************************************************************/
1396 void evel_measurement_disk_use_timereadlast_set(MEASUREMENT_DISK_USE * const disk_use,
1397                                     const double val)
1398 {
1399   EVEL_ENTER();
1400   evel_set_option_double(&disk_use->timereadlast, val, "Disk read time last set");
1401   EVEL_EXIT();
1402 }
1403 /**************************************************************************//**
1404  * Set milliseconds a read operation took to complete;
1405  * provide the maximum measurement within the measurement interval
1406  *
1407  * @note  The property is treated as immutable: it is only valid to call
1408  *        the setter once.  However, we don't assert if the caller tries to
1409  *        overwrite, just ignoring the update instead.
1410  *
1411  * @param disk_use     Pointer to the Disk Use.
1412  * @param val          double
1413  *****************************************************************************/
1414 void evel_measurement_disk_use_timereadmax_set(MEASUREMENT_DISK_USE * const disk_use,
1415                                     const double val)
1416 {
1417   EVEL_ENTER();
1418   evel_set_option_double(&disk_use->timereadmax, val, "Disk read time maximum set");
1419   EVEL_EXIT();
1420 }
1421 /**************************************************************************//**
1422  * Set milliseconds a read operation took to complete;
1423  * provide the minimum measurement within the measurement interval
1424  *
1425  * @note  The property is treated as immutable: it is only valid to call
1426  *        the setter once.  However, we don't assert if the caller tries to
1427  *        overwrite, just ignoring the update instead.
1428  *
1429  * @param disk_use     Pointer to the Disk Use.
1430  * @param val          double
1431  *****************************************************************************/
1432 void evel_measurement_disk_use_timereadmin_set(MEASUREMENT_DISK_USE * const disk_use,
1433                                     const double val)
1434 {
1435   EVEL_ENTER();
1436   evel_set_option_double(&disk_use->timereadmin, val, "Disk read time minimum set");
1437   EVEL_EXIT();
1438 }
1439 /**************************************************************************//**
1440  * Set milliseconds a write operation took to complete;
1441  * provide the average measurement within the measurement interval
1442  *
1443  * @note  The property is treated as immutable: it is only valid to call
1444  *        the setter once.  However, we don't assert if the caller tries to
1445  *        overwrite, just ignoring the update instead.
1446  *
1447  * @param disk_use     Pointer to the Disk Use.
1448  * @param val          double
1449  *****************************************************************************/
1450 void evel_measurement_disk_use_timewriteavg_set(MEASUREMENT_DISK_USE * const disk_use,
1451                                     const double val)
1452 {
1453   EVEL_ENTER();
1454   evel_set_option_double(&disk_use->timewriteavg, val, "Disk write time average set");
1455   EVEL_EXIT();
1456 }
1457
1458 /**************************************************************************//**
1459  * Set milliseconds a write operation took to complete;
1460  * provide the last measurement within the measurement interval
1461  *
1462  * @note  The property is treated as immutable: it is only valid to call
1463  *        the setter once.  However, we don't assert if the caller tries to
1464  *        overwrite, just ignoring the update instead.
1465  *
1466  * @param disk_use     Pointer to the Disk Use.
1467  * @param val          double
1468  *****************************************************************************/
1469 void evel_measurement_disk_use_timewritelast_set(MEASUREMENT_DISK_USE * const disk_use,
1470                                     const double val)
1471 {
1472   EVEL_ENTER();
1473   evel_set_option_double(&disk_use->timewritelast, val, "Disk write time last set");
1474   EVEL_EXIT();
1475 }
1476 /**************************************************************************//**
1477  * Set milliseconds a write operation took to complete;
1478  * provide the maximum measurement within the measurement interval
1479  *
1480  * @note  The property is treated as immutable: it is only valid to call
1481  *        the setter once.  However, we don't assert if the caller tries to
1482  *        overwrite, just ignoring the update instead.
1483  *
1484  * @param disk_use     Pointer to the Disk Use.
1485  * @param val          double
1486  *****************************************************************************/
1487 void evel_measurement_disk_use_timewritemax_set(MEASUREMENT_DISK_USE * const disk_use,
1488                                     const double val)
1489 {
1490   EVEL_ENTER();
1491   evel_set_option_double(&disk_use->timewritemax, val, "Disk write time max set");
1492   EVEL_EXIT();
1493 }
1494 /**************************************************************************//**
1495  * Set milliseconds a write operation took to complete;
1496  * provide the average measurement within the measurement interval
1497  *
1498  * @note  The property is treated as immutable: it is only valid to call
1499  *        the setter once.  However, we don't assert if the caller tries to
1500  *        overwrite, just ignoring the update instead.
1501  *
1502  * @param disk_use     Pointer to the Disk Use.
1503  * @param val          double
1504  *****************************************************************************/
1505 void evel_measurement_disk_use_timewritemin_set(MEASUREMENT_DISK_USE * const disk_use,
1506                                     const double val)
1507 {
1508   EVEL_ENTER();
1509   evel_set_option_double(&disk_use->timewritemin, val, "Disk write time min set");
1510   EVEL_EXIT();
1511 }
1512
1513 /**************************************************************************//**
1514  * Add an additional File System usage value name/value pair to the
1515  * Measurement.
1516  *
1517  * The filesystem_name is null delimited ASCII string.  The library takes a
1518  * copy so the caller does not have to preserve values after the function
1519  * returns.
1520  *
1521  * @param measurement     Pointer to the measurement.
1522  * @param filesystem_name   ASCIIZ string with the file-system's UUID.
1523  * @param block_configured  Block storage configured.
1524  * @param block_used        Block storage in use.
1525  * @param block_iops        Block storage IOPS.
1526  * @param ephemeral_configured  Ephemeral storage configured.
1527  * @param ephemeral_used        Ephemeral storage in use.
1528  * @param ephemeral_iops        Ephemeral storage IOPS.
1529  *****************************************************************************/
1530 void evel_measurement_fsys_use_add(EVENT_MEASUREMENT * measurement,
1531                                    char * filesystem_name,
1532                                    double block_configured,
1533                                    double block_used,
1534                                    int block_iops,
1535                                    double ephemeral_configured,
1536                                    double ephemeral_used,
1537                                    int ephemeral_iops)
1538 {
1539   MEASUREMENT_FSYS_USE * fsys_use = NULL;
1540   EVEL_ENTER();
1541
1542   /***************************************************************************/
1543   /* Check assumptions.                                                      */
1544   /***************************************************************************/
1545   assert(measurement != NULL);
1546   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1547   assert(filesystem_name != NULL);
1548   assert(block_configured >= 0.0);
1549   assert(block_used >= 0.0);
1550   assert(block_iops >= 0);
1551   assert(ephemeral_configured >= 0.0);
1552   assert(ephemeral_used >= 0.0);
1553   assert(ephemeral_iops >= 0);
1554
1555   /***************************************************************************/
1556   /* Allocate a container for the value and push onto the list.              */
1557   /***************************************************************************/
1558   EVEL_DEBUG("Adding filesystem_name=%s", filesystem_name);
1559   fsys_use = malloc(sizeof(MEASUREMENT_FSYS_USE));
1560   assert(fsys_use != NULL);
1561   memset(fsys_use, 0, sizeof(MEASUREMENT_FSYS_USE));
1562   fsys_use->filesystem_name = strdup(filesystem_name);
1563   fsys_use->block_configured = block_configured;
1564   fsys_use->block_used = block_used;
1565   fsys_use->block_iops = block_iops;
1566   fsys_use->ephemeral_configured = block_configured;
1567   fsys_use->ephemeral_used = ephemeral_used;
1568   fsys_use->ephemeral_iops = ephemeral_iops;
1569
1570   dlist_push_last(&measurement->filesystem_usage, fsys_use);
1571
1572   EVEL_EXIT();
1573 }
1574
1575 /**************************************************************************//**
1576  * Add a Feature usage value name/value pair to the Measurement.
1577  *
1578  * The name is null delimited ASCII string.  The library takes
1579  * a copy so the caller does not have to preserve values after the function
1580  * returns.
1581  *
1582  * @param measurement     Pointer to the measurement.
1583  * @param feature         ASCIIZ string with the feature's name.
1584  * @param utilization     Utilization of the feature.
1585  *****************************************************************************/
1586 void evel_measurement_feature_use_add(EVENT_MEASUREMENT * measurement,
1587                                       char * feature,
1588                                       int utilization)
1589 {
1590   MEASUREMENT_FEATURE_USE * feature_use = NULL;
1591   EVEL_ENTER();
1592
1593   /***************************************************************************/
1594   /* Check assumptions.                                                      */
1595   /***************************************************************************/
1596   assert(measurement != NULL);
1597   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1598   assert(feature != NULL);
1599   assert(utilization >= 0);
1600
1601   /***************************************************************************/
1602   /* Allocate a container for the value and push onto the list.              */
1603   /***************************************************************************/
1604   EVEL_DEBUG("Adding Feature=%s Use=%d", feature, utilization);
1605   feature_use = malloc(sizeof(MEASUREMENT_FEATURE_USE));
1606   assert(feature_use != NULL);
1607   memset(feature_use, 0, sizeof(MEASUREMENT_FEATURE_USE));
1608   feature_use->feature_id = strdup(feature);
1609   assert(feature_use->feature_id != NULL);
1610   feature_use->feature_utilization = utilization;
1611
1612   dlist_push_last(&measurement->feature_usage, feature_use);
1613
1614   EVEL_EXIT();
1615 }
1616
1617 /**************************************************************************//**
1618  * Add a Additional Measurement value name/value pair to the Report.
1619  *
1620  * The name is null delimited ASCII string.  The library takes
1621  * a copy so the caller does not have to preserve values after the function
1622  * returns.
1623  *
1624  * @param measurement   Pointer to the Measaurement.
1625  * @param group    ASCIIZ string with the measurement group's name.
1626  * @param name     ASCIIZ string containing the measurement's name.
1627  * @param value    ASCIIZ string containing the measurement's value.
1628  *****************************************************************************/
1629 void evel_measurement_custom_measurement_add(EVENT_MEASUREMENT * measurement,
1630                                              const char * const group,
1631                                              const char * const name,
1632                                              const char * const value)
1633 {
1634   MEASUREMENT_GROUP * measurement_group = NULL;
1635   CUSTOM_MEASUREMENT * custom_measurement = NULL;
1636   DLIST_ITEM * item = NULL;
1637   EVEL_ENTER();
1638
1639   /***************************************************************************/
1640   /* Check assumptions.                                                      */
1641   /***************************************************************************/
1642   assert(measurement != NULL);
1643   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1644   assert(group != NULL);
1645   assert(name != NULL);
1646   assert(value != NULL);
1647
1648   /***************************************************************************/
1649   /* Allocate a container for the name/value pair.                           */
1650   /***************************************************************************/
1651   EVEL_DEBUG("Adding Measurement Group=%s Name=%s Value=%s",
1652               group, name, value);
1653   custom_measurement = malloc(sizeof(CUSTOM_MEASUREMENT));
1654   assert(custom_measurement != NULL);
1655   memset(custom_measurement, 0, sizeof(CUSTOM_MEASUREMENT));
1656   custom_measurement->name = strdup(name);
1657   assert(custom_measurement->name != NULL);
1658   custom_measurement->value = strdup(value);
1659   assert(custom_measurement->value != NULL);
1660
1661   /***************************************************************************/
1662   /* See if we have that group already.                                      */
1663   /***************************************************************************/
1664   item = dlist_get_first(&measurement->additional_measurements);
1665   while (item != NULL)
1666   {
1667     measurement_group = (MEASUREMENT_GROUP *) item->item;
1668     assert(measurement_group != NULL);
1669
1670     EVEL_DEBUG("Got measurement group %s", measurement_group->name);
1671     if (strcmp(group, measurement_group->name) == 0)
1672     {
1673       EVEL_DEBUG("Found existing Measurement Group");
1674       break;
1675     }
1676     item = dlist_get_next(item);
1677   }
1678
1679   /***************************************************************************/
1680   /* If we didn't have the group already, create it.                         */
1681   /***************************************************************************/
1682   if (item == NULL)
1683   {
1684     EVEL_DEBUG("Creating new Measurement Group");
1685     measurement_group = malloc(sizeof(MEASUREMENT_GROUP));
1686     assert(measurement_group != NULL);
1687     memset(measurement_group, 0, sizeof(MEASUREMENT_GROUP));
1688     measurement_group->name = strdup(group);
1689     assert(measurement_group->name != NULL);
1690     dlist_initialize(&measurement_group->measurements);
1691     dlist_push_last(&measurement->additional_measurements, measurement_group);
1692   }
1693
1694   /***************************************************************************/
1695   /* If we didn't have the group already, create it.                         */
1696   /***************************************************************************/
1697   dlist_push_last(&measurement_group->measurements, custom_measurement);
1698
1699   EVEL_EXIT();
1700 }
1701
1702 /**************************************************************************//**
1703  * Add a Codec usage value name/value pair to the Measurement.
1704  *
1705  * The name is null delimited ASCII string.  The library takes
1706  * a copy so the caller does not have to preserve values after the function
1707  * returns.
1708  *
1709  * @param measurement     Pointer to the measurement.
1710  * @param codec           ASCIIZ string with the codec's name.
1711  * @param utilization     Number of codecs in use.
1712  *****************************************************************************/
1713 void evel_measurement_codec_use_add(EVENT_MEASUREMENT * measurement,
1714                                     char * codec,
1715                                     int utilization)
1716 {
1717   MEASUREMENT_CODEC_USE * codec_use = NULL;
1718   EVEL_ENTER();
1719
1720   /***************************************************************************/
1721   /* Check assumptions.                                                      */
1722   /***************************************************************************/
1723   assert(measurement != NULL);
1724   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1725   assert(codec != NULL);
1726   assert(utilization >= 0.0);
1727
1728   /***************************************************************************/
1729   /* Allocate a container for the value and push onto the list.              */
1730   /***************************************************************************/
1731   EVEL_DEBUG("Adding Codec=%s Use=%d", codec, utilization);
1732   codec_use = malloc(sizeof(MEASUREMENT_CODEC_USE));
1733   assert(codec_use != NULL);
1734   memset(codec_use, 0, sizeof(MEASUREMENT_CODEC_USE));
1735   codec_use->codec_id = strdup(codec);
1736   assert(codec_use->codec_id != NULL);
1737   codec_use->number_in_use = utilization;
1738
1739   dlist_push_last(&measurement->codec_usage, codec_use);
1740
1741   EVEL_EXIT();
1742 }
1743
1744
1745 /**************************************************************************//**
1746  * Set the Media Ports in Use property of the Measurement.
1747  *
1748  * @note  The property is treated as immutable: it is only valid to call
1749  *        the setter once.  However, we don't assert if the caller tries to
1750  *        overwrite, just ignoring the update instead.
1751  *
1752  * @param measurement         Pointer to the measurement.
1753  * @param media_ports_in_use  The media port usage to set.
1754  *****************************************************************************/
1755 void evel_measurement_media_port_use_set(EVENT_MEASUREMENT * measurement,
1756                                          int media_ports_in_use)
1757 {
1758   EVEL_ENTER();
1759
1760   /***************************************************************************/
1761   /* Check preconditions.                                                    */
1762   /***************************************************************************/
1763   assert(measurement != NULL);
1764   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1765   assert(media_ports_in_use >= 0);
1766
1767   evel_set_option_int(&measurement->media_ports_in_use,
1768                       media_ports_in_use,
1769                       "Media Ports In Use");
1770   EVEL_EXIT();
1771 }
1772
1773 /**************************************************************************//**
1774  * Set the VNFC Scaling Metric property of the Measurement.
1775  *
1776  * @note  The property is treated as immutable: it is only valid to call
1777  *        the setter once.  However, we don't assert if the caller tries to
1778  *        overwrite, just ignoring the update instead.
1779  *
1780  * @param measurement     Pointer to the measurement.
1781  * @param scaling_metric  The scaling metric to set.
1782  *****************************************************************************/
1783 void evel_measurement_vnfc_scaling_metric_set(EVENT_MEASUREMENT * measurement,
1784                                               int scaling_metric)
1785 {
1786   EVEL_ENTER();
1787
1788   /***************************************************************************/
1789   /* Check preconditions.                                                    */
1790   /***************************************************************************/
1791   assert(measurement != NULL);
1792   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1793   assert(scaling_metric >= 0.0);
1794
1795   evel_set_option_int(&measurement->vnfc_scaling_metric,
1796                          scaling_metric,
1797                          "VNFC Scaling Metric");
1798   EVEL_EXIT();
1799 }
1800
1801 /**************************************************************************//**
1802  * Create a new Latency Bucket to be added to a Measurement event.
1803  *
1804  * @note    The mandatory fields on the ::MEASUREMENT_LATENCY_BUCKET must be
1805  *          supplied to this factory function and are immutable once set.
1806  *          Optional fields have explicit setter functions, but again values
1807  *          may only be set once so that the ::MEASUREMENT_LATENCY_BUCKET has
1808  *          immutable properties.
1809  *
1810  * @param count         Count of events in this bucket.
1811  *
1812  * @returns pointer to the newly manufactured ::MEASUREMENT_LATENCY_BUCKET.
1813  *          If the structure is not used it must be released using free.
1814  * @retval  NULL  Failed to create the Latency Bucket.
1815  *****************************************************************************/
1816 MEASUREMENT_LATENCY_BUCKET * evel_new_meas_latency_bucket(const int count)
1817 {
1818   MEASUREMENT_LATENCY_BUCKET * bucket;
1819
1820   EVEL_ENTER();
1821
1822   /***************************************************************************/
1823   /* Check preconditions.                                                    */
1824   /***************************************************************************/
1825   assert(count >= 0);
1826
1827   /***************************************************************************/
1828   /* Allocate, then set Mandatory Parameters.                                */
1829   /***************************************************************************/
1830   EVEL_DEBUG("Creating bucket, count = %d", count);
1831   bucket = malloc(sizeof(MEASUREMENT_LATENCY_BUCKET));
1832   assert(bucket != NULL);
1833
1834   /***************************************************************************/
1835   /* Set Mandatory Parameters.                                               */
1836   /***************************************************************************/
1837   bucket->count = count;
1838
1839   /***************************************************************************/
1840   /* Initialize Optional Parameters.                                         */
1841   /***************************************************************************/
1842   evel_init_option_double(&bucket->high_end);
1843   evel_init_option_double(&bucket->low_end);
1844
1845   EVEL_EXIT();
1846
1847   return bucket;
1848 }
1849
1850 /**************************************************************************//**
1851  * Set the High End property of the Measurement Latency Bucket.
1852  *
1853  * @note  The property is treated as immutable: it is only valid to call
1854  *        the setter once.  However, we don't assert if the caller tries to
1855  *        overwrite, just ignoring the update instead.
1856  *
1857  * @param bucket        Pointer to the Measurement Latency Bucket.
1858  * @param high_end      High end of the bucket's range.
1859  *****************************************************************************/
1860 void evel_meas_latency_bucket_high_end_set(
1861                                      MEASUREMENT_LATENCY_BUCKET * const bucket,
1862                                      const double high_end)
1863 {
1864   EVEL_ENTER();
1865
1866   /***************************************************************************/
1867   /* Check preconditions.                                                    */
1868   /***************************************************************************/
1869   assert(high_end >= 0.0);
1870   evel_set_option_double(&bucket->high_end, high_end, "High End");
1871
1872   EVEL_EXIT();
1873 }
1874
1875 /**************************************************************************//**
1876  * Set the Low End property of the Measurement Latency Bucket.
1877  *
1878  * @note  The property is treated as immutable: it is only valid to call
1879  *        the setter once.  However, we don't assert if the caller tries to
1880  *        overwrite, just ignoring the update instead.
1881  *
1882  * @param bucket        Pointer to the Measurement Latency Bucket.
1883  * @param low_end       Low end of the bucket's range.
1884  *****************************************************************************/
1885 void evel_meas_latency_bucket_low_end_set(
1886                                      MEASUREMENT_LATENCY_BUCKET * const bucket,
1887                                      const double low_end)
1888 {
1889   EVEL_ENTER();
1890
1891   /***************************************************************************/
1892   /* Check preconditions.                                                    */
1893   /***************************************************************************/
1894   assert(low_end >= 0.0);
1895   evel_set_option_double(&bucket->low_end, low_end, "Low End");
1896   EVEL_EXIT();
1897 }
1898
1899 /**************************************************************************//**
1900  * Add an additional Measurement Latency Bucket to the specified event.
1901  *
1902  * @param measurement   Pointer to the Measurement event.
1903  * @param bucket        Pointer to the Measurement Latency Bucket to add.
1904  *****************************************************************************/
1905 void evel_meas_latency_bucket_add(EVENT_MEASUREMENT * const measurement,
1906                                   MEASUREMENT_LATENCY_BUCKET * const bucket)
1907 {
1908   EVEL_ENTER();
1909
1910   /***************************************************************************/
1911   /* Check preconditions.                                                    */
1912   /***************************************************************************/
1913   assert(measurement != NULL);
1914   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
1915   assert(bucket != NULL);
1916   dlist_push_last(&measurement->latency_distribution, bucket);
1917
1918   EVEL_EXIT();
1919 }
1920
1921 /**************************************************************************//**
1922  * Add an additional Latency Distribution bucket to the Measurement.
1923  *
1924  * This function implements the previous API, purely for convenience.
1925  *
1926  * @param measurement   Pointer to the measurement.
1927  * @param low_end       Low end of the bucket's range.
1928  * @param high_end      High end of the bucket's range.
1929  * @param count         Count of events in this bucket.
1930  *****************************************************************************/
1931 void evel_measurement_latency_add(EVENT_MEASUREMENT * const measurement,
1932                                   const double low_end,
1933                                   const double high_end,
1934                                   const int count)
1935 {
1936   MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
1937
1938   EVEL_ENTER();
1939
1940   /***************************************************************************/
1941   /* Trust the assertions in the underlying methods.                         */
1942   /***************************************************************************/
1943   bucket = evel_new_meas_latency_bucket(count);
1944   evel_meas_latency_bucket_low_end_set(bucket, low_end);
1945   evel_meas_latency_bucket_high_end_set(bucket, high_end);
1946   evel_meas_latency_bucket_add(measurement, bucket);
1947
1948   EVEL_EXIT();
1949 }
1950
1951 /**************************************************************************//**
1952  * Create a new vNIC Use to be added to a Measurement event.
1953  *
1954  * @note    The mandatory fields on the ::MEASUREMENT_VNIC_PERFORMANCE must be supplied
1955  *          to this factory function and are immutable once set. Optional
1956  *          fields have explicit setter functions, but again values may only be
1957  *          set once so that the ::MEASUREMENT_VNIC_PERFORMANCE has immutable
1958  *          properties.
1959  *
1960  * @param vnic_id               ASCIIZ string with the vNIC's ID.
1961  * @param val_suspect           True or false confidence in data.
1962  *
1963  * @returns pointer to the newly manufactured ::MEASUREMENT_VNIC_PERFORMANCE.
1964  *          If the structure is not used it must be released using
1965  *          ::evel_measurement_free_vnic_performance.
1966  * @retval  NULL  Failed to create the vNIC Use.
1967  *****************************************************************************/
1968 MEASUREMENT_VNIC_PERFORMANCE * evel_measurement_new_vnic_performance(char * const vnic_id,
1969                                                      char * const val_suspect)
1970 {
1971   MEASUREMENT_VNIC_PERFORMANCE * vnic_performance;
1972
1973   EVEL_ENTER();
1974
1975   /***************************************************************************/
1976   /* Check preconditions.                                                    */
1977   /***************************************************************************/
1978   assert(vnic_id != NULL);
1979   assert(!strcmp(val_suspect,"true") || !strcmp(val_suspect,"false"));
1980
1981   /***************************************************************************/
1982   /* Allocate, then set Mandatory Parameters.                                */
1983   /***************************************************************************/
1984   EVEL_DEBUG("Adding VNIC ID=%s", vnic_id);
1985   vnic_performance = malloc(sizeof(MEASUREMENT_VNIC_PERFORMANCE));
1986   assert(vnic_performance != NULL);
1987   vnic_performance->vnic_id = strdup(vnic_id);
1988   vnic_performance->valuesaresuspect = strdup(val_suspect);
1989
1990   /***************************************************************************/
1991   /* Initialize Optional Parameters.                                         */
1992   /***************************************************************************/
1993   evel_init_option_double(&vnic_performance-> recvd_bcast_packets_acc);
1994   evel_init_option_double(&vnic_performance-> recvd_bcast_packets_delta);
1995   evel_init_option_double(&vnic_performance-> recvd_discarded_packets_acc);
1996   evel_init_option_double(&vnic_performance-> recvd_discarded_packets_delta);
1997   evel_init_option_double(&vnic_performance-> recvd_error_packets_acc);
1998   evel_init_option_double(&vnic_performance-> recvd_error_packets_delta);
1999   evel_init_option_double(&vnic_performance-> recvd_mcast_packets_acc);
2000   evel_init_option_double(&vnic_performance-> recvd_mcast_packets_delta);
2001   evel_init_option_double(&vnic_performance-> recvd_octets_acc);
2002   evel_init_option_double(&vnic_performance-> recvd_octets_delta);
2003   evel_init_option_double(&vnic_performance-> recvd_total_packets_acc);
2004   evel_init_option_double(&vnic_performance-> recvd_total_packets_delta);
2005   evel_init_option_double(&vnic_performance-> recvd_ucast_packets_acc);
2006   evel_init_option_double(&vnic_performance-> recvd_ucast_packets_delta);
2007   evel_init_option_double(&vnic_performance-> tx_bcast_packets_acc);
2008   evel_init_option_double(&vnic_performance-> tx_bcast_packets_delta);
2009   evel_init_option_double(&vnic_performance-> tx_discarded_packets_acc);
2010   evel_init_option_double(&vnic_performance-> tx_discarded_packets_delta);
2011   evel_init_option_double(&vnic_performance-> tx_error_packets_acc);
2012   evel_init_option_double(&vnic_performance-> tx_error_packets_delta);
2013   evel_init_option_double(&vnic_performance-> tx_mcast_packets_acc);
2014   evel_init_option_double(&vnic_performance-> tx_mcast_packets_delta);
2015   evel_init_option_double(&vnic_performance-> tx_octets_acc);
2016   evel_init_option_double(&vnic_performance-> tx_octets_delta);
2017   evel_init_option_double(&vnic_performance-> tx_total_packets_acc);
2018   evel_init_option_double(&vnic_performance-> tx_total_packets_delta);
2019   evel_init_option_double(&vnic_performance-> tx_ucast_packets_acc);
2020   evel_init_option_double(&vnic_performance-> tx_ucast_packets_delta);
2021
2022   EVEL_EXIT();
2023
2024   return vnic_performance;
2025 }
2026
2027 /**************************************************************************//**
2028  * Free a vNIC Use.
2029  *
2030  * Free off the ::MEASUREMENT_VNIC_PERFORMANCE supplied.  Will free all the contained
2031  * allocated memory.
2032  *
2033  * @note It does not free the vNIC Use itself, since that may be part of a
2034  * larger structure.
2035  *****************************************************************************/
2036 void evel_measurement_free_vnic_performance(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance)
2037 {
2038   EVEL_ENTER();
2039
2040   /***************************************************************************/
2041   /* Check preconditions.                                                    */
2042   /***************************************************************************/
2043   assert(vnic_performance != NULL);
2044   assert(vnic_performance->vnic_id != NULL);
2045   assert(vnic_performance->valuesaresuspect != NULL);
2046
2047   /***************************************************************************/
2048   /* Free the duplicated string.                                             */
2049   /***************************************************************************/
2050   free(vnic_performance->vnic_id);
2051   free(vnic_performance->valuesaresuspect);
2052   vnic_performance->vnic_id = NULL;
2053
2054   EVEL_EXIT();
2055 }
2056
2057 /**************************************************************************//**
2058  * Set the Accumulated Broadcast Packets Received in measurement interval
2059  * property of the vNIC performance.
2060  *
2061  * @note  The property is treated as immutable: it is only valid to call
2062  *        the setter once.  However, we don't assert if the caller tries to
2063  *        overwrite, just ignoring the update instead.
2064  *
2065  * @param vnic_performance      Pointer to the vNIC Use.
2066  * @param recvd_bcast_packets_acc
2067  *****************************************************************************/
2068 void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2069                                     const double recvd_bcast_packets_acc)
2070 {
2071   EVEL_ENTER();
2072
2073   /***************************************************************************/
2074   /* Check preconditions.                                                    */
2075   /***************************************************************************/
2076   assert(recvd_bcast_packets_acc >= 0.0);
2077
2078   evel_set_option_double(&vnic_performance->recvd_bcast_packets_acc,
2079                       recvd_bcast_packets_acc,
2080                       "Broadcast Packets accumulated");
2081
2082   EVEL_EXIT();
2083 }
2084
2085 /**************************************************************************//**
2086  * Set the Delta Broadcast Packets Received in measurement interval
2087  * property of the vNIC performance.
2088  *
2089  * @note  The property is treated as immutable: it is only valid to call
2090  *        the setter once.  However, we don't assert if the caller tries to
2091  *        overwrite, just ignoring the update instead.
2092  *
2093  * @param vnic_performance      Pointer to the vNIC Use.
2094  * @param recvd_bcast_packets_delta
2095  *****************************************************************************/
2096 void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2097                                     const double recvd_bcast_packets_delta)
2098 {
2099   EVEL_ENTER();
2100
2101   /***************************************************************************/
2102   /* Check preconditions.                                                    */
2103   /***************************************************************************/
2104   assert(recvd_bcast_packets_delta >= 0.0);
2105
2106   evel_set_option_double(&vnic_performance->recvd_bcast_packets_delta,
2107                       recvd_bcast_packets_delta,
2108                       "Delta Broadcast Packets recieved");
2109
2110   EVEL_EXIT();
2111 }
2112
2113
2114 /**************************************************************************//**
2115  * Set the Discarded Packets Received in measurement interval
2116  * property of the vNIC performance.
2117  *
2118  * @note  The property is treated as immutable: it is only valid to call
2119  *        the setter once.  However, we don't assert if the caller tries to
2120  *        overwrite, just ignoring the update instead.
2121  *
2122  * @param vnic_performance      Pointer to the vNIC Use.
2123  * @param recvd_discard_packets_acc
2124  *****************************************************************************/
2125 void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2126                                     const double recvd_discard_packets_acc)
2127 {
2128   EVEL_ENTER();
2129
2130   /***************************************************************************/
2131   /* Check preconditions.                                                    */
2132   /***************************************************************************/
2133   assert(recvd_discard_packets_acc >= 0.0);
2134
2135   evel_set_option_double(&vnic_performance->recvd_discarded_packets_acc,
2136                       recvd_discard_packets_acc,
2137                       "Discarded Packets accumulated");
2138
2139   EVEL_EXIT();
2140 }
2141
2142 /**************************************************************************//**
2143  * Set the Delta Discarded Packets Received in measurement interval
2144  * property of the vNIC performance.
2145  *
2146  * @note  The property is treated as immutable: it is only valid to call
2147  *        the setter once.  However, we don't assert if the caller tries to
2148  *        overwrite, just ignoring the update instead.
2149  *
2150  * @param vnic_performance      Pointer to the vNIC Use.
2151  * @param recvd_discard_packets_delta
2152  *****************************************************************************/
2153 void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2154                                     const double recvd_discard_packets_delta)
2155 {
2156   EVEL_ENTER();
2157
2158   /***************************************************************************/
2159   /* Check preconditions.                                                    */
2160   /***************************************************************************/
2161   assert(recvd_discard_packets_delta >= 0.0);
2162
2163   evel_set_option_double(&vnic_performance->recvd_discarded_packets_delta,
2164                       recvd_discard_packets_delta,
2165                       "Delta Discarded Packets recieved");
2166
2167   EVEL_EXIT();
2168 }
2169
2170
2171 /**************************************************************************//**
2172  * Set the Error Packets Received in measurement interval
2173  * property of the vNIC performance.
2174  *
2175  * @note  The property is treated as immutable: it is only valid to call
2176  *        the setter once.  However, we don't assert if the caller tries to
2177  *        overwrite, just ignoring the update instead.
2178  *
2179  * @param vnic_performance      Pointer to the vNIC Use.
2180  * @param recvd_error_packets_acc
2181  *****************************************************************************/
2182 void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2183                                     const double recvd_error_packets_acc)
2184 {
2185   EVEL_ENTER();
2186
2187   /***************************************************************************/
2188   /* Check preconditions.                                                    */
2189   /***************************************************************************/
2190   assert(recvd_error_packets_acc >= 0.0);
2191
2192   evel_set_option_double(&vnic_performance->recvd_error_packets_acc,
2193                       recvd_error_packets_acc,
2194                       "Error Packets received accumulated");
2195
2196   EVEL_EXIT();
2197 }
2198
2199 /**************************************************************************//**
2200  * Set the Delta Error Packets Received in measurement interval
2201  * property of the vNIC performance.
2202  *
2203  * @note  The property is treated as immutable: it is only valid to call
2204  *        the setter once.  However, we don't assert if the caller tries to
2205  *        overwrite, just ignoring the update instead.
2206  *
2207  * @param vnic_performance      Pointer to the vNIC Use.
2208  * @param recvd_error_packets_delta
2209  *****************************************************************************/
2210 void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2211                                     const double recvd_error_packets_delta)
2212 {
2213   EVEL_ENTER();
2214
2215   /***************************************************************************/
2216   /* Check preconditions.                                                    */
2217   /***************************************************************************/
2218   assert(recvd_error_packets_delta >= 0.0);
2219
2220   evel_set_option_double(&vnic_performance->recvd_error_packets_delta,
2221                       recvd_error_packets_delta,
2222                       "Delta Error Packets recieved");
2223
2224   EVEL_EXIT();
2225 }
2226
2227 /**************************************************************************//**
2228  * Set the Accumulated Multicast Packets Received in measurement interval
2229  * property of the vNIC performance.
2230  *
2231  * @note  The property is treated as immutable: it is only valid to call
2232  *        the setter once.  However, we don't assert if the caller tries to
2233  *        overwrite, just ignoring the update instead.
2234  *
2235  * @param vnic_performance      Pointer to the vNIC Use.
2236  * @param recvd_mcast_packets_acc
2237  *****************************************************************************/
2238 void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2239                                     const double recvd_mcast_packets_acc)
2240 {
2241   EVEL_ENTER();
2242
2243   /***************************************************************************/
2244   /* Check preconditions.                                                    */
2245   /***************************************************************************/
2246   assert(recvd_mcast_packets_acc >= 0.0);
2247
2248   evel_set_option_double(&vnic_performance->recvd_mcast_packets_acc,
2249                       recvd_mcast_packets_acc,
2250                       "Multicast Packets accumulated");
2251
2252   EVEL_EXIT();
2253 }
2254
2255 /**************************************************************************//**
2256  * Set the Delta Multicast Packets Received in measurement interval
2257  * property of the vNIC performance.
2258  *
2259  * @note  The property is treated as immutable: it is only valid to call
2260  *        the setter once.  However, we don't assert if the caller tries to
2261  *        overwrite, just ignoring the update instead.
2262  *
2263  * @param vnic_performance      Pointer to the vNIC Use.
2264  * @param recvd_mcast_packets_delta
2265  *****************************************************************************/
2266 void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2267                                     const double recvd_mcast_packets_delta)
2268 {
2269   EVEL_ENTER();
2270
2271   /***************************************************************************/
2272   /* Check preconditions.                                                    */
2273   /***************************************************************************/
2274   assert(recvd_mcast_packets_delta >= 0.0);
2275
2276   evel_set_option_double(&vnic_performance->recvd_mcast_packets_delta,
2277                       recvd_mcast_packets_delta,
2278                       "Delta Multicast Packets recieved");
2279
2280   EVEL_EXIT();
2281 }
2282
2283 /**************************************************************************//**
2284  * Set the Accumulated Octets Received in measurement interval
2285  * property of the vNIC performance.
2286  *
2287  * @note  The property is treated as immutable: it is only valid to call
2288  *        the setter once.  However, we don't assert if the caller tries to
2289  *        overwrite, just ignoring the update instead.
2290  *
2291  * @param vnic_performance      Pointer to the vNIC Use.
2292  * @param recvd_octets_acc
2293  *****************************************************************************/
2294 void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2295                                     const double recvd_octets_acc)
2296 {
2297   EVEL_ENTER();
2298
2299   /***************************************************************************/
2300   /* Check preconditions.                                                    */
2301   /***************************************************************************/
2302   assert(recvd_octets_acc >= 0.0);
2303
2304   evel_set_option_double(&vnic_performance->recvd_octets_acc,
2305                       recvd_octets_acc,
2306                       "Octets received accumulated");
2307
2308   EVEL_EXIT();
2309 }
2310
2311 /**************************************************************************//**
2312  * Set the Delta Octets Received in measurement interval
2313  * property of the vNIC performance.
2314  *
2315  * @note  The property is treated as immutable: it is only valid to call
2316  *        the setter once.  However, we don't assert if the caller tries to
2317  *        overwrite, just ignoring the update instead.
2318  *
2319  * @param vnic_performance      Pointer to the vNIC Use.
2320  * @param recvd_octets_delta
2321  *****************************************************************************/
2322 void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2323                                     const double recvd_octets_delta)
2324 {
2325   EVEL_ENTER();
2326
2327   /***************************************************************************/
2328   /* Check preconditions.                                                    */
2329   /***************************************************************************/
2330   assert(recvd_octets_delta >= 0.0);
2331
2332   evel_set_option_double(&vnic_performance->recvd_octets_delta,
2333                       recvd_octets_delta,
2334                       "Delta Octets recieved");
2335
2336   EVEL_EXIT();
2337 }
2338
2339 /**************************************************************************//**
2340  * Set the Accumulated Total Packets Received in measurement interval
2341  * property of the vNIC performance.
2342  *
2343  * @note  The property is treated as immutable: it is only valid to call
2344  *        the setter once.  However, we don't assert if the caller tries to
2345  *        overwrite, just ignoring the update instead.
2346  *
2347  * @param vnic_performance      Pointer to the vNIC Use.
2348  * @param recvd_total_packets_acc
2349  *****************************************************************************/
2350 void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2351                                     const double recvd_total_packets_acc)
2352 {
2353   EVEL_ENTER();
2354
2355   /***************************************************************************/
2356   /* Check preconditions.                                                    */
2357   /***************************************************************************/
2358   assert(recvd_total_packets_acc >= 0.0);
2359
2360   evel_set_option_double(&vnic_performance->recvd_total_packets_acc,
2361                       recvd_total_packets_acc,
2362                       "Total Packets accumulated");
2363
2364   EVEL_EXIT();
2365 }
2366
2367 /**************************************************************************//**
2368  * Set the Delta Total Packets Received in measurement interval
2369  * property of the vNIC performance.
2370  *
2371  * @note  The property is treated as immutable: it is only valid to call
2372  *        the setter once.  However, we don't assert if the caller tries to
2373  *        overwrite, just ignoring the update instead.
2374  *
2375  * @param vnic_performance      Pointer to the vNIC Use.
2376  * @param recvd_total_packets_delta
2377  *****************************************************************************/
2378 void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2379                                     const double recvd_total_packets_delta)
2380 {
2381   EVEL_ENTER();
2382
2383   /***************************************************************************/
2384   /* Check preconditions.                                                    */
2385   /***************************************************************************/
2386   assert(recvd_total_packets_delta >= 0.0);
2387
2388   evel_set_option_double(&vnic_performance->recvd_total_packets_delta,
2389                       recvd_total_packets_delta,
2390                       "Delta Total Packets recieved");
2391
2392   EVEL_EXIT();
2393 }
2394
2395 /**************************************************************************//**
2396  * Set the Accumulated Unicast Packets Received in measurement interval
2397  * property of the vNIC performance.
2398  *
2399  * @note  The property is treated as immutable: it is only valid to call
2400  *        the setter once.  However, we don't assert if the caller tries to
2401  *        overwrite, just ignoring the update instead.
2402  *
2403  * @param vnic_performance      Pointer to the vNIC Use.
2404  * @param recvd_ucast_packets_acc
2405  *****************************************************************************/
2406 void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2407                                     const double recvd_ucast_packets_acc)
2408 {
2409   EVEL_ENTER();
2410
2411   /***************************************************************************/
2412   /* Check preconditions.                                                    */
2413   /***************************************************************************/
2414   assert(recvd_ucast_packets_acc >= 0.0);
2415
2416   evel_set_option_double(&vnic_performance->recvd_ucast_packets_acc,
2417                       recvd_ucast_packets_acc,
2418                       "Unicast Packets received accumulated");
2419
2420   EVEL_EXIT();
2421 }
2422
2423 /**************************************************************************//**
2424  * Set the Delta Unicast packets Received in measurement interval
2425  * property of the vNIC performance.
2426  *
2427  * @note  The property is treated as immutable: it is only valid to call
2428  *        the setter once.  However, we don't assert if the caller tries to
2429  *        overwrite, just ignoring the update instead.
2430  *
2431  * @param vnic_performance      Pointer to the vNIC Use.
2432  * @param recvd_ucast_packets_delta
2433  *****************************************************************************/
2434 void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2435                                     const double recvd_ucast_packets_delta)
2436 {
2437   EVEL_ENTER();
2438
2439   /***************************************************************************/
2440   /* Check preconditions.                                                    */
2441   /***************************************************************************/
2442   assert(recvd_ucast_packets_delta >= 0.0);
2443
2444   evel_set_option_double(&vnic_performance->recvd_ucast_packets_delta,
2445                       recvd_ucast_packets_delta,
2446                       "Delta Unicast packets recieved");
2447
2448   EVEL_EXIT();
2449 }
2450
2451 /**************************************************************************//**
2452  * Set the Transmitted Broadcast Packets in measurement interval
2453  * property of the vNIC performance.
2454  *
2455  * @note  The property is treated as immutable: it is only valid to call
2456  *        the setter once.  However, we don't assert if the caller tries to
2457  *        overwrite, just ignoring the update instead.
2458  *
2459  * @param vnic_performance      Pointer to the vNIC Use.
2460  * @param tx_bcast_packets_acc
2461  *****************************************************************************/
2462 void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2463                                     const double tx_bcast_packets_acc)
2464 {
2465   EVEL_ENTER();
2466
2467   /***************************************************************************/
2468   /* Check preconditions.                                                    */
2469   /***************************************************************************/
2470   assert(tx_bcast_packets_acc >= 0.0);
2471
2472   evel_set_option_double(&vnic_performance->tx_bcast_packets_acc,
2473                       tx_bcast_packets_acc,
2474                       "Transmitted Broadcast Packets accumulated");
2475
2476   EVEL_EXIT();
2477 }
2478
2479 /**************************************************************************//**
2480  * Set the Delta Broadcast packets Transmitted in measurement interval
2481  * property of the vNIC performance.
2482  *
2483  * @note  The property is treated as immutable: it is only valid to call
2484  *        the setter once.  However, we don't assert if the caller tries to
2485  *        overwrite, just ignoring the update instead.
2486  *
2487  * @param vnic_performance      Pointer to the vNIC Use.
2488  * @param tx_bcast_packets_delta
2489  *****************************************************************************/
2490 void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2491                                     const double tx_bcast_packets_delta)
2492 {
2493   EVEL_ENTER();
2494
2495   /***************************************************************************/
2496   /* Check preconditions.                                                    */
2497   /***************************************************************************/
2498   assert(tx_bcast_packets_delta >= 0.0);
2499
2500   evel_set_option_double(&vnic_performance->tx_bcast_packets_delta,
2501                       tx_bcast_packets_delta,
2502                       "Delta Transmitted Broadcast packets ");
2503
2504   EVEL_EXIT();
2505 }
2506
2507 /**************************************************************************//**
2508  * Set the Transmitted Discarded Packets in measurement interval
2509  * property of the vNIC performance.
2510  *
2511  * @note  The property is treated as immutable: it is only valid to call
2512  *        the setter once.  However, we don't assert if the caller tries to
2513  *        overwrite, just ignoring the update instead.
2514  *
2515  * @param vnic_performance      Pointer to the vNIC Use.
2516  * @param tx_discarded_packets_acc
2517  *****************************************************************************/
2518 void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2519                                     const double tx_discarded_packets_acc)
2520 {
2521   EVEL_ENTER();
2522
2523   /***************************************************************************/
2524   /* Check preconditions.                                                    */
2525   /***************************************************************************/
2526   assert(tx_discarded_packets_acc >= 0.0);
2527
2528   evel_set_option_double(&vnic_performance->tx_discarded_packets_acc,
2529                       tx_discarded_packets_acc,
2530                       "Transmitted Discarded Packets accumulated");
2531
2532   EVEL_EXIT();
2533 }
2534
2535 /**************************************************************************//**
2536  * Set the Delta Discarded packets Transmitted in measurement interval
2537  * property of the vNIC performance.
2538  *
2539  * @note  The property is treated as immutable: it is only valid to call
2540  *        the setter once.  However, we don't assert if the caller tries to
2541  *        overwrite, just ignoring the update instead.
2542  *
2543  * @param vnic_performance      Pointer to the vNIC Use.
2544  * @param tx_discarded_packets_delta
2545  *****************************************************************************/
2546 void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2547                                     const double tx_discarded_packets_delta)
2548 {
2549   EVEL_ENTER();
2550
2551   /***************************************************************************/
2552   /* Check preconditions.                                                    */
2553   /***************************************************************************/
2554   assert(tx_discarded_packets_delta >= 0.0);
2555
2556   evel_set_option_double(&vnic_performance->tx_discarded_packets_delta,
2557                       tx_discarded_packets_delta,
2558                       "Delta Transmitted Discarded packets ");
2559
2560   EVEL_EXIT();
2561 }
2562
2563 /**************************************************************************//**
2564  * Set the Transmitted Errored Packets in measurement interval
2565  * property of the vNIC performance.
2566  *
2567  * @note  The property is treated as immutable: it is only valid to call
2568  *        the setter once.  However, we don't assert if the caller tries to
2569  *        overwrite, just ignoring the update instead.
2570  *
2571  * @param vnic_performance      Pointer to the vNIC Use.
2572  * @param tx_error_packets_acc
2573  *****************************************************************************/
2574 void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2575                                     const double tx_error_packets_acc)
2576 {
2577   EVEL_ENTER();
2578
2579   /***************************************************************************/
2580   /* Check preconditions.                                                    */
2581   /***************************************************************************/
2582   assert(tx_error_packets_acc >= 0.0);
2583
2584   evel_set_option_double(&vnic_performance->tx_error_packets_acc,
2585                       tx_error_packets_acc,
2586                       "Transmitted Error Packets accumulated");
2587
2588   EVEL_EXIT();
2589 }
2590
2591 /**************************************************************************//**
2592  * Set the Delta Errored packets Transmitted in measurement interval
2593  * property of the vNIC performance.
2594  *
2595  * @note  The property is treated as immutable: it is only valid to call
2596  *        the setter once.  However, we don't assert if the caller tries to
2597  *        overwrite, just ignoring the update instead.
2598  *
2599  * @param vnic_performance      Pointer to the vNIC Use.
2600  * @param tx_error_packets_delta
2601  *****************************************************************************/
2602 void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2603                                     const double tx_error_packets_delta)
2604 {
2605   EVEL_ENTER();
2606
2607   /***************************************************************************/
2608   /* Check preconditions.                                                    */
2609   /***************************************************************************/
2610   assert(tx_error_packets_delta >= 0.0);
2611
2612   evel_set_option_double(&vnic_performance->tx_error_packets_delta,
2613                       tx_error_packets_delta,
2614                       "Delta Transmitted Error packets ");
2615
2616   EVEL_EXIT();
2617 }
2618
2619 /**************************************************************************//**
2620  * Set the Transmitted Multicast Packets in measurement interval
2621  * property of the vNIC performance.
2622  *
2623  * @note  The property is treated as immutable: it is only valid to call
2624  *        the setter once.  However, we don't assert if the caller tries to
2625  *        overwrite, just ignoring the update instead.
2626  *
2627  * @param vnic_performance      Pointer to the vNIC Use.
2628  * @param tx_mcast_packets_acc
2629  *****************************************************************************/
2630 void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2631                                     const double tx_mcast_packets_acc)
2632 {
2633   EVEL_ENTER();
2634
2635   /***************************************************************************/
2636   /* Check preconditions.                                                    */
2637   /***************************************************************************/
2638   assert(tx_mcast_packets_acc >= 0.0);
2639
2640   evel_set_option_double(&vnic_performance->tx_mcast_packets_acc,
2641                       tx_mcast_packets_acc,
2642                       "Transmitted Multicast Packets accumulated");
2643
2644   EVEL_EXIT();
2645 }
2646
2647 /**************************************************************************//**
2648  * Set the Delta Multicast packets Transmitted in measurement interval
2649  * property of the vNIC performance.
2650  *
2651  * @note  The property is treated as immutable: it is only valid to call
2652  *        the setter once.  However, we don't assert if the caller tries to
2653  *        overwrite, just ignoring the update instead.
2654  *
2655  * @param vnic_performance      Pointer to the vNIC Use.
2656  * @param tx_mcast_packets_delta
2657  *****************************************************************************/
2658 void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2659                                     const double tx_mcast_packets_delta)
2660 {
2661   EVEL_ENTER();
2662
2663   /***************************************************************************/
2664   /* Check preconditions.                                                    */
2665   /***************************************************************************/
2666   assert(tx_mcast_packets_delta >= 0.0);
2667
2668   evel_set_option_double(&vnic_performance->tx_mcast_packets_delta,
2669                       tx_mcast_packets_delta,
2670                       "Delta Transmitted Multicast packets ");
2671
2672   EVEL_EXIT();
2673 }
2674
2675 /**************************************************************************//**
2676  * Set the Transmitted Octets in measurement interval
2677  * property of the vNIC performance.
2678  *
2679  * @note  The property is treated as immutable: it is only valid to call
2680  *        the setter once.  However, we don't assert if the caller tries to
2681  *        overwrite, just ignoring the update instead.
2682  *
2683  * @param vnic_performance      Pointer to the vNIC Use.
2684  * @param tx_octets_acc
2685  *****************************************************************************/
2686 void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2687                                     const double tx_octets_acc)
2688 {
2689   EVEL_ENTER();
2690
2691   /***************************************************************************/
2692   /* Check preconditions.                                                    */
2693   /***************************************************************************/
2694   assert(tx_octets_acc >= 0.0);
2695
2696   evel_set_option_double(&vnic_performance->tx_octets_acc,
2697                       tx_octets_acc,
2698                       "Transmitted Octets accumulated");
2699
2700   EVEL_EXIT();
2701 }
2702
2703 /**************************************************************************//**
2704  * Set the Delta Octets Transmitted in measurement interval
2705  * property of the vNIC performance.
2706  *
2707  * @note  The property is treated as immutable: it is only valid to call
2708  *        the setter once.  However, we don't assert if the caller tries to
2709  *        overwrite, just ignoring the update instead.
2710  *
2711  * @param vnic_performance      Pointer to the vNIC Use.
2712  * @param tx_octets_delta
2713  *****************************************************************************/
2714 void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2715                                     const double tx_octets_delta)
2716 {
2717   EVEL_ENTER();
2718
2719   /***************************************************************************/
2720   /* Check preconditions.                                                    */
2721   /***************************************************************************/
2722   assert(tx_octets_delta >= 0.0);
2723
2724   evel_set_option_double(&vnic_performance->tx_octets_delta,
2725                       tx_octets_delta,
2726                       "Delta Transmitted Octets ");
2727
2728   EVEL_EXIT();
2729 }
2730
2731
2732 /**************************************************************************//**
2733  * Set the Transmitted Total Packets in measurement interval
2734  * property of the vNIC performance.
2735  *
2736  * @note  The property is treated as immutable: it is only valid to call
2737  *        the setter once.  However, we don't assert if the caller tries to
2738  *        overwrite, just ignoring the update instead.
2739  *
2740  * @param vnic_performance      Pointer to the vNIC Use.
2741  * @param tx_total_packets_acc
2742  *****************************************************************************/
2743 void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2744                                     const double tx_total_packets_acc)
2745 {
2746   EVEL_ENTER();
2747
2748   /***************************************************************************/
2749   /* Check preconditions.                                                    */
2750   /***************************************************************************/
2751   assert(tx_total_packets_acc >= 0.0);
2752
2753   evel_set_option_double(&vnic_performance->tx_total_packets_acc,
2754                       tx_total_packets_acc,
2755                       "Transmitted Total Packets accumulated");
2756
2757   EVEL_EXIT();
2758 }
2759
2760 /**************************************************************************//**
2761  * Set the Delta Total Packets Transmitted in measurement interval
2762  * property of the vNIC performance.
2763  *
2764  * @note  The property is treated as immutable: it is only valid to call
2765  *        the setter once.  However, we don't assert if the caller tries to
2766  *        overwrite, just ignoring the update instead.
2767  *
2768  * @param vnic_performance      Pointer to the vNIC Use.
2769  * @param tx_total_packets_delta
2770  *****************************************************************************/
2771 void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2772                                     const double tx_total_packets_delta)
2773 {
2774   EVEL_ENTER();
2775
2776   /***************************************************************************/
2777   /* Check preconditions.                                                    */
2778   /***************************************************************************/
2779   assert(tx_total_packets_delta >= 0.0);
2780
2781   evel_set_option_double(&vnic_performance->tx_total_packets_delta,
2782                       tx_total_packets_delta,
2783                       "Delta Transmitted Total Packets ");
2784
2785   EVEL_EXIT();
2786 }
2787
2788
2789 /**************************************************************************//**
2790  * Set the Transmitted Unicast Packets in measurement interval
2791  * property of the vNIC performance.
2792  *
2793  * @note  The property is treated as immutable: it is only valid to call
2794  *        the setter once.  However, we don't assert if the caller tries to
2795  *        overwrite, just ignoring the update instead.
2796  *
2797  * @param vnic_performance      Pointer to the vNIC Use.
2798  * @param tx_ucast_packets_acc
2799  *****************************************************************************/
2800 void evel_vnic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2801                                     const double tx_ucast_packets_acc)
2802 {
2803   EVEL_ENTER();
2804
2805   /***************************************************************************/
2806   /* Check preconditions.                                                    */
2807   /***************************************************************************/
2808   assert(tx_ucast_packets_acc >= 0.0);
2809
2810   evel_set_option_double(&vnic_performance->tx_ucast_packets_acc,
2811                       tx_ucast_packets_acc,
2812                       "Transmitted Unicast Packets accumulated");
2813
2814   EVEL_EXIT();
2815 }
2816
2817 /**************************************************************************//**
2818  * Set the Delta Octets Transmitted in measurement interval
2819  * property of the vNIC performance.
2820  *
2821  * @note  The property is treated as immutable: it is only valid to call
2822  *        the setter once.  However, we don't assert if the caller tries to
2823  *        overwrite, just ignoring the update instead.
2824  *
2825  * @param vnic_performance      Pointer to the vNIC Use.
2826  * @param tx_ucast_packets_delta
2827  *****************************************************************************/
2828 void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance,
2829                                     const double tx_ucast_packets_delta)
2830 {
2831   EVEL_ENTER();
2832
2833   /***************************************************************************/
2834   /* Check preconditions.                                                    */
2835   /***************************************************************************/
2836   assert(tx_ucast_packets_delta >= 0.0);
2837
2838   evel_set_option_double(&vnic_performance->tx_ucast_packets_delta,
2839                       tx_ucast_packets_delta,
2840                       "Delta Transmitted Unicast Packets ");
2841
2842   EVEL_EXIT();
2843 }
2844
2845
2846 /**************************************************************************//**
2847  * Add an additional vNIC Use to the specified Measurement event.
2848  *
2849  * @param measurement   Pointer to the measurement.
2850  * @param vnic_performance      Pointer to the vNIC Use to add.
2851  *****************************************************************************/
2852 void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement,
2853                             MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance)
2854 {
2855   EVEL_ENTER();
2856
2857   /***************************************************************************/
2858   /* Check preconditions.                                                    */
2859   /***************************************************************************/
2860   assert(measurement != NULL);
2861   assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
2862   assert(vnic_performance != NULL);
2863
2864   dlist_push_last(&measurement->vnic_usage, vnic_performance);
2865
2866   EVEL_EXIT();
2867 }
2868
2869 /**************************************************************************//**
2870  * Add an additional vNIC usage record Measurement.
2871  *
2872  * This function implements the previous API, purely for convenience.
2873  *
2874  * The ID is null delimited ASCII string.  The library takes a copy so the
2875  * caller does not have to preserve values after the function returns.
2876  *
2877  * @param measurement           Pointer to the measurement.
2878  * @param vnic_id               ASCIIZ string with the vNIC's ID.
2879  * @param valset                true or false confidence level
2880  * @param recvd_bcast_packets_acc         Recieved broadcast packets
2881  * @param recvd_bcast_packets_delta       Received delta broadcast packets
2882  * @param recvd_discarded_packets_acc     Recieved discarded packets
2883  * @param recvd_discarded_packets_delta   Received discarded delta packets
2884  * @param recvd_error_packets_acc         Received error packets
2885  * @param recvd_error_packets_delta,      Received delta error packets
2886  * @param recvd_mcast_packets_acc         Received multicast packets
2887  * @param recvd_mcast_packets_delta       Received delta multicast packets
2888  * @param recvd_octets_acc                Received octets
2889  * @param recvd_octets_delta              Received delta octets
2890  * @param recvd_total_packets_acc         Received total packets
2891  * @param recvd_total_packets_delta       Received delta total packets
2892  * @param recvd_ucast_packets_acc         Received Unicast packets
2893  * @param recvd_ucast_packets_delta       Received delta unicast packets
2894  * @param tx_bcast_packets_acc            Transmitted broadcast packets
2895  * @param tx_bcast_packets_delta          Transmitted delta broadcast packets
2896  * @param tx_discarded_packets_acc        Transmitted packets discarded
2897  * @param tx_discarded_packets_delta      Transmitted delta discarded packets
2898  * @param tx_error_packets_acc            Transmitted error packets
2899  * @param tx_error_packets_delta          Transmitted delta error packets
2900  * @param tx_mcast_packets_acc            Transmitted multicast packets accumulated
2901  * @param tx_mcast_packets_delta          Transmitted delta multicast packets
2902  * @param tx_octets_acc                   Transmitted octets
2903  * @param tx_octets_delta                 Transmitted delta octets
2904  * @param tx_total_packets_acc            Transmitted total packets
2905  * @param tx_total_packets_delta          Transmitted delta total packets
2906  * @param tx_ucast_packets_acc            Transmitted Unicast packets
2907  * @param tx_ucast_packets_delta          Transmitted delta Unicast packets
2908  *****************************************************************************/
2909 void evel_measurement_vnic_performance_add(EVENT_MEASUREMENT * const measurement,
2910                                char * const vnic_id,
2911                                char * valset,
2912                                double recvd_bcast_packets_acc,
2913                                double recvd_bcast_packets_delta,
2914                                double recvd_discarded_packets_acc,
2915                                double recvd_discarded_packets_delta,
2916                                double recvd_error_packets_acc,
2917                                double recvd_error_packets_delta,
2918                                double recvd_mcast_packets_acc,
2919                                double recvd_mcast_packets_delta,
2920                                double recvd_octets_acc,
2921                                double recvd_octets_delta,
2922                                double recvd_total_packets_acc,
2923                                double recvd_total_packets_delta,
2924                                double recvd_ucast_packets_acc,
2925                                double recvd_ucast_packets_delta,
2926                                double tx_bcast_packets_acc,
2927                                double tx_bcast_packets_delta,
2928                                double tx_discarded_packets_acc,
2929                                double tx_discarded_packets_delta,
2930                                double tx_error_packets_acc,
2931                                double tx_error_packets_delta,
2932                                double tx_mcast_packets_acc,
2933                                double tx_mcast_packets_delta,
2934                                double tx_octets_acc,
2935                                double tx_octets_delta,
2936                                double tx_total_packets_acc,
2937                                double tx_total_packets_delta,
2938                                double tx_ucast_packets_acc,
2939                                double tx_ucast_packets_delta)
2940 {
2941   MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
2942   EVEL_ENTER();
2943
2944   /***************************************************************************/
2945   /* Trust the assertions in the underlying methods.                         */
2946   /***************************************************************************/
2947   vnic_performance = evel_measurement_new_vnic_performance(vnic_id, valset);
2948                                            
2949   evel_vnic_performance_rx_bcast_pkt_acc_set(vnic_performance, recvd_bcast_packets_acc);
2950   evel_vnic_performance_rx_bcast_pkt_delta_set(vnic_performance, recvd_bcast_packets_delta);
2951   evel_vnic_performance_rx_discard_pkt_acc_set(vnic_performance, recvd_discarded_packets_acc);
2952   evel_vnic_performance_rx_discard_pkt_delta_set(vnic_performance, recvd_discarded_packets_delta);
2953   evel_vnic_performance_rx_error_pkt_acc_set(vnic_performance, recvd_error_packets_acc);
2954   evel_vnic_performance_rx_error_pkt_delta_set(vnic_performance, recvd_error_packets_delta);
2955   evel_vnic_performance_rx_mcast_pkt_acc_set(vnic_performance, recvd_mcast_packets_acc);
2956   evel_vnic_performance_rx_mcast_pkt_delta_set(vnic_performance, recvd_mcast_packets_delta);
2957   evel_vnic_performance_rx_octets_acc_set(vnic_performance, recvd_octets_acc);
2958   evel_vnic_performance_rx_octets_delta_set(vnic_performance, recvd_octets_delta);
2959   evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, recvd_total_packets_acc);
2960   evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, recvd_total_packets_delta);
2961   evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_performance, recvd_ucast_packets_acc);
2962   evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_performance, recvd_ucast_packets_delta);
2963   evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_performance, tx_bcast_packets_acc);
2964   evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_performance, tx_bcast_packets_delta);
2965   evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_performance, tx_discarded_packets_acc);
2966   evel_vnic_performance_tx_discarded_pkt_delta_set(vnic_performance, tx_discarded_packets_delta);
2967   evel_vnic_performance_tx_error_pkt_acc_set(vnic_performance, tx_error_packets_acc);
2968   evel_vnic_performance_tx_error_pkt_delta_set(vnic_performance, tx_error_packets_delta);
2969   evel_vnic_performance_tx_mcast_pkt_acc_set(vnic_performance, tx_mcast_packets_acc);
2970   evel_vnic_performance_tx_mcast_pkt_delta_set(vnic_performance, tx_mcast_packets_delta);
2971   evel_vnic_performance_tx_octets_acc_set(vnic_performance, tx_octets_acc);
2972   evel_vnic_performance_tx_octets_delta_set(vnic_performance, tx_octets_delta);
2973   evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, tx_total_packets_acc);
2974   evel_vnic_performance_tx_total_pkt_delta_set(vnic_performance, tx_total_packets_delta);
2975   evel_vnic_performance_tx_ucast_pkt_acc_set(vnic_performance, tx_ucast_packets_acc);
2976   evel_vnic_performance_tx_ucast_pkt_delta_set(vnic_performance, tx_ucast_packets_delta);
2977   evel_meas_vnic_performance_add(measurement, vnic_performance);
2978 }
2979
2980 /**************************************************************************//**
2981  * Encode the measurement as a JSON measurement.
2982  *
2983  * @param jbuf          Pointer to the ::EVEL_JSON_BUFFER to encode into.
2984  * @param event         Pointer to the ::EVENT_HEADER to encode.
2985  *****************************************************************************/
2986 void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf,
2987                                   EVENT_MEASUREMENT * event)
2988 {
2989   MEASUREMENT_CPU_USE * cpu_use = NULL;
2990   MEASUREMENT_MEM_USE * mem_use = NULL;
2991   MEASUREMENT_DISK_USE * disk_use = NULL;
2992   MEASUREMENT_FSYS_USE * fsys_use = NULL;
2993   MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
2994   MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
2995   MEASUREMENT_ERRORS * errors = NULL;
2996   MEASUREMENT_FEATURE_USE * feature_use = NULL;
2997   MEASUREMENT_CODEC_USE * codec_use = NULL;
2998   MEASUREMENT_GROUP * measurement_group = NULL;
2999   CUSTOM_MEASUREMENT * custom_measurement = NULL;
3000   DLIST_ITEM * item = NULL;
3001   DLIST_ITEM * nested_item = NULL;
3002   DLIST_ITEM * addl_info_item = NULL;
3003   OTHER_FIELD *addl_info = NULL;
3004
3005   EVEL_ENTER();
3006
3007   /***************************************************************************/
3008   /* Check preconditions.                                                    */
3009   /***************************************************************************/
3010   assert(event != NULL);
3011   assert(event->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
3012
3013   evel_json_encode_header(jbuf, &event->header);
3014   evel_json_open_named_object(jbuf, "measurementsForVfScalingFields");
3015
3016   /***************************************************************************/
3017   /* Mandatory fields.                                                       */
3018   /***************************************************************************/
3019   evel_enc_kv_int(jbuf, "measurementInterval", event->measurement_interval);
3020
3021   /***************************************************************************/
3022   /* Optional fields.                                                        */
3023   /***************************************************************************/
3024   // additional fields
3025   evel_json_checkpoint(jbuf);
3026   if (evel_json_open_opt_named_list(jbuf, "additionalFields"))
3027   {
3028     bool item_added = false;
3029
3030     addl_info_item = dlist_get_first(&event->additional_info);
3031     while (addl_info_item != NULL)
3032     {
3033       addl_info = (OTHER_FIELD*) addl_info_item->item;
3034       assert(addl_info != NULL);
3035
3036       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3037                                           "additionalFields",
3038                                           addl_info->name))
3039       {
3040         evel_json_open_object(jbuf);
3041         evel_enc_kv_string(jbuf, "name", addl_info->name);
3042         evel_enc_kv_string(jbuf, "value", addl_info->value);
3043         evel_json_close_object(jbuf);
3044         item_added = true;
3045       }
3046       addl_info_item = dlist_get_next(addl_info_item);
3047     }
3048     evel_json_close_list(jbuf);
3049
3050     /*************************************************************************/
3051     /* If we've not written anything, rewind to before we opened the list.   */
3052     /*************************************************************************/
3053     if (!item_added)
3054     {
3055       evel_json_rewind(jbuf);
3056     }
3057   }
3058
3059   // TBD additional json objects
3060   evel_enc_kv_opt_int(jbuf, "concurrentSessions", &event->concurrent_sessions);
3061   evel_enc_kv_opt_int(jbuf, "configuredEntities", &event->configured_entities);
3062
3063   /***************************************************************************/
3064   /* CPU Use list.                                                           */
3065   /***************************************************************************/
3066   evel_json_checkpoint(jbuf);
3067   if (evel_json_open_opt_named_list(jbuf, "cpuUsageArray"))
3068   {
3069     bool item_added = false;
3070
3071     item = dlist_get_first(&event->cpu_usage);
3072     while (item != NULL)
3073     {
3074       cpu_use = (MEASUREMENT_CPU_USE*) item->item;
3075       assert(cpu_use != NULL);
3076
3077       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3078                                           "cpuUsageArray",
3079                                           cpu_use->id))
3080       {
3081         evel_json_open_object(jbuf);
3082         evel_enc_kv_string(jbuf, "cpuIdentifier", cpu_use->id);
3083         evel_enc_kv_opt_double(jbuf, "cpuIdle", &cpu_use->idle);
3084         evel_enc_kv_opt_double(jbuf, "cpuUsageInterrupt", &cpu_use->intrpt);
3085         evel_enc_kv_opt_double(jbuf, "cpuUsageNice", &cpu_use->nice);
3086         evel_enc_kv_opt_double(jbuf, "cpuUsageSoftIrq", &cpu_use->softirq);
3087         evel_enc_kv_opt_double(jbuf, "cpuUsageSteal", &cpu_use->steal);
3088         evel_enc_kv_opt_double(jbuf, "cpuUsageSystem", &cpu_use->sys);
3089         evel_enc_kv_opt_double(jbuf, "cpuUsageUser", &cpu_use->user);
3090         evel_enc_kv_opt_double(jbuf, "cpuWait", &cpu_use->wait);
3091         evel_enc_kv_double(jbuf, "percentUsage",cpu_use->usage);
3092         evel_json_close_object(jbuf);
3093         item_added = true;
3094       }
3095       item = dlist_get_next(item);
3096     }
3097     evel_json_close_list(jbuf);
3098
3099     /*************************************************************************/
3100     /* If we've not written anything, rewind to before we opened the list.   */
3101     /*************************************************************************/
3102     if (!item_added)
3103     {
3104       evel_json_rewind(jbuf);
3105     }
3106   }
3107
3108
3109   /***************************************************************************/
3110   /* Disk Use list.                                                           */
3111   /***************************************************************************/
3112   evel_json_checkpoint(jbuf);
3113   if (evel_json_open_opt_named_list(jbuf, "diskUsageArray"))
3114   {
3115     bool item_added = false;
3116
3117     item = dlist_get_first(&event->disk_usage);
3118     while (item != NULL)
3119     {
3120       disk_use = (MEASUREMENT_DISK_USE*) item->item;
3121       assert(disk_use != NULL);
3122
3123       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3124                                           "diskUsageArray",
3125                                           disk_use->id))
3126       {
3127         evel_json_open_object(jbuf);
3128         evel_enc_kv_string(jbuf, "diskIdentifier", disk_use->id);
3129         evel_enc_kv_opt_double(jbuf, "diskIoTimeAvg", &disk_use->iotimeavg);
3130         evel_enc_kv_opt_double(jbuf, "diskIoTimeLast", &disk_use->iotimelast);
3131         evel_enc_kv_opt_double(jbuf, "diskIoTimeMax", &disk_use->iotimemax);
3132         evel_enc_kv_opt_double(jbuf, "diskIoTimeMin", &disk_use->iotimemin);
3133         evel_enc_kv_opt_double(jbuf, "diskMergedReadAvg", &disk_use->mergereadavg);
3134         evel_enc_kv_opt_double(jbuf, "diskMergedReadLast", &disk_use->mergereadlast);
3135         evel_enc_kv_opt_double(jbuf, "diskMergedReadMax", &disk_use->mergereadmax);
3136         evel_enc_kv_opt_double(jbuf, "diskMergedReadMin", &disk_use->mergereadmin);
3137         evel_enc_kv_opt_double(jbuf, "diskMergedWriteAvg", &disk_use->mergewriteavg);
3138         evel_enc_kv_opt_double(jbuf, "diskMergedWriteLast", &disk_use->mergewritelast);
3139         evel_enc_kv_opt_double(jbuf, "diskMergedWriteMax", &disk_use->mergewritemax);
3140         evel_enc_kv_opt_double(jbuf, "diskMergedWriteMin", &disk_use->mergewritemin);
3141         evel_enc_kv_opt_double(jbuf, "diskOctetsReadAvg", &disk_use->octetsreadavg);
3142         evel_enc_kv_opt_double(jbuf, "diskOctetsReadLast", &disk_use->octetsreadlast);
3143         evel_enc_kv_opt_double(jbuf, "diskOctetsReadMax", &disk_use->octetsreadmax);
3144         evel_enc_kv_opt_double(jbuf, "diskOctetsReadMin", &disk_use->octetsreadmin);
3145         evel_enc_kv_opt_double(jbuf, "diskOctetsWriteAvg", &disk_use->octetswriteavg);
3146         evel_enc_kv_opt_double(jbuf, "diskOctetsWriteLast", &disk_use->octetswritelast);
3147         evel_enc_kv_opt_double(jbuf, "diskOctetsWriteMax", &disk_use->octetswritemax);
3148         evel_enc_kv_opt_double(jbuf, "diskOctetsWriteMin", &disk_use->octetswritemin);
3149         evel_enc_kv_opt_double(jbuf, "diskOpsReadAvg", &disk_use->opsreadavg);
3150         evel_enc_kv_opt_double(jbuf, "diskOpsReadLast", &disk_use->opsreadlast);
3151         evel_enc_kv_opt_double(jbuf, "diskOpsReadMax", &disk_use->opsreadmax);
3152         evel_enc_kv_opt_double(jbuf, "diskOpsReadMin", &disk_use->opsreadmin);
3153         evel_enc_kv_opt_double(jbuf, "diskOpsWriteAvg", &disk_use->opswriteavg);
3154         evel_enc_kv_opt_double(jbuf, "diskOpsWriteLast", &disk_use->opswritelast);
3155         evel_enc_kv_opt_double(jbuf, "diskOpsWriteMax", &disk_use->opswritemax);
3156         evel_enc_kv_opt_double(jbuf, "diskOpsWriteMin", &disk_use->opswritemin);
3157         evel_enc_kv_opt_double(jbuf, "diskPendingOperationsAvg", &disk_use->pendingopsavg);
3158         evel_enc_kv_opt_double(jbuf, "diskPendingOperationsLast", &disk_use->pendingopslast);
3159         evel_enc_kv_opt_double(jbuf, "diskPendingOperationsMax", &disk_use->pendingopsmax);
3160         evel_enc_kv_opt_double(jbuf, "diskPendingOperationsMin", &disk_use->pendingopsmin);
3161         evel_enc_kv_opt_double(jbuf, "diskTimeReadAvg", &disk_use->timereadavg);
3162         evel_enc_kv_opt_double(jbuf, "diskTimeReadLast", &disk_use->timereadlast);
3163         evel_enc_kv_opt_double(jbuf, "diskTimeReadMax", &disk_use->timereadmax);
3164         evel_enc_kv_opt_double(jbuf, "diskTimeReadMin", &disk_use->timereadmin);
3165         evel_enc_kv_opt_double(jbuf, "diskTimeWriteAvg", &disk_use->timewriteavg);
3166         evel_enc_kv_opt_double(jbuf, "diskTimeWriteLast", &disk_use->timewritelast);
3167         evel_enc_kv_opt_double(jbuf, "diskTimeWriteMax", &disk_use->timewritemax);
3168         evel_enc_kv_opt_double(jbuf, "diskTimeWriteMin", &disk_use->timewritemin);
3169         evel_json_close_object(jbuf);
3170         item_added = true;
3171       }
3172       item = dlist_get_next(item);
3173     }
3174     evel_json_close_list(jbuf);
3175
3176     /*************************************************************************/
3177     /* If we've not written anything, rewind to before we opened the list.   */
3178     /*************************************************************************/
3179     if (!item_added)
3180     {
3181       evel_json_rewind(jbuf);
3182     }
3183   }
3184
3185   /***************************************************************************/
3186   /* Filesystem Usage list.                                                  */
3187   /***************************************************************************/
3188   evel_json_checkpoint(jbuf);
3189   if (evel_json_open_opt_named_list(jbuf, "filesystemUsageArray"))
3190   {
3191     bool item_added = false;
3192
3193     item = dlist_get_first(&event->filesystem_usage);
3194     while (item != NULL)
3195     {
3196       fsys_use = (MEASUREMENT_FSYS_USE *) item->item;
3197       assert(fsys_use != NULL);
3198
3199       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3200                                           "filesystemUsageArray",
3201                                           fsys_use->filesystem_name))
3202       {
3203         evel_json_open_object(jbuf);
3204         evel_enc_kv_double(
3205           jbuf, "blockConfigured", fsys_use->block_configured);
3206         evel_enc_kv_int(jbuf, "blockIops", fsys_use->block_iops);
3207         evel_enc_kv_double(jbuf, "blockUsed", fsys_use->block_used);
3208         evel_enc_kv_double(
3209           jbuf, "ephemeralConfigured", fsys_use->ephemeral_configured);
3210         evel_enc_kv_int(jbuf, "ephemeralIops", fsys_use->ephemeral_iops);
3211         evel_enc_kv_double(jbuf, "ephemeralUsed", fsys_use->ephemeral_used);
3212         evel_enc_kv_string(jbuf, "filesystemName", fsys_use->filesystem_name);
3213         evel_json_close_object(jbuf);
3214         item_added = true;
3215       }
3216       item = dlist_get_next(item);
3217     }
3218     evel_json_close_list(jbuf);
3219
3220     /*************************************************************************/
3221     /* If we've not written anything, rewind to before we opened the list.   */
3222     /*************************************************************************/
3223     if (!item_added)
3224     {
3225       evel_json_rewind(jbuf);
3226     }
3227   }
3228
3229   /***************************************************************************/
3230   /* Latency distribution.                                                   */
3231   /***************************************************************************/
3232   item = dlist_get_first(&event->latency_distribution);
3233   if ((item != NULL) &&
3234       evel_json_open_opt_named_list(jbuf, "latencyDistribution"))
3235   {
3236     while (item != NULL)
3237     {
3238       bucket = (MEASUREMENT_LATENCY_BUCKET*) item->item;
3239       assert(bucket != NULL);
3240
3241       evel_json_open_object(jbuf);
3242       evel_enc_kv_opt_double(
3243         jbuf, "lowEndOfLatencyBucket", &bucket->low_end);
3244       evel_enc_kv_opt_double(
3245         jbuf, "highEndOfLatencyBucket", &bucket->high_end);
3246       evel_enc_kv_int(jbuf, "countsInTheBucket", bucket->count);
3247       evel_json_close_object(jbuf);
3248       item = dlist_get_next(item);
3249     }
3250     evel_json_close_list(jbuf);
3251   }
3252
3253   evel_enc_kv_opt_double(
3254     jbuf, "meanRequestLatency", &event->mean_request_latency);
3255   evel_enc_kv_opt_int(jbuf, "requestRate", &event->request_rate);
3256
3257   /***************************************************************************/
3258   /* vNIC Usage TBD Performance array                          */
3259   /***************************************************************************/
3260   evel_json_checkpoint(jbuf);
3261   if (evel_json_open_opt_named_list(jbuf, "vNicUsageArray"))
3262   {
3263     bool item_added = false;
3264
3265     item = dlist_get_first(&event->vnic_usage);
3266     while (item != NULL)
3267     {
3268       vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *) item->item;
3269       assert(vnic_performance != NULL);
3270
3271       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3272                                           "vNicPerformanceArray",
3273                                           vnic_performance->vnic_id))
3274       {
3275         evel_json_open_object(jbuf);
3276
3277         /*********************************************************************/
3278         /* Optional fields.                                                  */
3279         /*********************************************************************/
3280         evel_enc_kv_opt_double( jbuf,
3281                  "receivedBroadcastPacketsAccumulated", &vnic_performance->recvd_bcast_packets_acc);
3282         evel_enc_kv_opt_double( jbuf,
3283                  "receivedBroadcastPacketsDelta", &vnic_performance->recvd_bcast_packets_delta);
3284         evel_enc_kv_opt_double( jbuf,
3285                  "receivedDiscardedPacketsAccumulated", &vnic_performance->recvd_discarded_packets_acc);
3286         evel_enc_kv_opt_double( jbuf,
3287                  "receivedDiscardedPacketsDelta", &vnic_performance->recvd_discarded_packets_delta);
3288         evel_enc_kv_opt_double( jbuf,
3289                  "receivedErrorPacketsAccumulated", &vnic_performance->recvd_error_packets_acc);
3290         evel_enc_kv_opt_double( jbuf,
3291                  "receivedErrorPacketsDelta", &vnic_performance->recvd_error_packets_delta);
3292         evel_enc_kv_opt_double( jbuf,
3293                  "receivedMulticastPacketsAccumulated", &vnic_performance->recvd_mcast_packets_acc);
3294         evel_enc_kv_opt_double( jbuf,
3295                  "receivedMulticastPacketsDelta", &vnic_performance->recvd_mcast_packets_delta);
3296         evel_enc_kv_opt_double( jbuf,
3297                  "receivedOctetsAccumulated", &vnic_performance->recvd_octets_acc);
3298         evel_enc_kv_opt_double( jbuf,
3299                  "receivedOctetsDelta", &vnic_performance->recvd_octets_delta);
3300         evel_enc_kv_opt_double( jbuf,
3301                  "receivedTotalPacketsAccumulated", &vnic_performance->recvd_total_packets_acc);
3302         evel_enc_kv_opt_double( jbuf,
3303                  "receivedTotalPacketsDelta", &vnic_performance->recvd_total_packets_delta);
3304         evel_enc_kv_opt_double( jbuf,
3305                  "receivedUnicastPacketsAccumulated", &vnic_performance->recvd_ucast_packets_acc);
3306         evel_enc_kv_opt_double( jbuf,
3307                  "receivedUnicastPacketsDelta", &vnic_performance->recvd_ucast_packets_delta);
3308         evel_enc_kv_opt_double( jbuf,
3309                  "transmittedBroadcastPacketsAccumulated", &vnic_performance->tx_bcast_packets_acc);
3310         evel_enc_kv_opt_double( jbuf,
3311                  "transmittedBroadcastPacketsDelta", &vnic_performance->tx_bcast_packets_delta);
3312         evel_enc_kv_opt_double( jbuf,
3313                  "transmittedDiscardedPacketsAccumulated", &vnic_performance->tx_discarded_packets_acc);
3314         evel_enc_kv_opt_double( jbuf,
3315                  "transmittedDiscardedPacketsDelta", &vnic_performance->tx_discarded_packets_delta);
3316         evel_enc_kv_opt_double( jbuf,
3317                  "transmittedErrorPacketsAccumulated", &vnic_performance->tx_error_packets_acc);
3318         evel_enc_kv_opt_double( jbuf,
3319                  "transmittedErrorPacketsDelta", &vnic_performance->tx_error_packets_delta);
3320         evel_enc_kv_opt_double( jbuf,
3321                  "transmittedMulticastPacketsAccumulated", &vnic_performance->tx_mcast_packets_acc);
3322         evel_enc_kv_opt_double( jbuf,
3323                  "transmittedMulticastPacketsDelta", &vnic_performance->tx_mcast_packets_delta);
3324         evel_enc_kv_opt_double( jbuf,
3325                  "transmittedOctetsAccumulated", &vnic_performance->tx_octets_acc);
3326         evel_enc_kv_opt_double( jbuf,
3327                  "transmittedOctetsDelta", &vnic_performance->tx_octets_delta);
3328         evel_enc_kv_opt_double( jbuf,
3329                  "transmittedTotalPacketsAccumulated", &vnic_performance->tx_total_packets_acc);
3330         evel_enc_kv_opt_double( jbuf,
3331                  "transmittedTotalPacketsDelta", &vnic_performance->tx_total_packets_delta);
3332         evel_enc_kv_opt_double( jbuf,
3333                  "transmittedUnicastPacketsAccumulated", &vnic_performance->tx_ucast_packets_acc);
3334         evel_enc_kv_opt_double( jbuf,
3335                  "transmittedUnicastPacketsDelta", &vnic_performance->tx_ucast_packets_delta);
3336
3337         /*********************************************************************/
3338         /* Mandatory fields.                                                 */
3339         /*********************************************************************/
3340         evel_enc_kv_string(jbuf, "valuesAreSuspect", vnic_performance->valuesaresuspect);
3341         evel_enc_kv_string(jbuf, "vNicIdentifier", vnic_performance->vnic_id);
3342
3343         evel_json_close_object(jbuf);
3344         item_added = true;
3345       }
3346       item = dlist_get_next(item);
3347     }
3348
3349     evel_json_close_list(jbuf);
3350
3351     /*************************************************************************/
3352     /* If we've not written anything, rewind to before we opened the list.   */
3353     /*************************************************************************/
3354     if (!item_added)
3355     {
3356       evel_json_rewind(jbuf);
3357     }
3358   }
3359
3360
3361   /***************************************************************************/
3362   /* Memory Use list.                                                           */
3363   /***************************************************************************/
3364   evel_json_checkpoint(jbuf);
3365   if (evel_json_open_opt_named_list(jbuf, "memoryUsageArray"))
3366   {
3367     bool item_added = false;
3368
3369     item = dlist_get_first(&event->mem_usage);
3370     while (item != NULL)
3371     {
3372       mem_use = (MEASUREMENT_MEM_USE*) item->item;
3373       assert(mem_use != NULL);
3374
3375       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3376                                           "memoryUsageArray",
3377                                           mem_use->id))
3378       {
3379         evel_json_open_object(jbuf);
3380         evel_enc_kv_double(jbuf, "memoryBuffered", mem_use->membuffsz);
3381         evel_enc_kv_opt_double(jbuf, "memoryCached", &mem_use->memcache);
3382         evel_enc_kv_opt_double(jbuf, "memoryConfigured", &mem_use->memconfig);
3383         evel_enc_kv_opt_double(jbuf, "memoryFree", &mem_use->memfree);
3384         evel_enc_kv_opt_double(jbuf, "memorySlabRecl", &mem_use->slabrecl);
3385         evel_enc_kv_opt_double(jbuf, "memorySlabUnrecl", &mem_use->slabunrecl);
3386         evel_enc_kv_opt_double(jbuf, "memoryUsed", &mem_use->memused);
3387         evel_enc_kv_string(jbuf, "vmIdentifier", mem_use->id);
3388         evel_json_close_object(jbuf);
3389         item_added = true;
3390       }
3391       item = dlist_get_next(item);
3392     }
3393     evel_json_close_list(jbuf);
3394
3395     /*************************************************************************/
3396     /* If we've not written anything, rewind to before we opened the list.   */
3397     /*************************************************************************/
3398     if (!item_added)
3399     {
3400       evel_json_rewind(jbuf);
3401     }
3402   }
3403
3404
3405   evel_enc_kv_opt_int(
3406     jbuf, "numberOfMediaPortsInUse", &event->media_ports_in_use);
3407   evel_enc_kv_opt_int(
3408     jbuf, "vnfcScalingMetric", &event->vnfc_scaling_metric);
3409
3410   /***************************************************************************/
3411   /* Errors list.                                                            */
3412   /***************************************************************************/
3413   if ((event->errors != NULL) &&
3414       evel_json_open_opt_named_object(jbuf, "errors"))
3415   {
3416     errors = event->errors;
3417     evel_enc_kv_int(jbuf, "receiveDiscards", errors->receive_discards);
3418     evel_enc_kv_int(jbuf, "receiveErrors", errors->receive_errors);
3419     evel_enc_kv_int(jbuf, "transmitDiscards", errors->transmit_discards);
3420     evel_enc_kv_int(jbuf, "transmitErrors", errors->transmit_errors);
3421     evel_json_close_object(jbuf);
3422   }
3423
3424   /***************************************************************************/
3425   /* Feature Utilization list.                                               */
3426   /***************************************************************************/
3427   evel_json_checkpoint(jbuf);
3428   if (evel_json_open_opt_named_list(jbuf, "featureUsageArray"))
3429   {
3430     bool item_added = false;
3431
3432     item = dlist_get_first(&event->feature_usage);
3433     while (item != NULL)
3434     {
3435       feature_use = (MEASUREMENT_FEATURE_USE*) item->item;
3436       assert(feature_use != NULL);
3437
3438       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3439                                           "featureUsageArray",
3440                                           feature_use->feature_id))
3441       {
3442         evel_json_open_object(jbuf);
3443         evel_enc_kv_string(jbuf, "featureIdentifier", feature_use->feature_id);
3444         evel_enc_kv_int(
3445           jbuf, "featureUtilization", feature_use->feature_utilization);
3446         evel_json_close_object(jbuf);
3447         item_added = true;
3448       }
3449       item = dlist_get_next(item);
3450     }
3451     evel_json_close_list(jbuf);
3452
3453     /*************************************************************************/
3454     /* If we've not written anything, rewind to before we opened the list.   */
3455     /*************************************************************************/
3456     if (!item_added)
3457     {
3458       evel_json_rewind(jbuf);
3459     }
3460   }
3461
3462   /***************************************************************************/
3463   /* Codec Utilization list.                                                 */
3464   /***************************************************************************/
3465   evel_json_checkpoint(jbuf);
3466   if (evel_json_open_opt_named_list(jbuf, "codecUsageArray"))
3467   {
3468     bool item_added = false;
3469
3470     item = dlist_get_first(&event->codec_usage);
3471     while (item != NULL)
3472     {
3473       codec_use = (MEASUREMENT_CODEC_USE*) item->item;
3474       assert(codec_use != NULL);
3475
3476       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3477                                           "codecUsageArray",
3478                                           codec_use->codec_id))
3479       {
3480         evel_json_open_object(jbuf);
3481         evel_enc_kv_string(jbuf, "codecIdentifier", codec_use->codec_id);
3482         evel_enc_kv_int(jbuf, "numberInUse", codec_use->number_in_use);
3483         evel_json_close_object(jbuf);
3484         item_added = true;
3485       }
3486       item = dlist_get_next(item);
3487     }
3488     evel_json_close_list(jbuf);
3489
3490     /*************************************************************************/
3491     /* If we've not written anything, rewind to before we opened the list.   */
3492     /*************************************************************************/
3493     if (!item_added)
3494     {
3495       evel_json_rewind(jbuf);
3496     }
3497   }
3498
3499   /***************************************************************************/
3500   /* Additional Measurement Groups list.                                     */
3501   /***************************************************************************/
3502   evel_json_checkpoint(jbuf);
3503   if (evel_json_open_opt_named_list(jbuf, "additionalMeasurements"))
3504   {
3505     bool item_added = false;
3506
3507     item = dlist_get_first(&event->additional_measurements);
3508     while (item != NULL)
3509     {
3510       measurement_group = (MEASUREMENT_GROUP *) item->item;
3511       assert(measurement_group != NULL);
3512
3513       if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
3514                                           "additionalMeasurements",
3515                                           measurement_group->name))
3516       {
3517         evel_json_open_object(jbuf);
3518         evel_enc_kv_string(jbuf, "name", measurement_group->name);
3519         evel_json_open_opt_named_list(jbuf, "measurements");
3520
3521         /*********************************************************************/
3522         /* Measurements list.                                                */
3523         /*********************************************************************/
3524         nested_item = dlist_get_first(&measurement_group->measurements);
3525         while (nested_item != NULL)
3526         {
3527           custom_measurement = (CUSTOM_MEASUREMENT *) nested_item->item;
3528           assert(custom_measurement != NULL);
3529
3530           evel_json_open_object(jbuf);
3531           evel_enc_kv_string(jbuf, "name", custom_measurement->name);
3532           evel_enc_kv_string(jbuf, "value", custom_measurement->value);
3533           evel_json_close_object(jbuf);
3534           nested_item = dlist_get_next(nested_item);
3535         }
3536         evel_json_close_list(jbuf);
3537         evel_json_close_object(jbuf);
3538         item_added = true;
3539       }
3540       item = dlist_get_next(item);
3541     }
3542     evel_json_close_list(jbuf);
3543
3544     /*************************************************************************/
3545     /* If we've not written anything, rewind to before we opened the list.   */
3546     /*************************************************************************/
3547     if (!item_added)
3548     {
3549       evel_json_rewind(jbuf);
3550     }
3551   }
3552
3553   /***************************************************************************/
3554   /* Although optional, we always generate the version.  Note that this      */
3555   /* closes the object, too.                                                 */
3556   /***************************************************************************/
3557   evel_enc_version(jbuf,
3558                    "measurementsForVfScalingVersion",
3559                    event->major_version,
3560                    event->minor_version);
3561   evel_json_close_object(jbuf);
3562
3563   EVEL_EXIT();
3564 }
3565
3566 /**************************************************************************//**
3567  * Free a Measurement.
3568  *
3569  * Free off the Measurement supplied.  Will free all the contained allocated
3570  * memory.
3571  *
3572  * @note It does not free the Measurement itself, since that may be part of a
3573  * larger structure.
3574  *****************************************************************************/
3575 void evel_free_measurement(EVENT_MEASUREMENT * event)
3576 {
3577   MEASUREMENT_CPU_USE * cpu_use = NULL;
3578   MEASUREMENT_DISK_USE * disk_use = NULL;
3579   MEASUREMENT_FSYS_USE * fsys_use = NULL;
3580   MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
3581   MEASUREMENT_MEM_USE * mem_use = NULL;
3582   MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
3583   MEASUREMENT_FEATURE_USE * feature_use = NULL;
3584   MEASUREMENT_CODEC_USE * codec_use = NULL;
3585   MEASUREMENT_GROUP * measurement_group = NULL;
3586   CUSTOM_MEASUREMENT * measurement = NULL;
3587   OTHER_FIELD *addl_info = NULL;
3588
3589   EVEL_ENTER();
3590
3591   /***************************************************************************/
3592   /* Check preconditions.  As an internal API we don't allow freeing NULL    */
3593   /* events as we do on the public API.                                      */
3594   /***************************************************************************/
3595   assert(event != NULL);
3596   assert(event->header.event_domain == EVEL_DOMAIN_MEASUREMENT);
3597
3598   /***************************************************************************/
3599   /* Free all internal strings then the header itself.                       */
3600   /***************************************************************************/
3601   addl_info = dlist_pop_last(&event->additional_info);
3602   while (addl_info != NULL)
3603   {
3604     EVEL_DEBUG("Freeing Additional Info (%s, %s)",
3605                addl_info->name,
3606                addl_info->value);
3607     free(addl_info->name);
3608     free(addl_info->value);
3609     free(addl_info);
3610     addl_info = dlist_pop_last(&event->additional_info);
3611   }
3612
3613
3614
3615   cpu_use = dlist_pop_last(&event->cpu_usage);
3616   while (cpu_use != NULL)
3617   {
3618     EVEL_DEBUG("Freeing CPU use Info (%s)", cpu_use->id);
3619     free(cpu_use->id);
3620     free(cpu_use);
3621     cpu_use = dlist_pop_last(&event->cpu_usage);
3622   }
3623   disk_use = dlist_pop_last(&event->disk_usage);
3624   while (disk_use != NULL)
3625   {
3626     EVEL_DEBUG("Freeing Disk use Info (%s)", disk_use->id);
3627     free(disk_use->id);
3628     free(disk_use);
3629     disk_use = dlist_pop_last(&event->disk_usage);
3630   }
3631   mem_use = dlist_pop_last(&event->mem_usage);
3632   while (mem_use != NULL)
3633   {
3634     EVEL_DEBUG("Freeing Memory use Info (%s)", mem_use->id);
3635     free(mem_use->id);
3636     free(mem_use->vmid);
3637     free(mem_use);
3638     mem_use = dlist_pop_last(&event->mem_usage);
3639   }
3640
3641   fsys_use = dlist_pop_last(&event->filesystem_usage);
3642   while (fsys_use != NULL)
3643   {
3644     EVEL_DEBUG("Freeing Filesystem Use info (%s)", fsys_use->filesystem_name);
3645     free(fsys_use->filesystem_name);
3646     free(fsys_use);
3647     fsys_use = dlist_pop_last(&event->filesystem_usage);
3648   }
3649
3650   bucket = dlist_pop_last(&event->latency_distribution);
3651   while (bucket != NULL)
3652   {
3653     EVEL_DEBUG("Freeing Latency Bucket");
3654     free(bucket);
3655     bucket = dlist_pop_last(&event->latency_distribution);
3656   }
3657
3658   vnic_performance = dlist_pop_last(&event->vnic_usage);
3659   while (vnic_performance != NULL)
3660   {
3661     EVEL_DEBUG("Freeing vNIC performance Info (%s)", vnic_performance->vnic_id);
3662     evel_measurement_free_vnic_performance(vnic_performance);
3663     free(vnic_performance);
3664     vnic_performance = dlist_pop_last(&event->vnic_usage);
3665   }
3666
3667   codec_use = dlist_pop_last(&event->codec_usage);
3668   while (codec_use != NULL)
3669   {
3670     EVEL_DEBUG("Freeing Codec use Info (%s)", codec_use->codec_id);
3671     free(codec_use->codec_id);
3672     free(codec_use);
3673     codec_use = dlist_pop_last(&event->codec_usage);
3674   }
3675
3676   if (event->errors != NULL)
3677   {
3678     EVEL_DEBUG("Freeing Errors");
3679     free(event->errors);
3680   }
3681
3682   feature_use = dlist_pop_last(&event->feature_usage);
3683   while (feature_use != NULL)
3684   {
3685     EVEL_DEBUG("Freeing Feature use Info (%s)", feature_use->feature_id);
3686     free(feature_use->feature_id);
3687     free(feature_use);
3688     feature_use = dlist_pop_last(&event->feature_usage);
3689   }
3690
3691   measurement_group = dlist_pop_last(&event->additional_measurements);
3692   while (measurement_group != NULL)
3693   {
3694     EVEL_DEBUG("Freeing Measurement Group (%s)", measurement_group->name);
3695
3696     measurement = dlist_pop_last(&measurement_group->measurements);
3697     while (measurement != NULL)
3698     {
3699       EVEL_DEBUG("Freeing Measurement (%s)", measurement->name);
3700       free(measurement->name);
3701       free(measurement->value);
3702       free(measurement);
3703       measurement = dlist_pop_last(&measurement_group->measurements);
3704     }
3705     free(measurement_group->name);
3706     free(measurement_group);
3707     measurement_group = dlist_pop_last(&event->additional_measurements);
3708   }
3709
3710   evel_free_header(&event->header);
3711
3712   EVEL_EXIT();
3713 }