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