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