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