From 16f861742ff1a59f049170773c8edc974cfeb927 Mon Sep 17 00:00:00 2001 From: "PATRACHARI, GAYATHRI (gp2421)" Date: Thu, 20 Sep 2018 08:10:49 -0400 Subject: VesAgent VES7.0 updates Issue-ID: VNFSDK-328 Change-Id: I7e06286e0f058be9b851225055f7b74dbd71ceee Signed-off-by: PATRACHARI, GAYATHRI (gp2421) --- .../evel/evel-library/code/evel_library/evel.c | 75 +- .../evel/evel-library/code/evel_library/evel.h | 5551 +++++++++++++++----- .../evel-library/code/evel_library/evel_event.c | 191 +- .../code/evel_library/evel_event_mgr.c | 1707 +++++- .../evel-library/code/evel_library/evel_fault.c | 94 +- .../code/evel_library/evel_heartbeat_fields.c | 88 +- .../evel-library/code/evel_library/evel_internal.h | 149 +- .../code/evel_library/evel_json_buffer.c | 15 +- .../code/evel_library/evel_jsonobject.c | 13 +- .../code/evel_library/evel_mobile_flow.c | 533 +- .../code/evel_library/evel_notification.c | 514 ++ .../evel-library/code/evel_library/evel_option.c | 115 +- .../evel-library/code/evel_library/evel_other.c | 338 +- .../code/evel_library/evel_pnf_registration.c | 573 ++ .../code/evel_library/evel_reporting_measurement.c | 9 +- .../code/evel_library/evel_scaling_measurement.c | 3621 ++++++++++--- .../code/evel_library/evel_sipsignaling.c | 98 +- .../code/evel_library/evel_state_change.c | 88 +- .../evel-library/code/evel_library/evel_strings.c | 110 +- .../evel-library/code/evel_library/evel_syslog.c | 172 +- .../code/evel_library/evel_threshold_cross.c | 543 +- .../evel-library/code/evel_library/evel_throttle.c | 7 +- .../evel-library/code/evel_library/evel_unit.c | 132 + .../code/evel_library/evel_voicequality.c | 234 +- .../evel-library/code/evel_library/hashtable.c | 143 +- .../evel-library/code/evel_library/hashtable.h | 60 +- .../evel-library/code/evel_library/quickstart.md | 86 +- .../evel-library/code/evel_library/ring_buffer.c | 6 +- .../evel/evel-library/code/evel_unit/Makefile | 44 + .../evel/evel-library/code/evel_unit/evel_unit.c | 1465 ++++-- 30 files changed, 13380 insertions(+), 3394 deletions(-) create mode 100644 veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_notification.c create mode 100644 veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_pnf_registration.c create mode 100644 veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_unit.c create mode 100644 veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/Makefile (limited to 'veslibrary/ves_clibrary/evel/evel-library/code') diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c index 4e4383e..f0e4dea 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c @@ -64,9 +64,13 @@ char *functional_role = NULL; * * @param fqdn The API's FQDN or IP address. * @param port The API's port. + * @param bakup_fqdn The API's Backup FQDN or IP address. + * @param bakup_port The API's Backup port. * @param path The optional path (may be NULL). * @param topic The optional topic part of the URL (may be NULL). + * @param ring buf size Ring buffer size * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS) + * @param activmode Whether to use ActivStandby(0) collectors or ActiveStandby(1) * @param cert_file_path Path to client certificate file * @param key_file_path Path to client key file * @param ca_info Path to CA cert file @@ -75,7 +79,10 @@ char *functional_role = NULL; * @param verify_host SSL verification of host 0 or 1 * @param username Username for Basic Authentication of requests. * @param password Password for Basic Authentication of requests. - * @param source_ip The ip of node we represent (NULL for default ip). + * @param bakup_username Username for Basic Authentication of Bakup FQDN. + * @param bakup_password Password for Basic Authentication of Bakup FQDN. + * @param source_ip The ip of node we represent.(NULL for default ip) + * @param bakup_source_ip The ip bakup fqdn interface.(NULL for default ip) * @param source_type The kind of node we represent. * @param role The role this node undertakes. * @param verbosity 0 for normal operation, positive values for chattier @@ -87,10 +94,13 @@ char *functional_role = NULL; *****************************************************************************/ EVEL_ERR_CODES evel_initialize(const char * const fqdn, int port, + const char * const bakup_fqdn, + int bakup_port, const char * const path, const char * const topic, int ring_buf_size, int secure, + int activmode, const char * const cert_file_path, const char * const key_file_path, const char * const ca_info, @@ -99,7 +109,10 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, long verify_host, const char * const username, const char * const password, + const char * const bakup_username, + const char * const bakup_password, const char * const source_ip, + const char * const bakup_source_ip, EVEL_SOURCE_TYPES source_type, const char * const role, int verbosity @@ -108,11 +121,13 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, EVEL_ERR_CODES rc = EVEL_SUCCESS; char base_api_url[EVEL_MAX_URL_LEN + 1] = {0}; char event_api_url[EVEL_MAX_URL_LEN + 1] = {0}; + char bakup_api_url[EVEL_MAX_URL_LEN + 1] = {0}; char throt_api_url[EVEL_MAX_URL_LEN + 1] = {0}; char path_url[EVEL_MAX_URL_LEN + 1] = {0}; char topic_url[EVEL_MAX_URL_LEN + 1] = {0}; char version_string[10] = {0}; int offset; + char * bakup_coll = NULL; /***************************************************************************/ /* Check assumptions. */ @@ -122,10 +137,17 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, assert(source_type < EVEL_MAX_SOURCE_TYPES); assert(role != NULL); + if( bakup_fqdn != NULL ) { + assert(bakup_port > 0 && bakup_port <= 65535); + } + /***************************************************************************/ /* Start logging so we can report on progress. */ /***************************************************************************/ - log_initialize(verbosity == 0 ? EVEL_LOG_INFO : EVEL_LOG_DEBUG, "EVEL"); + if( verbosity >= EVEL_LOG_MIN && verbosity <= EVEL_LOG_MAX) + log_initialize(verbosity, "EVEL"); + else + log_initialize(EVEL_LOG_MIN, "EVEL"); EVEL_INFO("EVEL started"); EVEL_INFO("API server is: %s", fqdn); EVEL_INFO("API port is: %d", port); @@ -237,6 +259,36 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, strncat(topic_url, topic, EVEL_MAX_URL_LEN) : "")); EVEL_INFO("Vendor Event Listener API is located at: %s", event_api_url); + /***************************************************************************/ + /* Build a common base of the Backup API URLs. */ + /***************************************************************************/ + if( bakup_fqdn != NULL ) + { + strcpy(path_url, "/"); + snprintf(base_api_url, + EVEL_MAX_URL_LEN, + "%s://%s:%d%s/eventListener/v%s", + secure ? "https" : "http", + bakup_fqdn, + bakup_port, + (((path != NULL) && (strlen(path) > 0)) ? + strncat(path_url, path, EVEL_MAX_URL_LEN) : ""), + version_string); + + /***************************************************************************/ + /* Build the URL to the event API. */ + /***************************************************************************/ + strcpy(topic_url, "/"); + snprintf(bakup_api_url, + EVEL_MAX_URL_LEN, + "%s%s", + base_api_url, + (((topic != NULL) && (strlen(topic) > 0)) ? + strncat(topic_url, topic, EVEL_MAX_URL_LEN) : "")); + EVEL_INFO("Vendor Backup Event Listener API is located at: %s", bakup_api_url); + bakup_coll = bakup_api_url; + } + /***************************************************************************/ /* Build the URL to the throttling API. */ /***************************************************************************/ @@ -250,10 +302,13 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, /* Spin-up the event-handler, which gets cURL readied for use. */ /***************************************************************************/ rc = event_handler_initialize(event_api_url, + bakup_coll, throt_api_url, source_ip, + bakup_source_ip, ring_buf_size, secure, + activmode, cert_file_path, key_file_path, ca_info, @@ -262,6 +317,8 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, verify_host, username, password, + bakup_username, + bakup_password, verbosity); if (rc != EVEL_SUCCESS) { @@ -448,6 +505,20 @@ void evel_free_event(void * event) free(evt_ptr); break; + case EVEL_DOMAIN_PNF_REGISTRATION: + EVEL_DEBUG("Event is an PNFRegistration at %lp", evt_ptr); + evel_free_pnf_registration((EVENT_PNF_REGISTRATION *)evt_ptr); + memset(evt_ptr, 0, sizeof(EVENT_PNF_REGISTRATION)); + free(evt_ptr); + break; + + case EVEL_DOMAIN_NOTIFICATION: + EVEL_DEBUG("Event is an Notification at %lp", evt_ptr); + evel_free_notification((EVENT_PNF_REGISTRATION *)evt_ptr); + memset(evt_ptr, 0, sizeof(EVENT_NOTIFICATION)); + free(evt_ptr); + break; + case EVEL_DOMAIN_BATCH: EVEL_DEBUG("Event is a Batch at %lp", evt_ptr); evel_free_batch((EVENT_HEADER *)evt_ptr); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h index 5c05993..c149749 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h @@ -46,8 +46,9 @@ extern "C" { /*****************************************************************************/ /* Supported API version. */ /*****************************************************************************/ -#define EVEL_API_MAJOR_VERSION 5 +#define EVEL_API_MAJOR_VERSION 7 #define EVEL_API_MINOR_VERSION 0 +#define EVEL_API_PATCH_VERSION 2 /**************************************************************************//** * Error codes @@ -76,6 +77,7 @@ typedef enum { *****************************************************************************/ typedef enum { EVEL_LOG_MIN = 0, + EVEL_LOG_WARN = 1, EVEL_LOG_SPAMMY = 30, EVEL_LOG_DEBUG = 40, EVEL_LOG_INFO = 50, @@ -131,6 +133,8 @@ typedef enum { EVEL_DOMAIN_OTHER, /** Another event. */ EVEL_DOMAIN_THRESHOLD_CROSS, /** A Threshold Crossing Event */ EVEL_DOMAIN_VOICE_QUALITY, /** A Voice Quality Event */ + EVEL_DOMAIN_NOTIFICATION, /** A Notification event. */ + EVEL_DOMAIN_PNF_REGISTRATION, /** A PNF Registration event. */ EVEL_MAX_DOMAINS /** Maximum number of recognized Event types. */ } EVEL_EVENT_DOMAINS; @@ -234,8 +238,8 @@ typedef enum { } EVEL_ALERT_TYPES; /**************************************************************************//** - * Alert types. - * JSON equivalent fields: newState, oldState + * Entity state. + * JSON equivalent fields: new_state, old_state *****************************************************************************/ typedef enum { EVEL_ENTITY_STATE_IN_SERVICE, @@ -244,6 +248,16 @@ typedef enum { EVEL_MAX_ENTITY_STATES } EVEL_ENTITY_STATE; +/**************************************************************************//** + * Operational state. + * JSON equivalent fields: operationalState, administrativeState + *****************************************************************************/ +typedef enum { + EVEL_OPER_STATE_IN_SERVICE, + EVEL_OPER_STATE_OUT_OF_SERVICE, + EVEL_MAX_OPER_STATES +} EVEL_OPER_STATE; + /**************************************************************************//** * Syslog facilities. * JSON equivalent field: syslogFacility @@ -362,6 +376,18 @@ typedef struct evel_option_string EVEL_BOOLEAN is_set; } EVEL_OPTION_STRING; +typedef struct evel_option_state +{ + EVEL_ENTITY_STATE state; + EVEL_BOOLEAN is_set; +} EVEL_OPTION_STATE; + +typedef struct evel_option_op_state +{ + EVEL_OPER_STATE state; + EVEL_BOOLEAN is_set; +} EVEL_OPTION_OP_STATE; + /**************************************************************************//** * Optional parameter holder for int. *****************************************************************************/ @@ -402,7 +428,7 @@ typedef struct internal_header_fields /*****************************************************************************/ /* Supported Common Event Header version. */ /*****************************************************************************/ -#define EVEL_HEADER_MAJOR_VERSION 3 +#define EVEL_HEADER_MAJOR_VERSION 4 #define EVEL_HEADER_MINOR_VERSION 0 #define EVEL_BATCH_MAJOR_VERSION 1 @@ -426,6 +452,7 @@ typedef struct event_header { char * event_name; char * source_name; char * reporting_entity_name; + char * event_listener_version; EVEL_EVENT_PRIORITIES priority; unsigned long long start_epoch_microsec; unsigned long long last_epoch_microsec; @@ -440,6 +467,8 @@ typedef struct event_header { EVEL_OPTION_INTHEADER_FIELDS internal_field; EVEL_OPTION_STRING nfcnaming_code; EVEL_OPTION_STRING nfnaming_code; + EVEL_OPTION_STRING nfVendor_name; + EVEL_OPTION_STRING timezone_offset; DLIST batch_events; } EVENT_HEADER; @@ -494,8 +523,8 @@ void evel_free_batch(EVENT_HEADER * event); /*****************************************************************************/ /* Supported Fault version. */ /*****************************************************************************/ -#define EVEL_FAULT_MAJOR_VERSION 2 -#define EVEL_FAULT_MINOR_VERSION 1 +#define EVEL_FAULT_MAJOR_VERSION 4 +#define EVEL_FAULT_MINOR_VERSION 0 /**************************************************************************//** * Fault. @@ -523,7 +552,7 @@ typedef struct event_fault { /***************************************************************************/ EVEL_OPTION_STRING category; EVEL_OPTION_STRING alarm_interface_a; - DLIST additional_info; + HASHTABLE_T *additional_info; } EVENT_FAULT; @@ -531,12 +560,11 @@ typedef struct event_fault { * Fault Additional Info. * JSON equivalent field: alarmAdditionalInformation *****************************************************************************/ -typedef struct fault_additional_info { + typedef struct fault_additional_info { char * name; char * value; } FAULT_ADDL_INFO; - /**************************************************************************//** * optional field block for fields specific to heartbeat events *****************************************************************************/ @@ -558,10 +586,314 @@ typedef struct event_heartbeat_fields /***************************************************************************/ /* Optional fields */ /***************************************************************************/ - DLIST additional_info; + HASHTABLE_T *additional_info; } EVENT_HEARTBEAT_FIELD; +/**************************************************************************//** + * Create a new Heartbeat fields event. + * + * @note The mandatory fields on the Heartbeat fields must be supplied to + * this factory function and are immutable once set. Optional fields + * have explicit setter functions, but again values may only be set + * once so that the event has immutable properties. + * @param event_name Unique Event Name confirming Domain AsdcModel Description + * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc + * @param vendor_id The vendor id to encode in the event instance id. + * @param event_id The vendor event id to encode in the event instance id. + * @returns pointer to the newly manufactured ::EVENT_HEARTBEAT_FIELD. If the event + * is not used (i.e. posted) it must be released using + * ::evel_free_hrtbt_field. + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_HEARTBEAT_FIELD * evel_new_heartbeat_field(int interval,const char* ev_name, const char *ev_id); + +/**************************************************************************//** + * Add a name/value pair to the Heartbeat fields, under the additionalFields array. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param event Pointer to the Heartbeat fields event. + * @param name ASCIIZ string with the field's name. The caller does not + * need to preserve the value once the function returns. + * @param value ASCIIZ string with the field's value. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ +void evel_hrtbt_field_addl_field_add(EVENT_HEARTBEAT_FIELD * const event, + const char * const name, + const char * const value); + +/**************************************************************************//** + * Set the Interval property of the Heartbeat fields event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param event Pointer to the Heartbeat fields event. + * @param product_id The vendor product id to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ +void evel_hrtbt_interval_set(EVENT_HEARTBEAT_FIELD * const event, + const int interval); + +/**************************************************************************//** + * Free a Heartbeat fields event. + * + * Free off the event supplied. Will free all the contained allocated memory. + * + * @note It does not free the event itself, since that may be part of a larger + * structure. + *****************************************************************************/ +void evel_free_hrtbt_field(EVENT_HEARTBEAT_FIELD * const event); + + +/*****************************************************************************/ +/* Supported PNF Registration version. */ +/*****************************************************************************/ +#define EVEL_PNF_REGISTRATION_MAJOR_VERSION 2 +#define EVEL_PNF_REGISTRATION_MINOR_VERSION 0 + +/**************************************************************************//** + * PNF Registration + * JSON equivalent field: pnfRegistrationFields + *****************************************************************************/ +typedef struct event_PNF_REGISTRATION { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + double version; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_STRING last_service_date; + EVEL_OPTION_STRING mac_address; + EVEL_OPTION_STRING manufacture_date; + EVEL_OPTION_STRING model_number; + EVEL_OPTION_STRING oam_v4_ipaddress; + EVEL_OPTION_STRING oam_v6_ipaddress; + EVEL_OPTION_STRING serial_number; + EVEL_OPTION_STRING sw_version; + EVEL_OPTION_STRING unit_family; + EVEL_OPTION_STRING unit_type; + EVEL_OPTION_STRING vendor_name; + HASHTABLE_T *additional_fields; + +} EVENT_PNF_REGISTRATION; + +/**************************************************************************//** + * Create a new PNF Registration event. + * + * @note The mandatory fields on the PNF Registration must be supplied to the + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once + * so that the State Change has immutable properties. + * + * @param event_name Unique Event Name confirming Domain AsdcModel Description + * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc + * + * @returns pointer to the newly manufactured ::EVENT_PNF_REGISTRATION. If the + * event is not used it must be released using + * ::evel_free_pnf_registration + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_PNF_REGISTRATION * evel_new_pnf_registration(const char* ev_name, const char *ev_id ); + +/**************************************************************************//** + * Free a PNF Registration. + * + * Free off the PNF Registration supplied. Will free all contained allocated + * memory. + * + * @note It does not free the PNF Registration itself, since that may be part + * of a larger structure. + *****************************************************************************/ +void evel_free_pnf_registration(EVENT_PNF_REGISTRATION * const pnf_registration); + +/**************************************************************************//** + * Add an additional field name/value pair to the PNF Registration + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param pnf_registration Pointer to the ::EVENT_PNF_REGISTRATION. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_pnf_registration_addl_field_add( + EVENT_PNF_REGISTRATION * const pnf_registration, + const char * const name, + const char * const value); + + + /****************************************************************//** + * Set the last service date + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param last_service_date The last service date to be set. ASCIIZ + * string. The caller does not need to preserve + * the value once the function returns. +*********************************************************************/ +void evel_pnfRegistration_last_service_date_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const last_service_date); + +/************************************************************************//** + * Set the Mac Address + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param mac_address The mac address to be set. ASCIIZ string. The + * caller does not need to preserve the value once + * the function returns. +***************************************************************************/ +void evel_pnfRegistration_mac_address_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const mac_address); + +/***********************************************************************//** + * Set the Manufacture Date + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param manufacture_date The manufacture date to be set. ASCIIZ string. + * The caller does not need to preserve the value + * once the function returns. +***************************************************************************/ +void evel_pnfRegistration_manufacture_date_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const manufacture_date); + +/***********************************************************************//** + * Set the Model Number + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param model_number The model Number to be set. ASCIIZ string. The caller + * does not need to preserve the value once the + * function returns. +***************************************************************************/ +void evel_pnfRegistration_model_number_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const model_number); + +/***********************************************************************//** + * Set the OAM v4 ipaddress + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param oam_v4_ipaddress Set the oam IP address. ASCIIZ string. + * The caller does not need + * preserve the value once the function returns. +*************************************************************************/ +void evel_pnfRegistration_oam_v4_ipaddress_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const oam_v4_ipaddress); + +/**********************************************************************//** + * Set the oam v6 ipaddress + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param oam_v6_ipaddress Set the oam IP address. ASCIIZ string. + * The caller does not need + * preserve the value once the function returns. +**************************************************************************/ +void evel_pnfRegistration_oam_v6_ipaddress_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const oam_v6_ipaddress); + +/**********************************************************************//** + * Set the Serial Number + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param serial_number The serial number to be set. ASCIIZ string. + * The caller does not need to preserve the + * value once the function returns. +**************************************************************************/ +void evel_pnfRegistration_serial_number_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const serial_number); + +/***********************************************************************//** + * Set the Software Version + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param sw_version The SW Version to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. +****************************************************************************/ +void evel_pnfRegistration_sw_version_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const sw_version); + +/***********************************************************************//** + * Set the Unit Family + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param unit_family The unit family to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. +***************************************************************************/ +void evel_pnfRegistration_unit_family_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const unit_family); + +/**********************************************************************//** + * Set the Unit type + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param unit_type The unit type to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. +****************************************************************************/ +void evel_pnfRegistration_unit_type_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const unit_type); + +/***********************************************************************//** + * Set the Vendor name + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param vendor_name The vendor name to be set. ASCIIZ string. The + * caller does not need to preserve the value once + * the function returns. +***************************************************************************/ +void evel_pnfRegistration_vendor_name_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const vendor_name); + /**************************************************************************//** * tuple which provides the name of a key along with its value and * relative order @@ -581,7 +913,7 @@ typedef struct json_object_instance { char *jsonstring; - unsigned long long objinst_epoch_microsec; + EVEL_OPTION_ULL objinst_epoch_microsec; DLIST object_keys; /*EVEL_INTERNAL_KEY list */ } EVEL_JSON_OBJECT_INSTANCE; @@ -648,19 +980,8 @@ void evel_free_jsonobject(EVEL_JSON_OBJECT * jsobj); /*****************************************************************************/ /* Supported Measurement version. */ /*****************************************************************************/ -#define EVEL_MEASUREMENT_MAJOR_VERSION 2 -#define EVEL_MEASUREMENT_MINOR_VERSION 1 - -/**************************************************************************//** - * Errors. - * JSON equivalent field: errors - *****************************************************************************/ -typedef struct measurement_errors { - int receive_discards; - int receive_errors; - int transmit_discards; - int transmit_errors; -} MEASUREMENT_ERRORS; +#define EVEL_MEASUREMENT_MAJOR_VERSION 4 +#define EVEL_MEASUREMENT_MINOR_VERSION 0 /**************************************************************************//** * Measurement. @@ -682,27 +1003,202 @@ typedef struct event_measurement { /***************************************************************************/ /* Optional fields */ /***************************************************************************/ - DLIST additional_info; - DLIST additional_measurements; - DLIST additional_objects; + HASHTABLE_T * additional_info; + DLIST additional_measurements; // arry of named hashmap + DLIST additional_objects; //array of json objects DLIST codec_usage; EVEL_OPTION_INT concurrent_sessions; EVEL_OPTION_INT configured_entities; DLIST cpu_usage; + + //VES6.0 Added field 14/07/2018 + DLIST huge_pages; + DLIST loads; + DLIST process_stats; + DLIST ipmis; + DLIST disk_usage; - MEASUREMENT_ERRORS * errors; - DLIST feature_usage; + DLIST machine_check_exception; + HASHTABLE_T * feature_usage; DLIST filesystem_usage; DLIST latency_distribution; EVEL_OPTION_DOUBLE mean_request_latency; DLIST mem_usage; EVEL_OPTION_INT media_ports_in_use; - EVEL_OPTION_INT request_rate; + EVEL_OPTION_DOUBLE request_rate; EVEL_OPTION_INT vnfc_scaling_metric; - DLIST vnic_usage; + DLIST nic_performance; } EVENT_MEASUREMENT; +typedef struct Measurement_machine_check_exception { + char * process_id; + EVEL_OPTION_DOUBLE corrected_memory_errors; + EVEL_OPTION_DOUBLE corrected_memory_errors_in_1Hr; + EVEL_OPTION_DOUBLE uncorrected_memory_errors; + EVEL_OPTION_DOUBLE uncorrected_memory_errors_in_1Hr; + +} MACHINE_CHECK_EXCEPTION; +/**************************************************************************//** +* Huge Pages. +* JSON equivalent field: hugePages +*****************************************************************************/ +typedef struct measurement_huge_page { + char * hugePagesIdentifier; + EVEL_OPTION_DOUBLE bytesUsed; + EVEL_OPTION_DOUBLE bytesFree; + EVEL_OPTION_DOUBLE vmPageNumberUsed; + EVEL_OPTION_DOUBLE vmPageNumberFree; + EVEL_OPTION_DOUBLE percentUsed; + EVEL_OPTION_DOUBLE percentFree; + } MEASUREMENT_HUGE_PAGE; + +/**************************************************************************//** +* Process Stats. +* JSON equivalent field: processStats +*****************************************************************************/ +typedef struct measurement_process_stats { + char * processIdentifier; + EVEL_OPTION_DOUBLE forkRate; + EVEL_OPTION_DOUBLE psStateBlocked; + EVEL_OPTION_DOUBLE psStatePaging; + EVEL_OPTION_DOUBLE psStateRunning; + EVEL_OPTION_DOUBLE psStateSleeping; + EVEL_OPTION_DOUBLE psStateStopped; + EVEL_OPTION_DOUBLE psStateZombie; + + } MEASUREMENT_PROCESS_STATS; + +/**************************************************************************//** +* Load. +* JSON equivalent field: load +*****************************************************************************/ +typedef struct measurement_load { + EVEL_OPTION_DOUBLE shortTerm; + EVEL_OPTION_DOUBLE midTerm; + EVEL_OPTION_DOUBLE longTerm; + + } MEASUREMENT_LOAD; + +/**************************************************************************//** + * Convert a ::EVEL_OPTION_OP_STATE to it's string form for JSON encoding. + * + * @param state The entity state to encode. + * + * @returns the corresponding string + *****************************************************************************/ +char * evel_entity_opt_op_state (EVEL_OPTION_OP_STATE * const state); + +/**************************************************************************//** + * Initialize an ::EVEL_OPTION_STATE to a not-set state. + * + * @param option Pointer to the ::EVEL_OPTION_INT. + *****************************************************************************/ +void evel_init_option_op_state(EVEL_OPTION_OP_STATE * const option); + +/**************************************************************************//** + * Set the value of an ::EVEL_OPTION_STATE. + * + * @param option Pointer to the ::EVEL_OPTION_STATE. + * @param value The value to set. + * @param description Description to be used in logging. + *****************************************************************************/ +void evel_set_option_op_state(EVEL_OPTION_OP_STATE * const option, + const int value, + const char * const description); +/**************************************************************************//** + * Add a huge page to measurement + * + * @param measurement Pointer to measurement + * @param hugePagesIdentifier Huge Page Identifier to add + *****************************************************************************/ +MEASUREMENT_HUGE_PAGE * evel_measurement_new_huge_page_add( + EVENT_MEASUREMENT * measurement, + const char * const hugePagesIdentifier ); + +/**************************************************************************//** + * Set bytes used value in a huge page + * + * @param huge_page Pointer to huge page + * @param val bytes used value + *****************************************************************************/ +void evel_measurement_huge_page_bytesUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Set bytes free value in a huge page + * + * @param huge_page Pointer to huge page + * @param val bytes free value + *****************************************************************************/ +void evel_measurement_huge_page_bytesFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Set Number of used VM Pages in numbers in a huge page + * + * @param huge_page Pointer to huge page + * @param val value + *****************************************************************************/ +void evel_measurement_huge_page_vmPageNumberUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Set Number of free VM Pages in numbers in a huge page + * + * @param huge_page Pointer to huge page + * @param val value + *****************************************************************************/ +void evel_measurement_huge_page_vmPageNumberFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Set Number of used hugePages in percent in a huge page + * + * @param huge_page Pointer to huge page + * @param val value + *****************************************************************************/ +void evel_measurement_huge_page_percentUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Set umber of free hugePages in percent in a huge page + * + * @param huge_page Pointer to huge page + * @param val value + *****************************************************************************/ +void evel_measurement_huge_page_percentFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val); + +/**************************************************************************//** + * Add an additional value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the measurement. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_measurement_addl_info_add(EVENT_MEASUREMENT * measurement, char * name, char * value); + +/**************************************************************************//** + * Add a json object to jsonObject list. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the ScalingMeasurement + * @param jsonobj Pointer to json object + *****************************************************************************/ +void evel_measurement_addl_object_add(EVENT_MEASUREMENT * measurement, EVEL_JSON_OBJECT *jsonobj); + /**************************************************************************//** * CPU Usage. * JSON equivalent field: cpuUsage @@ -718,6 +1214,18 @@ typedef struct measurement_cpu_use { EVEL_OPTION_DOUBLE sys; EVEL_OPTION_DOUBLE user; EVEL_OPTION_DOUBLE wait; + + /* + * Ves6.0 added fields 14/07/2018 + */ + EVEL_OPTION_DOUBLE cpuCapacityContention; + EVEL_OPTION_DOUBLE cpuDemandAvg; + EVEL_OPTION_DOUBLE cpuDemandMhz; + EVEL_OPTION_DOUBLE cpuDemandPct; + EVEL_OPTION_DOUBLE cpuLatencyAvg; + EVEL_OPTION_DOUBLE cpuOverheadAvg; + EVEL_OPTION_DOUBLE cpuSwapWaitTime; + } MEASUREMENT_CPU_USE; @@ -767,6 +1275,23 @@ typedef struct measurement_disk_use { EVEL_OPTION_DOUBLE timewritelast; EVEL_OPTION_DOUBLE timewritemax; EVEL_OPTION_DOUBLE timewritemin; + /* + * VES6.0 Added fields 14/07/2018 + */ + EVEL_OPTION_DOUBLE diskBusResets; + EVEL_OPTION_DOUBLE diskCommandsAborted; + EVEL_OPTION_DOUBLE diskTime; + EVEL_OPTION_DOUBLE diskFlushRequests; + EVEL_OPTION_DOUBLE diskFlushTime; + EVEL_OPTION_DOUBLE diskCommandsAvg; + EVEL_OPTION_DOUBLE diskReadCommandsAvg; + EVEL_OPTION_DOUBLE diskWriteCommandsAvg; + EVEL_OPTION_DOUBLE diskTotalReadLatencyAvg; + EVEL_OPTION_DOUBLE diskTotalWriteLatencyAvg; + EVEL_OPTION_DOUBLE diskWeightedIoTimeAvg; + EVEL_OPTION_DOUBLE diskWeightedIoTimeLast; + EVEL_OPTION_DOUBLE diskWeightedIoTimeMax; + EVEL_OPTION_DOUBLE diskWeightedIoTimeMin; } MEASUREMENT_DISK_USE; @@ -784,1963 +1309,3790 @@ typedef struct measurement_disk_use { MEASUREMENT_DISK_USE * evel_measurement_new_disk_use_add(EVENT_MEASUREMENT * measurement, char * id); /**************************************************************************//** - * Filesystem Usage. - * JSON equivalent field: filesystemUsage + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the average over the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_fsys_use { - char * filesystem_name; - double block_configured; - double block_iops; - double block_used; - double ephemeral_configured; - double ephemeral_iops; - double ephemeral_used; -} MEASUREMENT_FSYS_USE; +void evel_measurement_disk_use_iotimeavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Memory Usage. - * JSON equivalent field: memoryUsage - *****************************************************************************/ -typedef struct measurement_mem_use { - char * id; - char * vmid; - double membuffsz; - EVEL_OPTION_DOUBLE memcache; - EVEL_OPTION_DOUBLE memconfig; - EVEL_OPTION_DOUBLE memfree; - EVEL_OPTION_DOUBLE slabrecl; - EVEL_OPTION_DOUBLE slabunrecl; - EVEL_OPTION_DOUBLE memused; -} MEASUREMENT_MEM_USE; - -/**************************************************************************//** - * Add an additional Memory usage value name/value pair to the Measurement. + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the last value within the measurement interval * - * The name and value are null delimited ASCII strings. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param id ASCIIZ string with the Memory identifier. - * @param vmidentifier ASCIIZ string with the VM's identifier. - * @param membuffsz Memory Size. + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_iotimelast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); +/**************************************************************************//** + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the maximum value within the measurement interval * - * @return Returns pointer to memory use structure in measurements + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add(EVENT_MEASUREMENT * measurement, - char * id, char *vmidentifier, double membuffsz); +void evel_measurement_disk_use_iotimemax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Set kilobytes of memory used for cache + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the minimum value within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_iotimemin_set(MEASUREMENT_DISK_USE * const disk_use, const double val); + /**************************************************************************//** - * Set kilobytes of memory configured in the virtual machine on which the VNFC reporting + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the average measurement within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_mergereadavg_set(MEASUREMENT_DISK_USE * const disk_use, const double val); + /**************************************************************************//** - * Set kilobytes of physical RAM left unused by the system + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the last measurement within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_memfree_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_mergereadlast_set(MEASUREMENT_DISK_USE * const disk_use, const double val); + /**************************************************************************//** - * Set the part of the slab that can be reclaimed such as caches measured in kilobytes + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the maximum measurement within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_slab_reclaimed_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_mergereadmax_set(MEASUREMENT_DISK_USE * const disk_use, const double val); /**************************************************************************//** - * Set the part of the slab that cannot be reclaimed such as caches measured in kilobytes + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the minimum measurement within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_mergereadmin_set(MEASUREMENT_DISK_USE * const disk_use, const double val); + /**************************************************************************//** - * Set the total memory minus the sum of free, buffered, cached and slab memory in kilobytes + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the last measurement within the measurement interval * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param mem_use Pointer to the Memory Use. + * @param disk_use Pointer to the Disk Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_usedup_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_disk_use_mergewritelast_set(MEASUREMENT_DISK_USE * const disk_use, const double val); + /**************************************************************************//** - * Latency Bucket. - * JSON equivalent field: latencyBucketMeasure + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_latency_bucket { - int count; - - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - EVEL_OPTION_DOUBLE high_end; - EVEL_OPTION_DOUBLE low_end; - -} MEASUREMENT_LATENCY_BUCKET; +void evel_measurement_disk_use_mergewritemax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Virtual NIC usage. - * JSON equivalent field: vNicUsage + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_vnic_performance { - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - /*Cumulative count of broadcast packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_bcast_packets_acc; - /*Count of broadcast packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_bcast_packets_delta; - /*Cumulative count of discarded packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_discarded_packets_acc; - /*Count of discarded packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_discarded_packets_delta; - /*Cumulative count of error packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_error_packets_acc; - /*Count of error packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_error_packets_delta; - /*Cumulative count of multicast packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_mcast_packets_acc; - /*Count of mcast packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_mcast_packets_delta; - /*Cumulative count of octets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_octets_acc; - /*Count of octets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_octets_delta; - /*Cumulative count of all packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_total_packets_acc; - /*Count of all packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_total_packets_delta; - /*Cumulative count of unicast packets received as read at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_ucast_packets_acc; - /*Count of unicast packets received within the measurement interval*/ - EVEL_OPTION_DOUBLE recvd_ucast_packets_delta; - /*Cumulative count of transmitted broadcast packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_bcast_packets_acc; - /*Count of transmitted broadcast packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_bcast_packets_delta; - /*Cumulative count of transmit discarded packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_discarded_packets_acc; - /*Count of transmit discarded packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_discarded_packets_delta; - /*Cumulative count of transmit error packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_error_packets_acc; - /*Count of transmit error packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_error_packets_delta; - /*Cumulative count of transmit multicast packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_mcast_packets_acc; - /*Count of transmit multicast packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_mcast_packets_delta; - /*Cumulative count of transmit octets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_octets_acc; - /*Count of transmit octets received within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_octets_delta; - /*Cumulative count of all transmit packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_total_packets_acc; - /*Count of transmit packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_total_packets_delta; - /*Cumulative count of all transmit unicast packets at the end of - the measurement interval*/ - EVEL_OPTION_DOUBLE tx_ucast_packets_acc; - /*Count of transmit unicast packets within the measurement interval*/ - EVEL_OPTION_DOUBLE tx_ucast_packets_delta; - /* Indicates whether vNicPerformance values are likely inaccurate - due to counter overflow or other condtions*/ - char *valuesaresuspect; - char *vnic_id; - -} MEASUREMENT_VNIC_PERFORMANCE; +void evel_measurement_disk_use_mergewriteavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Codec Usage. - * JSON equivalent field: codecsInUse + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_codec_use { - char * codec_id; - int number_in_use; -} MEASUREMENT_CODEC_USE; +void evel_measurement_disk_use_mergewritemin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Feature Usage. - * JSON equivalent field: featuresInUse + * Set number of octets per second read from a disk or partition; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_feature_use { - char * feature_id; - int feature_utilization; -} MEASUREMENT_FEATURE_USE; +void evel_measurement_disk_use_octetsreadavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Measurement Group. - * JSON equivalent field: additionalMeasurements + * Set number of octets per second read from a disk or partition; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct measurement_group { - char * name; - DLIST measurements; -} MEASUREMENT_GROUP; +void evel_measurement_disk_use_octetsreadlast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Custom Defined Measurement. - * JSON equivalent field: measurements + * Set number of octets per second read from a disk or partition; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct custom_measurement { - char * name; - char * value; -} CUSTOM_MEASUREMENT; - -/*****************************************************************************/ -/* Supported Report version. */ -/*****************************************************************************/ -#define EVEL_REPORT_MAJOR_VERSION 1 -#define EVEL_REPORT_MINOR_VERSION 1 +void evel_measurement_disk_use_octetsreadmax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Report. - * JSON equivalent field: measurementsForVfReportingFields + * Set number of octets per second read from a disk or partition; + * provide the minimum measurement within the measurement interval * - * @note This is an experimental event type and is not currently a formal part - * of AT&T's specification. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct event_report { - /***************************************************************************/ - /* Header and version */ - /***************************************************************************/ - EVENT_HEADER header; - int major_version; - int minor_version; - - /***************************************************************************/ - /* Mandatory fields */ - /***************************************************************************/ - double measurement_interval; +void evel_measurement_disk_use_octetsreadmin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - DLIST feature_usage; - DLIST measurement_groups; +/**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_octetswriteavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -} EVENT_REPORT; +/**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_octetswritelast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Mobile GTP Per Flow Metrics. - * JSON equivalent field: gtpPerFlowMetrics + * Set number of octets per second written to a disk or partition; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct mobile_gtp_per_flow_metrics { - double avg_bit_error_rate; - double avg_packet_delay_variation; - int avg_packet_latency; - int avg_receive_throughput; - int avg_transmit_throughput; - int flow_activation_epoch; - int flow_activation_microsec; - int flow_deactivation_epoch; - int flow_deactivation_microsec; - time_t flow_deactivation_time; - char * flow_status; - int max_packet_delay_variation; - int num_activation_failures; - int num_bit_errors; - int num_bytes_received; - int num_bytes_transmitted; - int num_dropped_packets; - int num_l7_bytes_received; - int num_l7_bytes_transmitted; - int num_lost_packets; - int num_out_of_order_packets; - int num_packet_errors; - int num_packets_received_excl_retrans; - int num_packets_received_incl_retrans; - int num_packets_transmitted_incl_retrans; - int num_retries; - int num_timeouts; - int num_tunneled_l7_bytes_received; - int round_trip_time; - int time_to_first_byte; +void evel_measurement_disk_use_octetswritemax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - EVEL_OPTION_INT ip_tos_counts[EVEL_TOS_SUPPORTED]; - EVEL_OPTION_INT tcp_flag_counts[EVEL_MAX_TCP_FLAGS]; - EVEL_OPTION_INT qci_cos_counts[EVEL_MAX_QCI_COS_TYPES]; - EVEL_OPTION_INT dur_connection_failed_status; - EVEL_OPTION_INT dur_tunnel_failed_status; - EVEL_OPTION_STRING flow_activated_by; - EVEL_OPTION_TIME flow_activation_time; - EVEL_OPTION_STRING flow_deactivated_by; - EVEL_OPTION_STRING gtp_connection_status; - EVEL_OPTION_STRING gtp_tunnel_status; - EVEL_OPTION_INT large_packet_rtt; - EVEL_OPTION_DOUBLE large_packet_threshold; - EVEL_OPTION_INT max_receive_bit_rate; - EVEL_OPTION_INT max_transmit_bit_rate; - EVEL_OPTION_INT num_gtp_echo_failures; - EVEL_OPTION_INT num_gtp_tunnel_errors; - EVEL_OPTION_INT num_http_errors; +/**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_octetswritemin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -} MOBILE_GTP_PER_FLOW_METRICS; +/**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opsreadavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -/*****************************************************************************/ -/* Supported Mobile Flow version. */ -/*****************************************************************************/ -#define EVEL_MOBILE_FLOW_MAJOR_VERSION 2 -#define EVEL_MOBILE_FLOW_MINOR_VERSION 0 +/**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opsreadlast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Mobile Flow. - * JSON equivalent field: mobileFlow + * Set number of read operations per second issued to the disk; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct event_mobile_flow { - /***************************************************************************/ - /* Header and version */ - /***************************************************************************/ - EVENT_HEADER header; - int major_version; - int minor_version; +void evel_measurement_disk_use_opsreadmax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); - /***************************************************************************/ - /* Mandatory fields */ - /***************************************************************************/ - char * flow_direction; - MOBILE_GTP_PER_FLOW_METRICS * gtp_per_flow_metrics; - char * ip_protocol_type; - char * ip_version; - char * other_endpoint_ip_address; - int other_endpoint_port; - char * reporting_endpoint_ip_addr; - int reporting_endpoint_port; - DLIST additional_info; /* JSON: additionalFields */ +/**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opsreadmin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - EVEL_OPTION_STRING application_type; - EVEL_OPTION_STRING app_protocol_type; - EVEL_OPTION_STRING app_protocol_version; - EVEL_OPTION_STRING cid; - EVEL_OPTION_STRING connection_type; - EVEL_OPTION_STRING ecgi; - EVEL_OPTION_STRING gtp_protocol_type; - EVEL_OPTION_STRING gtp_version; - EVEL_OPTION_STRING http_header; - EVEL_OPTION_STRING imei; - EVEL_OPTION_STRING imsi; - EVEL_OPTION_STRING lac; - EVEL_OPTION_STRING mcc; - EVEL_OPTION_STRING mnc; - EVEL_OPTION_STRING msisdn; - EVEL_OPTION_STRING other_functional_role; - EVEL_OPTION_STRING rac; - EVEL_OPTION_STRING radio_access_technology; - EVEL_OPTION_STRING sac; - EVEL_OPTION_INT sampling_algorithm; - EVEL_OPTION_STRING tac; - EVEL_OPTION_STRING tunnel_id; - EVEL_OPTION_STRING vlan_id; +/**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opswriteavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -} EVENT_MOBILE_FLOW; +/**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opswritelast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -/*****************************************************************************/ -/* Supported Other field version. */ -/*****************************************************************************/ -#define EVEL_OTHER_EVENT_MAJOR_VERSION 1 -#define EVEL_OTHER_EVENT_MINOR_VERSION 1 +/**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_opswritemax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Other. - * JSON equivalent field: otherFields + * Set number of write operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct event_other { - EVENT_HEADER header; - int major_version; - int minor_version; +void evel_measurement_disk_use_opswritemin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); - HASHTABLE_T *namedarrays; /* HASHTABLE_T */ - DLIST jsonobjects; /* DLIST of EVEL_JSON_OBJECT */ - DLIST namedvalues; -} EVENT_OTHER; +/**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_pendingopsavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Other Field. - * JSON equivalent field: otherFields + * Set queue size of pending I/O operations per second; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double *****************************************************************************/ -typedef struct other_field { - char * name; - char * value; -} OTHER_FIELD; +void evel_measurement_disk_use_pendingopslast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); +/**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_pendingopsmax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -/*****************************************************************************/ -/* Supported Service Events version. */ -/*****************************************************************************/ -#define EVEL_HEARTBEAT_FIELD_MAJOR_VERSION 1 -#define EVEL_HEARTBEAT_FIELD_MINOR_VERSION 1 +/**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_pendingopsmin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); +/**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timereadavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); -/*****************************************************************************/ -/* Supported Signaling version. */ -/*****************************************************************************/ -#define EVEL_SIGNALING_MAJOR_VERSION 1 -#define EVEL_SIGNALING_MINOR_VERSION 0 +/**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timereadlast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); /**************************************************************************//** - * Vendor VNF Name fields. - * JSON equivalent field: vendorVnfNameFields + * Set milliseconds a read operation took to complete; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timereadmax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timereadmin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timewriteavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timewritelast_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); +/**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timewritemax_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_timewritemin_set(MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Number of bus resets over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskBusResets_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Number of disk commands aborted over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskCommandsAborted_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Nanoseconds spent on disk cache reads/writes within the measurement + * interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskTime_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Total flush requests of the disk cache over the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskFlushRequests_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Milliseconds spent on disk cache flushing over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskFlushTime_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Average number of commands per second over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Average number of read commands issued per second to the disk over the + * measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskReadCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Average number of write commands issued per second to the disk over the + * measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskWriteCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Average read time from the perspective of a Guest OS: sum of the Kernel + * Read Latency and Physical Device Read Latency in milliseconds over the + * measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskTotalReadLatencyAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Average write time from the perspective of a Guest OS: sum of the + * Kernel Write Latency and Physical Device Write Latency in milliseconds over + * the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskTotalWriteLatencyAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Measure in ms over 1 sec of both I/O completion time and the backlog + * that may be accumulating. Value is the average within the collection + * interval. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskWeightedIoTimeAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Measure in ms over 1 sec of both I/O completion time and the backlog + * that may be accumulating. Value is the last within the collection interval. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskWeightedIoTimeLast_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Measure in ms over 1 sec of both I/O completion time and the backlog + * that may be accumulating. Value is the maximum within the collection + * interval. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskWeightedIoTimeMax_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Set Measure in ms over 1 sec of both I/O completion time and the backlog + * that may be accumulating. Value is the minimum within the collection + * interval. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_diskWeightedIoTimeMin_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val); + +/**************************************************************************//** + * Filesystem Usage. + * JSON equivalent field: filesystemUsage + *****************************************************************************/ +typedef struct measurement_fsys_use { + char * filesystem_name; + double block_configured; + double block_iops; + double block_used; + double ephemeral_configured; + double ephemeral_iops; + double ephemeral_used; +} MEASUREMENT_FSYS_USE; + +/**************************************************************************//** + * Memory Usage. + * JSON equivalent field: memoryUsage + *****************************************************************************/ +typedef struct measurement_mem_use { + char * vmid; + double memused; + double memfree; + EVEL_OPTION_DOUBLE membuffsz; + EVEL_OPTION_DOUBLE memcache; + EVEL_OPTION_DOUBLE memconfig; + EVEL_OPTION_DOUBLE slabrecl; + EVEL_OPTION_DOUBLE slabunrecl; + /* + * VES6.0 Added fields 14/07/2018 + */ + EVEL_OPTION_DOUBLE memoryDemand; + EVEL_OPTION_DOUBLE memoryLatencyAvg; + EVEL_OPTION_DOUBLE memorySharedAvg; + EVEL_OPTION_DOUBLE memorySwapInAvg; + EVEL_OPTION_DOUBLE memorySwapInRateAvg; + EVEL_OPTION_DOUBLE memorySwapOutAvg; + EVEL_OPTION_DOUBLE memorySwapOutRateAvg; + EVEL_OPTION_DOUBLE memorySwapUsedAvg; + EVEL_OPTION_DOUBLE percentMemoryUsage; + +} MEASUREMENT_MEM_USE; + +/**************************************************************************//** + * Add an additional Memory usage value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the measurement. + * @param vmidentifier ASCIIZ string with the VM's identifier. + * @param memfree Memory Free Size. + * @param memused Memory Used + * + * @return Returns pointer to memory use structure in measurements + *****************************************************************************/ +MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add( + EVENT_MEASUREMENT * measurement, + char *vmidentifier, + double memfree, + double memused); + +/**************************************************************************//** + * Set kilobytes of memory used for cache + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); +/**************************************************************************//** + * Set kilobytes of memory Buffered + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_mem_buffered_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + * Set kilobytes of memory configured in the virtual machine on which the VNFC + * reporting + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + * Set the part of the slab that can be reclaimed such as caches measured in + * kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_slab_reclaimed_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + * Set the part of the slab that cannot be reclaimed such as caches measured + * in kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + * Set the Host demand in kibibytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memoryDemand_set(MEASUREMENT_MEM_USE * const mem_use, const double val); + +/**************************************************************************//** + * Set the memory latency average in Percentage of time the VM is + * waiting to access swapped or compressed memory + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memoryLatencyAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the shared memory in kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySharedAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Amount of memory swapped-in from host cache in kibibytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySwapInAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Rate at which memory is swapped from disk into active memory + * during the interval in kilobytes per second + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySwapInRateAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Amount of memory swapped-out to host cache in kibibytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySwapOutAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Rate at which memory is being swapped from active memory to disk + * during the current interval in kilobytes per second + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySwapOutRateAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Space used for caching swapped pages in the host cache in kibibytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_memorySwapUsedAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + ** Set the Percentage of memory usage; value = + * (memoryUsed / (memoryUsed + memoryFree) x 100 if denomintor is nonzero, + * or 0, if otherwise. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ +void evel_measurement_mem_use_percentMemoryUsage_set(MEASUREMENT_MEM_USE * const mem_use, + const double val); + +/**************************************************************************//** + * Latency Bucket. + * JSON equivalent field: latencyBucketMeasure + *****************************************************************************/ +typedef struct measurement_latency_bucket { + int count; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_DOUBLE high_end; + EVEL_OPTION_DOUBLE low_end; + +} MEASUREMENT_LATENCY_BUCKET; + +/**************************************************************************//** + * Virtual NIC performance. + * JSON equivalent field: NicPerformance + *****************************************************************************/ +typedef struct measurement_nic_performance { + + /* Indicates whether NicPerformance values are likely inaccurate + due to counter overflow or other condtions*/ + char * nic_id; + char * valuesaresuspect; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_OP_STATE administrativeState; + EVEL_OPTION_OP_STATE operationalState; + EVEL_OPTION_DOUBLE receivedPercentDiscard; + EVEL_OPTION_DOUBLE receivedPercentError; + EVEL_OPTION_DOUBLE receivedUtilization; + EVEL_OPTION_DOUBLE speed; + EVEL_OPTION_DOUBLE transmittedPercentDiscard; + EVEL_OPTION_DOUBLE transmittedPercentError; + EVEL_OPTION_DOUBLE transmittedUtilization; + + /*Cumulative count of broadcast packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_bcast_packets_acc; + /*Count of broadcast packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_bcast_packets_delta; + /*Cumulative count of discarded packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_discarded_packets_acc; + /*Count of discarded packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_discarded_packets_delta; + /*Cumulative count of error packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_error_packets_acc; + /*Count of error packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_error_packets_delta; + /*Cumulative count of multicast packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_mcast_packets_acc; + /*Count of mcast packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_mcast_packets_delta; + /*Cumulative count of octets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_octets_acc; + /*Count of octets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_octets_delta; + /*Cumulative count of all packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_total_packets_acc; + /*Count of all packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_total_packets_delta; + /*Cumulative count of unicast packets received as read at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_ucast_packets_acc; + /*Count of unicast packets received within the measurement interval*/ + EVEL_OPTION_DOUBLE recvd_ucast_packets_delta; + /*Cumulative count of transmitted broadcast packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_bcast_packets_acc; + /*Count of transmitted broadcast packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_bcast_packets_delta; + /*Cumulative count of transmit discarded packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_discarded_packets_acc; + /*Count of transmit discarded packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_discarded_packets_delta; + /*Cumulative count of transmit error packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_error_packets_acc; + /*Count of transmit error packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_error_packets_delta; + /*Cumulative count of transmit multicast packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_mcast_packets_acc; + /*Count of transmit multicast packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_mcast_packets_delta; + /*Cumulative count of transmit octets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_octets_acc; + /*Count of transmit octets received within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_octets_delta; + /*Cumulative count of all transmit packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_total_packets_acc; + /*Count of transmit packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_total_packets_delta; + /*Cumulative count of all transmit unicast packets at the end of + the measurement interval*/ + EVEL_OPTION_DOUBLE tx_ucast_packets_acc; + /*Count of transmit unicast packets within the measurement interval*/ + EVEL_OPTION_DOUBLE tx_ucast_packets_delta; + +} MEASUREMENT_NIC_PERFORMANCE; + +/**************************************************************************//** + * Codec Usage. + * JSON equivalent field: codecsInUse + *****************************************************************************/ +typedef struct measurement_codec_use { + char * codec_id; + int number_in_use; +} MEASUREMENT_CODEC_USE; + +/**************************************************************************//** + * Feature Usage. + * JSON equivalent field: featuresInUse + *****************************************************************************/ +typedef struct measurement_feature_use { + char * feature_id; + int feature_utilization; +} MEASUREMENT_FEATURE_USE; + +/**************************************************************************//** + * Measurement Group. + * JSON equivalent field: additionalMeasurements + *****************************************************************************/ +typedef struct measurement_group { + char * name; + DLIST measurements; +} MEASUREMENT_GROUP; + +/* +* VES6.0 added fields 14July +*/ + +/**************************************************************************//** +* IPMI. +* JSON equivalent field: Ipmi +*****************************************************************************/ +typedef struct measurement_ipmi { + EVEL_OPTION_DOUBLE exitAirTemperature; + EVEL_OPTION_DOUBLE frontPanelTemperature; + EVEL_OPTION_DOUBLE ioModuleTemperature; + EVEL_OPTION_DOUBLE systemAirflow; + DLIST ipmi_base_board_temparature; + DLIST ipmi_base_board_voltage; + DLIST ipmi_battery; + DLIST ipmi_fan; + DLIST ipmi_hsbp; + DLIST ipmi_global_agg_temp_margin; + DLIST ipmi_nic; + DLIST ipmi_power; + DLIST ipmi_processor; + +} MEASUREMENT_IPMI; + +/**************************************************************************//** +* IPMI base board temperature +* JSON equivalent field: PercentUsage +*****************************************************************************/ +typedef struct measurement_ipmi_bb_temperature { + char * BBTemperatureID; + EVEL_OPTION_DOUBLE BBTemperature; + + } MEASUREMENT_IPMI_BB_TEMPERATURE; + +typedef struct measurement_ipmi_bb_voltage { + char * BBVoltageRegID; + EVEL_OPTION_DOUBLE voltageRegTemperature; + + } MEASUREMENT_IPMI_BB_VOLTAGE; + +typedef struct measurement_ipmi_battery { + char * batteryIdentifier; + EVEL_OPTION_STRING batteryType; + EVEL_OPTION_DOUBLE batteryVoltageLevel; + + } MEASUREMENT_IPMI_BATTERY; + + +typedef struct measurement_ipmi_fan { + char * fanIdentifier; + EVEL_OPTION_DOUBLE fanSpeed; + + } MEASUREMENT_IPMI_FAN; + +typedef struct measurement_ipmi_hsbp { + char * hsbpIdentifier; + EVEL_OPTION_DOUBLE hsbpTemperature; + + } MEASUREMENT_IPMI_HSBP; + +typedef struct measurement_ipmi_global_agg_temp_margin { + char * globalAggTempID; + EVEL_OPTION_DOUBLE globalAggTempMargin; + + } MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN; + +typedef struct measurement_ipmi_nic { + char * nicIdentifier; + EVEL_OPTION_DOUBLE nicTemperature; + + } MEASUREMENT_IPMI_NIC; + +typedef struct measurement_ipmi_power_supply { + char * powerSupplyIdentifier; + EVEL_OPTION_DOUBLE powerSupplyInputPower; + EVEL_OPTION_DOUBLE powerSupplyCurrentOutput; + EVEL_OPTION_DOUBLE powerSupplyTemperature; + + } MEASUREMENT_IPMI_POWER_SUPPLY; + +typedef struct measurement_ipmi_processor { + char * processorIdentifier; + EVEL_OPTION_DOUBLE pprocessorThermalControl; + EVEL_OPTION_DOUBLE processorDtsThermalMargin; + DLIST processorDimmAggregateThermalMargin; + + } MEASUREMENT_IPMI_PROCESSOR; + +typedef struct measurement_ipmi_processor_dimmAgg_therm { + char * MarginIdentifier; + double thermalMargin; + + } MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM; + +/**************************************************************************//** + * Custom Defined Measurement. + * JSON equivalent field: measurements + *****************************************************************************/ +typedef struct custom_measurement { + char * name; + char * value; +} CUSTOM_MEASUREMENT; + +/*****************************************************************************/ +/* Supported Report version. */ +/*****************************************************************************/ +#define EVEL_REPORT_MAJOR_VERSION 1 +#define EVEL_REPORT_MINOR_VERSION 0 + +/**************************************************************************//** + * Report. + * JSON equivalent field: measurementsForVfReportingFields + * + * @note This is an experimental event type and is not currently a formal part + * of AT&T's specification. + *****************************************************************************/ +typedef struct event_report { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + double measurement_interval; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + DLIST feature_usage; + DLIST measurement_groups; + +} EVENT_REPORT; + +/**************************************************************************//** + * Mobile GTP Per Flow Metrics. + * JSON equivalent field: gtpPerFlowMetrics + *****************************************************************************/ +typedef struct mobile_gtp_per_flow_metrics { + double avg_bit_error_rate; + double avg_packet_delay_variation; + int avg_packet_latency; + int avg_receive_throughput; + int avg_transmit_throughput; + int flow_activation_epoch; + int flow_activation_microsec; + int flow_deactivation_epoch; + int flow_deactivation_microsec; + time_t flow_deactivation_time; + char * flow_status; + int max_packet_delay_variation; + int num_activation_failures; + int num_bit_errors; + int num_bytes_received; + int num_bytes_transmitted; + int num_dropped_packets; + int num_l7_bytes_received; + int num_l7_bytes_transmitted; + int num_lost_packets; + int num_out_of_order_packets; + int num_packet_errors; + int num_packets_received_excl_retrans; + int num_packets_received_incl_retrans; + int num_packets_transmitted_incl_retrans; + int num_retries; + int num_timeouts; + int num_tunneled_l7_bytes_received; + int round_trip_time; + int time_to_first_byte; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_INT ip_tos_counts[EVEL_TOS_SUPPORTED]; + EVEL_OPTION_INT tcp_flag_counts[EVEL_MAX_TCP_FLAGS]; + EVEL_OPTION_INT qci_cos_counts[EVEL_MAX_QCI_COS_TYPES]; + EVEL_OPTION_INT dur_connection_failed_status; + EVEL_OPTION_INT dur_tunnel_failed_status; + EVEL_OPTION_STRING flow_activated_by; + EVEL_OPTION_TIME flow_activation_time; + EVEL_OPTION_STRING flow_deactivated_by; + EVEL_OPTION_STRING gtp_connection_status; + EVEL_OPTION_STRING gtp_tunnel_status; + EVEL_OPTION_INT large_packet_rtt; + EVEL_OPTION_DOUBLE large_packet_threshold; + EVEL_OPTION_INT max_receive_bit_rate; + EVEL_OPTION_INT max_transmit_bit_rate; + EVEL_OPTION_INT num_gtp_echo_failures; + EVEL_OPTION_INT num_gtp_tunnel_errors; + EVEL_OPTION_INT num_http_errors; + HASHTABLE_T *ip_tos_count_list; + HASHTABLE_T *mobile_qci_cos_count_list; + HASHTABLE_T *tcp_flag_count_list; + +} MOBILE_GTP_PER_FLOW_METRICS; + +/*****************************************************************************/ +/* Supported Mobile Flow version. */ +/*****************************************************************************/ +#define EVEL_MOBILE_FLOW_MAJOR_VERSION 4 +#define EVEL_MOBILE_FLOW_MINOR_VERSION 0 + +/**************************************************************************//** + * Mobile Flow. + * JSON equivalent field: mobileFlow + *****************************************************************************/ +typedef struct event_mobile_flow { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + char * flow_direction; + MOBILE_GTP_PER_FLOW_METRICS * gtp_per_flow_metrics; + char * ip_protocol_type; + char * ip_version; + char * other_endpoint_ip_address; + int other_endpoint_port; + char * reporting_endpoint_ip_addr; + int reporting_endpoint_port; + HASHTABLE_T *additional_info; /* JSON: additionalFields */ + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_STRING application_type; + EVEL_OPTION_STRING app_protocol_type; + EVEL_OPTION_STRING app_protocol_version; + EVEL_OPTION_STRING cid; + EVEL_OPTION_STRING connection_type; + EVEL_OPTION_STRING ecgi; + EVEL_OPTION_STRING gtp_protocol_type; + EVEL_OPTION_STRING gtp_version; + EVEL_OPTION_STRING http_header; + EVEL_OPTION_STRING imei; + EVEL_OPTION_STRING imsi; + EVEL_OPTION_STRING lac; + EVEL_OPTION_STRING mcc; + EVEL_OPTION_STRING mnc; + EVEL_OPTION_STRING msisdn; + EVEL_OPTION_STRING other_functional_role; + EVEL_OPTION_STRING rac; + EVEL_OPTION_STRING radio_access_technology; + EVEL_OPTION_STRING sac; + EVEL_OPTION_INT sampling_algorithm; + EVEL_OPTION_STRING tac; + EVEL_OPTION_STRING tunnel_id; + EVEL_OPTION_STRING vlan_id; + +} EVENT_MOBILE_FLOW; + +/*****************************************************************************/ +/* Supported Other field version. */ +/*****************************************************************************/ +#define EVEL_OTHER_EVENT_MAJOR_VERSION 3 +#define EVEL_OTHER_EVENT_MINOR_VERSION 0 + +/**************************************************************************//** + * Other. + * JSON equivalent field: otherFields + *****************************************************************************/ +typedef struct event_other { + EVENT_HEADER header; + int major_version; + int minor_version; + + DLIST arrayOfNamedHashMap; + HASHTABLE_T *hashMap; + DLIST jsonobjects; /* DLIST of EVEL_JSON_OBJECT */ + +/** to delete + DLIST namedvalues; + HASHTABLE_T *namedarrays;****/ /* HASHTABLE_T */ + +} EVENT_OTHER; + +/**************************************************************************//** + * Other Field. + * JSON equivalent field: otherFields + *****************************************************************************/ +typedef struct other_field { + char * name; + char * value; +} OTHER_FIELD; + + +/*****************************************************************************/ +/* Supported Service Events version. */ +/*****************************************************************************/ +#define EVEL_HEARTBEAT_FIELD_MAJOR_VERSION 3 +#define EVEL_HEARTBEAT_FIELD_MINOR_VERSION 0 + + +/*****************************************************************************/ +/* Supported Signaling version. */ +/*****************************************************************************/ +#define EVEL_SIGNALING_MAJOR_VERSION 3 +#define EVEL_SIGNALING_MINOR_VERSION 0 + +/**************************************************************************//** + * Vendor VNF Name fields. + * JSON equivalent field: vendorVnfNameFields + *****************************************************************************/ +typedef struct vendor_vnfname_field { + char * vendorname; + EVEL_OPTION_STRING vfmodule; + EVEL_OPTION_STRING vnfname; +} VENDOR_VNFNAME_FIELD; + +/**************************************************************************//** + * Signaling. + * JSON equivalent field: signalingFields + *****************************************************************************/ +typedef struct event_signaling { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + VENDOR_VNFNAME_FIELD vnfname_field; + EVEL_OPTION_STRING correlator; /* JSON: correlator */ + EVEL_OPTION_STRING local_ip_address; /* JSON: localIpAddress */ + EVEL_OPTION_STRING local_port; /* JSON: localPort */ + EVEL_OPTION_STRING remote_ip_address; /* JSON: remoteIpAddress */ + EVEL_OPTION_STRING remote_port; /* JSON: remotePort */ + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + EVEL_OPTION_STRING compressed_sip; /* JSON: compressedSip */ + EVEL_OPTION_STRING summary_sip; /* JSON: summarySip */ + HASHTABLE_T *additional_info; + +} EVENT_SIGNALING; + +/*****************************************************************************/ +/* Supported State Change version. */ +/*****************************************************************************/ +#define EVEL_STATE_CHANGE_MAJOR_VERSION 4 +#define EVEL_STATE_CHANGE_MINOR_VERSION 0 + +/**************************************************************************//** + * State Change. + * JSON equivalent field: stateChangeFields + *****************************************************************************/ +typedef struct event_state_change { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + EVEL_ENTITY_STATE new_state; + EVEL_ENTITY_STATE old_state; + char * state_interface; + double version; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + HASHTABLE_T *additional_fields; + +} EVENT_STATE_CHANGE; + +/*****************************************************************************/ +/* Supported Notification version. */ +/*****************************************************************************/ +#define EVEL_NOTIFICATION_MAJOR_VERSION 2 +#define EVEL_NOTIFICATION_MINOR_VERSION 0 + +/**************************************************************************//** + * Notification. + * JSON equivalent field: notificationFields + *****************************************************************************/ +typedef struct event_notification { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + double version; + char * changeIdentifier; + char * changeType; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + HASHTABLE_T *additional_fields; + DLIST arrayOfNamedHashMap; + EVEL_OPTION_STRING changeContact; + EVEL_OPTION_STATE new_state; + EVEL_OPTION_STATE old_state; + EVEL_OPTION_STRING state_interface; + +} EVENT_NOTIFICATION; + +/*****************************************************************************/ +/* Supported Syslog version. */ +/*****************************************************************************/ +#define EVEL_SYSLOG_MAJOR_VERSION 4 +#define EVEL_SYSLOG_MINOR_VERSION 0 + +/**************************************************************************//** + * Syslog. + * JSON equivalent field: syslogFields + *****************************************************************************/ +typedef struct event_syslog { + /***************************************************************************/ + /* Header and version */ + /***************************************************************************/ + EVENT_HEADER header; + int major_version; + int minor_version; + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + EVEL_SOURCE_TYPES event_source_type; + char * syslog_msg; + char * syslog_tag; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + HASHTABLE_T * additional_fields; + EVEL_OPTION_STRING event_source_host; + EVEL_OPTION_INT syslog_facility; + EVEL_OPTION_INT syslog_priority; + EVEL_OPTION_STRING syslog_proc; + EVEL_OPTION_INT syslog_proc_id; + EVEL_OPTION_STRING syslog_s_data; + EVEL_OPTION_STRING syslog_sdid; + EVEL_OPTION_STRING syslog_severity; + double syslog_fver; + EVEL_OPTION_INT syslog_ver; + EVEL_OPTION_STRING syslog_timeStamp; + EVEL_OPTION_STRING syslog_msgHost; + +} EVENT_SYSLOG; + +/**************************************************************************//** + * Copyright. + * JSON equivalent object: attCopyrightNotice + *****************************************************************************/ +typedef struct copyright { + char * useAndRedistribution; + char * condition1; + char * condition2; + char * condition3; + char * condition4; + char * disclaimerLine1; + char * disclaimerLine2; + char * disclaimerLine3; + char * disclaimerLine4; +} COPYRIGHT; + +/**************************************************************************//** + * Library initialization. + * + * Initialize the EVEL library. + * + * @note This function initializes the cURL library. Applications making use + * of libcurl may need to pull the initialization out of here. Note + * also that this function is not threadsafe as a result - refer to + * libcurl's API documentation for relevant warnings. + * + * @sa Matching Term function. + * +* @param fqdn The API's FQDN or IP address. + * @param port The API's port. + * @param bakup_fqdn The API's FQDN or IP address. + * @param bakup_port The API's port. + * @param path The optional path (may be NULL). + * @param topic The optional topic part of the URL (may be NULL). + * @param ring_buf_size Ring buffer size (>=100) ~ Avg Messages in 1hr + * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS). + * @param activmode Whether to use ActiveActive or ActiveStandby collector mode + * @param cert_file_path Path to client certificate file + * @param key_file_path Path to client key file + * @param ca_info Path to CA info + * @param ca_file_path Path to CA file + * @param verify_peer SSL verification of peer 0 or 1 + * @param verify_host SSL verification of host 0 or 1 + * @param username Username for Basic Authentication of requests. + * @param password Password for Basic Authentication of requests. + * @param bakup_username Username for Basic Authentication of Bakup FQDN. + * @param bakup_password Password for Basic Authentication of Bakup FQDN. + * @param source_ip The ip of node we represent.(NULL for default ip) + * @param bakup_source_ip The ip bakup fqdn interface.(NULL for default ip) + * @param source_type The kind of node we represent. + * @param role The role this node undertakes. + * @param verbosity 0 for normal operation, positive values for chattier + * logs. + * + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval ::EVEL_ERR_CODES On failure. + *****************************************************************************/ +EVEL_ERR_CODES evel_initialize(const char * const fqdn, + int port, + const char * const bakup_fqdn, + int bakup_port, + const char * const path, + const char * const topic, + int ring_buf_size, + int secure, + int activmode, + const char * const cert_file_path, + const char * const key_file_path, + const char * const ca_info, + const char * const ca_file_path, + long verify_peer, + long verify_host, + const char * const username, + const char * const password, + const char * const bakup_username, + const char * const bakup_password, + const char * const source_ip, + const char * const bakup_source_ip, + EVEL_SOURCE_TYPES source_type, + const char * const role, + int verbosity + ); + +/**************************************************************************//** + * Initialize value for vm_name for all coming events + * @param source_name Source name string. + * Must confirm with EVEL source name standard + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval ::EVEL_ERR_CODES On failure. + *****************************************************************************/ +EVEL_ERR_CODES evel_set_source_name(char * src_name); + + +/**************************************************************************//** + * Clean up the EVEL library. + * + * @note that at present don't expect Init/Term cycling not to leak memory! + * + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval "One of ::EVEL_ERR_CODES" On failure. + *****************************************************************************/ +EVEL_ERR_CODES evel_terminate(void); + +EVEL_ERR_CODES evel_post_event(EVENT_HEADER * event); +const char * evel_error_string(void); + + +/**************************************************************************//** + * Free an event. + * + * Free off the event supplied. Will free all the contained allocated memory. + * + * @note It is safe to free a NULL pointer. + *****************************************************************************/ +void evel_free_event(void * event); + +/**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * + * @param json Pointer to where to store the JSON encoded data. + * @param mode Event mode or Batch mode + * @param max_size Size of storage available in json_body. + * @param event Pointer to the ::EVENT_HEADER to encode. + * @returns Number of bytes actually written. + *****************************************************************************/ +int evel_json_encode_event(char * json, + int max_size, + EVENT_HEADER * event); +int evel_json_encode_batch_event(char * json, + int max_size, + EVENT_HEADER * event); + +/**************************************************************************//** + * Callback function to provide returned data. + * + * Copy data into the supplied buffer, write_callback::ptr, checking size + * limits. + * + * @returns Number of bytes placed into write_callback::ptr. 0 for EOF. + *****************************************************************************/ +size_t evel_write_callback(void *contents, + size_t size, + size_t nmemb, + void *userp); + +/*****************************************************************************/ +/*****************************************************************************/ +/* */ +/* HEARTBEAT - (includes common header, too) */ +/* */ +/*****************************************************************************/ +/*****************************************************************************/ + +/**************************************************************************//** + * Create a new heartbeat event. + * + * @note that the heartbeat is just a "naked" commonEventHeader! + * + * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is + * not used it must be released using ::evel_free_event + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_HEADER * evel_new_heartbeat(void); + +/**************************************************************************//** + * Create a new heartbeat event of given name and type. + * + * @note that the heartbeat is just a "naked" commonEventHeader! + * + * @param event_name Unique Event Name: {DomainAbbreviation}_{AsdcModel or ApplicationPlatform}_{DescriptionOfInfoBeingConveyed} + * @param event_id A universal identifier of the event for: troubleshooting, cross-referencing of alarms for alarm correlation, offline log analysis, etc + * + * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is + * not used it must be released using ::evel_free_event + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_HEADER * evel_new_heartbeat_nameid(const char* ev_name, const char *ev_id); + + +/**************************************************************************//** + * Free an event header. + * + * Free off the event header supplied. Will free all the contained allocated + * memory. + * + * @note It does not free the header itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_header(EVENT_HEADER * const event); + +/**************************************************************************//** + * Initialize a newly created event header. + * + * @param header Pointer to the header being initialized. + *****************************************************************************/ +void evel_init_header(EVENT_HEADER * const header,const char *const eventname); + +/**************************************************************************//** + * Set the Event Type property of the event header. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_header_type_set(EVENT_HEADER * const header, + const char * const type); + +/**************************************************************************//** + * Set the next event_sequence to use. + * + * @param sequence The next sequence number to use. + *****************************************************************************/ +void evel_set_global_event_sequence(const int sequence); + +/**************************************************************************//** + * Set the Event Sequence property of the event header. + * + * @note This is mainly for tracking fault event sequence numbers + * + * @param header Pointer to the ::EVENT_HEADER. + * @param sequence_number + * + *****************************************************************************/ +void evel_event_sequence_set(EVENT_HEADER * const header,const int sequence_number); + +/**************************************************************************//** + * Set the Start Epoch property of the event header. + * + * @note The Start Epoch defaults to the time of event creation. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param start_epoch_microsec + * The start epoch to set, in microseconds. + *****************************************************************************/ +void evel_start_epoch_set(EVENT_HEADER * const header, + const unsigned long long start_epoch_microsec); + +/**************************************************************************//** + * Set the Last Epoch property of the event header. + * + * @note The Last Epoch defaults to the time of event creation. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param last_epoch_microsec + * The last epoch to set, in microseconds. + *****************************************************************************/ +void evel_last_epoch_set(EVENT_HEADER * const header, + const unsigned long long last_epoch_microsec); + +/**************************************************************************//** + * Set the Reporting Entity Name property of the event header. + * + * @note The Reporting Entity Name defaults to the OpenStack VM Name. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param entity_name The entity name to set. + *****************************************************************************/ +void evel_reporting_entity_name_set(EVENT_HEADER * const header, + const char * const entity_name); + +/**************************************************************************//** + * Set the source Name property of the event header. + * + * @note The source Name defaults to the OpenStack VM Name. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param source_name The entity name to set. + *****************************************************************************/ +void evel_source_name_set(EVENT_HEADER * const header, + const char * const source_name); + +/**************************************************************************//** + * Set the Reporting Entity Id property of the event header. + * + * @note The Reporting Entity Id defaults to the OpenStack VM UUID. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param entity_id The entity id to set. + *****************************************************************************/ +void evel_reporting_entity_id_set(EVENT_HEADER * const header, + const char * const entity_id); + +/**************************************************************************//** + * Set the NFC Naming code property of the event header. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param nfcnamingcode String + *****************************************************************************/ +void evel_nfcnamingcode_set(EVENT_HEADER * const header, + const char * const nfcnam); +/**************************************************************************//** + * Set the NF Naming code property of the event header. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param nfnamingcode String + *****************************************************************************/ +void evel_nfnamingcode_set(EVENT_HEADER * const header, + const char * const nfnam); + +/**************************************************************************//** + * Set the NF Vendor Name + * + * @param nfVendorName NF Vendor Name to use + *****************************************************************************/ +void evel_nf_vendor_name_set(EVENT_HEADER * const header, char * nfVendorName); + +/**************************************************************************//** + * Set the time zone offset + * + * @param timeZoneOffset Time zone offset to use. + *****************************************************************************/ +void evel_time_zone_offset_set(EVENT_HEADER * const header, char * timeZoneOffset); + +/**************************************************************************//** + * Set the source ID + * + * @param sourceId source ID to use + *****************************************************************************/ +void evel_source_id_set(EVENT_HEADER * const header, char * sourceId); + +/*****************************************************************************/ +/*****************************************************************************/ +/* */ +/* FAULT */ +/* */ +/*****************************************************************************/ +/*****************************************************************************/ + +/**************************************************************************//** + * Create a new fault event. + * + * @note The mandatory fields on the Fault must be supplied to this factory + * function and are immutable once set. Optional fields have explicit + * setter functions, but again values may only be set once so that the + * Fault has immutable properties. + * @param event_name Unique Event Name + * @param event_id A universal identifier of the event for analysis etc + * @param condition The condition indicated by the Fault. + * @param specific_problem The specific problem triggering the fault. + * @param priority The priority of the event. + * @param severity The severity of the Fault. + * @param ev_source_type Source of Alarm event + * @param version fault version + * @param status status of Virtual Function + * @returns pointer to the newly manufactured ::EVENT_FAULT. If the event is + * not used (i.e. posted) it must be released using ::evel_free_fault. + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_FAULT * evel_new_fault(const char* ev_name, const char *ev_id, + const char * const condition, + const char * const specific_problem, + EVEL_EVENT_PRIORITIES priority, + EVEL_SEVERITIES severity, + EVEL_SOURCE_TYPES ev_source_type, + EVEL_VF_STATUSES status); + +/**************************************************************************//** + * Free a Fault. + * + * Free off the Fault supplied. Will free all the contained allocated memory. + * + * @note It does not free the Fault itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_fault(EVENT_FAULT * event); + +/**************************************************************************//** + * Set the Fault Category property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param category Category : license, link, routing, security, signaling. + * ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_fault_category_set(EVENT_FAULT * fault, + const char * const category); + +/**************************************************************************//** + * Set the Alarm Interface A property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param interface The Alarm Interface A to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_fault_interface_set(EVENT_FAULT * fault, + const char * const interface); + +/**************************************************************************//** + * Add an additional value name/value pair to the Fault. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the fault. + * @param name ASCIIZ string with the attribute's name. + * @param value ASCIIZ string with the attribute's value. + *****************************************************************************/ +void evel_fault_addl_info_add(EVENT_FAULT * fault, char * name, char * value); + +/**************************************************************************//** + * Set the Event Type property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_fault_type_set(EVENT_FAULT * fault, const char * const type); + +/*****************************************************************************/ +/*****************************************************************************/ +/* */ +/* MEASUREMENT */ +/* */ +/*****************************************************************************/ +/*****************************************************************************/ + +/**************************************************************************//** + * Create a new Measurement event. + * + * @note The mandatory fields on the Measurement must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once so + * that the Measurement has immutable properties. + * + * @param measurement_interval + * @param event_name Unique Event Name + * @param event_id A universal identifier of the event for analysis etc + * + * @returns pointer to the newly manufactured ::EVENT_MEASUREMENT. If the + * event is not used (i.e. posted) it must be released using + * ::evel_free_event. + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_MEASUREMENT * evel_new_measurement(double measurement_interval,const char* ev_name, const char *ev_id); + +/**************************************************************************//** + * Free a Measurement. + * + * Free off the Measurement supplied. Will free all the contained allocated + * memory. + * + * @note It does not free the Measurement itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_measurement(EVENT_MEASUREMENT * event); + +/**************************************************************************//** + * Set the Event Type property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the Measurement. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_measurement_type_set(EVENT_MEASUREMENT * measurement, + const char * const type); + +/**************************************************************************//** + * Set the Concurrent Sessions property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the Measurement. + * @param concurrent_sessions The Concurrent Sessions to be set. + *****************************************************************************/ +void evel_measurement_conc_sess_set(EVENT_MEASUREMENT * measurement, + int concurrent_sessions); + +/**************************************************************************//** + * Set the Configured Entities property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the Measurement. + * @param configured_entities The Configured Entities to be set. + *****************************************************************************/ +void evel_measurement_cfg_ents_set(EVENT_MEASUREMENT * measurement, + int configured_entities); + + +/**************************************************************************//** + * Set the Mean Request Latency property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the Measurement. + * @param mean_request_latency The Mean Request Latency to be set. + *****************************************************************************/ +void evel_measurement_mean_req_lat_set(EVENT_MEASUREMENT * measurement, + double mean_request_latency); + +/**************************************************************************//** + * Set the Request Rate property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the Measurement. + * @param request_rate The Request Rate to be set. + *****************************************************************************/ +void evel_measurement_request_rate_set(EVENT_MEASUREMENT * measurement, + double request_rate); + +/**************************************************************************//** + * Add an additional CPU usage value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the measurement. + * @param id ASCIIZ string with the CPU's identifier. + * @param usage CPU utilization. + *****************************************************************************/ +MEASUREMENT_CPU_USE * evel_measurement_new_cpu_use_add(EVENT_MEASUREMENT * measurement, char * id, double usage); + +/**************************************************************************//** + * Set the CPU Idle value in measurement interval + * percentage of CPU time spent in the idle task + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_idle_set(MEASUREMENT_CPU_USE *const cpu_use, + const double val); + +/**************************************************************************//** + * Set the percentage of time spent servicing interrupts + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_interrupt_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); + +/**************************************************************************//** + * Set the percentage of time spent running user space processes that have been niced + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_nice_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); + +/**************************************************************************//** + * Set the percentage of time spent handling soft irq interrupts + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_softirq_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); +/**************************************************************************//** + * Set the percentage of time spent in involuntary wait + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_steal_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); +/**************************************************************************//** + * Set the percentage of time spent on system tasks running the kernel + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_system_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); +/**************************************************************************//** + * Set the percentage of time spent running un-niced user space processes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_usageuser_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); +/**************************************************************************//** + * Set the percentage of CPU time spent waiting for I/O operations to complete + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct vendor_vnfname_field { - char * vendorname; - EVEL_OPTION_STRING vfmodule; - EVEL_OPTION_STRING vnfname; -} VENDOR_VNFNAME_FIELD; +void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * Signaling. - * JSON equivalent field: signalingFields + * Set the The amount of time the CPU cannot run due to contention, in + * milliseconds over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct event_signaling { - /***************************************************************************/ - /* Header and version */ - /***************************************************************************/ - EVENT_HEADER header; - int major_version; - int minor_version; - - /***************************************************************************/ - /* Mandatory fields */ - /***************************************************************************/ - VENDOR_VNFNAME_FIELD vnfname_field; - EVEL_OPTION_STRING correlator; /* JSON: correlator */ - EVEL_OPTION_STRING local_ip_address; /* JSON: localIpAddress */ - EVEL_OPTION_STRING local_port; /* JSON: localPort */ - EVEL_OPTION_STRING remote_ip_address; /* JSON: remoteIpAddress */ - EVEL_OPTION_STRING remote_port; /* JSON: remotePort */ - - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - EVEL_OPTION_STRING compressed_sip; /* JSON: compressedSip */ - EVEL_OPTION_STRING summary_sip; /* JSON: summarySip */ - DLIST additional_info; - -} EVENT_SIGNALING; +void evel_measurement_cpu_use_cpuCapacityContention_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * Sgnaling Additional Field. - * JSON equivalent field: additionalFields + * Set the total CPU time that the NF/NFC/VM could use if there was no + * contention, in milliseconds over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct signaling_additional_field { - char * name; - char * value; -} SIGNALING_ADDL_FIELD; - -/*****************************************************************************/ -/* Supported State Change version. */ -/*****************************************************************************/ -#define EVEL_STATE_CHANGE_MAJOR_VERSION 1 -#define EVEL_STATE_CHANGE_MINOR_VERSION 2 +void evel_measurement_cpu_use_cpuDemandAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * State Change. - * JSON equivalent field: stateChangeFields + * Set the CPU demand in MHz + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct event_state_change { - /***************************************************************************/ - /* Header and version */ - /***************************************************************************/ - EVENT_HEADER header; - int major_version; - int minor_version; - - /***************************************************************************/ - /* Mandatory fields */ - /***************************************************************************/ - EVEL_ENTITY_STATE new_state; - EVEL_ENTITY_STATE old_state; - char * state_interface; - double version; - - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - DLIST additional_fields; - -} EVENT_STATE_CHANGE; +void evel_measurement_cpu_use_cpuDemandMhz_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * State Change Additional Field. - * JSON equivalent field: additionalFields + * Set the CPU demand as a percentage of the provisioned capacity + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct state_change_additional_field { - char * name; - char * value; -} STATE_CHANGE_ADDL_FIELD; - -/*****************************************************************************/ -/* Supported Syslog version. */ -/*****************************************************************************/ -#define EVEL_SYSLOG_MAJOR_VERSION 3 -#define EVEL_SYSLOG_MINOR_VERSION 0 +void evel_measurement_cpu_use_cpuDemandPct_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * Syslog. - * JSON equivalent field: syslogFields + * Set the Percentage of time the VM is unable to run because it is + * contending for access to the physical CPUs + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct event_syslog { - /***************************************************************************/ - /* Header and version */ - /***************************************************************************/ - EVENT_HEADER header; - int major_version; - int minor_version; - - /***************************************************************************/ - /* Mandatory fields */ - /***************************************************************************/ - EVEL_SOURCE_TYPES event_source_type; - char * syslog_msg; - char * syslog_tag; - - /***************************************************************************/ - /* Optional fields */ - /***************************************************************************/ - EVEL_OPTION_STRING additional_filters; - EVEL_OPTION_STRING event_source_host; - EVEL_OPTION_INT syslog_facility; - EVEL_OPTION_INT syslog_priority; - EVEL_OPTION_STRING syslog_proc; - EVEL_OPTION_INT syslog_proc_id; - EVEL_OPTION_STRING syslog_s_data; - EVEL_OPTION_STRING syslog_sdid; - EVEL_OPTION_STRING syslog_severity; - double syslog_fver; - EVEL_OPTION_INT syslog_ver; - -} EVENT_SYSLOG; +void evel_measurement_cpu_use_cpuLatencyAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * Copyright. - * JSON equivalent object: attCopyrightNotice + * Set the overhead demand above available allocations and reservations, + * in milliseconds over the measurement Interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double *****************************************************************************/ -typedef struct copyright { - char * useAndRedistribution; - char * condition1; - char * condition2; - char * condition3; - char * condition4; - char * disclaimerLine1; - char * disclaimerLine2; - char * disclaimerLine3; - char * disclaimerLine4; -} COPYRIGHT; +void evel_measurement_cpu_use_cpuOverheadAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); /**************************************************************************//** - * Library initialization. - * - * Initialize the EVEL library. + * Set the swap wait time, in milliseconds over the measurement Interval * - * @note This function initializes the cURL library. Applications making use - * of libcurl may need to pull the initialization out of here. Note - * also that this function is not threadsafe as a result - refer to - * libcurl's API documentation for relevant warnings. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @sa Matching Term function. + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ +void evel_measurement_cpu_use_cpuSwapWaitTime_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val); + + +/**************************************************************************//** + * Add an additional File System usage value name/value pair to the + * Measurement. * - * @param fqdn The API's FQDN or IP address. - * @param port The API's port. - * @param path The optional path (may be NULL). - * @param topic The optional topic part of the URL (may be NULL). - * @param ring_buf_size Ring buffer size (>=100) ~ Avg Messages in 1hr - * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS). - * @param cert_file_path Path to client certificate file - * @param key_file_path Path to client key file - * @param ca_info Path to CA info - * @param ca_file_path Path to CA file - * @param verify_peer SSL verification of peer 0 or 1 - * @param verify_host SSL verification of host 0 or 1 - * @param username Username for Basic Authentication of requests. - * @param password Password for Basic Authentication of requests. - * @param source_ip The ip of node we represent.(NULL for default ip) - * @param source_type The kind of node we represent. - * @param role The role this node undertakes. - * @param verbosity 0 for normal operation, positive values for chattier - * logs. + * The filesystem_name is null delimited ASCII string. The library takes a + * copy so the caller does not have to preserve values after the function + * returns. * - * @returns Status code - * @retval EVEL_SUCCESS On success - * @retval ::EVEL_ERR_CODES On failure. + * @param measurement Pointer to the measurement. + * @param filesystem_name ASCIIZ string with the file-system's UUID. + * @param block_configured Block storage configured. + * @param block_used Block storage in use. + * @param block_iops Block storage IOPS. + * @param ephemeral_configured Ephemeral storage configured. + * @param ephemeral_used Ephemeral storage in use. + * @param ephemeral_iops Ephemeral storage IOPS. *****************************************************************************/ -EVEL_ERR_CODES evel_initialize(const char * const fqdn, - int port, - const char * const path, - const char * const topic, - int ring_buf_size, - int secure, - const char * const cert_file_path, - const char * const key_file_path, - const char * const ca_info, - const char * const ca_file_path, - long verify_peer, - long verify_host, - const char * const username, - const char * const password, - const char * const source_ip, - EVEL_SOURCE_TYPES source_type, - const char * const role, - int verbosity - ); +void evel_measurement_fsys_use_add(EVENT_MEASUREMENT * measurement, + char * filesystem_name, + double block_configured, + double block_used, + double block_iops, + double ephemeral_configured, + double ephemeral_used, + double ephemeral_iops); /**************************************************************************//** - * Initialize value for vm_name for all coming events - * @param source_name Source name string. - * Must confirm with EVEL source name standard - * @returns Status code - * @retval EVEL_SUCCESS On success - * @retval ::EVEL_ERR_CODES On failure. + * Add a Feature usage value name/value pair to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the measurement. + * @param feature ASCIIZ string with the feature's name. + * @param utilization Utilization of the feature. *****************************************************************************/ -EVEL_ERR_CODES evel_set_source_name(char * src_name); - +void evel_measurement_feature_use_add(EVENT_MEASUREMENT * measurement, + char * feature, + char * utilization); /**************************************************************************//** - * Clean up the EVEL library. + * Add a new Additional Measurement hashmap to the Measurement. * - * @note that at present don't expect Init/Term cycling not to leak memory! + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. * - * @returns Status code - * @retval EVEL_SUCCESS On success - * @retval "One of ::EVEL_ERR_CODES" On failure. + * @param measurement Pointer to the Measurement. + * @param name ASCIIZ string containing the hashmap name *****************************************************************************/ -EVEL_ERR_CODES evel_terminate(void); +HASHTABLE_T * evel_measurement_new_addl_measurement( + EVENT_MEASUREMENT * measurement, + const char * const name); -EVEL_ERR_CODES evel_post_event(EVENT_HEADER * event); -const char * evel_error_string(void); +/**************************************************************************//** + * Add a new Additional Measurement hashmap to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param ht Pointer hashmap. + * @param name ASCIIZ string containing the measurement's name. + * @param Value ASCIIZ string containing the measurement's value. + *****************************************************************************/ +void evel_measurement_addl_measurement_set ( + HASHTABLE_T * const ht, + const char * const name, + const char * const value); +/**************************************************************************//** + * Add a Codec usage value name/value pair to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the measurement. + * @param codec ASCIIZ string with the codec's name. + * @param utilization Utilization of the feature. + *****************************************************************************/ +void evel_measurement_codec_use_add(EVENT_MEASUREMENT * measurement, + char * codec, + int utilization); /**************************************************************************//** - * Free an event. + * Set the Media Ports in Use property of the Measurement. * - * Free off the event supplied. Will free all the contained allocated memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It is safe to free a NULL pointer. + * @param measurement Pointer to the measurement. + * @param media_ports_in_use The media port usage to set. *****************************************************************************/ -void evel_free_event(void * event); +void evel_measurement_media_port_use_set(EVENT_MEASUREMENT * measurement, + int media_ports_in_use); /**************************************************************************//** - * Encode the event as a JSON event object according to AT&T's schema. + * Set the VNFC Scaling Metric property of the Measurement. * - * @param json Pointer to where to store the JSON encoded data. - * @param mode Event mode or Batch mode - * @param max_size Size of storage available in json_body. - * @param event Pointer to the ::EVENT_HEADER to encode. - * @returns Number of bytes actually written. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the measurement. + * @param scaling_metric The scaling metric to set. *****************************************************************************/ -int evel_json_encode_event(char * json, - int max_size, - EVENT_HEADER * event); -int evel_json_encode_batch_event(char * json, - int max_size, - EVENT_HEADER * event); +void evel_measurement_vnfc_scaling_metric_set(EVENT_MEASUREMENT * measurement, + int scaling_metric); + /**************************************************************************//** - * Initialize an event instance id. + * Create a new Latency Bucket to be added to a Measurement event. * - * @param vfield Pointer to the event vnfname field being initialized. - * @param vendor_id The vendor id to encode in the event instance id. - * @param event_id The event id to encode in the event instance id. + * @note The mandatory fields on the ::MEASUREMENT_LATENCY_BUCKET must be + * supplied to this factory function and are immutable once set. + * Optional fields have explicit setter functions, but again values + * may only be set once so that the ::MEASUREMENT_LATENCY_BUCKET has + * immutable properties. + * + * @param count Count of events in this bucket. + * + * @returns pointer to the newly manufactured ::MEASUREMENT_LATENCY_BUCKET. + * @retval NULL Failed to create the Latency Bucket. *****************************************************************************/ -void evel_init_vendor_field(VENDOR_VNFNAME_FIELD * const vfield, - const char * const vendor_name); +MEASUREMENT_LATENCY_BUCKET * evel_new_meas_latency_bucket(const int count); /**************************************************************************//** - * Set the Vendor module property of the Vendor. + * Set the High End property of the Measurement Latency Bucket. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vfield Pointer to the Vendor field. - * @param module_name The module name to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param bucket Pointer to the Measurement Latency Bucket. + * @param high_end High end of the bucket's range. *****************************************************************************/ -void evel_vendor_field_module_set(VENDOR_VNFNAME_FIELD * const vfield, - const char * const module_name); +void evel_meas_latency_bucket_high_end_set( + MEASUREMENT_LATENCY_BUCKET * const bucket, + const double high_end); + /**************************************************************************//** - * Set the Vendor module property of the Vendor. + * Set the Low End property of the Measurement Latency Bucket. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vfield Pointer to the Vendor field. - * @param module_name The module name to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param bucket Pointer to the Measurement Latency Bucket. + * @param low_end Low end of the bucket's range. *****************************************************************************/ -void evel_vendor_field_vnfname_set(VENDOR_VNFNAME_FIELD * const vfield, - const char * const vnfname); +void evel_meas_latency_bucket_low_end_set( + MEASUREMENT_LATENCY_BUCKET * const bucket, + const double low_end); + /**************************************************************************//** - * Free an event instance id. + * Add an additional Measurement Latency Bucket to the specified event. * - * @param vfield Pointer to the event vnfname_field being freed. + * @param measurement Pointer to the Measurement event. + * @param bucket Pointer to the Measurement Latency Bucket to add. *****************************************************************************/ -void evel_free_event_vendor_field(VENDOR_VNFNAME_FIELD * const vfield); +void evel_meas_latency_bucket_add(EVENT_MEASUREMENT * const measurement, + MEASUREMENT_LATENCY_BUCKET * const bucket); /**************************************************************************//** - * Callback function to provide returned data. + * Add an additional Latency Distribution bucket to the Measurement. * - * Copy data into the supplied buffer, write_callback::ptr, checking size - * limits. + * This function implements the previous API, purely for convenience. * - * @returns Number of bytes placed into write_callback::ptr. 0 for EOF. + * @param measurement Pointer to the measurement. + * @param low_end Low end of the bucket's range. + * @param high_end High end of the bucket's range. + * @param count Count of events in this bucket. *****************************************************************************/ -size_t evel_write_callback(void *contents, - size_t size, - size_t nmemb, - void *userp); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* HEARTBEAT - (includes common header, too) */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ +void evel_measurement_latency_add(EVENT_MEASUREMENT * const measurement, + const double low_end, + const double high_end, + const int count); /**************************************************************************//** - * Create a new heartbeat event. + * Create a new NIC Use to be added to a Measurement event. * - * @note that the heartbeat is just a "naked" commonEventHeader! + * @note The mandatory fields on the ::MEASUREMENT_NIC_PERFORMANCE must be supplied + * to this factory function and are immutable once set. Optional + * fields have explicit setter functions, but again values may only be + * set once so that the ::MEASUREMENT_NIC_PERFORMANCE has immutable + * properties. * - * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is - * not used it must be released using ::evel_free_event - * @retval NULL Failed to create the event. + * @param nic_id ASCIIZ string with the NIC's ID. + * @param val_suspect True or false confidence in data. + * + * @returns pointer to the newly manufactured ::MEASUREMENT_NIC_PERFORMANCE. + * If the structure is not used it must be released using + * ::evel_measurement_free_nic_performance. + * @retval NULL Failed to create the NIC Use. *****************************************************************************/ -EVENT_HEADER * evel_new_heartbeat(void); +MEASUREMENT_NIC_PERFORMANCE * evel_measurement_new_nic_performance(char * const nic_id, char * const val_suspect); /**************************************************************************//** - * Create a new heartbeat event of given name and type. + * Free a NIC Use. * - * @note that the heartbeat is just a "naked" commonEventHeader! + * Free off the ::MEASUREMENT_NIC_PERFORMANCE supplied. Will free all the contained + * allocated memory. * - * @param event_name Unique Event Name: {DomainAbbreviation}_{AsdcModel or ApplicationPlatform}_{DescriptionOfInfoBeingConveyed} - * @param event_id A universal identifier of the event for: troubleshooting, cross-referencing of alarms for alarm correlation, offline log analysis, etc + * @note It does not free the NIC Use itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_measurement_free_nic_performance(MEASUREMENT_NIC_PERFORMANCE * const nic_performance); + +/**************************************************************************//** + * Set the administrative State of the NIC performance. * - * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is - * not used it must be released using ::evel_free_event - * @retval NULL Failed to create the event. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param state *****************************************************************************/ -EVENT_HEADER * evel_new_heartbeat_nameid(const char* ev_name, const char *ev_id); +void evel_nic_performance_administrativeState_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const EVEL_OPER_STATE state); +/**************************************************************************//** + * Set the operational state of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param state + *****************************************************************************/ +void evel_nic_performance_operationalState_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const EVEL_OPER_STATE state); /**************************************************************************//** - * Free an event header. + * Set the Percentage of discarded packets received of the NIC performance. * - * Free off the event header supplied. Will free all the contained allocated - * memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It does not free the header itself, since that may be part of a - * larger structure. + * @param nic_performance Pointer to the NIC Use. + * @param receivedPercentDiscard *****************************************************************************/ -void evel_free_header(EVENT_HEADER * const event); +void evel_nic_performance_receivedPercentDiscard_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedPercentDiscard); /**************************************************************************//** - * Initialize a newly created event header. + * Set the Percentage of error packets received of the NIC performance. * - * @param header Pointer to the header being initialized. + + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param receivedPercentError *****************************************************************************/ -void evel_init_header(EVENT_HEADER * const header,const char *const eventname); +void evel_nic_performance_receivedPercentError_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedPercentError); /**************************************************************************//** - * Set the Event Type property of the event header. + * Set the Percentage of utilization received of the NIC performance. * - * @param header Pointer to the ::EVENT_HEADER. - * @param type The Event Type to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param receivedUtilization *****************************************************************************/ -void evel_header_type_set(EVENT_HEADER * const header, - const char * const type); +void evel_nic_performance_receivedUtilization_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedUtilization); /**************************************************************************//** - * Set the Start Epoch property of the event header. + * Set the Speed configured in mbps of the NIC performance. * - * @note The Start Epoch defaults to the time of event creation. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param header Pointer to the ::EVENT_HEADER. - * @param start_epoch_microsec - * The start epoch to set, in microseconds. + * @param nic_performance Pointer to the NIC Use. + * @param Speed *****************************************************************************/ -void evel_start_epoch_set(EVENT_HEADER * const header, - const unsigned long long start_epoch_microsec); +void evel_nic_performance_speed_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double speed); /**************************************************************************//** - * Set the Last Epoch property of the event header. + * Set the Percentage of discarded packets transmitted of the NIC performance. * - * @note The Last Epoch defaults to the time of event creation. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param header Pointer to the ::EVENT_HEADER. - * @param last_epoch_microsec - * The last epoch to set, in microseconds. + * @param nic_performance Pointer to the NIC Use. + * @param transmittedPercentDiscard *****************************************************************************/ -void evel_last_epoch_set(EVENT_HEADER * const header, - const unsigned long long last_epoch_microsec); +void evel_nic_performance_transmittedPercentDiscard_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedPercentDiscard); /**************************************************************************//** - * Set the Reporting Entity Name property of the event header. + * Set the Percentage of error packets received of the NIC performance. * - * @note The Reporting Entity Name defaults to the OpenStack VM Name. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param header Pointer to the ::EVENT_HEADER. - * @param entity_name The entity name to set. + * @param nic_performance Pointer to the NIC Use. + * @param transmittedPercentError + *****************************************************************************/ +void evel_nic_performance_transmittedPercentError_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedPercentError); + +/**************************************************************************//** + * Set the Percentage of utilization transmitted of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param transmittedUtilization *****************************************************************************/ -void evel_reporting_entity_name_set(EVENT_HEADER * const header, - const char * const entity_name); +void evel_nic_performance_transmittedUtilization_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedUtilization); /**************************************************************************//** - * Set the Reporting Entity Id property of the event header. + * Set the Accumulated Broadcast Packets Received in measurement interval + * property of the NIC performance. * - * @note The Reporting Entity Id defaults to the OpenStack VM UUID. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param header Pointer to the ::EVENT_HEADER. - * @param entity_id The entity id to set. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_bcast_packets_acc *****************************************************************************/ -void evel_reporting_entity_id_set(EVENT_HEADER * const header, - const char * const entity_id); - +void evel_nic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_bcast_packets_acc); /**************************************************************************//** - * Set the NFC Naming code property of the event header. + * Set the Delta Broadcast Packets Received in measurement interval + * property of the NIC performance. * - * @param header Pointer to the ::EVENT_HEADER. - * @param nfcnamingcode String + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param recvd_bcast_packets_delta *****************************************************************************/ -void evel_nfcnamingcode_set(EVENT_HEADER * const header, - const char * const nfcnam); +void evel_nic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_bcast_packets_delta); /**************************************************************************//** - * Set the NF Naming code property of the event header. + * Set the Discarded Packets Received in measurement interval + * property of the NIC performance. * - * @param header Pointer to the ::EVENT_HEADER. - * @param nfnamingcode String + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param recvd_discard_packets_acc *****************************************************************************/ -void evel_nfnamingcode_set(EVENT_HEADER * const header, - const char * const nfnam); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* FAULT */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - +void evel_nic_performance_rx_discard_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_discard_packets_acc); /**************************************************************************//** - * Create a new fault event. + * Set the Delta Discarded Packets Received in measurement interval + * property of the NIC performance. * - * @note The mandatory fields on the Fault must be supplied to this factory - * function and are immutable once set. Optional fields have explicit - * setter functions, but again values may only be set once so that the - * Fault has immutable properties. - * @param event_name Unique Event Name - * @param event_id A universal identifier of the event for analysis etc - * @param condition The condition indicated by the Fault. - * @param specific_problem The specific problem triggering the fault. - * @param priority The priority of the event. - * @param severity The severity of the Fault. - * @param ev_source_type Source of Alarm event - * @param version fault version - * @param status status of Virtual Function - * @returns pointer to the newly manufactured ::EVENT_FAULT. If the event is - * not used (i.e. posted) it must be released using ::evel_free_fault. - * @retval NULL Failed to create the event. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param recvd_discard_packets_delta *****************************************************************************/ -EVENT_FAULT * evel_new_fault(const char* ev_name, const char *ev_id, - const char * const condition, - const char * const specific_problem, - EVEL_EVENT_PRIORITIES priority, - EVEL_SEVERITIES severity, - EVEL_SOURCE_TYPES ev_source_type, - EVEL_VF_STATUSES status); - +void evel_nic_performance_rx_discard_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_discard_packets_delta); /**************************************************************************//** - * Free a Fault. + * Set the Error Packets Received in measurement interval + * property of the NIC performance. * - * Free off the Fault supplied. Will free all the contained allocated memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It does not free the Fault itself, since that may be part of a - * larger structure. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_error_packets_acc *****************************************************************************/ -void evel_free_fault(EVENT_FAULT * event); - +void evel_nic_performance_rx_error_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_error_packets_acc); /**************************************************************************//** - * Set the Fault Category property of the Fault. + * Set the Delta Error Packets Received in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param fault Pointer to the fault. - * @param category Category : license, link, routing, security, signaling. - * ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_error_packets_delta *****************************************************************************/ -void evel_fault_category_set(EVENT_FAULT * fault, - const char * const category); - +void evel_nic_performance_rx_error_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_error_packets_delta); /**************************************************************************//** - * Set the Alarm Interface A property of the Fault. + * Set the Accumulated Multicast Packets Received in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param fault Pointer to the fault. - * @param interface The Alarm Interface A to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_mcast_packets_acc *****************************************************************************/ -void evel_fault_interface_set(EVENT_FAULT * fault, - const char * const interface); - +void evel_nic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_mcast_packets_acc); /**************************************************************************//** - * Add an additional value name/value pair to the Fault. + * Set the Delta Multicast Packets Received in measurement interval + * property of the NIC performance. * - * The name and value are null delimited ASCII strings. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param fault Pointer to the fault. - * @param name ASCIIZ string with the attribute's name. - * @param value ASCIIZ string with the attribute's value. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_mcast_packets_delta *****************************************************************************/ -void evel_fault_addl_info_add(EVENT_FAULT * fault, char * name, char * value); - +void evel_nic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_mcast_packets_delta); /**************************************************************************//** - * Set the Event Type property of the Fault. + * Set the Accumulated Octets Received in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param fault Pointer to the fault. - * @param type The Event Type to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_octets_acc *****************************************************************************/ -void evel_fault_type_set(EVENT_FAULT * fault, const char * const type); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* MEASUREMENT */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ - +void evel_nic_performance_rx_octets_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_octets_acc); /**************************************************************************//** - * Create a new Measurement event. + * Set the Delta Octets Received in measurement interval + * property of the NIC performance. * - * @note The mandatory fields on the Measurement must be supplied to this - * factory function and are immutable once set. Optional fields have - * explicit setter functions, but again values may only be set once so - * that the Measurement has immutable properties. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement_interval - * @param event_name Unique Event Name - * @param event_id A universal identifier of the event for analysis etc + * @param nic_performance Pointer to the NIC Use. + * @param recvd_octets_delta + *****************************************************************************/ +void evel_nic_performance_rx_octets_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_octets_delta); +/**************************************************************************//** + * Set the Accumulated Total Packets Received in measurement interval + * property of the NIC performance. * - * @returns pointer to the newly manufactured ::EVENT_MEASUREMENT. If the - * event is not used (i.e. posted) it must be released using - * ::evel_free_event. - * @retval NULL Failed to create the event. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param recvd_total_packets_acc *****************************************************************************/ -EVENT_MEASUREMENT * evel_new_measurement(double measurement_interval,const char* ev_name, const char *ev_id); - +void evel_nic_performance_rx_total_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_total_packets_acc); /**************************************************************************//** - * Free a Measurement. + * Set the Delta Total Packets Received in measurement interval + * property of the NIC performance. * - * Free off the Measurement supplied. Will free all the contained allocated - * memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It does not free the Measurement itself, since that may be part of a - * larger structure. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_total_packets_delta *****************************************************************************/ -void evel_free_measurement(EVENT_MEASUREMENT * event); - +void evel_nic_performance_rx_total_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_total_packets_delta); /**************************************************************************//** - * Set the Event Type property of the Measurement. + * Set the Accumulated Unicast Packets Received in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the Measurement. - * @param type The Event Type to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_ucast_packets_acc *****************************************************************************/ -void evel_measurement_type_set(EVENT_MEASUREMENT * measurement, - const char * const type); - +void evel_nic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_ucast_packets_acc); /**************************************************************************//** - * Set the Concurrent Sessions property of the Measurement. + * Set the Delta Unicast packets Received in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the Measurement. - * @param concurrent_sessions The Concurrent Sessions to be set. + * @param nic_performance Pointer to the NIC Use. + * @param recvd_ucast_packets_delta *****************************************************************************/ -void evel_measurement_conc_sess_set(EVENT_MEASUREMENT * measurement, - int concurrent_sessions); - +void evel_nic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double recvd_ucast_packets_delta); /**************************************************************************//** - * Set the Configured Entities property of the Measurement. + * Set the Transmitted Broadcast Packets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the Measurement. - * @param configured_entities The Configured Entities to be set. + * @param nic_performance Pointer to the NIC Use. + * @param tx_bcast_packets_acc *****************************************************************************/ -void evel_measurement_cfg_ents_set(EVENT_MEASUREMENT * measurement, - int configured_entities); - +void evel_nic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_bcast_packets_acc); /**************************************************************************//** - * Add an additional set of Errors to the Measurement. + * Set the Delta Broadcast packets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param receive_discards The number of receive discards. - * @param receive_errors The number of receive errors. - * @param transmit_discards The number of transmit discards. - * @param transmit_errors The number of transmit errors. + * @param nic_performance Pointer to the NIC Use. + * @param tx_bcast_packets_delta *****************************************************************************/ -void evel_measurement_errors_set(EVENT_MEASUREMENT * measurement, - int receive_discards, - int receive_errors, - int transmit_discards, - int transmit_errors); - +void evel_nic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_bcast_packets_delta); /**************************************************************************//** - * Set the Mean Request Latency property of the Measurement. + * Set the Transmitted Discarded Packets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the Measurement. - * @param mean_request_latency The Mean Request Latency to be set. + * @param nic_performance Pointer to the NIC Use. + * @param tx_discarded_packets_acc *****************************************************************************/ -void evel_measurement_mean_req_lat_set(EVENT_MEASUREMENT * measurement, - double mean_request_latency); - +void evel_nic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_discarded_packets_acc); /**************************************************************************//** - * Set the Request Rate property of the Measurement. + * Set the Delta Discarded packets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the Measurement. - * @param request_rate The Request Rate to be set. + * @param nic_performance Pointer to the NIC Use. + * @param tx_discarded_packets_delta *****************************************************************************/ -void evel_measurement_request_rate_set(EVENT_MEASUREMENT * measurement, - int request_rate); - +void evel_nic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_discarded_packets_delta); /**************************************************************************//** - * Add an additional CPU usage value name/value pair to the Measurement. + * Set the Transmitted Errored Packets in measurement interval + * property of the NIC performance. * - * The name and value are null delimited ASCII strings. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param id ASCIIZ string with the CPU's identifier. - * @param usage CPU utilization. + * @param nic_performance Pointer to the NIC Use. + * @param tx_error_packets_acc *****************************************************************************/ -MEASUREMENT_CPU_USE * evel_measurement_new_cpu_use_add(EVENT_MEASUREMENT * measurement, char * id, double usage); - +void evel_nic_performance_tx_error_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_error_packets_acc); /**************************************************************************//** - * Set the CPU Idle value in measurement interval - * percentage of CPU time spent in the idle task + * Set the Delta Errored packets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_error_packets_delta *****************************************************************************/ -void evel_measurement_cpu_use_idle_set(MEASUREMENT_CPU_USE *const cpu_use, - const double val); - +void evel_nic_performance_tx_error_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_error_packets_delta); /**************************************************************************//** - * Set the percentage of time spent servicing interrupts + * Set the Transmitted Multicast Packets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_mcast_packets_acc *****************************************************************************/ -void evel_measurement_cpu_use_interrupt_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); - +void evel_nic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_mcast_packets_acc); /**************************************************************************//** - * Set the percentage of time spent running user space processes that have been niced + * Set the Delta Multicast packets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_mcast_packets_delta *****************************************************************************/ -void evel_measurement_cpu_use_nice_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); - +void evel_nic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_mcast_packets_delta); /**************************************************************************//** - * Set the percentage of time spent handling soft irq interrupts + * Set the Transmitted Octets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_octets_acc *****************************************************************************/ -void evel_measurement_cpu_use_softirq_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); +void evel_nic_performance_tx_octets_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_octets_acc); /**************************************************************************//** - * Set the percentage of time spent in involuntary wait + * Set the Delta Octets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_octets_delta *****************************************************************************/ -void evel_measurement_cpu_use_steal_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); +void evel_nic_performance_tx_octets_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_octets_delta); /**************************************************************************//** - * Set the percentage of time spent on system tasks running the kernel + * Set the Transmitted Total Packets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_total_packets_acc *****************************************************************************/ -void evel_measurement_cpu_use_system_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); +void evel_nic_performance_tx_total_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_total_packets_acc); /**************************************************************************//** - * Set the percentage of time spent running un-niced user space processes + * Set the Delta Total Packets Transmitted in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_total_packets_delta *****************************************************************************/ -void evel_measurement_cpu_use_usageuser_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); +void evel_nic_performance_tx_total_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_total_packets_delta); /**************************************************************************//** - * Set the percentage of CPU time spent waiting for I/O operations to complete + * Set the Transmitted Unicast Packets in measurement interval + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param cpu_use Pointer to the CPU Use. - * @param val double + * @param nic_performance Pointer to the NIC Use. + * @param tx_ucast_packets_acc *****************************************************************************/ -void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE * const cpu_use, - const double val); - +void evel_nic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_ucast_packets_acc); /**************************************************************************//** - * Add an additional File System usage value name/value pair to the - * Measurement. + * Set the Delta Octets Transmitted in measurement interval + * property of the NIC performance. * - * The filesystem_name is null delimited ASCII string. The library takes a - * copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param filesystem_name ASCIIZ string with the file-system's UUID. - * @param block_configured Block storage configured. - * @param block_used Block storage in use. - * @param block_iops Block storage IOPS. - * @param ephemeral_configured Ephemeral storage configured. - * @param ephemeral_used Ephemeral storage in use. - * @param ephemeral_iops Ephemeral storage IOPS. + * @param nic_performance Pointer to the NIC Use. + * @param tx_ucast_packets_delta *****************************************************************************/ -void evel_measurement_fsys_use_add(EVENT_MEASUREMENT * measurement, - char * filesystem_name, - double block_configured, - double block_used, - double block_iops, - double ephemeral_configured, - double ephemeral_used, - double ephemeral_iops); +void evel_nic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double tx_ucast_packets_delta); /**************************************************************************//** - * Add a Feature usage value name/value pair to the Measurement. - * - * The name is null delimited ASCII string. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * Add an additional NIC Use to the specified Measurement event. * - * @param measurement Pointer to the measurement. - * @param feature ASCIIZ string with the feature's name. - * @param utilization Utilization of the feature. + * @param measurement Pointer to the measurement. + * @param nic_performance Pointer to the NIC Use to add. *****************************************************************************/ -void evel_measurement_feature_use_add(EVENT_MEASUREMENT * measurement, - char * feature, - int utilization); +void evel_meas_nic_performance_add(EVENT_MEASUREMENT * const measurement, + MEASUREMENT_NIC_PERFORMANCE * const nic_performance); /**************************************************************************//** - * Add a Additional Measurement value name/value pair to the Measurement. - * - * The name is null delimited ASCII string. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * Add an additional NIC usage record Measurement. * - * @param measurement Pointer to the Measurement. - * @param group ASCIIZ string with the measurement group's name. - * @param name ASCIIZ string containing the measurement's name. - * @param name ASCIIZ string containing the measurement's value. - *****************************************************************************/ -void evel_measurement_custom_measurement_add(EVENT_MEASUREMENT * measurement, - const char * const group, - const char * const name, - const char * const value); - -/**************************************************************************//** - * Add a Codec usage value name/value pair to the Measurement. + * This function implements the previous API, purely for convenience. * - * The name is null delimited ASCII string. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * The ID is null delimited ASCII string. The library takes a copy so the + * caller does not have to preserve values after the function returns. * - * @param measurement Pointer to the measurement. - * @param codec ASCIIZ string with the codec's name. - * @param utilization Utilization of the feature. + * @param measurement Pointer to the measurement. + * @param nic_id ASCIIZ string with the NIC's ID. + * @param valset true or false confidence level + * @param admin_state Administrative state + * @param op_state Operational state + * @param receivedPercentDiscard Percentage of discarded packets received; + * @param receivedPercentError Percentage of error packets received + * @param receivedUtilization Percentage of utilization received + * @param speed Speed configured in mbps + * @param transmittedPercentDiscard Percentage of discarded packets transmitted + * @param transmittedPercentError Percentage of error packets received + * @param transmittedUtilization Percentage of utilization transmitted + * @param recvd_bcast_packets_acc Recieved broadcast packets + * @param recvd_bcast_packets_delta Received delta broadcast packets + * @param recvd_discarded_packets_acc Recieved discarded packets + * @param recvd_discarded_packets_delta Received discarded delta packets + * @param recvd_error_packets_acc Received error packets + * @param recvd_error_packets_delta, Received delta error packets + * @param recvd_mcast_packets_acc Received multicast packets + * @param recvd_mcast_packets_delta Received delta multicast packets + * @param recvd_octets_acc Received octets + * @param recvd_octets_delta Received delta octets + * @param recvd_total_packets_acc Received total packets + * @param recvd_total_packets_delta Received delta total packets + * @param recvd_ucast_packets_acc Received Unicast packets + * @param recvd_ucast_packets_delta Received delta unicast packets + * @param tx_bcast_packets_acc Transmitted broadcast packets + * @param tx_bcast_packets_delta Transmitted delta broadcast packets + * @param tx_discarded_packets_acc Transmitted packets discarded + * @param tx_discarded_packets_delta Transmitted delta discarded packets + * @param tx_error_packets_acc Transmitted error packets + * @param tx_error_packets_delta Transmitted delta error packets + * @param tx_mcast_packets_acc Transmitted multicast packets accumulated + * @param tx_mcast_packets_delta Transmitted delta multicast packets + * @param tx_octets_acc Transmitted octets + * @param tx_octets_delta Transmitted delta octets + * @param tx_total_packets_acc Transmitted total packets + * @param tx_total_packets_delta Transmitted delta total packets + * @param tx_ucast_packets_acc Transmitted Unicast packets + * @param tx_ucast_packets_delta Transmitted delta Unicast packets *****************************************************************************/ -void evel_measurement_codec_use_add(EVENT_MEASUREMENT * measurement, - char * codec, - int utilization); +void evel_measurement_nic_performance_add(EVENT_MEASUREMENT * const measurement, + char * const nic_id, + char * valset, + EVEL_OPER_STATE admin_state, + EVEL_OPER_STATE op_state, + double receivedPercentDiscard, + double receivedPercentError, + double receivedUtilization, + double speed, + double transmittedPercentDiscard, + double transmittedPercentError, + double transmittedUtilization, + double recvd_bcast_packets_acc, + double recvd_bcast_packets_delta, + double recvd_discarded_packets_acc, + double recvd_discarded_packets_delta, + double recvd_error_packets_acc, + double recvd_error_packets_delta, + double recvd_mcast_packets_acc, + double recvd_mcast_packets_delta, + double recvd_octets_acc, + double recvd_octets_delta, + double recvd_total_packets_acc, + double recvd_total_packets_delta, + double recvd_ucast_packets_acc, + double recvd_ucast_packets_delta, + double tx_bcast_packets_acc, + double tx_bcast_packets_delta, + double tx_discarded_packets_acc, + double tx_discarded_packets_delta, + double tx_error_packets_acc, + double tx_error_packets_delta, + double tx_mcast_packets_acc, + double tx_mcast_packets_delta, + double tx_octets_acc, + double tx_octets_delta, + double tx_total_packets_acc, + double tx_total_packets_delta, + double tx_ucast_packets_acc, + double tx_ucast_packets_delta); + +MEASUREMENT_IPMI * evel_measurement_new_ipmi_add( + EVENT_MEASUREMENT * measurement); /**************************************************************************//** - * Set the Media Ports in Use property of the Measurement. + * Set the System fan exit air flow temperature in Celsius of IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param media_ports_in_use The media port usage to set. + * @param ipmi Pointer to the IPMI + * @param double *****************************************************************************/ -void evel_measurement_media_port_use_set(EVENT_MEASUREMENT * measurement, - int media_ports_in_use); +void evel_measurement_ipmi_exitAirTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val); /**************************************************************************//** - * Set the VNFC Scaling Metric property of the Measurement. + * Set the Front panel temp in Celsius of IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param scaling_metric The scaling metric to set. + * @param ipmi Pointer to the IPMI + * @param double *****************************************************************************/ -void evel_measurement_vnfc_scaling_metric_set(EVENT_MEASUREMENT * measurement, - int scaling_metric); +void evel_measurement_ipmi_frontPanelTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val); /**************************************************************************//** - * Create a new Latency Bucket to be added to a Measurement event. + * Set the Io module temp in Celsius of IPMI * - * @note The mandatory fields on the ::MEASUREMENT_LATENCY_BUCKET must be - * supplied to this factory function and are immutable once set. - * Optional fields have explicit setter functions, but again values - * may only be set once so that the ::MEASUREMENT_LATENCY_BUCKET has - * immutable properties. - * - * @param count Count of events in this bucket. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @returns pointer to the newly manufactured ::MEASUREMENT_LATENCY_BUCKET. - * @retval NULL Failed to create the Latency Bucket. + * @param ipmi Pointer to the IPMI + * @param double *****************************************************************************/ -MEASUREMENT_LATENCY_BUCKET * evel_new_meas_latency_bucket(const int count); +void evel_measurement_ipmi_ioModuleTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val); /**************************************************************************//** - * Set the High End property of the Measurement Latency Bucket. + * Set the Airflow in cubic feet per minute (cfm) of IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param bucket Pointer to the Measurement Latency Bucket. - * @param high_end High end of the bucket's range. + * @param ipmi Pointer to the IPMI Use. + * @param double *****************************************************************************/ -void evel_meas_latency_bucket_high_end_set( - MEASUREMENT_LATENCY_BUCKET * const bucket, - const double high_end); +void evel_measurement_ipmi_systemAirflow_set(MEASUREMENT_IPMI *ipmi, + const double val); /**************************************************************************//** - * Set the Low End property of the Measurement Latency Bucket. + * Add a new Baseboard Temperature Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param bucket Pointer to the Measurement Latency Bucket. - * @param low_end Low end of the bucket's range. + * @param ipmi Pointer to the IPMI + * @param id Indentifier *****************************************************************************/ -void evel_meas_latency_bucket_low_end_set( - MEASUREMENT_LATENCY_BUCKET * const bucket, - const double low_end); +MEASUREMENT_IPMI_BB_TEMPERATURE *evel_measurement_new_base_board_temp_add( + MEASUREMENT_IPMI * ipmi, + char * id); /**************************************************************************//** - * Add an additional Measurement Latency Bucket to the specified event. + * Set the Baseboard temperature in celsius * - * @param measurement Pointer to the Measurement event. - * @param bucket Pointer to the Measurement Latency Bucket to add. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI + * @param bb_temp Pointer to base board tempeature + * @param id Indentifier *****************************************************************************/ -void evel_meas_latency_bucket_add(EVENT_MEASUREMENT * const measurement, - MEASUREMENT_LATENCY_BUCKET * const bucket); +void evel_measurement_ipmi_bb_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BB_TEMPERATURE * bb_temp, + const double val); /**************************************************************************//** - * Add an additional Latency Distribution bucket to the Measurement. + * Add a new Baseboard Voltage Regulator Array element to IPMI * - * This function implements the previous API, purely for convenience. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param low_end Low end of the bucket's range. - * @param high_end High end of the bucket's range. - * @param count Count of events in this bucket. + * @param ipmi Pointer to the IPMI + * @param id Indentifier *****************************************************************************/ -void evel_measurement_latency_add(EVENT_MEASUREMENT * const measurement, - const double low_end, - const double high_end, - const int count); +MEASUREMENT_IPMI_BB_VOLTAGE *evel_measurement_new_base_board_volt_add( + MEASUREMENT_IPMI * ipmi, + const char const * id); /**************************************************************************//** - * Create a new vNIC Use to be added to a Measurement event. + * Set the Voltage regulator temperature in celsius * - * @note The mandatory fields on the ::MEASUREMENT_VNIC_PERFORMANCE must be supplied - * to this factory function and are immutable once set. Optional - * fields have explicit setter functions, but again values may only be - * set once so that the ::MEASUREMENT_VNIC_PERFORMANCE has immutable - * properties. - * - * @param vnic_id ASCIIZ string with the vNIC's ID. - * @param val_suspect True or false confidence in data. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @returns pointer to the newly manufactured ::MEASUREMENT_VNIC_PERFORMANCE. - * If the structure is not used it must be released using - * ::evel_measurement_free_vnic_performance. - * @retval NULL Failed to create the vNIC Use. + * @param ipmi Pointer to the IPMI + * @param bb_volt Pointer to base board Voltage regulator + * @param val value *****************************************************************************/ -MEASUREMENT_VNIC_PERFORMANCE * evel_measurement_new_vnic_performance(char * const vnic_id, char * const val_suspect); +void evel_measurement_ipmi_bb_volt_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BB_VOLTAGE * bb_volt, + const double val); /**************************************************************************//** - * Free a vNIC Use. + * Add a new IPMI Battery Array element to IPMI * - * Free off the ::MEASUREMENT_VNIC_PERFORMANCE supplied. Will free all the contained - * allocated memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It does not free the vNIC Use itself, since that may be part of a - * larger structure. + * @param ipmi Pointer to the IPMI + * @param id Indentifier *****************************************************************************/ -void evel_measurement_free_vnic_performance(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance); +MEASUREMENT_IPMI_BATTERY *evel_measurement_new_ipmi_battery_add( + MEASUREMENT_IPMI * ipmi, + char * id); /**************************************************************************//** - * Set the Accumulated Broadcast Packets Received in measurement interval - * property of the vNIC performance. + * Set the battery type in IPMI Battery * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_bcast_packets_acc + * @param ipmi Pointer to the IPMI + * @param ipmiBattery Pointer to IPMI Battery + * @param batteryType Batterry Type *****************************************************************************/ -void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_bcast_packets_acc); +void evel_measurement_ipmi_battery_type_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BATTERY * ipmiBattery, + const char * const batteryType); + /**************************************************************************//** - * Set the Delta Broadcast Packets Received in measurement interval - * property of the vNIC performance. + * Set the Battery voltage level in IPMI Battery * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_bcast_packets_delta + * @param ipmi Pointer to the IPMI + * @param ipmiBattery Pointer to IPMI Battery + * @param val Battery voltage level *****************************************************************************/ -void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_bcast_packets_delta); +void evel_measurement_ipmi_battery_voltage_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BATTERY * ipmiBattery, + const double val); + /**************************************************************************//** - * Set the Discarded Packets Received in measurement interval - * property of the vNIC performance. + * Add a new IPMI Fan Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_discard_packets_acc + * @param ipmi Pointer to the IPMI + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_discard_packets_acc); +MEASUREMENT_IPMI_FAN *evel_measurement_new_ipmi_fan_add( + MEASUREMENT_IPMI * ipmi, + char * id); + /**************************************************************************//** - * Set the Delta Discarded Packets Received in measurement interval - * property of the vNIC performance. + * Set the Fan Identifier in IPMI FAN * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_discard_packets_delta + * @param ipmi Pointer to the IPMI + * @param ipmiFan Pointer to IPMI FAN + * @param val Fan Identifier *****************************************************************************/ -void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_discard_packets_delta); +void evel_measurement_ipmi_fan_speed_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_FAN * ipmiFan, + const double val); + /**************************************************************************//** - * Set the Error Packets Received in measurement interval - * property of the vNIC performance. + * Add a new IPMI HSBP Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_error_packets_acc + * @param ipmi Pointer to the IPMI + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_error_packets_acc); +MEASUREMENT_IPMI_HSBP *evel_measurement_new_ipmi_hsbp_add( + MEASUREMENT_IPMI * ipmi, + char * id); + /**************************************************************************//** - * Set the Delta Error Packets Received in measurement interval - * property of the vNIC performance. + * Set the Hot swap backplane power temperature in celsius in IPMI HSBP * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_error_packets_delta + * @param ipmi Pointer to the IPMI + * @param ipmiHsbp Pointer to ipmi Hsbp + * @param val value *****************************************************************************/ -void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_error_packets_delta); +void evel_measurement_ipmi_hsbp_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_HSBP * ipmiHsbp, + const double val); + /**************************************************************************//** - * Set the Accumulated Multicast Packets Received in measurement interval - * property of the vNIC performance. + * Add a new IPMI Global Aggregate Temperature Margin Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_mcast_packets_acc + * @param ipmi Pointer to the IPMI. + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_mcast_packets_acc); +MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN *evel_measurement_new_ipmi_global_temp_add( + MEASUREMENT_IPMI * ipmi, + const char * const id); + /**************************************************************************//** - * Set the Delta Multicast Packets Received in measurement interval - * property of the vNIC performance. + * Set the IPMI Global Aggregate Temperature Margin * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_mcast_packets_delta + * @param ipmi Pointer to the IPMI. + * @param ipmig_temp Pointer to IPMI Global Aggregate Temperature Margin + * @param val value *****************************************************************************/ -void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_mcast_packets_delta); +void evel_measurement_ipmi_global_temp_margin_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN * ipmig_temp, + const double val); + /**************************************************************************//** - * Set the Accumulated Octets Received in measurement interval - * property of the vNIC performance. + * Add a new IPMI NIC Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_octets_acc + * @param ipmi Pointer to the IPMI Use. + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_octets_acc); +MEASUREMENT_IPMI_NIC *evel_measurement_new_ipmi_nic_add( + MEASUREMENT_IPMI * ipmi, + char * id); + /**************************************************************************//** - * Set the Delta Octets Received in measurement interval - * property of the vNIC performance. + * Set the NIC temperature in IPMI NIC * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_octets_delta + * @param ipmi Pointer to the IPMI Use. + * @param ipminic Pointer to IPMI NIC + * @param val value *****************************************************************************/ -void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_octets_delta); +void evel_measurement_ipmi_nic_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_NIC * ipminic, + const double val); + /**************************************************************************//** - * Set the Accumulated Total Packets Received in measurement interval - * property of the vNIC performance. + * Add a new IPMI Power Supply Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_total_packets_acc + * @param ipmi Pointer to the IPMI Use. + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_total_packets_acc); +MEASUREMENT_IPMI_POWER_SUPPLY *evel_measurement_new_ipmi_power_add( + MEASUREMENT_IPMI * ipmi, + char * id); + /**************************************************************************//** - * Set the Delta Total Packets Received in measurement interval - * property of the vNIC performance. + * Set the Power Supply input power in watts * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_total_packets_delta + * @param ipmi Pointer to the IPMI Use. + * @param ipmipwr Pointer to IPMI Power Supply + * @param val Value *****************************************************************************/ -void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_total_packets_delta); +void evel_measurement_ipmi_power_inputpwr_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val); + /**************************************************************************//** - * Set the Accumulated Unicast Packets Received in measurement interval - * property of the vNIC performance. + * Set the Current output voltage as a percentage of the design specified level * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_ucast_packets_acc + * @param ipmi Pointer to the IPMI Use. + * @param ipmipwr Pointer to IPMI Power Supply + * @param val Value *****************************************************************************/ -void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_ucast_packets_acc); +void evel_measurement_ipmi_power_current_op_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val); + /**************************************************************************//** - * Set the Delta Unicast packets Received in measurement interval - * property of the vNIC performance. + * Set the Power supply temperature in Celsius * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param recvd_ucast_packets_delta + * @param ipmi Pointer to the IPMI Use. + * @param ipmipwr Pointer to IPMI Power Supply + * @param val Value *****************************************************************************/ -void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double recvd_ucast_packets_delta); +void evel_measurement_ipmi_power_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val); + /**************************************************************************//** - * Set the Transmitted Broadcast Packets in measurement interval - * property of the vNIC performance. + * Add a new IPMI Processor Array element to IPMI * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_bcast_packets_acc + * @param ipmi Pointer to the IPMI Use. + * @param id Indentifier *****************************************************************************/ -void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_bcast_packets_acc); +MEASUREMENT_IPMI_PROCESSOR *evel_measurement_new_ipmi_processor_add( + MEASUREMENT_IPMI * ipmi, + char * id); + /**************************************************************************//** - * Set the Delta Broadcast packets Transmitted in measurement interval - * property of the vNIC performance. + * Set the processor thermal control percent * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_bcast_packets_delta + * @param ipmi Pointer to the IPMI Use. + * @param ipmi_processor Pointer to IPMI processor + * @param val Value *****************************************************************************/ -void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_bcast_packets_delta); +void evel_measurement_ipmi_processor_theralCtrl_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor, + const double val); + /**************************************************************************//** - * Set the Transmitted Discarded Packets in measurement interval - * property of the vNIC performance. + * Set the processor DTS thermal margin(Front panel temperature in celsius) * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_discarded_packets_acc + * @param ipmi Pointer to the IPMI Use. + * @param ipmi_processor Pointer to IPMI processor + * @param val Value *****************************************************************************/ -void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_discarded_packets_acc); +void evel_measurement_ipmi_processor_theralMargin_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor, + const double val); + /**************************************************************************//** - * Set the Delta Discarded packets Transmitted in measurement interval - * property of the vNIC performance. + * Add a new Array element to Processor * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_discarded_packets_delta + * @param ipmi Pointer to the IPMI Use. + * @param ipmi_processor Pointer to IPMI Processor + * @param therm_margin Thermal margin *****************************************************************************/ -void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_discarded_packets_delta); +MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add( + MEASUREMENT_IPMI * ipmi, + MEASUREMENT_IPMI_PROCESSOR *ipmi_processor, + const char * const id, double therm_margin); + /**************************************************************************//** - * Set the Transmitted Errored Packets in measurement interval - * property of the vNIC performance. + * Add a new Array element to loads * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_error_packets_acc + * @param measurement Pointer to measurement. *****************************************************************************/ -void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_error_packets_acc); +MEASUREMENT_LOAD * evel_measurement_new_loads_add( + EVENT_MEASUREMENT * measurement); + /**************************************************************************//** - * Set the Delta Errored packets Transmitted in measurement interval - * property of the vNIC performance. + * Set the short term value in load * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_error_packets_delta + * @param load Pointer to load. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_error_packets_delta); +void evel_measurement_load_shortTerm_set(MEASUREMENT_LOAD *load, + const double val); + /**************************************************************************//** - * Set the Transmitted Multicast Packets in measurement interval - * property of the vNIC performance. + * Set the MID term value in load * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_mcast_packets_acc + * @param load Pointer to load. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_mcast_packets_acc); +void evel_measurement_load_midTerm_set(MEASUREMENT_LOAD *load, + const double val); + /**************************************************************************//** - * Set the Delta Multicast packets Transmitted in measurement interval - * property of the vNIC performance. + * Set the Long term value in load * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_mcast_packets_delta + * @param load Pointer to load. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_mcast_packets_delta); +void evel_measurement_load_longTerm_set(MEASUREMENT_LOAD *load, + const double val); + /**************************************************************************//** - * Set the Transmitted Octets in measurement interval - * property of the vNIC performance. + * Add a new Array element to Process Stats of measurement * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_octets_acc + * @param measurement Pointer to measurement. + * @param processIdentifier process Identifier *****************************************************************************/ -void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_octets_acc); +MEASUREMENT_PROCESS_STATS * evel_measurement_new_process_stats_add( + EVENT_MEASUREMENT * measurement, + const char * const processIdentifier ); + /**************************************************************************//** - * Set the Delta Octets Transmitted in measurement interval - * property of the vNIC performance. + * Set the fork rate (The number of threads created since the last reboot) in + * Process Stats * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_octets_delta + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_octets_delta); +void evel_measurement_process_stat_forkRate_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); + /**************************************************************************//** - * Set the Transmitted Total Packets in measurement interval - * property of the vNIC performance. + * Set the The number of processes in a blocked state in Process Stats * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_total_packets_acc + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_total_packets_acc); +void evel_measurement_process_stat_psStateBlocked_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); + /**************************************************************************//** - * Set the Delta Total Packets Transmitted in measurement interval - * property of the vNIC performance. + * Set the The number of processes in a paging state in Process Stats * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_total_packets_delta + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_total_packets_delta); +void evel_measurement_process_stat_psStatePaging_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); + /**************************************************************************//** - * Set the Transmitted Unicast Packets in measurement interval - * property of the vNIC performance. + * Set the The number of processes in a running state in Process Stats * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_ucast_packets_acc + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_ucast_packets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_ucast_packets_acc); +void evel_measurement_process_stat_psStateRunning_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); + /**************************************************************************//** - * Set the Delta Octets Transmitted in measurement interval - * property of the vNIC performance. + * Set the The number of processes in a sleeping state in Process Stats * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. - * @param tx_ucast_packets_delta + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_ucast_packets_delta); +void evel_measurement_process_stat_psStateSleeping_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); /**************************************************************************//** - * Add an additional vNIC Use to the specified Measurement event. + * Set the The number of processes in a stopped state in Process Stats * - * @param measurement Pointer to the measurement. - * @param vnic_performance Pointer to the vNIC Use to add. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement, - MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance); +void evel_measurement_process_stat_psStateStopped_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); /**************************************************************************//** - * Add an additional vNIC usage record Measurement. + * Set the The number of processes in a zombie state in Process Stats * - * This function implements the previous API, purely for convenience. - * - * The ID is null delimited ASCII string. The library takes a copy so the - * caller does not have to preserve values after the function returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param measurement Pointer to the measurement. - * @param vnic_id ASCIIZ string with the vNIC's ID. - * @param valset true or false confidence level - * @param recvd_bcast_packets_acc Recieved broadcast packets - * @param recvd_bcast_packets_delta Received delta broadcast packets - * @param recvd_discarded_packets_acc Recieved discarded packets - * @param recvd_discarded_packets_delta Received discarded delta packets - * @param recvd_error_packets_acc Received error packets - * @param recvd_error_packets_delta, Received delta error packets - * @param recvd_mcast_packets_acc Received multicast packets - * @param recvd_mcast_packets_delta Received delta multicast packets - * @param recvd_octets_acc Received octets - * @param recvd_octets_delta Received delta octets - * @param recvd_total_packets_acc Received total packets - * @param recvd_total_packets_delta Received delta total packets - * @param recvd_ucast_packets_acc Received Unicast packets - * @param recvd_ucast_packets_delta Received delta unicast packets - * @param tx_bcast_packets_acc Transmitted broadcast packets - * @param tx_bcast_packets_delta Transmitted delta broadcast packets - * @param tx_discarded_packets_acc Transmitted packets discarded - * @param tx_discarded_packets_delta Transmitted delta discarded packets - * @param tx_error_packets_acc Transmitted error packets - * @param tx_error_packets_delta Transmitted delta error packets - * @param tx_mcast_packets_acc Transmitted multicast packets accumulated - * @param tx_mcast_packets_delta Transmitted delta multicast packets - * @param tx_octets_acc Transmitted octets - * @param tx_octets_delta Transmitted delta octets - * @param tx_total_packets_acc Transmitted total packets - * @param tx_total_packets_delta Transmitted delta total packets - * @param tx_ucast_packets_acc Transmitted Unicast packets - * @param tx_ucast_packets_delta Transmitted delta Unicast packets + * @param process_stat Pointer to process stat. + * @param val value *****************************************************************************/ -void evel_measurement_vnic_performance_add(EVENT_MEASUREMENT * const measurement, - char * const vnic_id, - char * valset, - double recvd_bcast_packets_acc, - double recvd_bcast_packets_delta, - double recvd_discarded_packets_acc, - double recvd_discarded_packets_delta, - double recvd_error_packets_acc, - double recvd_error_packets_delta, - double recvd_mcast_packets_acc, - double recvd_mcast_packets_delta, - double recvd_octets_acc, - double recvd_octets_delta, - double recvd_total_packets_acc, - double recvd_total_packets_delta, - double recvd_ucast_packets_acc, - double recvd_ucast_packets_delta, - double tx_bcast_packets_acc, - double tx_bcast_packets_delta, - double tx_discarded_packets_acc, - double tx_discarded_packets_delta, - double tx_error_packets_acc, - double tx_error_packets_delta, - double tx_mcast_packets_acc, - double tx_mcast_packets_delta, - double tx_octets_acc, - double tx_octets_delta, - double tx_total_packets_acc, - double tx_total_packets_delta, - double tx_ucast_packets_acc, - double tx_ucast_packets_delta); - -/*****************************************************************************/ -/*****************************************************************************/ -/* */ -/* REPORT */ -/* */ -/*****************************************************************************/ -/*****************************************************************************/ +void evel_measurement_process_stat_psStateZombie_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val); /**************************************************************************//** - * Create a new Report event. - * - * @note The mandatory fields on the Report must be supplied to this - * factory function and are immutable once set. Optional fields have - * explicit setter functions, but again values may only be set once so - * that the Report has immutable properties. + * Add a new Machine check exception array element to measurement * - * @param measurement_interval - * @param event_name Unique Event Name - * @param event_id A universal identifier of the event for analysis etc + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @returns pointer to the newly manufactured ::EVENT_REPORT. If the event is - * not used (i.e. posted) it must be released using - * ::evel_free_report. - * @retval NULL Failed to create the event. + * @param measurement Pointer to measurement. + * @param process_id process Identifier *****************************************************************************/ -EVENT_REPORT * evel_new_report(double measurement_interval,const char* ev_name, const char *ev_id); +MACHINE_CHECK_EXCEPTION * evel_measurement_new_machine_check_exception_add( + EVENT_MEASUREMENT * measurement, + const char * const process_id ); /**************************************************************************//** - * Free a Report. + * Set the Total hardware errors that were corrected by the hardware + * in Machine check exception * - * Free off the Report supplied. Will free all the contained allocated memory. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @note It does not free the Report itself, since that may be part of a - * larger structure. + * @param machine_check Pointer to Machine check exception. + * @param val value *****************************************************************************/ -void evel_free_report(EVENT_REPORT * event); +void evel_measurement_machine_check_cor_mem_err_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val); /**************************************************************************//** - * Set the Event Type property of the Report. + * Set the Total hardware errors that were corrected over last one hour + * in Machine check exception * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param report Pointer to the Report. - * @param type The Event Type to be set. ASCIIZ string. The caller - * does not need to preserve the value once the function - * returns. + * @param machine_check Pointer to Machine check exception. + * @param val value *****************************************************************************/ -void evel_report_type_set(EVENT_REPORT * report, const char * const type); +void evel_measurement_machine_check_cor_mem_err_1hr_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val); /**************************************************************************//** - * Add a Feature usage value name/value pair to the Report. + * Set the Total hardware errors that were uncorrected by the hardware + * in Machine check exception * - * The name is null delimited ASCII string. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param report Pointer to the report. - * @param feature ASCIIZ string with the feature's name. - * @param utilization Utilization of the feature. + * @param machine_check Pointer to Machine check exception. + * @param val value *****************************************************************************/ -void evel_report_feature_use_add(EVENT_REPORT * report, - char * feature, - int utilization); +void evel_measurement_machine_check_uncor_mem_err_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val); /**************************************************************************//** - * Add a Additional Measurement value name/value pair to the Report. + * Set the Total hardware errors that were uncorrected over last one hour + * in Machine check exception * - * The name is null delimited ASCII string. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. * - * @param report Pointer to the report. - * @param group ASCIIZ string with the measurement group's name. - * @param name ASCIIZ string containing the measurement's name. - * @param value ASCIIZ string containing the measurement's value. + * @param machine_check Pointer to Machine check exception. + * @param val value *****************************************************************************/ -void evel_report_custom_measurement_add(EVENT_REPORT * report, - const char * const group, - const char * const name, - const char * const value); +void evel_measurement_machine_check_uncor_mem_err_1hr_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val); /*****************************************************************************/ /*****************************************************************************/ @@ -2784,7 +5136,22 @@ EVENT_MOBILE_FLOW * evel_new_mobile_flow( int other_endpoint_port, const char * const reporting_endpoint_ip_addr, int reporting_endpoint_port); - +/**************************************************************************//** + * Add an additional value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile flow. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_flow_addl_field_add(EVENT_MOBILE_FLOW * const event, char * name, char * value); /**************************************************************************//** * Free a Mobile Flow. * @@ -3337,17 +5704,7 @@ void evel_mobile_gtp_metrics_tun_status_set( MOBILE_GTP_PER_FLOW_METRICS * metrics, const char * const status); -/**************************************************************************//** - * Set an IP Type-of-Service count property of the Mobile GTP Per Flow metrics. - * - * @param metrics Pointer to the Mobile GTP Per Flow Metrics. - * @param index The index of the IP Type-of-Service. - * @param count The count. - *****************************************************************************/ -void evel_mobile_gtp_metrics_iptos_set(MOBILE_GTP_PER_FLOW_METRICS * metrics, - int index, - int count); - + /**************************************************************************//** * Set the Large Packet Round-Trip Time property of the Mobile GTP Per Flow * Metrics. @@ -3405,6 +5762,66 @@ void evel_mobile_gtp_metrics_max_trx_bit_rate_set( MOBILE_GTP_PER_FLOW_METRICS * metrics, int rate); +/**************************************************************************//** + * Add an IP Tos count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_ip_tos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const char * const name, + const char * const value); + +/**************************************************************************//** + * Add an QCI Cos count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_qci_cos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const EVEL_QCI_COS_TYPES qci_cos, + const char * const value); + +/**************************************************************************//** + * Add an TCP Flag count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_tcp_flag_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const EVEL_TCP_FLAGS tcp_flag, + const char * const value); + /**************************************************************************//** * Set the Number of GTP Echo Failures property of the Mobile GTP Per Flow * Metrics. @@ -3450,36 +5867,52 @@ void evel_mobile_gtp_metrics_num_http_errors_set( int num); /**************************************************************************//** - * Add a TCP flag count to the metrics. + * Add a IP Tos count list to the metrics. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * * @param metrics Pointer to the Mobile GTP Per Flow Metrics. - * @param tcp_flag The TCP flag count to be updated. - * @param count The associated flag count. + * @param name Key of the hashmap + * @param value Value of the hashmap. *****************************************************************************/ -void evel_mobile_gtp_metrics_tcp_flag_count_add( - MOBILE_GTP_PER_FLOW_METRICS * metrics, - const EVEL_TCP_FLAGS tcp_flag, - const int count); +void evel_mobile_ip_tos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const char * const name, + const char * const value); /**************************************************************************//** - * Add a QCI COS count to the metrics. + * Add TCP Flag count list to the metrics. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * * @param metrics Pointer to the Mobile GTP Per Flow Metrics. - * @param qci_cos The QCI COS count to be updated. - * @param count The associated QCI COS count. + * @param name Key of the hashmap + * @param value Value of the hashmap. *****************************************************************************/ -void evel_mobile_gtp_metrics_qci_cos_count_add( - MOBILE_GTP_PER_FLOW_METRICS * metrics, - const EVEL_QCI_COS_TYPES qci_cos, - const int count); +void evel_mobile_tcp_flag_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const char * const name, + const char * const value); + +/**************************************************************************//** + * Add a QCI cos count list to the metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param name Key of the hashmap + * @param value Value of the hashmap. + *****************************************************************************/ +void evel_mobile_qci_cos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const char * const name, + const char * const value); /*****************************************************************************/ /*****************************************************************************/ @@ -3769,6 +6202,171 @@ void evel_state_change_type_set(EVENT_STATE_CHANGE * const state_change, void evel_state_change_addl_field_add(EVENT_STATE_CHANGE * const state_change, const char * const name, const char * const value); +/*****************************************************************************/ +/*****************************************************************************/ +/* */ +/* Notification */ +/* */ +/*****************************************************************************/ +/*****************************************************************************/ + +/**************************************************************************//** + * Create a new Notification event. + * + * @note The mandatory fields on the Syslog must be supplied to this factory + * function and are immutable once set. Optional fields have explicit + * setter functions, but again values may only be set once so that the + * Syslog has immutable properties. + * + * @param event_name Unique Event Name + * @param event_id A universal identifier of the event for analysis etc + * @param new_state The new state of the reporting entity. + * @param old_state The old state of the reporting entity. + * @param interface The card or port name of the reporting entity. + * + * @returns pointer to the newly manufactured ::EVENT_NOTIFICATION. If the + * event is not used it must be released using + * ::evel_free_notification + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_NOTIFICATION * evel_new_notification( + const char* ev_name, const char *ev_id, + const char * const changeIdentifier, + const char * const changeType); +/**************************************************************************//** + * Free a Notification. + * + * + * Free off the Notification supplied. Will free all the contained allocated + * memory. + * + * @note It does not free the Notification itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_notification(EVENT_NOTIFICATION * const notification); + +/**************************************************************************//** + * Set the Event Type property of the Notification. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_notification_type_set(EVENT_NOTIFICATION * const notification, + const char * const type); + +/**************************************************************************//** + * Add an additional field name/value pair to the Notification. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_notification_addl_field_add(EVENT_NOTIFICATION * const notification, + const char * const name, + const char * const value); + +/**************************************************************************//** + * Convert a ::EVEL_OPTION_STATE to it's string form for JSON encoding. + * + * @param state The entity state to encode. + * + * @returns the corresponding string + *****************************************************************************/ +char * evel_entity_opt_state (EVEL_OPTION_STATE * const state); + +/**************************************************************************//** + * Initialize an ::EVEL_OPTION_STATE to a not-set state. + * + * @param option Pointer to the ::EVEL_OPTION_INT. + *****************************************************************************/ +void evel_init_option_state(EVEL_OPTION_STATE * const option); + +/**************************************************************************//** + * Set the value of an ::EVEL_OPTION_STATE. + * + * @param option Pointer to the ::EVEL_OPTION_STATE. + * @param value The value to set. + * @param description Description to be used in logging. + *****************************************************************************/ +void evel_set_option_state(EVEL_OPTION_STATE * const option, + const int value, + const char * const description); + +/**************************************************************************//** + * Set the Identifier for a contact related to the change of notification event + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param changeContact ASCIIZ string with the attribute's value + *****************************************************************************/ +void evel_notification_changeContact_set( + EVENT_NOTIFICATION * const notification, + const char * const changeContact); + +/**************************************************************************//** + * Set the Card or port name of the entity that changed state of notification + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param state_interface ASCIIZ string with the attribute's value + *****************************************************************************/ +void evel_notification_state_interface_set( + EVENT_NOTIFICATION * const notification, + const char * const state_interface); + +/**************************************************************************//** + * Set the New state of the entity of notification event + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param state Enter value of EVEL_ENTITY_STATE + *****************************************************************************/ +void evel_notification_new_state_set( + EVENT_NOTIFICATION * const notification, + const EVEL_ENTITY_STATE state); + +/**************************************************************************//** + * Set the Old state of entity of notification event + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param state Enter value of EVEL_ENTITY_STATE + *****************************************************************************/ +void evel_notification_old_state_set( + EVENT_NOTIFICATION * const notification, + const EVEL_ENTITY_STATE state); + +/**************************************************************************//** + * Add a new named hashmap to notification event + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param name Name of the hashmap + *****************************************************************************/ +HASHTABLE_T * evel_notification_add_new_named_hashmap( + EVENT_NOTIFICATION * const notification, + const char * const name); + +/**************************************************************************//** + * Set the name and value for the named hashmap of notification event + * + * @param ht Pointer to named hashmap + * @param name Key name + * @param value value corresponding to key + *****************************************************************************/ +void evel_notification_named_hashmap_set( + HASHTABLE_T * const ht, + const char * const name, + const char * const value); /*****************************************************************************/ /*****************************************************************************/ @@ -3817,6 +6415,25 @@ EVENT_SYSLOG * evel_new_syslog(const char* ev_name, const char *ev_id, void evel_syslog_type_set(EVENT_SYSLOG * syslog, const char * const type); +/**************************************************************************//** + * Add an additional value name/value pair to the Syslog. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param syslog Pointer to the syslog. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_syslog_addl_fields_set(EVENT_SYSLOG * syslog, + const char * const name, + const char * const value); + /**************************************************************************//** * Free a Syslog. * @@ -3843,8 +6460,8 @@ void evel_free_syslog(EVENT_SYSLOG * event); * returns. *****************************************************************************/ void evel_syslog_addl_field_add(EVENT_SYSLOG * syslog, - char * name, - char * value); + const char * name, + const char * value); /**************************************************************************//** * Set the Event Source Host property of the Syslog. @@ -3875,6 +6492,20 @@ void evel_syslog_event_source_host_set(EVENT_SYSLOG * syslog, *****************************************************************************/ void evel_syslog_facility_set(EVENT_SYSLOG * syslog, EVEL_SYSLOG_FACILITIES facility); +/**************************************************************************//** + * Set the priority of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param priority The Syslog priority to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_syslog_priority_set(EVENT_SYSLOG * syslog, + const int priority); /**************************************************************************//** * Set the Process property of the Syslog. @@ -3889,6 +6520,32 @@ void evel_syslog_facility_set(EVENT_SYSLOG * syslog, *****************************************************************************/ void evel_syslog_proc_set(EVENT_SYSLOG * syslog, const char * const proc); +/**************************************************************************//** + * Set the timestamp parsed from non-VES syslog message + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param time_stamp The timestamp to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ +void evel_syslog_timeStamp_set(EVENT_SYSLOG * syslog, const char * const time_stamp); + +/**************************************************************************//** + * Set the hostname parsed from non-VES syslog message + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param msg_host The hostname to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ +void evel_syslog_MsgHost_set(EVENT_SYSLOG * syslog, const char * const msg_host); + /**************************************************************************//** * Set the Process ID property of the Syslog. * @@ -4012,9 +6669,32 @@ void evel_other_type_set(EVENT_OTHER * other, * @param name ASCIIZ string with the attribute's name. * @param value ASCIIZ string with the attribute's value. *****************************************************************************/ -void evel_other_field_add(EVENT_OTHER * other, - char * name, - char * value); +void evel_other_field_add_hashmap(EVENT_OTHER * other, char * name, char *value); + +/**************************************************************************//** + * Add a new named hashmap to other event + * + * @param notification Pointer to other + * @param name Name of the hashmap + *****************************************************************************/ +HASHTABLE_T * evel_other_add_new_hashmap_to_hmarray(EVENT_OTHER * const other, + const char * const name); + +/**************************************************************************//** + * Add a value name/value pair to named hashmap of Other. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param other Pointer to the Other. + * @param name ASCIIZ string with the attribute's name. + * @param value ASCIIZ string with the attribute's value. + *****************************************************************************/ +void evel_other_set_hashmap_in_hmarray( + HASHTABLE_T * const ht, + const char * const name, + const char * const value); /*****************************************************************************/ /*****************************************************************************/ @@ -4036,8 +6716,8 @@ int evel_get_measurement_interval(); /*****************************************************************************/ /* Supported Report version. */ /*****************************************************************************/ -#define EVEL_VOICEQ_MAJOR_VERSION 1 -#define EVEL_VOICEQ_MINOR_VERSION 1 +#define EVEL_VOICEQ_MAJOR_VERSION 4 +#define EVEL_VOICEQ_MINOR_VERSION 0 /**************************************************************************//** * End of Call Voice Quality Metrices @@ -4053,14 +6733,14 @@ typedef struct end_of_call_vqm_summaries { /***************************************************************************/ /* Optional fields */ /***************************************************************************/ - EVEL_OPTION_INT endpointJitter; + EVEL_OPTION_INT localRtpOctetsLost; EVEL_OPTION_INT endpointRtpOctetsDiscarded; EVEL_OPTION_INT endpointRtpOctetsReceived; EVEL_OPTION_INT endpointRtpOctetsSent; EVEL_OPTION_INT endpointRtpPacketsDiscarded; EVEL_OPTION_INT endpointRtpPacketsReceived; EVEL_OPTION_INT endpointRtpPacketsSent; - EVEL_OPTION_INT localJitter; + EVEL_OPTION_INT localMaxJitterBufferDelay; EVEL_OPTION_INT localRtpOctetsDiscarded; EVEL_OPTION_INT localRtpOctetsReceived; EVEL_OPTION_INT localRtpOctetsSent; @@ -4068,10 +6748,18 @@ typedef struct end_of_call_vqm_summaries { EVEL_OPTION_INT localRtpPacketsReceived; EVEL_OPTION_INT localRtpPacketsSent; EVEL_OPTION_INT mosCqe; - EVEL_OPTION_INT packetsLost; + EVEL_OPTION_INT localRtpPacketsLost; EVEL_OPTION_INT packetLossPercent; EVEL_OPTION_INT rFactor; EVEL_OPTION_INT roundTripDelay; + EVEL_OPTION_INT endpointAverageJitter; + EVEL_OPTION_INT endpointMaxJitter; + EVEL_OPTION_INT endpointRtpOctetsLost; + EVEL_OPTION_INT endpointRtpPacketsLost; + EVEL_OPTION_INT localAverageJitter; + EVEL_OPTION_INT localAverageJitterBufferDelay; + EVEL_OPTION_INT localMaxJitter; + EVEL_OPTION_INT oneWayDelay; } END_OF_CALL_VOICE_QUALITY_METRICS; @@ -4103,17 +6791,9 @@ typedef struct event_voiceQuality { /* Optional fields */ /***************************************************************************/ EVEL_OPTION_STRING phoneNumber; - DLIST additionalInformation; + HASHTABLE_T * additionalInformation; } EVENT_VOICE_QUALITY; -/**************************************************************************//** - * Voice Quality Additional Info. - * JSON equivalent field: additionalInformation - *****************************************************************************/ -typedef struct voice_quality_additional_info { - char * name; - char * value; -} VOICE_QUALITY_ADDL_INFO; /**************************************************************************//** * Create a new voice quality event. @@ -4211,14 +6891,45 @@ void evel_voice_quality_rtcp_data_set(EVENT_VOICE_QUALITY * voiceQuality, * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param voiceQuality Pointer to the Voice Quality Event. - * @param nameFields The Vendor, VNF and VfModule names to be set. - * ASCIIZ string. The caller does not need to - * preserve the value once the function - * returns. + * @param voiceQuality Pointer to the Voice Quality Event. + * @param modulename The Vendor, VNF and VfModule names to be set. + * ASCIIZ string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ +void evel_voice_quality_vnfmodule_name_set(EVENT_VOICE_QUALITY * voiceQuality, + const char * const module_name); +/**************************************************************************//** + * Set the Vendor VNF Name fields for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param voiceQuality Pointer to the Voice Quality Event. + * @param modulename The Vendor, VNF and VfModule names to be set. + * ASCIIZ string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ +void evel_voice_quality_vnfname_set(EVENT_VOICE_QUALITY * voiceQuality, + const char * const vnfname); + +/**************************************************************************//** + * Set the Phone Number associated with the Correlator for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param voiceQuality Pointer to the Voice Quality Event. + * @param calleeCodecForCall The Phone Number to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. *****************************************************************************/ -void evel_voice_quality_name_fields_set(EVENT_VOICE_QUALITY * voiceQuality, - const char * const nameFields); +void evel_voice_quality_phone_number_set(EVENT_VOICE_QUALITY * voiceQuality, + const char * const phoneNumber); /**************************************************************************//** * Add an End of Call Voice Quality Metrices @@ -4228,39 +6939,39 @@ void evel_voice_quality_name_fields_set(EVENT_VOICE_QUALITY * voiceQuality, * after the function returns. * * @param voiceQuality Pointer to the measurement. - * @param adjacencyName Adjacency name - * @param endpointDescription Enumeration: ‘Caller’, ‘Callee’. - * @param endpointJitter Endpoint jitter - * @param endpointRtpOctetsDiscarded Endpoint RTP octets discarded. - * @param endpointRtpOctetsReceived Endpoint RTP octets received. - * @param endpointRtpOctetsSent Endpoint RTP octets sent - * @param endpointRtpPacketsDiscarded Endpoint RTP packets discarded. - * @param endpointRtpPacketsReceived Endpoint RTP packets received. - * @param endpointRtpPacketsSent Endpoint RTP packets sent. - * @param localJitter Local jitter. - * @param localRtpOctetsDiscarded Local RTP octets discarded. - * @param localRtpOctetsReceived Local RTP octets received. - * @param localRtpOctetsSent Local RTP octets sent. - * @param localRtpPacketsDiscarded Local RTP packets discarded. - * @param localRtpPacketsReceived Local RTP packets received. - * @param localRtpPacketsSent Local RTP packets sent. - * @param mosCqe Decimal range from 1 to 5 - * (1 decimal place) - * @param packetsLost No Packets lost - * @param packetLossPercent Calculated percentage packet loss - * @param rFactor rFactor from 0 to 100 - * @param roundTripDelay Round trip delay in milliseconds + * @param adjacencyName Adjacency name + * @param endpointDescription Enumeration: ‘Caller’, ‘Callee’. + * @param localRtpOctetsLost localRtpOctetsLost + * @param endpointRtpOctetsDiscarded Endpoint RTP octets discarded. + * @param endpointRtpOctetsReceived Endpoint RTP octets received. + * @param endpointRtpOctetsSent Endpoint RTP octets sent + * @param endpointRtpPacketsDiscarded Endpoint RTP packets discarded. + * @param endpointRtpPacketsReceived Endpoint RTP packets received. + * @param endpointRtpPacketsSent Endpoint RTP packets sent. + * @param localMaxJitterBufferDelay Local max jitter buffer Delay. + * @param localRtpOctetsDiscarded Local RTP octets discarded. + * @param localRtpOctetsReceived Local RTP octets received. + * @param localRtpOctetsSent Local RTP octets sent. + * @param localRtpPacketsDiscarded Local RTP packets discarded. + * @param localRtpPacketsReceived Local RTP packets received. + * @param localRtpPacketsSent Local RTP packets sent. + * @param mosCqe Decimal range from 1 to 5 + * (1 decimal place) + * @param localRtpPacketsLost Local RTP Packets lost + * @param packetLossPercent Calculated percentage packet loss + * @param rFactor rFactor from 0 to 100 + * @param roundTripDelay Round trip delay in milliseconds *****************************************************************************/ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, const char * adjacencyName, EVEL_SERVICE_ENDPOINT_DESC endpointDescription, - int endpointJitter, + int localRtpOctetsLost, int endpointRtpOctetsDiscarded, int endpointRtpOctetsReceived, int endpointRtpOctetsSent, int endpointRtpPacketsDiscarded, int endpointRtpPacketsReceived, int endpointRtpPacketsSent, - int localJitter, + int localMaxJitterBufferDelay, int localRtpOctetsDiscarded, int localRtpOctetsReceived, int localRtpOctetsSent, @@ -4268,10 +6979,18 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, int localRtpPacketsReceived, int localRtpPacketsSent, int mosCqe, - int packetsLost, + int localRtpPacketsLost, int packetLossPercent, int rFactor, - int roundTripDelay); + int roundTripDelay, + int endpointAverageJitter, + int endpointMaxJitter, + int endpointRtpOctetsLost, + int endpointRtpPacketsLost, + int localAverageJitter, + int localAverageJitterBufferDelay, + int localMaxJitter, + int oneWayDelay); /**************************************************************************//** * Free a Voice Quality. @@ -4311,9 +7030,9 @@ void evel_voice_quality_addl_info_add(EVENT_VOICE_QUALITY * voiceQuality, char * /*****************************************************************************/ typedef enum evel_event_action { - EVEL_EVENT_ACTION_CLEAR, - EVEL_EVENT_ACTION_CONTINUE, EVEL_EVENT_ACTION_SET, + EVEL_EVENT_ACTION_CONTINUE, + EVEL_EVENT_ACTION_CLEAR, EVEL_MAX_EVENT_ACTION }EVEL_EVENT_ACTION; @@ -4328,16 +7047,15 @@ typedef enum evel_alert_type { typedef struct perf_counter { char * criticality; - char * name; char * thresholdCrossed; - char * value; + HASHTABLE_T *hashmap; }PERF_COUNTER; /*****************************************************************************/ /* Supported Threshold Crossing version. */ /*****************************************************************************/ -#define EVEL_THRESHOLD_CROSS_MAJOR_VERSION 2 +#define EVEL_THRESHOLD_CROSS_MAJOR_VERSION 4 #define EVEL_THRESHOLD_CROSS_MINOR_VERSION 0 /**************************************************************************//** @@ -4355,18 +7073,18 @@ typedef struct event_threshold_cross { /***************************************************************************/ /* Mandatory fields */ /***************************************************************************/ - PERF_COUNTER additionalParameters; + DLIST additionalParameters; EVEL_EVENT_ACTION alertAction; char * alertDescription; EVEL_ALERT_TYPE alertType; - unsigned long long collectionTimestamp; + char * collectionTimestamp; EVEL_SEVERITIES eventSeverity; - unsigned long long eventStartTimestamp; + char * eventStartTimestamp; /***************************************************************************/ /* Optional fields */ /***************************************************************************/ - DLIST additional_info; + HASHTABLE_T *additional_info; EVEL_OPTION_STRING alertValue; DLIST alertidList; EVEL_OPTION_STRING dataCollector; @@ -4388,16 +7106,12 @@ typedef struct event_threshold_cross { * * @param event_name Unique Event Name * @param event_id A universal identifier of the event for analysis etc - * @param char* tcriticality Performance Counter Criticality MAJ MIN, - * @param char* tname Performance Counter Threshold name - * @param char* tthresholdCrossed Counter Threshold crossed value - * @param char* tvalue Counter actual value * @param EVEL_EVENT_ACTION talertAction Alert set continue or clear * @param char* talertDescription * @param EVEL_ALERT_TYPE talertType Kind of anamoly - * @param unsigned long long tcollectionTimestamp time at which alert was collected + * @param char * tcollectionTimestamp time at which alert was collected * @param EVEL_SEVERITIES teventSeverity Severity of Alert - * @param unsigned long long teventStartTimestamp Time when this alert started + * @param char * teventStartTimestamp Time when this alert started * * @returns pointer to the newly manufactured ::EVENT_THRESHOLD_CROSS. If the * event is not used it must be released using @@ -4406,16 +7120,36 @@ typedef struct event_threshold_cross { *****************************************************************************/ EVENT_THRESHOLD_CROSS * evel_new_threshold_cross( const char* ev_name, const char *ev_id, - char * tcriticality, - char * tname, - char * tthresholdCrossed, - char * tvalue, - EVEL_EVENT_ACTION talertAction, + EVEL_ALERT_ACTIONS talertAction, char * talertDescription, EVEL_ALERT_TYPE talertType, - unsigned long long tcollectionTimestamp, + char * tcollectionTimestamp, EVEL_SEVERITIES teventSeverity, - unsigned long long teventStartTimestamp); + char * teventStartTimestamp); + +/**************************************************************************//** + * Add the TCA additional performance counter + * + * @param tcp Pointer to the ::EVENT_THRESHOLD_CROSS. + * @param char* tcriticality Performance Counter criticality + * @param char* tthresholdCrossed Performance Counter Threshold name + *****************************************************************************/ +PERF_COUNTER * evel_threshold_cross_add_addl_parameters( + EVENT_THRESHOLD_CROSS * const event, + char * tcriticality, + char * tthresholdCrossed); + +/**************************************************************************//** + * Set the TCA name / Value for additional performance counter + * + * @param PERF_COUNTER perf_ctr Pointer to additional Parameter array element + * @param char* name Performance Counter Threshold name + * @param char* value Performance Counter actual value + *****************************************************************************/ +void evel_threshold_cross_addl_parameters_hashmap_set( + PERF_COUNTER * perf_ctr, + char * name, + char * value); /**************************************************************************//** * Free a Threshold cross event. @@ -4517,6 +7251,7 @@ void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const tcp, /* Debug macros. */ /*****************************************************************************/ #define EVEL_DEBUG(FMT, ...) log_debug(EVEL_LOG_DEBUG, (FMT), ##__VA_ARGS__) +#define EVEL_WARN(FMT, ...) log_debug(EVEL_LOG_WARN, (FMT), ##__VA_ARGS__) #define EVEL_INFO(FMT, ...) log_debug(EVEL_LOG_INFO, (FMT), ##__VA_ARGS__) #define EVEL_SPAMMY(FMT, ...) log_debug(EVEL_LOG_SPAMMY, (FMT), ##__VA_ARGS__) #define EVEL_ERROR(FMT, ...) log_debug(EVEL_LOG_ERROR, "ERROR: " FMT, \ diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c index 5babb67..88ef12f 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c @@ -43,7 +43,7 @@ static int event_sequence = 1; * * @param sequence The next sequence number to use. *****************************************************************************/ -void evel_set_next_event_sequence(const int sequence) +void evel_set_global_event_sequence(const int sequence) { EVEL_ENTER(); @@ -145,6 +145,9 @@ void evel_init_header(EVENT_HEADER * const header,const char *const eventname) { char scratchpad[EVEL_MAX_STRING_LEN + 1] = {0}; struct timeval tv; + char eventListenerVersion[10] = {0}; + int offset; + int offset1; EVEL_ENTER(); @@ -168,20 +171,39 @@ void evel_init_header(EVENT_HEADER * const header,const char *const eventname) header->priority = EVEL_PRIORITY_NORMAL; header->reporting_entity_name = strdup(openstack_vm_name()); header->source_name = strdup(openstack_vm_name()); - header->sequence = event_sequence; + header->sequence = 0; header->start_epoch_microsec = header->last_epoch_microsec; header->major_version = EVEL_HEADER_MAJOR_VERSION; header->minor_version = EVEL_HEADER_MINOR_VERSION; event_sequence++; + /***************************************************************************/ + /* Event Listener Version */ + /***************************************************************************/ + offset = sprintf(eventListenerVersion, "%d", EVEL_API_MAJOR_VERSION); + if ((EVEL_API_MINOR_VERSION != 0) && (EVEL_API_PATCH_VERSION == 0)) + { + sprintf(eventListenerVersion + offset, ".%d", EVEL_API_MINOR_VERSION); + } + else if (EVEL_API_PATCH_VERSION != 0) + { + offset1 = sprintf(eventListenerVersion + offset, ".%d", EVEL_API_MINOR_VERSION); + offset = offset + offset1; + sprintf(eventListenerVersion + offset, ".%d", EVEL_API_PATCH_VERSION); + } + + EVEL_INFO("Setting event listener version to %s", eventListenerVersion); + header->event_listener_version = strdup(eventListenerVersion); /***************************************************************************/ /* Optional parameters. */ /***************************************************************************/ evel_init_option_string(&header->event_type); evel_init_option_string(&header->nfcnaming_code); evel_init_option_string(&header->nfnaming_code); - evel_force_option_string(&header->reporting_entity_id, openstack_vm_uuid()); - evel_force_option_string(&header->source_id, openstack_vm_uuid()); + evel_init_option_string(&header->reporting_entity_id); + evel_init_option_string(&header->timezone_offset); + evel_init_option_string(&header->nfVendor_name); + evel_init_option_string(&header->source_id); evel_init_option_intheader(&header->internal_field); dlist_initialize(&header->batch_events); @@ -200,6 +222,9 @@ void evel_init_header(EVENT_HEADER * const header,const char *const eventname) void evel_init_header_nameid(EVENT_HEADER * const header,const char *const eventname, const char *eventid) { struct timeval tv; + char eventListenerVersion[10] = {0}; + int offset; + int offset1; EVEL_ENTER(); @@ -210,7 +235,7 @@ void evel_init_header_nameid(EVENT_HEADER * const header,const char *const event gettimeofday(&tv, NULL); /***************************************************************************/ - /* Initialize the header. Get a new event sequence number. Note that if */ + /* Initialize the header. Reset event sequence number. Note that if */ /* any memory allocation fails in here we will fail gracefully because */ /* everything downstream can cope with NULLs. */ /***************************************************************************/ @@ -221,20 +246,38 @@ void evel_init_header_nameid(EVENT_HEADER * const header,const char *const event header->priority = EVEL_PRIORITY_NORMAL; header->reporting_entity_name = strdup(openstack_vm_name()); header->source_name = strdup(openstack_vm_name()); - header->sequence = event_sequence; + header->sequence = 0; header->start_epoch_microsec = header->last_epoch_microsec; header->major_version = EVEL_HEADER_MAJOR_VERSION; header->minor_version = EVEL_HEADER_MINOR_VERSION; - event_sequence++; + /***************************************************************************/ + /* Event Listener Version */ + /***************************************************************************/ + offset = sprintf(eventListenerVersion, "%d", EVEL_API_MAJOR_VERSION); + if ((EVEL_API_MINOR_VERSION != 0) && (EVEL_API_PATCH_VERSION == 0)) + { + sprintf(eventListenerVersion + offset, ".%d", EVEL_API_MINOR_VERSION); + } + else if (EVEL_API_PATCH_VERSION != 0) + { + offset1 = sprintf(eventListenerVersion + offset, ".%d", EVEL_API_MINOR_VERSION); + offset = offset + offset1; + sprintf(eventListenerVersion + offset, ".%d", EVEL_API_PATCH_VERSION); + } + + EVEL_INFO("Setting event listener version to %s", eventListenerVersion); + header->event_listener_version = strdup(eventListenerVersion); /***************************************************************************/ /* Optional parameters. */ /***************************************************************************/ evel_init_option_string(&header->event_type); evel_init_option_string(&header->nfcnaming_code); evel_init_option_string(&header->nfnaming_code); - evel_force_option_string(&header->reporting_entity_id, openstack_vm_uuid()); - evel_force_option_string(&header->source_id, openstack_vm_uuid()); + evel_init_option_string(&header->reporting_entity_id); + evel_init_option_string(&header->timezone_offset); + evel_init_option_string(&header->source_id); + evel_init_option_string(&header->nfVendor_name); evel_init_option_intheader(&header->internal_field); dlist_initialize(&header->batch_events); @@ -269,6 +312,29 @@ void evel_header_type_set(EVENT_HEADER * const header, EVEL_EXIT(); } +/**************************************************************************//** + * Set the Event Sequence property of the event header. + * + * @note The Start Epoch defaults to the time of event creation. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param start_epoch_microsec + * The start epoch to set, in microseconds. + *****************************************************************************/ +void evel_event_sequence_set(EVENT_HEADER * const header,const int sequence_number) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(header != NULL); + header->sequence = sequence_number; + + EVEL_EXIT(); +} + + /**************************************************************************//** * Set the Start Epoch property of the event header. * @@ -388,6 +454,36 @@ void evel_reporting_entity_name_set(EVENT_HEADER * const header, EVEL_EXIT(); } +/**************************************************************************//** + * Set the source Name property of the event header. + * + * @note The source Name defaults to the OpenStack VM Name. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param source_name The entity name to set. + *****************************************************************************/ +void evel_source_name_set(EVENT_HEADER * const header, + const char * const source_name) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(header != NULL); + assert(source_name != NULL); + assert(header->source_name != NULL); + + /***************************************************************************/ + /* Free the previously allocated memory and replace it with a copy of the */ + /* provided one. */ + /***************************************************************************/ + free(header->source_name); + header->source_name = strdup(source_name); + + EVEL_EXIT(); +} + /**************************************************************************//** * Set the Reporting Entity Id property of the event header. * @@ -417,6 +513,57 @@ void evel_reporting_entity_id_set(EVENT_HEADER * const header, EVEL_EXIT(); } +/**************************************************************************//** + * Set the time zone offset + * + * @param timeZoneOffset Time zone offset to use. + *****************************************************************************/ +void evel_time_zone_offset_set(EVENT_HEADER * const header, char * timeZoneOffset) +{ + EVEL_ENTER(); + + assert(header != NULL); + assert(timeZoneOffset != NULL); + EVEL_INFO("Setting time zone offset to %s", timeZoneOffset); + evel_set_option_string(&header->timezone_offset, timeZoneOffset, "Time Zone Offset to GMT"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the NF Vendor Name + * + * @param nfVendorName NF Vendor Name to use + *****************************************************************************/ +void evel_nf_vendor_name_set(EVENT_HEADER * const header, char * nfVendorName) +{ + EVEL_ENTER(); + + assert(header != NULL); + assert(nfVendorName != NULL); + EVEL_INFO("Setting NF Vendor Name to %s", nfVendorName); + evel_set_option_string(&header->nfVendor_name, nfVendorName, "NF Vendor Name"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the source ID + * + * @param sourceId source ID to use + *****************************************************************************/ +void evel_source_id_set(EVENT_HEADER * const header, char * sourceId) +{ + EVEL_ENTER(); + + assert(header != NULL); + assert(sourceId != NULL); + EVEL_INFO("Setting source ID to %s", sourceId); + evel_set_option_string(&header->source_id, sourceId, "source ID"); + + EVEL_EXIT(); +} + /**************************************************************************//** * Encode the event as a JSON event object according to AT&T's schema. * @@ -449,6 +596,7 @@ void evel_json_encode_header(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_string(jbuf, "domain", domain); evel_enc_kv_string(jbuf, "eventId", event->event_id); evel_enc_kv_string(jbuf, "eventName", event->event_name); + evel_enc_kv_string(jbuf, "vesEventListenerVersion", event->event_listener_version); evel_enc_kv_ull(jbuf, "lastEpochMicrosec", event->last_epoch_microsec); evel_enc_kv_string(jbuf, "priority", priority); evel_enc_kv_string( @@ -456,8 +604,10 @@ void evel_json_encode_header(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_int(jbuf, "sequence", event->sequence); evel_enc_kv_string(jbuf, "sourceName", event->source_name); evel_enc_kv_ull(jbuf, "startEpochMicrosec", event->start_epoch_microsec); - evel_enc_version( - jbuf, "version", event->major_version, event->minor_version); + char * version = "4.0.2"; + evel_enc_kv_string(jbuf, "version", version); + // evel_enc_version( + // jbuf, "version", event->major_version, event->minor_version); /***************************************************************************/ /* Optional fields. */ @@ -468,6 +618,8 @@ void evel_json_encode_header(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_string(jbuf, "sourceId", &event->source_id); evel_enc_kv_opt_string(jbuf, "nfcNamingCode", &event->nfcnaming_code); evel_enc_kv_opt_string(jbuf, "nfNamingCode", &event->nfnaming_code); + evel_enc_kv_opt_string(jbuf, "timeZoneOffset", &event->timezone_offset); + evel_enc_kv_opt_string(jbuf, "nfVendorName", &event->nfVendor_name); evel_json_close_object(jbuf); @@ -499,7 +651,10 @@ void evel_free_header(EVENT_HEADER * const event) free(event->event_id); evel_free_option_string(&event->event_type); free(event->event_name); + free(event->event_listener_version); evel_free_option_string(&event->reporting_entity_id); + evel_free_option_string(&event->timezone_offset); + evel_free_option_string(&event->nfVendor_name); free(event->reporting_entity_name); evel_free_option_string(&event->source_id); evel_free_option_string(&event->nfcnaming_code); @@ -557,6 +712,14 @@ void evel_json_encode_eventtype( evel_json_encode_state_change(jbuf, (EVENT_STATE_CHANGE *)event); break; + case EVEL_DOMAIN_NOTIFICATION: + evel_json_encode_notification(jbuf, (EVENT_NOTIFICATION *)event); + break; + + case EVEL_DOMAIN_PNF_REGISTRATION: + evel_json_encode_pnf_registration(jbuf, (EVENT_PNF_REGISTRATION *)event); + break; + case EVEL_DOMAIN_SYSLOG: evel_json_encode_syslog(jbuf, (EVENT_SYSLOG *)event); break; @@ -833,14 +996,14 @@ void evel_json_encode_vendor_field(EVEL_JSON_BUFFER * jbuf, assert(vfield != NULL); assert(vfield->vendorname != NULL); - evel_json_open_named_object(jbuf, "vendorVnfNameFields"); + evel_json_open_named_object(jbuf, "vendorNfNameFields"); /***************************************************************************/ /* Mandatory fields. */ /***************************************************************************/ evel_enc_kv_string(jbuf, "vendorName", vfield->vendorname); - evel_enc_kv_opt_string(jbuf, "vfModuleName", &vfield->vfmodule); - evel_enc_kv_opt_string(jbuf, "vnfName", &vfield->vnfname); + evel_enc_kv_opt_string(jbuf, "nfModuleName", &vfield->vfmodule); + evel_enc_kv_opt_string(jbuf, "nfName", &vfield->vnfname); /***************************************************************************/ /* Optional fields. */ diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c index fb94daf..4127f25 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c @@ -1,6 +1,6 @@ /*************************************************************************//** * - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. * * Unless otherwise specified, all software contained herein is * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ * How long we're prepared to wait for the API service to respond in * seconds. *****************************************************************************/ -static const int EVEL_API_TIMEOUT = 5; +static const int EVEL_API_TIMEOUT = 10; /*****************************************************************************/ /* Prototypes of locally scoped functions. */ @@ -58,21 +58,29 @@ static bool evel_tokens_match_command_list(const MEMORY_CHUNK * const chunk, static bool evel_token_equals_string(const MEMORY_CHUNK * const chunk, const jsmntok_t * const json_token, const char * check_string); +static void * event_multi_handler(void * arg __attribute__ ((unused))); +static EVEL_ERR_CODES evel_re_setup_curl(); /**************************************************************************//** * Buffers for error strings from libcurl. *****************************************************************************/ static char curl_err_string[CURL_ERROR_SIZE] = ""; +static char curl_err_string2[CURL_ERROR_SIZE] = ""; /**************************************************************************//** * Handle for the API into libcurl. *****************************************************************************/ static CURL * curl_handle = NULL; +static CURL * curl_handle2 = NULL; +static CURLM * multi_handle = NULL; +int curr_global_handles = 0; +int activmode = -1; /**************************************************************************//** * Special headers that we send. *****************************************************************************/ static struct curl_slist * hdr_chunk = NULL; +static struct curl_slist * hdr_chunk2 = NULL; /**************************************************************************//** * Message queue for sending events to the API. @@ -104,6 +112,30 @@ static char * evel_event_api_url; static char * evel_throt_api_url; static char * evel_batch_api_url; +static char * evel_bevent_api_url; +static char * evel_bthrot_api_url; +static char * evel_bbatch_api_url; + +/**************************************************************************//** + * Storage for other CURL related parameters + *****************************************************************************/ +int evel_secure = -1; +int evel_verbosity = -1; + +long evel_verify_peer = 0; +long evel_verify_host = 0; + +static char * evel_source_ip = NULL; +static char * evel_source_ip_bakup = NULL; +static char * evel_cert_file_path = NULL; +static char * evel_key_file_path = NULL; +static char * evel_ca_info = NULL; +static char * evel_ca_file_path = NULL; +static char * evel_username = NULL; +static char * evel_password = NULL; +static char * evel_username2 = NULL; +static char * evel_password2 = NULL; + /**************************************************************************//** * Initialize the event handler. * @@ -129,10 +161,13 @@ static char * evel_batch_api_url; * logs. *****************************************************************************/ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, + const char * const bakup_api_url, const char * const throt_api_url, const char * const source_ip, + const char * const source_ip_bakup, int ring_buf_size, int secure, + int activitymode, const char * const cert_file_path, const char * const key_file_path, const char * const ca_info, @@ -141,6 +176,8 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, long verify_host, const char * const username, const char * const password, + const char * const username2, + const char * const password2, int verbosity) { int rc = EVEL_SUCCESS; @@ -157,6 +194,12 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, assert(throt_api_url != NULL); assert(username != NULL); assert(password != NULL); + if( bakup_api_url != NULL ) + { + assert(username2 != NULL); + assert(password2 != NULL); + } + /***************************************************************************/ /* Store the API URLs. */ @@ -168,7 +211,98 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, assert(evel_batch_api_url != NULL); evel_throt_api_url = strdup(throt_api_url); assert(evel_throt_api_url != NULL); + curr_global_handles = 1; + + if( bakup_api_url != NULL ) + { + evel_bevent_api_url = strdup(bakup_api_url); + assert(evel_bevent_api_url != NULL); + sprintf(batch_api_url,"%s/eventBatch",event_api_url); + evel_bbatch_api_url = strdup(batch_api_url); + assert(evel_bbatch_api_url != NULL); + evel_bthrot_api_url = strdup(throt_api_url); + assert(evel_bthrot_api_url != NULL); + curr_global_handles = 2; + } + + /***********************************************************************//** + * Store other parameters + ***************************************************************************/ + evel_secure = secure; + evel_verbosity = verbosity; + + evel_verify_peer = verify_peer; + evel_verify_host = verify_host; + + evel_source_ip = NULL; + if (source_ip != NULL) + { + evel_source_ip = strdup(source_ip); + assert(evel_source_ip != NULL); + } + + evel_source_ip_bakup = NULL; + if (source_ip_bakup != NULL) + { + evel_source_ip_bakup = strdup(source_ip_bakup); + assert(evel_source_ip_bakup != NULL); + } + + evel_cert_file_path = NULL; + if (cert_file_path != NULL) + { + evel_cert_file_path = strdup(cert_file_path); + assert(evel_cert_file_path != NULL); + } + + evel_key_file_path = NULL; + if (key_file_path != NULL) + { + evel_key_file_path = strdup(key_file_path); + assert(evel_key_file_path != NULL); + } + + evel_ca_info = NULL; + if (ca_info != NULL) + { + evel_ca_info = strdup(ca_info); + assert(evel_ca_info != NULL); + } + + evel_ca_file_path = NULL; + if (ca_file_path != NULL) + { + evel_ca_file_path = strdup(ca_file_path); + assert(evel_ca_file_path != NULL); + } + + evel_username = NULL; + if (username != NULL) + { + evel_username = strdup(username); + assert(evel_username != NULL); + } + + evel_password = NULL; + if (password != NULL) + { + evel_password = strdup(password); + assert(evel_password != NULL); + } + evel_username2 = NULL; + if (username2 != NULL) + { + evel_username2 = strdup(username2); + assert(evel_username2 != NULL); + } + + evel_password2 = NULL; + if (password2 != NULL) + { + evel_password2 = strdup(password2); + assert(evel_password2 != NULL); + } curl_version_info_data *d = curl_version_info(CURLVERSION_NOW); /* compare with the 24 bit hex number in 8 bit fields */ @@ -203,6 +337,16 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_handle2 = curl_easy_init(); + if (curl_handle2 == NULL) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to get backup libCURL handle"); + goto exit_label; + } + } /***************************************************************************/ /* Prime the library to give friendly error codes. */ /***************************************************************************/ @@ -217,6 +361,21 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_ERRORBUFFER, + curl_err_string2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL2 to provide friendly errors. " + "Error code=%d", curl_rc); + goto exit_label; + } + } + + /***************************************************************************/ /* If running in verbose mode generate more output. */ /***************************************************************************/ @@ -230,8 +389,22 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d", curl_rc); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_VERBOSE, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to be verbose. " + "Error code=%d", curl_rc); + goto exit_label; + } + } + } + + /***************************************************************************/ /* Set the URL for the API. */ /***************************************************************************/ @@ -245,6 +418,21 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, } EVEL_INFO("Initializing CURL to send events to: %s", event_api_url); + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_URL, + bakup_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ /* send all data to this function. */ /***************************************************************************/ @@ -258,6 +446,21 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_WRITEFUNCTION, + evel_write_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ /* configure local ip address if provided */ @@ -280,6 +483,23 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, } } } + if( source_ip_bakup != NULL ) + { + snprintf(local_address,sizeof(local_address),source_ip_bakup); + if( local_address[0] != '\0' ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_INTERFACE, + local_address); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize bakup libCURL with the local address. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + } /***************************************************************************/ /* configure SSL options for HTTPS transfers */ @@ -298,6 +518,19 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSLCERT, + cert_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client cert. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } } if( key_file_path != NULL ) @@ -312,6 +545,19 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSLKEY, + key_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client key. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } } if( ca_info != NULL ) @@ -326,6 +572,19 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_CAINFO, + ca_info); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert file. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } } if( ca_file_path != NULL ) @@ -340,6 +599,19 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_CAPATH, + ca_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert path. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } } curl_rc = curl_easy_setopt(curl_handle, @@ -363,6 +635,29 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSL_VERIFYPEER, + verify_peer); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with SSL Server verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSL_VERIFYHOST, + verify_host); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with Client host verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } } @@ -381,6 +676,20 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_USERAGENT, + "libcurl-agent/1.0"); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ /* Specify that we are going to POST data. */ @@ -393,6 +702,18 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_POST, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ /* we want to use our own read function. */ @@ -405,6 +726,18 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "function. Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_READFUNCTION, read_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ /* All of our events are JSON encoded. We also suppress the */ @@ -427,6 +760,21 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + hdr_chunk2 = curl_slist_append(hdr_chunk2, "Content-type: application/json"); + hdr_chunk2 = curl_slist_append(hdr_chunk2, "Expect:"); + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_HTTPHEADER, hdr_chunk2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ /* Set the timeout for the operation. */ @@ -441,6 +789,18 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, "Error code=%d (%s)", curl_rc, curl_err_string); goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_TIMEOUT, EVEL_API_TIMEOUT); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ /* Set that we want Basic authentication with username:password Base-64 */ @@ -471,6 +831,45 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, goto exit_label; } + if( bakup_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL for Basic Authentication. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_USERNAME, username2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with username. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_PASSWORD, password2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with password. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + + multi_handle = curl_multi_init();; + if (multi_handle == NULL) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to get libCURL Multi handle"); + goto exit_label; + } + activmode = activitymode; + + } + + /***************************************************************************/ /* Initialize a message ring-buffer to be used between the foreground and */ /* the thread which sends the messages. This can't fail. */ @@ -515,7 +914,11 @@ EVEL_ERR_CODES event_handler_run() /* Start the event handler thread. */ /***************************************************************************/ evt_handler_state = EVT_HANDLER_INACTIVE; - pthread_rc = pthread_create(&evt_handler_thread, NULL, event_handler, NULL); + if( curr_global_handles <= 1 ) + pthread_rc = pthread_create(&evt_handler_thread, NULL, event_handler, NULL); + else + pthread_rc = pthread_create(&evt_handler_thread, NULL, event_multi_handler, NULL); + if (pthread_rc != 0) { rc = EVEL_PTHREAD_LIBRARY_FAIL; @@ -588,16 +991,31 @@ EVEL_ERR_CODES event_handler_terminate() /***************************************************************************/ /* Clean-up the cURL library. */ /***************************************************************************/ + if (multi_handle != NULL) + { + curl_multi_cleanup(multi_handle); + } if (curl_handle != NULL) { curl_easy_cleanup(curl_handle); curl_handle = NULL; } + if (curl_handle2 != NULL) + { + curl_easy_cleanup(curl_handle2); + curl_handle2 = NULL; + } if (hdr_chunk != NULL) { curl_slist_free_all(hdr_chunk); hdr_chunk = NULL; } + if (hdr_chunk2 != NULL) + { + curl_slist_free_all(hdr_chunk2); + hdr_chunk2 = NULL; + } + /***************************************************************************/ /* Free off the stored API URL strings. */ @@ -881,25 +1299,332 @@ size_t evel_write_callback(void *contents, return realsize; } + /**************************************************************************//** - * Event Handler. - * - * Watch for messages coming on the internal queue and send them to the - * listener. + * Post an event to the Vendor Event Listener API. * - * param[in] arg Argument - unused. + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval "One of ::EVEL_ERR_CODES" On failure. *****************************************************************************/ -static void * event_handler(void * arg __attribute__ ((unused))) +static EVEL_ERR_CODES evel_postmulti_message(char *msg, size_t size, int *still, + CURL *handle, CURL *bhandle, int numhandles ) { - int old_type = 0; - EVENT_HEADER * msg = NULL; - EVENT_INTERNAL * internal_msg = NULL; - int json_size = 0; - char json_body[EVEL_MAX_JSON_BODY]; int rc = EVEL_SUCCESS; - CURLcode curl_rc; + CURLcode curl_rc = CURLE_OK; + MEMORY_CHUNK rx_chunk[2]; + MEMORY_CHUNK tx_chunk[2]; + int i; - EVEL_INFO("Event handler thread started"); + EVEL_ENTER(); + + EVEL_INFO("Sending :%s: %d\n",msg, numhandles); + + /***************************************************************************/ + /* Create the memory chunk to be used for the response to the post. The */ + /* will be realloced. */ + /***************************************************************************/ +for (i=0;i= 0) { + timeout.tv_sec = curl_timeo / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curl_timeo % 1000) * 1000; + } + + /* get file descriptors from the transfers */ + mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); + + if(mc != CURLM_OK) { + EVEL_ERROR("curl_multi_fdset() failed, code %d.\n", mc); + break; + } + + /* On success the value of maxfd is guaranteed to be >= -1. We call + select(maxfd + 1, ...); specially in case of (maxfd == -1) there are + no fds ready yet so we call select(0, ...) --or Sleep() on Windows-- + to sleep 100ms, which is the minimum suggested value in the + curl_multi_fdset() doc. */ + + if(maxfd == -1) { +#ifdef _WIN32 + Sleep(100); + rc = 0; +#else + /* Portable sleep for platforms other than Windows. */ + struct timeval wait = { 0, 300000 }; /* 250ms */ + rc = select(0, NULL, NULL, NULL, &wait); +#endif + } + else { + /* Note that on some platforms 'timeout' may be modified by select(). + If you need access to the original value save a copy beforehand. */ + rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); + } + + switch(rc) { + case -1: + /* select error */ + break; + case 0: /* timeout */ + default: /* action */ + //curl_multi_perform(multi_handle, &still_running); + evel_postmulti_message(jsonmsg, size, &still_running, currhandle, bakkhandle, nhandles); + } + } while(still_running); + + /* See how the transfers went */ + while((msg = curl_multi_info_read(multi_handle, &msgs_left))) { + if(msg->msg == CURLMSG_DONE) { + int idx; + EVEL_DEBUG("Transfer status - %s\n", curl_multi_strerror(msg->data.result)); + + /* Find out which handle this message is about */ + for(idx = 0; idxeasy_handle == currhandle) break; + else if(msg->easy_handle == bakkhandle) break; + } + + switch(idx) { + case 0: + curl_rc = msg->data.result; + break; + case 1: + curl_rc = msg->data.result; + break; + } + } + } + + /* we start some action by calling perform right away */ + curl_multi_remove_handle(multi_handle, currhandle); + if(nhandles==2){ + curl_multi_remove_handle(multi_handle, bakkhandle); + } + + EVEL_DEBUG("Transfer completed with status %s\n", curl_multi_strerror(curl_rc)); + if( curl_rc == 0 || curl_rc == 55 ) + return EVEL_SUCCESS; + else + return EVEL_CURL_LIBRARY_FAIL; + +} +/**************************************************************************//** + * Event Handler. + * + * Watch for messages coming on the internal queue and send them to the + * listener. + * + * param[in] arg Argument - unused. + *****************************************************************************/ +static void * event_multi_handler(void * arg __attribute__ ((unused))) +{ + int old_type = 0; + EVENT_HEADER * msg = NULL; + EVENT_INTERNAL * internal_msg = NULL; + int json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + int rc = EVEL_SUCCESS; + CURLcode curl_rc; + CURL *currhandler = NULL; + CURL *bakhandler = NULL; + char *send_url = NULL; + char *send_url2 = NULL; + + EVEL_INFO("Event multi handler thread started"); /***************************************************************************/ /* Set this thread to be cancellable immediately. */ @@ -921,12 +1646,12 @@ static void * event_handler(void * arg __attribute__ ((unused))) "Handler will exit immediately!"); } + currhandler = curl_handle; while (evt_handler_state == EVT_HANDLER_ACTIVE) { /*************************************************************************/ /* Wait for a message to be received. */ /*************************************************************************/ - EVEL_DEBUG("Event handler getting any messages"); msg = ring_buffer_read(&event_buffer); /*************************************************************************/ @@ -945,22 +1670,35 @@ static void * event_handler(void * arg __attribute__ ((unused))) /***************************************************************************/ /* Set the URL for the API. */ /***************************************************************************/ - curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url); - if (curl_rc != CURLE_OK) - { - rc = EVEL_CURL_LIBRARY_FAIL; - log_error_state("Failed to initialize libCURL with the Batch API URL. " - "Error code=%d (%s)", curl_rc, curl_err_string); + if( currhandler == curl_handle){ + send_url = evel_batch_api_url; + send_url2 = evel_bbatch_api_url; + bakhandler = curl_handle2; + } else if(currhandler == curl_handle2) { + send_url = evel_bbatch_api_url; + send_url2 = evel_batch_api_url; + bakhandler = curl_handle; } /***********************************************************************/ /* Send the JSON across the API. */ /***********************************************************************/ EVEL_DEBUG("Sending Batch JSON of size %d is: %s", json_size, json_body); - rc = evel_post_api(json_body, json_size); + rc = evel_post_multiapi(json_body, json_size, currhandler, send_url, bakhandler, send_url2); if (rc != EVEL_SUCCESS) { - EVEL_ERROR("Failed to transfer the data. Error code=%d", rc); + EVEL_ERROR("Failed to transfer the data to %s. Error code=%d", send_url, rc); + EVEL_INFO("Switched Collector ..."); + if( currhandler == curl_handle){ + currhandler = curl_handle2; + bakhandler = curl_handle; + } else if(currhandler == curl_handle2) { + currhandler = curl_handle; + bakhandler = curl_handle2; + } + rc = evel_post_multiapi(json_body, json_size, currhandler, send_url2, bakhandler,send_url); + if (rc != EVEL_SUCCESS) + EVEL_ERROR("Failed to transfer the data to failover %s. Error code=%d", send_url2, rc); } } else if (msg->event_domain != EVEL_DOMAIN_INTERNAL ) @@ -975,23 +1713,37 @@ static void * event_handler(void * arg __attribute__ ((unused))) /***************************************************************************/ /* Set the URL for the API. */ /***************************************************************************/ - curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); - if (curl_rc != CURLE_OK) - { - rc = EVEL_CURL_LIBRARY_FAIL; - log_error_state("Failed to initialize libCURL with the API URL. " - "Error code=%d (%s)", curl_rc, curl_err_string); + if( currhandler == curl_handle){ + send_url = evel_event_api_url; + send_url2 = evel_bevent_api_url; + bakhandler = curl_handle2; + } else if(currhandler == curl_handle2) { + send_url = evel_bevent_api_url; + send_url2 = evel_event_api_url; + bakhandler = curl_handle; } /***********************************************************************/ /* Send the JSON across the API. */ /***********************************************************************/ - EVEL_DEBUG("Sending JSON of size %d is: %s", json_size, json_body); - rc = evel_post_api(json_body, json_size); + EVEL_DEBUG("Sending Batch JSON of size %d is: %s", json_size, json_body); + rc = evel_post_multiapi(json_body, json_size, currhandler, send_url, bakhandler, send_url2); if (rc != EVEL_SUCCESS) { - EVEL_ERROR("Failed to transfer the data. Error code=%d", rc); + EVEL_ERROR("Failed to transfer the data to %s. Error code=%d", send_url, rc); + EVEL_INFO("Switched Collector ..."); + if( currhandler == curl_handle){ + currhandler = curl_handle2; + bakhandler = curl_handle; + } else if(currhandler == curl_handle2) { + currhandler = curl_handle; + bakhandler = curl_handle2; + } + rc = evel_post_multiapi(json_body, json_size, currhandler, send_url2, bakhandler,send_url); + if (rc != EVEL_SUCCESS) + EVEL_ERROR("Failed to transfer the data to failover %s. Error code=%d", send_url2, rc); } + } else { @@ -1075,71 +1827,305 @@ static void * event_handler(void * arg __attribute__ ((unused))) return (NULL); } + /**************************************************************************//** - * Handle a JSON response from the listener, contained in a ::MEMORY_CHUNK. + * Event Handler. * - * Tokenize the response, and decode any tokens found. + * Watch for messages coming on the internal queue and send them to the + * listener. * - * @param chunk The memory chunk containing the response. - * @param post The memory chunk in which to place any resulting POST. + * param[in] arg Argument - unused. *****************************************************************************/ -void evel_handle_event_response(const MEMORY_CHUNK * const chunk, - MEMORY_CHUNK * const post) +static void * event_handler(void * arg __attribute__ ((unused))) { - jsmn_parser json_parser; - jsmntok_t json_tokens[EVEL_MAX_RESPONSE_TOKENS]; - int num_tokens = 0; + int old_type = 0; + EVENT_HEADER * msg = NULL; + EVENT_INTERNAL * internal_msg = NULL; + int json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + int rc = EVEL_SUCCESS; + CURLcode curl_rc; - EVEL_ENTER(); + EVEL_INFO("Event handler thread started"); /***************************************************************************/ - /* Check preconditions. */ + /* Set this thread to be cancellable immediately. */ /***************************************************************************/ - assert(chunk != NULL); - assert(priority_post.memory == NULL); - - EVEL_DEBUG("Response size = %d", chunk->size); - EVEL_DEBUG("Response = %s", chunk->memory); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_type); /***************************************************************************/ - /* Initialize the parser and tokenize the response. */ + /* Set the handler as active, defending against weird situations like */ + /* immediately shutting down after initializing the library so the */ + /* handler never gets started up properly. */ /***************************************************************************/ - jsmn_init(&json_parser); - num_tokens = jsmn_parse(&json_parser, - chunk->memory, - chunk->size, - json_tokens, - EVEL_MAX_RESPONSE_TOKENS); - - if (num_tokens < 0) + if (evt_handler_state == EVT_HANDLER_INACTIVE) { - EVEL_ERROR("Failed to parse JSON response. " - "Error code=%d", num_tokens); + evt_handler_state = EVT_HANDLER_ACTIVE; } - else if (num_tokens == 0) + else { - EVEL_DEBUG("No tokens found in JSON response"); + EVEL_ERROR("Event Handler State was not INACTIVE at start-up - " + "Handler will exit immediately!"); } - else + + while (evt_handler_state == EVT_HANDLER_ACTIVE) { - EVEL_DEBUG("Decode JSON response tokens"); - if (!evel_handle_response_tokens(chunk, json_tokens, num_tokens, post)) + /*************************************************************************/ + /* Wait for a message to be received. */ + /*************************************************************************/ + EVEL_DEBUG("Event handler getting any messages"); + msg = ring_buffer_read(&event_buffer); + + /*************************************************************************/ + /* Internal events get special treatment while regular events get posted */ + /* to the far side. */ + /*************************************************************************/ + if (msg->event_domain == EVEL_DOMAIN_BATCH ) { - EVEL_ERROR("Failed to handle JSON response."); - } - } + EVEL_DEBUG("Batch event received"); - EVEL_EXIT(); -} + /***********************************************************************/ + /* Encode the event in JSON. */ + /***********************************************************************/ + json_size = evel_json_encode_batch_event(json_body, EVEL_MAX_JSON_BODY, msg); -/**************************************************************************//** - * Handle a JSON response from the listener, as a list of tokens from JSMN. - * - * @param chunk Memory chunk containing the JSON buffer. - * @param json_tokens Array of tokens to handle. - * @param num_tokens The number of tokens to handle. - * @param post The memory chunk in which to place any resulting POST. - * @return true if we handled the response, false otherwise. + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the Batch API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + + /***********************************************************************/ + /* Send the JSON across the API. */ + /***********************************************************************/ + EVEL_DEBUG("Sending Batch JSON of size %d is: %s", json_size, json_body); + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data %s. Error code=%d", evel_batch_api_url, rc); + } + } + else if (msg->event_domain != EVEL_DOMAIN_INTERNAL ) + { + EVEL_DEBUG("External event received"); + + /***********************************************************************/ + /* Encode the event in JSON. */ + /***********************************************************************/ + json_size = evel_json_encode_event(json_body, EVEL_MAX_JSON_BODY, msg); + + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + + /***********************************************************************/ + /* Send the JSON across the API. */ + /***********************************************************************/ + EVEL_DEBUG("Sending JSON of size %d is: %s", json_size, json_body); + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data %s. Error code=%d",evel_event_api_url, rc); + EVEL_INFO("First Retry sending the message by setting the connection afresh"); + rc = evel_re_setup_curl(); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to re-setup CURL- First attempt. Error code=%d", rc); + goto next; + } + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data after First retry - %s. Error code=%d",evel_event_api_url, rc); + EVEL_INFO("Second Retry sending the message by setting the connection afresh"); + + rc = evel_re_setup_curl(); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to re-setup CURL- Second attempt. Error code=%d", rc); + goto next; } + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data after Second retry - %s. Error code=%d",evel_event_api_url, rc); + EVEL_INFO("Third Retry sending the message by setting the connection afresh"); + + rc = evel_re_setup_curl(); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to re-setup CURL- Third attempt. Error code=%d", rc); + goto next; + } + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data after Third retry - %s. Error code=%d",evel_event_api_url, rc); + } + } + } + } + } + else + { + EVEL_DEBUG("Internal event received"); + internal_msg = (EVENT_INTERNAL *) msg; + assert(internal_msg->command == EVT_CMD_TERMINATE); + evt_handler_state = EVT_HANDLER_TERMINATING; + } + +next: + + /*************************************************************************/ + /* We are responsible for freeing the memory. */ + /*************************************************************************/ + evel_free_event(msg); + msg = NULL; + + /*************************************************************************/ + /* There may be a single priority post to be sent. */ + /*************************************************************************/ + if (priority_post.memory != NULL) + { + EVEL_DEBUG("Priority Post"); + + /***********************************************************************/ + /* Set the URL for the throttling API. */ + /***********************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_throt_api_url); + if (curl_rc != CURLE_OK) + { + /*********************************************************************/ + /* This is only likely to happen with CURLE_OUT_OF_MEMORY, in which */ + /* case we carry on regardless. */ + /*********************************************************************/ + EVEL_ERROR("Failed to set throttling URL. Error code=%d", rc); + } + else + { + rc = evel_post_api(priority_post.memory, priority_post.size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer priority post. Error code=%d", rc); + } + } + + /***********************************************************************/ + /* Reinstate the URL for the event API. */ + /***********************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); + if (curl_rc != CURLE_OK) + { + /*********************************************************************/ + /* This is only likely to happen with CURLE_OUT_OF_MEMORY, in which */ + /* case we carry on regardless. */ + /*********************************************************************/ + EVEL_ERROR("Failed to reinstate events URL. Error code=%d", rc); + } + + /***********************************************************************/ + /* We are responsible for freeing the memory. */ + /***********************************************************************/ + free(priority_post.memory); + priority_post.memory = NULL; + } + } + + /***************************************************************************/ + /* The event handler is now exiting. The ring-buffer could contain events */ + /* which have not been processed, so deplete those. Because we've been */ + /* asked to exit we can be confident that the foreground will have stopped */ + /* sending events in so we know that this process will conclude! */ + /***************************************************************************/ + evt_handler_state = EVT_HANDLER_TERMINATING; + while (!ring_buffer_is_empty(&event_buffer)) + { + EVEL_DEBUG("Reading event from buffer"); + msg = ring_buffer_read(&event_buffer); + evel_free_event(msg); + } + evt_handler_state = EVT_HANDLER_TERMINATED; + EVEL_INFO("Event handler thread stopped"); + + return (NULL); +} + +/**************************************************************************//** + * Handle a JSON response from the listener, contained in a ::MEMORY_CHUNK. + * + * Tokenize the response, and decode any tokens found. + * + * @param chunk The memory chunk containing the response. + * @param post The memory chunk in which to place any resulting POST. + *****************************************************************************/ +void evel_handle_event_response(const MEMORY_CHUNK * const chunk, + MEMORY_CHUNK * const post) +{ + jsmn_parser json_parser; + jsmntok_t json_tokens[EVEL_MAX_RESPONSE_TOKENS]; + int num_tokens = 0; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(chunk != NULL); + assert(priority_post.memory == NULL); + + EVEL_DEBUG("Response size = %d", chunk->size); + EVEL_DEBUG("Response = %s", chunk->memory); + + /***************************************************************************/ + /* Initialize the parser and tokenize the response. */ + /***************************************************************************/ + jsmn_init(&json_parser); + num_tokens = jsmn_parse(&json_parser, + chunk->memory, + chunk->size, + json_tokens, + EVEL_MAX_RESPONSE_TOKENS); + + if (num_tokens < 0) + { + EVEL_ERROR("Failed to parse JSON response. " + "Error code=%d", num_tokens); + } + else if (num_tokens == 0) + { + EVEL_DEBUG("No tokens found in JSON response"); + } + else + { + //EVEL_DEBUG("Decode JSON response tokens"); + //if (!evel_handle_response_tokens(chunk, json_tokens, num_tokens, post)) + //{ + // EVEL_ERROR("Failed to handle JSON response."); + //} + } + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Handle a JSON response from the listener, as a list of tokens from JSMN. + * + * @param chunk Memory chunk containing the JSON buffer. + * @param json_tokens Array of tokens to handle. + * @param num_tokens The number of tokens to handle. + * @param post The memory chunk in which to place any resulting POST. + * @return true if we handled the response, false otherwise. *****************************************************************************/ bool evel_handle_response_tokens(const MEMORY_CHUNK * const chunk, const jsmntok_t * const json_tokens, @@ -1233,3 +2219,566 @@ bool evel_token_equals_string(const MEMORY_CHUNK * const chunk, return result; } + +static EVEL_ERR_CODES evel_re_setup_curl() +{ + + int rc = EVEL_SUCCESS; + CURLcode curl_rc = CURLE_OK; + char local_address[64]; + + EVEL_ENTER(); + /***************************************************************************/ + /* Clean-up the cURL library. */ + /***************************************************************************/ + if (multi_handle != NULL) + { + curl_multi_cleanup(multi_handle); + } + if (curl_handle != NULL) + { + curl_easy_cleanup(curl_handle); + curl_handle = NULL; + } + if (curl_handle2 != NULL) + { + curl_easy_cleanup(curl_handle2); + curl_handle2 = NULL; + } + if (hdr_chunk != NULL) + { + curl_slist_free_all(hdr_chunk); + hdr_chunk = NULL; + } + if (hdr_chunk2 != NULL) + { + curl_slist_free_all(hdr_chunk2); + hdr_chunk2 = NULL; + } + + curl_rc = curl_global_init(CURL_GLOBAL_SSL); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL. Error code=%d", curl_rc); + goto exit_label; + } + + + /***************************************************************************/ + /* Get a curl handle which we'll use for all of our output. */ + /***************************************************************************/ + curl_handle = curl_easy_init(); + if (curl_handle == NULL) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to get libCURL handle"); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_handle2 = curl_easy_init(); + if (curl_handle2 == NULL) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to get backup libCURL handle"); + goto exit_label; + } + } + /***************************************************************************/ + /* Prime the library to give friendly error codes. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_ERRORBUFFER, + curl_err_string); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to provide friendly errors. " + "Error code=%d", curl_rc); + goto exit_label; + } + + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_ERRORBUFFER, + curl_err_string2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL2 to provide friendly errors. " + "Error code=%d", curl_rc); + goto exit_label; + } + } + /***************************************************************************/ + /* If running in verbose mode generate more output. */ + /***************************************************************************/ + if (evel_verbosity > 0) + { + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to be verbose. " + "Error code=%d", curl_rc); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_VERBOSE, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to be verbose. " + "Error code=%d", curl_rc); + goto exit_label; + } + } + + } + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + EVEL_INFO("Initializing CURL to send events to: %s", evel_event_api_url); + + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_URL, + evel_bevent_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ + /* send all data to this function. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_WRITEFUNCTION, + evel_write_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the write callback. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_WRITEFUNCTION, + evel_write_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ + /* configure local ip address if provided */ + /* Default ip if NULL */ + /***************************************************************************/ + if( evel_source_ip != NULL ) + { + snprintf(local_address,sizeof(local_address),evel_source_ip); + if( local_address[0] != '\0' ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_INTERFACE, + local_address); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the local address. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + if( evel_source_ip_bakup != NULL ) + { + snprintf(local_address,sizeof(local_address),evel_source_ip_bakup); + if( local_address[0] != '\0' ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_INTERFACE, + local_address); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize bakup libCURL with the local address. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + } + /***************************************************************************/ + /* configure SSL options for HTTPS transfers */ + /***************************************************************************/ + if( evel_secure ) + { + if( evel_cert_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSLCERT, + evel_cert_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client cert. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSLCERT, + evel_cert_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client cert. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + if( evel_key_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSLKEY, + evel_key_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client key. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSLKEY, + evel_key_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client key. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + if( evel_ca_info != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_CAINFO, + evel_ca_info); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert file. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_CAINFO, + evel_ca_info); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert file. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + if( evel_ca_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_CAPATH, + evel_ca_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert path. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_CAPATH, + evel_ca_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert path. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSL_VERIFYPEER, + evel_verify_peer); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with SSL Server verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSL_VERIFYHOST, + evel_verify_host); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with Client host verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSL_VERIFYPEER, + evel_verify_peer); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with SSL Server verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_SSL_VERIFYHOST, + evel_verify_host); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with Client host verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + /***************************************************************************/ + /* some servers don't like requests that are made without a user-agent */ + /* field, so we provide one. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_USERAGENT, + "libcurl-agent/1.0"); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to upload. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, + CURLOPT_USERAGENT, + "libcurl-agent/1.0"); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + /***************************************************************************/ + /* Specify that we are going to POST data. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_POST, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to upload. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_POST, 1L); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ + /* we want to use our own read function. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to upload using read " + "function. Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_READFUNCTION, read_callback); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ + /* All of our events are JSON encoded. We also suppress the */ + /* Expect: 100-continue header that we would otherwise get since it */ + /* confuses some servers. */ + /* */ + /* @TODO: do AT&T want this behavior? */ + /***************************************************************************/ + hdr_chunk = curl_slist_append(hdr_chunk, "Content-type: application/json"); + hdr_chunk = curl_slist_append(hdr_chunk, "Expect:"); + + /***************************************************************************/ + /* set our custom set of headers. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, hdr_chunk); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL to use custom headers. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + hdr_chunk2 = curl_slist_append(hdr_chunk2, "Content-type: application/json"); + hdr_chunk2 = curl_slist_append(hdr_chunk2, "Expect:"); + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_HTTPHEADER, hdr_chunk2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ + /* Set the timeout for the operation. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_TIMEOUT, + EVEL_API_TIMEOUT); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL for API timeout. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2,CURLOPT_TIMEOUT, EVEL_API_TIMEOUT); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + } + + /***************************************************************************/ + /* Set that we want Basic authentication with username:password Base-64 */ + /* encoded for the operation. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL for Basic Authentication. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_USERNAME, evel_username); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with username. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, evel_password); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with password. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + if( evel_bevent_api_url != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL for Basic Authentication. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_USERNAME, evel_username2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with username. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle2, CURLOPT_PASSWORD, evel_password2); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with password. " + "Error code=%d (%s)", curl_rc, curl_err_string2); + goto exit_label; + } + multi_handle = curl_multi_init(); + if (multi_handle == NULL) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to get libCURL Multi handle"); + goto exit_label; + } + } +exit_label: + EVEL_EXIT(); + + return(rc); +} diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c index 38b07a7..3029cf1 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c @@ -92,13 +92,18 @@ EVENT_FAULT * evel_new_fault(const char * ev_name, fault->major_version = EVEL_FAULT_MAJOR_VERSION; fault->minor_version = EVEL_FAULT_MINOR_VERSION; fault->event_severity = severity; + if( severity == EVEL_SEVERITY_NORMAL ) + evel_event_sequence_set(&fault->header,0); + else + evel_event_sequence_set(&fault->header,1); fault->event_source_type = ev_source_type; fault->vf_status = status; fault->alarm_condition = strdup(condition); fault->specific_problem = strdup(specific_problem); evel_init_option_string(&fault->category); evel_init_option_string(&fault->alarm_interface_a); - dlist_initialize(&fault->additional_info); +/** Prakash dlist_initialize(&fault->additional_info); **/ + fault->additional_info = ht_create(); exit_label: EVEL_EXIT(); @@ -122,7 +127,9 @@ exit_label: *****************************************************************************/ void evel_fault_addl_info_add(EVENT_FAULT * fault, char * name, char * value) { - FAULT_ADDL_INFO * addl_info = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -134,7 +141,7 @@ void evel_fault_addl_info_add(EVENT_FAULT * fault, char * name, char * value) assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - addl_info = malloc(sizeof(FAULT_ADDL_INFO)); +/** Prakash addl_info = malloc(sizeof(FAULT_ADDL_INFO)); assert(addl_info != NULL); memset(addl_info, 0, sizeof(FAULT_ADDL_INFO)); addl_info->name = strdup(name); @@ -143,6 +150,14 @@ void evel_fault_addl_info_add(EVENT_FAULT * fault, char * name, char * value) assert(addl_info->value != NULL); dlist_push_last(&fault->additional_info, addl_info); +**********/ + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(fault->additional_info, nam, val); EVEL_EXIT(); } @@ -243,8 +258,11 @@ void evel_fault_type_set(EVENT_FAULT * fault, const char * const type) void evel_json_encode_fault(EVEL_JSON_BUFFER * jbuf, EVENT_FAULT * event) { - FAULT_ADDL_INFO * addl_info = NULL; - DLIST_ITEM * addl_info_item = NULL; +/*** Prakash FAULT_ADDL_INFO * addl_info = NULL; + DLIST_ITEM * addl_info_item = NULL; ****/ + HASHTABLE_T *ht; + ENTRY_T *entry; + char * fault_severity; char * fault_source_type; char * fault_vf_status; @@ -284,34 +302,46 @@ void evel_json_encode_fault(EVEL_JSON_BUFFER * jbuf, /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "alarmAdditionalInformation")) + ht = event->additional_info; + if( ht != NULL ) { - bool item_added = false; - - addl_info_item = dlist_get_first(&event->additional_info); - while (addl_info_item != NULL) + bool added = false; + if( ht->size > 0) { - addl_info = (FAULT_ADDL_INFO*) addl_info_item->item; - assert(addl_info != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "alarmAdditionalInformation", - addl_info->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "alarmAdditionalInformation")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", addl_info->name); - evel_enc_kv_string(jbuf, "value", addl_info->value); - evel_json_close_object(jbuf); - item_added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding alarmAdditionalInformation %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "alarmAdditionalInformation", + entry->key)) + { + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - addl_info_item = dlist_get_next(addl_info_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ /*************************************************************************/ - if (!item_added) + if (!added) { evel_json_rewind(jbuf); } @@ -333,7 +363,8 @@ void evel_json_encode_fault(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_fault(EVENT_FAULT * event) { - FAULT_ADDL_INFO * addl_info = NULL; +/*** Prakash FAULT_ADDL_INFO * addl_info = NULL; **/ + HASHTABLE_T *ht; EVEL_ENTER(); @@ -347,17 +378,12 @@ void evel_free_fault(EVENT_FAULT * event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - addl_info = dlist_pop_last(&event->additional_info); - while (addl_info != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Info (%s, %s)", - addl_info->name, - addl_info->value); - free(addl_info->name); - free(addl_info->value); - free(addl_info); - addl_info = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } + free(event->alarm_condition); free(event->specific_problem); evel_free_option_string(&event->category); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c index 031632a..5b97906 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c @@ -77,7 +77,8 @@ EVENT_HEARTBEAT_FIELD * evel_new_heartbeat_field(int interval,const char* ev_nam event->minor_version = EVEL_HEARTBEAT_FIELD_MINOR_VERSION; event->heartbeat_interval = interval; - dlist_initialize(&event->additional_info); + + event->additional_info = ht_create(); exit_label: @@ -102,7 +103,9 @@ void evel_hrtbt_field_addl_field_add(EVENT_HEARTBEAT_FIELD * const event, const char * const name, const char * const value) { - OTHER_FIELD * nv_pair = NULL; + + char *nam=NULL; + char *val=NULL; EVEL_ENTER(); @@ -115,14 +118,11 @@ void evel_hrtbt_field_addl_field_add(EVENT_HEARTBEAT_FIELD * const event, assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - nv_pair = malloc(sizeof(OTHER_FIELD)); - assert(nv_pair != NULL); - nv_pair->name = strdup(name); - nv_pair->value = strdup(value); - assert(nv_pair->name != NULL); - assert(nv_pair->value != NULL); - dlist_push_last(&event->additional_info, nv_pair); + nam = strdup(name); + val = strdup(value); + + ht_insert(event->additional_info, nam, val); EVEL_EXIT(); } @@ -166,8 +166,8 @@ void evel_hrtbt_interval_set(EVENT_HEARTBEAT_FIELD * const event, void evel_json_encode_hrtbt_field(EVEL_JSON_BUFFER * const jbuf, EVENT_HEARTBEAT_FIELD * const event) { - OTHER_FIELD * nv_pair = NULL; - DLIST_ITEM * dlist_item = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; EVEL_ENTER(); @@ -178,7 +178,7 @@ void evel_json_encode_hrtbt_field(EVEL_JSON_BUFFER * const jbuf, assert(event->header.event_domain == EVEL_DOMAIN_HEARTBEAT_FIELD); evel_json_encode_header(jbuf, &event->header); - evel_json_open_named_object(jbuf, "heartbeatField"); + evel_json_open_named_object(jbuf, "heartbeatFields"); /***************************************************************************/ /* Mandatory fields */ @@ -194,29 +194,46 @@ void evel_json_encode_hrtbt_field(EVEL_JSON_BUFFER * const jbuf, /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalFields")) + + /***************************************************************************/ + /* Go through the Hashmap of additional information and encode key / Value */ + /***************************************************************************/ + ht = event->additional_info; + if( ht != NULL ) { bool added = false; - - dlist_item = dlist_get_first(&event->additional_info); - while (dlist_item != NULL) + if( ht->size > 0) { - nv_pair = (OTHER_FIELD *) dlist_item->item; - assert(nv_pair != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalFields", - nv_pair->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", nv_pair->name); - evel_enc_kv_string(jbuf, "value", nv_pair->value); - evel_json_close_object(jbuf); - added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - dlist_item = dlist_get_next(dlist_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ @@ -242,7 +259,7 @@ void evel_json_encode_hrtbt_field(EVEL_JSON_BUFFER * const jbuf, *****************************************************************************/ void evel_free_hrtbt_field(EVENT_HEARTBEAT_FIELD * const event) { - OTHER_FIELD * nv_pair = NULL; + HASHTABLE_T *ht; EVEL_ENTER(); @@ -255,15 +272,12 @@ void evel_free_hrtbt_field(EVENT_HEARTBEAT_FIELD * const event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - nv_pair = dlist_pop_last(&event->additional_info); - while (nv_pair != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Other Field (%s, %s)", nv_pair->name, nv_pair->value); - free(nv_pair->name); - free(nv_pair->value); - free(nv_pair); - nv_pair = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } + evel_free_header(&event->header); EVEL_EXIT(); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h index d1a952b..02a4697 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h @@ -172,27 +172,36 @@ typedef struct evel_throttle_spec { * @param[in] event_api_url * The URL where the Vendor Event Listener API is expected * to be. + * @param[in] bakup_api_url + * The BakupURL where the Vendor Backup Listener is expected + * to be. * @param[in] throt_api_url * The URL where the Throttling API is expected to be. - * @param[in] source_ip Source IP of VES Agent - * @param[in] ring_buf_size Initialization size of Ring Buffer + * @param[in] source_ip Source IP of VES Agent + * @param[in] bakup_source_ip Backup Source IP of VES Agent + * @param[in] ring_buf_size Initialization size of Ring Buffer * @param[in] secure Whether Using http or https * @param[in] cert_file_path Path to Client Certificate file * @param[in] key_file_path Path to Client key file * @param[in] ca_info Path to CA info file - * @param[in] ca_file_path Path to CA file - * @param[in] verify_peer Using peer verification or not + * @param[in] ca_file_path Path to CA file +* @param[in] verify_peer Using peer verification or not * @param[in] verify_host Using host verification or not * @param[in] username The username for the Basic Authentication of requests. * @param[in] password The password for the Basic Authentication of requests. + * @param[in] username2 The username for the Bakup requests. + * @param[in] password2 The password for the Bakup requests. * @param verbosity 0 for normal operation, positive values for chattier * logs. *****************************************************************************/ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, + const char * const bakup_api_url, const char * const throt_api_url, const char * const source_ip, + const char * const bakup_source_ip, int ring_buf_size, int secure, + int activitymode, const char * const cert_file_path, const char * const key_file_path, const char * const ca_info, @@ -201,6 +210,8 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, long verify_host, const char * const username, const char * const password, + const char * const username2, + const char * const password2, int verbosity); /**************************************************************************//** @@ -356,6 +367,15 @@ void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, void evel_json_encode_state_change(EVEL_JSON_BUFFER * jbuf, EVENT_STATE_CHANGE * state_change); +/**************************************************************************//** + * Encode the notification as a JSON event + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param notification Pointer to the ::EVENT_NOTIFICATION to encode. + *****************************************************************************/ +void evel_json_encode_notification(EVEL_JSON_BUFFER * jbuf, + EVENT_NOTIFICATION * notification); + /**************************************************************************//** * Encode the Syslog in JSON according to AT&T's schema for the event type. * @@ -374,6 +394,44 @@ void evel_json_encode_syslog(EVEL_JSON_BUFFER * jbuf, void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, EVENT_OTHER * event); +/**************************************************************************//** + * Encode the PNF Registration as a JSON PNF Registration + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param pnf_registration Pointer to the ::EVENT_PNF_REGISTRATION to encode. + *****************************************************************************/ +void evel_json_encode_pnf_registration(EVEL_JSON_BUFFER * jbuf, + EVENT_PNF_REGISTRATION * pnf_registration); + +/**************************************************************************//** + * Encode the Voce Quality in JSON according to AT&T's schema for the voice + * quality type. + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param event Pointer to the ::EVENT_HEADER to encode. + *****************************************************************************/ +void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, + EVENT_VOICE_QUALITY * event); + +/**************************************************************************//** + * Encode the Signaling in JSON according to AT&T's schema for the + * event type. + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param event Pointer to the ::EVENT_HEADER to encode. + *****************************************************************************/ +void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf, + EVENT_THRESHOLD_CROSS * const event); + +/**************************************************************************//** + * Encode the instance id as a JSON object according to AT&T's schema. + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param vfield Pointer to the ::VENDOR_VNFNAME_FIELD to encode. + *****************************************************************************/ +void evel_json_encode_vendor_field(EVEL_JSON_BUFFER * jbuf, + VENDOR_VNFNAME_FIELD * vfield); + /**************************************************************************//** * Set the next event_sequence to use. * @@ -451,6 +509,17 @@ void evel_enc_kv_int(EVEL_JSON_BUFFER * jbuf, const char * const key, const int value); +/**************************************************************************//** + * Encode a string key and json object value to a ::EVEL_JSON_BUFFER. + * + * @param jbuf Pointer to working ::EVEL_JSON_BUFFER. + * @param key Pointer to the key to encode. + * @param value The corresponding json string to encode. + *****************************************************************************/ +void evel_enc_kv_object(EVEL_JSON_BUFFER * jbuf, + const char * const key, + const char * value); + /**************************************************************************//** * Encode a string key and double value to a ::EVEL_JSON_BUFFER. * @@ -532,6 +601,50 @@ void evel_enc_version(EVEL_JSON_BUFFER * jbuf, const char * const key, const int major_version, const int minor_version); +/**************************************************************************//** + * Initialize an event instance id. + * + * @param vfield Pointer to the event vnfname field being initialized. + * @param vendor_id The vendor id to encode in the event instance id. + * @param event_id The event id to encode in the event instance id. + *****************************************************************************/ +void evel_init_vendor_field(VENDOR_VNFNAME_FIELD * const vfield, + const char * const vendor_name); + +/**************************************************************************//** + * Set the Vendor module property of the Vendor. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vfield Pointer to the Vendor field. + * @param module_name The module name to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_vendor_field_module_set(VENDOR_VNFNAME_FIELD * const vfield, + const char * const module_name); +/**************************************************************************//** + * Set the Vendor VNF name + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vfield Pointer to the Vendor field. + * @param vnfname The VNF Name to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_vendor_field_vnfname_set(VENDOR_VNFNAME_FIELD * const vfield, + const char * const vnfname); +/**************************************************************************//** + * Free an event instance id. + * + * @param vfield Pointer to the event vnfname_field being freed. + *****************************************************************************/ +void evel_free_event_vendor_field(VENDOR_VNFNAME_FIELD * const vfield); /**************************************************************************//** * Add the key and opening bracket of an optional named list to a JSON buffer. @@ -789,7 +902,7 @@ char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action); * @param alert_type The alert_type to convert. * @returns The equivalent string. *****************************************************************************/ -char * evel_alert_type(const EVEL_ALERT_TYPES alert_type); +char * evel_alert_type(const EVEL_ALERT_TYPE alert_type); /**************************************************************************//** * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string. @@ -854,8 +967,8 @@ void evel_init_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option); * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS. * @param value The value to set. *****************************************************************************/ -void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, - const void* value); +void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * option, + void* value); /**************************************************************************//** * Set the value of an ::EVEL_OPTION_INTHEADER_FIELDS. * @@ -863,8 +976,8 @@ void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, * @param value The value to set. * @param description Description to be used in logging. *****************************************************************************/ -void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, - const void * value, +void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * option, + void * value, const char * const description); /**************************************************************************//** * Free the underlying resources of an ::EVEL_OPTION_INTHEADER_FIELDS. @@ -873,4 +986,22 @@ void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, *****************************************************************************/ void evel_free_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option); +/**************************************************************************//** + * Initialize an ::EVEL_OPTION_STATE to a not-set state. + * + * @param option Pointer to the ::EVEL_OPTION_INT. + *****************************************************************************/ +void evel_init_option_state(EVEL_OPTION_STATE * const option); + +/**************************************************************************//** + * Set the value of an ::EVEL_OPTION_STATE. + * + * @param option Pointer to the ::EVEL_OPTION_STATE. + * @param value The value to set. + * @param description Description to be used in logging. + *****************************************************************************/ +void evel_set_option_state(EVEL_OPTION_STATE * const option, + const int value, + const char * const description); + #endif diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c index cae5ab1..a7ad019 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c @@ -521,6 +521,7 @@ void evel_enc_version(EVEL_JSON_BUFFER * jbuf, const int major_version, const int minor_version) { + float ver; EVEL_ENTER(); /***************************************************************************/ @@ -529,14 +530,14 @@ void evel_enc_version(EVEL_JSON_BUFFER * jbuf, assert(jbuf != NULL); assert(key != NULL); - evel_enc_kv_int(jbuf, key, major_version); - if (minor_version != 0) - { + ver = (float)major_version + (float)minor_version/10.0; + jbuf->offset += snprintf(jbuf->json + jbuf->offset, - jbuf->max_size - jbuf->offset, - ".%d", - minor_version); - } + jbuf->max_size - jbuf->offset, + "%s\"%s\": \"%.1f\"", + evel_json_kv_comma(jbuf), + key, + ver); EVEL_EXIT(); } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c index 4f788bd..36ee2d5 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c @@ -96,7 +96,6 @@ exit_label: EVEL_JSON_OBJECT_INSTANCE * evel_new_jsonobjinstance(const char *const yourjson) { EVEL_JSON_OBJECT_INSTANCE *jobjinst = NULL; - jsmntok_t *key; int resultCode; jsmn_parser p; jsmntok_t tokens[MAX_JSON_TOKENS]; // a number >= total number of tokens @@ -298,7 +297,7 @@ void evel_jsonobject_nfsubscriptionid_set(EVEL_JSON_OBJECT * pinst, const char * void evel_epoch_microsec_set(EVEL_JSON_OBJECT_INSTANCE * pinst, const unsigned long long epmicrosec) { assert(epmicrosec != 0 ); - pinst->objinst_epoch_microsec = epmicrosec; + evel_set_option_ull(&pinst->objinst_epoch_microsec , epmicrosec, "Json object instance microsec set"); } /**************************************************************************//** @@ -321,7 +320,7 @@ void evel_jsonobject_add_jsoninstance(EVEL_JSON_OBJECT * pobj, EVEL_JSON_OBJECT_ assert(pobj != NULL); assert(jinst != NULL); - EVEL_DEBUG("Adding json object instance"); + EVEL_DEBUG("Adding json object instance %p",jinst); dlist_push_last(&pobj->jsonobjectinstances, jinst); @@ -375,6 +374,7 @@ void evel_free_internal_key(EVEL_INTERNAL_KEY * keyp) free(keyp->keyname); evel_free_option_string(&keyp->keyvalue); + free(keyp); EVEL_EXIT(); } @@ -407,6 +407,7 @@ void evel_free_jsonobjinst(EVEL_JSON_OBJECT_INSTANCE * objinst) evel_free_internal_key(other_field); other_field = dlist_pop_last(&objinst->object_keys); } + free(objinst); EVEL_EXIT(); } @@ -425,6 +426,7 @@ void evel_free_jsonobject(EVEL_JSON_OBJECT * jsobj) EVEL_ENTER(); assert(jsobj != NULL); + EVEL_DEBUG("Freeing Json Object (%s)", jsobj->object_name); free(jsobj->object_name); evel_free_option_string(&jsobj->objectschema); evel_free_option_string(&jsobj->objectschemaurl); @@ -437,11 +439,12 @@ void evel_free_jsonobject(EVEL_JSON_OBJECT * jsobj) other_field = dlist_pop_last(&jsobj->jsonobjectinstances); while (other_field != NULL) { - EVEL_DEBUG("Freeing Object Instance Field (%s)", - other_field->jsonstring); + EVEL_DEBUG("Freeing jsonObject Instance Field %p (%s)", + other_field,other_field->jsonstring); evel_free_jsonobjinst(other_field); other_field = dlist_pop_last(&jsobj->jsonobjectinstances); } + free(jsobj); EVEL_EXIT(); } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c index 90b1a44..53fbce3 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c @@ -28,6 +28,7 @@ #include "evel.h" #include "evel_internal.h" +#include "evel_throttle.h" /*****************************************************************************/ /* Array of strings to use when encoding TCP flags. */ @@ -172,7 +173,7 @@ EVENT_MOBILE_FLOW * evel_new_mobile_flow(const char* ev_name, const char *ev_id, evel_init_option_string(&mobile_flow->tac); evel_init_option_string(&mobile_flow->tunnel_id); evel_init_option_string(&mobile_flow->vlan_id); - dlist_initialize(&mobile_flow->additional_info); + mobile_flow->additional_info = ht_create(); exit_label: EVEL_EXIT(); @@ -196,7 +197,8 @@ exit_label: *****************************************************************************/ void evel_mobile_flow_addl_field_add(EVENT_MOBILE_FLOW * const event, char * name, char * value) { - OTHER_FIELD * nv_pair = NULL; + char *nam=NULL; + char *val=NULL; EVEL_ENTER(); @@ -209,14 +211,11 @@ void evel_mobile_flow_addl_field_add(EVENT_MOBILE_FLOW * const event, char * nam assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - nv_pair = malloc(sizeof(OTHER_FIELD)); - assert(nv_pair != NULL); - nv_pair->name = strdup(name); - nv_pair->value = strdup(value); - assert(nv_pair->name != NULL); - assert(nv_pair->value != NULL); - dlist_push_last(&event->additional_info, nv_pair); + nam = strdup(name); + val = strdup(value); + + ht_insert(event->additional_info, nam, val); EVEL_EXIT(); } @@ -933,8 +932,8 @@ void evel_mobile_flow_vlan_id_set(EVENT_MOBILE_FLOW * mobile_flow, void evel_json_encode_mobile_flow(EVEL_JSON_BUFFER * jbuf, EVENT_MOBILE_FLOW * event) { - OTHER_FIELD * nv_pair = NULL; - DLIST_ITEM * dlist_item = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; EVEL_ENTER(); @@ -952,29 +951,43 @@ void evel_json_encode_mobile_flow(EVEL_JSON_BUFFER * jbuf, /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalFields")) + + ht = event->additional_info; + if( ht != NULL ) { bool added = false; - - dlist_item = dlist_get_first(&event->additional_info); - while (dlist_item != NULL) + if( ht->size > 0) { - nv_pair = (OTHER_FIELD *) dlist_item->item; - assert(nv_pair != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalFields", - nv_pair->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", nv_pair->name); - evel_enc_kv_string(jbuf, "value", nv_pair->value); - evel_json_close_object(jbuf); - added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - dlist_item = dlist_get_next(dlist_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ @@ -1051,8 +1064,7 @@ void evel_json_encode_mobile_flow(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_mobile_flow(EVENT_MOBILE_FLOW * event) { - OTHER_FIELD * nv_pair = NULL; - + HASHTABLE_T *ht; EVEL_ENTER(); /***************************************************************************/ @@ -1099,14 +1111,10 @@ void evel_free_mobile_flow(EVENT_MOBILE_FLOW * event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - nv_pair = dlist_pop_last(&event->additional_info); - while (nv_pair != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Other Field (%s, %s)", nv_pair->name, nv_pair->value); - free(nv_pair->name); - free(nv_pair->value); - free(nv_pair); - nv_pair = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } evel_free_header(&event->header); @@ -1313,6 +1321,10 @@ MOBILE_GTP_PER_FLOW_METRICS * evel_new_mobile_gtp_flow_metrics( evel_init_option_int(&metrics->num_gtp_tunnel_errors); evel_init_option_int(&metrics->num_http_errors); + metrics->ip_tos_count_list = ht_create(); + metrics->mobile_qci_cos_count_list = ht_create(); + metrics->tcp_flag_count_list = ht_create(); + exit_label: EVEL_EXIT(); return metrics; @@ -1667,6 +1679,135 @@ void evel_mobile_gtp_metrics_max_trx_bit_rate_set( EVEL_EXIT(); } +/**************************************************************************//** + * Add an IP Tos count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_ip_tos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const char * const name, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != NULL); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(metrics->ip_tos_count_list, nam, val); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add an QCI Cos count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_qci_cos_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const EVEL_QCI_COS_TYPES qci_cos, + const char * const value) + +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != NULL); + assert(qci_cos >= 0); + assert(qci_cos < EVEL_MAX_QCI_COS_TYPES); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", evel_qci_cos_strings[qci_cos], value); + + nam = strdup(evel_qci_cos_strings[qci_cos]); + val = strdup(value); + + ht_insert(metrics->mobile_qci_cos_count_list, nam, val); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add an TCP Flag count list value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the Mobile GTP Per Flow Metrics. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_mobile_gtp_metrics_tcp_flag_count_list_add( + MOBILE_GTP_PER_FLOW_METRICS * metrics, + const EVEL_TCP_FLAGS tcp_flag, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != NULL); + assert(tcp_flag >= 0); + assert(tcp_flag < EVEL_MAX_TCP_FLAGS); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", evel_tcp_flag_strings[tcp_flag], value); + + nam = strdup(evel_tcp_flag_strings[tcp_flag]); + val = strdup(value); + + ht_insert(metrics->tcp_flag_count_list, nam, val); + + EVEL_EXIT(); +} + /**************************************************************************//** * Set the Number of GTP Echo Failures property of the Mobile GTP Per Flow * Metrics. @@ -1830,6 +1971,9 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( EVEL_JSON_BUFFER * jbuf, MOBILE_GTP_PER_FLOW_METRICS * metrics) { + HASHTABLE_T *ht; + ENTRY_T *entry; + int index; bool found_ip_tos; bool found_tcp_flag; @@ -1913,18 +2057,18 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( if (found_ip_tos) { - evel_json_open_named_list(jbuf, "ipTosCountList"); + evel_json_open_named_object(jbuf, "ipTosCountList"); for (index = 0; index < EVEL_TOS_SUPPORTED; index++) { if (metrics->ip_tos_counts[index].is_set) { evel_enc_list_item(jbuf, - "[\"%d\", %d]", + "\"%d\": \"%d\"", index, metrics->ip_tos_counts[index].value); } } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); } if (found_ip_tos) @@ -1982,18 +2126,18 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( if (found_tcp_flag) { - evel_json_open_named_list(jbuf, "tcpFlagCountList"); + evel_json_open_named_object(jbuf, "tcpFlagCountList"); for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++) { if (metrics->tcp_flag_counts[index].is_set) { evel_enc_list_item(jbuf, - "[\"%s\", %d]", + "\"%s\": \"%d\"", evel_tcp_flag_strings[index], metrics->tcp_flag_counts[index].value); } } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); } /***************************************************************************/ @@ -2032,7 +2176,7 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( if (found_qci_cos) { - evel_json_open_named_list(jbuf, "mobileQciCosList"); + evel_json_open_named_object(jbuf, "mobileQciCosList"); for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++) { if (metrics->qci_cos_counts[index].is_set) @@ -2042,23 +2186,23 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( evel_qci_cos_strings[index]); } } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); } if (found_qci_cos) { - evel_json_open_named_list(jbuf, "mobileQciCosCountList"); + evel_json_open_named_object(jbuf, "mobileQciCosCountList"); for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++) { if (metrics->qci_cos_counts[index].is_set) { evel_enc_list_item(jbuf, - "[\"%s\", %d]", + "\"%s\": \"%d\"", evel_qci_cos_strings[index], metrics->qci_cos_counts[index].value); } } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); } evel_enc_kv_opt_int( @@ -2086,6 +2230,279 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( jbuf, "numGtpTunnelErrors", &metrics->num_gtp_tunnel_errors); evel_enc_kv_opt_int(jbuf, "numHttpErrors", &metrics->num_http_errors); + evel_json_checkpoint(jbuf); + ht = metrics->ip_tos_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "ipTosCountList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipTosCountList", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + ht = metrics->ip_tos_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipTosList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding MobileFlowFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipTosList", + entry->key)) + { + evel_enc_list_item(jbuf, "\"%s\"", entry->key); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + ht = metrics->mobile_qci_cos_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "mobileQciCosCountList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "mobileQciCosCountList", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + ht = metrics->mobile_qci_cos_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "mobileQciCosList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding MobileFlowFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "mobileQciCosList", + entry->key)) + { + evel_enc_list_item(jbuf, "\"%s\"", entry->key); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + ht = metrics->tcp_flag_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "tcpFlagCountList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "tcpFlagCountList", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + ht = metrics->tcp_flag_count_list; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "tcpFlagList")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding MobileFlowFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "tcpFlagList", + entry->key)) + { + + evel_enc_list_item(jbuf, "\"%s\"", entry->key); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } evel_json_close_object(jbuf); EVEL_EXIT(); @@ -2102,6 +2519,8 @@ void evel_json_encode_mobile_flow_gtp_flow_metrics( *****************************************************************************/ void evel_free_mobile_gtp_flow_metrics(MOBILE_GTP_PER_FLOW_METRICS * metrics) { + HASHTABLE_T *ht; + EVEL_ENTER(); /***************************************************************************/ @@ -2119,5 +2538,23 @@ void evel_free_mobile_gtp_flow_metrics(MOBILE_GTP_PER_FLOW_METRICS * metrics) evel_free_option_string(&metrics->gtp_connection_status); evel_free_option_string(&metrics->gtp_tunnel_status); + ht = metrics->ip_tos_count_list; + if( ht != NULL ) + { + ht_destroy(ht); + } + + ht = metrics->mobile_qci_cos_count_list; + if( ht != NULL ) + { + ht_destroy(ht); + } + + ht = metrics->tcp_flag_count_list; + if( ht != NULL ) + { + ht_destroy(ht); + } + EVEL_EXIT(); } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_notification.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_notification.c new file mode 100644 index 0000000..6307dd1 --- /dev/null +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_notification.c @@ -0,0 +1,514 @@ +/*************************************************************************//** + * + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************/ +/**************************************************************************//** + * @file + * Implementation of EVEL functions relating to the notification. + * + ****************************************************************************/ + +#include +#include +#include + +#include "evel_throttle.h" + +/**************************************************************************//** + * Create a new notification event. + * + * @note The mandatory fields on the notification must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once + * so that the notification has immutable properties. + * + * @param event_name Unique Event Name confirming Domain AsdcModel Description + * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc + * @param interface The card or port name of the reporting entity. + * + * @returns pointer to the newly manufactured ::EVENT_NOTIFICATION. If the + * event is not used it must be released using + * ::evel_free_notification + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_NOTIFICATION * evel_new_notification(const char* ev_name, + const char *ev_id, + const char * const changeIdentifier, + const char * const changeType) +{ + EVENT_NOTIFICATION * notification = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(changeIdentifier != NULL); + assert(changeType != NULL); + + /***************************************************************************/ + /* Allocate the notification. */ + /***************************************************************************/ + notification = malloc(sizeof(EVENT_NOTIFICATION)); + if (notification == NULL) + { + log_error_state("Out of memory"); + goto exit_label; + } + memset(notification, 0, sizeof(EVENT_NOTIFICATION)); + EVEL_DEBUG("New notification is at %lp", notification); + + /***************************************************************************/ + /* Initialize the header & the notification fields. Optional string */ + /* values are uninitialized (NULL). */ + /***************************************************************************/ + evel_init_header_nameid(¬ification->header,ev_name,ev_id); + notification->header.event_domain = EVEL_DOMAIN_NOTIFICATION; + notification->major_version = EVEL_NOTIFICATION_MAJOR_VERSION; + notification->minor_version = EVEL_NOTIFICATION_MINOR_VERSION; + notification->changeIdentifier = strdup(changeIdentifier); + notification->changeType = strdup(changeType); + + /****** Optional Parameters ******/ + evel_init_option_state(¬ification->new_state); + evel_init_option_state(¬ification->old_state); + evel_init_option_string(¬ification->changeContact); + evel_init_option_string(¬ification->state_interface); + dlist_initialize(¬ification->arrayOfNamedHashMap); + notification->additional_fields = ht_create(); + +exit_label: + EVEL_EXIT(); + return notification; +} + +/**************************************************************************//** + * Free a notification. + * + * Free off the notification supplied. Will free all the contained allocated + * memory. + * + * @note It does not free the notification itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_notification(EVENT_NOTIFICATION * const notification) +{ + HASHTABLE_T *ht; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. As an internal API we don't allow freeing NULL */ + /* events as we do on the public API. */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + /***************************************************************************/ + /* Free all internal strings then the header itself. */ + /***************************************************************************/ + ht = notification->additional_fields; + if( ht != NULL ) + { + ht_destroy(ht); + } + + ht = dlist_pop_last(¬ification->arrayOfNamedHashMap); + while (ht != NULL) + { + EVEL_DEBUG("Freeing Notification arrayOfNamedHashMap"); + ht_destroy(ht); + ht = dlist_pop_last(¬ification->arrayOfNamedHashMap); + } + + evel_free_option_string(¬ification->state_interface); + evel_free_option_string(¬ification->changeContact); + evel_free_header(¬ification->header); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Event Type property of the notification. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_notification_type_set(EVENT_NOTIFICATION * const notification, + const char * const type) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + evel_header_type_set(¬ification->header, type); + + EVEL_EXIT(); +} + +void evel_notification_changeContact_set( + EVENT_NOTIFICATION * const notification, + const char * const changeContact) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + assert(changeContact != NULL); + + evel_set_option_string(¬ification->changeContact, + changeContact, + "Change contact"); + + EVEL_EXIT(); +} + +void evel_notification_state_interface_set( + EVENT_NOTIFICATION * const notification, + const char * const state_interface) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + assert(state_interface != NULL); + + evel_set_option_string(¬ification->state_interface, + state_interface, + "State Interface"); + + EVEL_EXIT(); +} + +void evel_notification_new_state_set( + EVENT_NOTIFICATION * const notification, + const EVEL_ENTITY_STATE state) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + assert(state < EVEL_MAX_ENTITY_STATES); + evel_set_option_state(¬ification->new_state, state, "New State"); + + EVEL_EXIT(); +} + +void evel_notification_old_state_set( + EVENT_NOTIFICATION * const notification, + const EVEL_ENTITY_STATE state) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + assert(state < EVEL_MAX_ENTITY_STATES); + evel_set_option_state(¬ification->old_state, state, "Old State"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add an additional field name/value pair to the notification. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param notification Pointer to the ::EVENT_NOTIFICATION. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_notification_addl_field_add(EVENT_NOTIFICATION * const notification, + const char * const name, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(notification->additional_fields, nam, val); + + EVEL_EXIT(); +} + +HASHTABLE_T * evel_notification_add_new_named_hashmap( + EVENT_NOTIFICATION * const notification, + const char * const name) +{ + HASHTABLE_T *ht; + char *nam=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + assert(name != NULL); + + EVEL_DEBUG("Adding HashMapName=%s", name); + + nam = strdup(name); + + ht = nht_create( nam ); + + if (ht != NULL) + { + dlist_push_last(¬ification->arrayOfNamedHashMap, ht); + } + + EVEL_EXIT(); + + return ht; +} + +void evel_notification_named_hashmap_set( + HASHTABLE_T * const ht, + const char * const name, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(ht != NULL); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(ht, nam, val); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Encode the notification as a JSON notification. + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param notification Pointer to the ::EVENT_NOTIFICATION to encode. + *****************************************************************************/ +void evel_json_encode_notification(EVEL_JSON_BUFFER * jbuf, + EVENT_NOTIFICATION * notification) +{ + HASHTABLE_T *ht; + ENTRY_T *entry; + DLIST_ITEM * dlist_item = NULL; + + char * new_state; + char * old_state; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(notification != NULL); + assert(notification->header.event_domain == EVEL_DOMAIN_NOTIFICATION); + + new_state = evel_entity_opt_state(¬ification->new_state); + old_state = evel_entity_opt_state(¬ification->old_state); + + evel_json_encode_header(jbuf, ¬ification->header); + evel_json_open_named_object(jbuf, "notificationFields"); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + evel_enc_kv_string(jbuf, "changeIdentifier", notification->changeIdentifier); + evel_enc_kv_string(jbuf, "changeType", notification->changeType); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + if (new_state != NULL) + { + evel_enc_kv_string(jbuf, "newState", new_state); + } + if (old_state != NULL) + { + evel_enc_kv_string(jbuf, "oldState", old_state); + } + evel_enc_kv_opt_string(jbuf, "changeContact", ¬ification->changeContact); + evel_enc_kv_opt_string(jbuf, "stateInterface", ¬ification->state_interface); + evel_json_checkpoint(jbuf); + ht = notification->additional_fields; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding notificationFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Checkpoint, so that we can wind back if all fields are suppressed. */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "arrayOfNamedHashMap")) + { + bool added_array = false; + + dlist_item = dlist_get_first(¬ification->arrayOfNamedHashMap); + while (dlist_item != NULL) + { + bool added = false; + ht = (HASHTABLE_T *) dlist_item->item; + assert(ht != NULL); + + if((ht->size > 0) && (ht-> n > 0)) + { + evel_json_checkpoint(jbuf); + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "name", ht->hmName); + if (evel_json_open_opt_named_object(jbuf, "hashMap")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding NotificationFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + ht->hmName, + entry->key)) + { + evel_enc_kv_string(jbuf, entry->key, entry->value); + added = true; + added_array = true; + } + entry = entry->next; + } + } + evel_json_close_object(jbuf); + if (!added) + { + evel_json_rewind(jbuf); + } + } + evel_json_close_object(jbuf); + } + + dlist_item = dlist_get_next(dlist_item); + } + + evel_json_close_list(jbuf); + + if (!added_array) + { + evel_json_rewind(jbuf); + } + } + evel_enc_version(jbuf, + "notificationFieldsVersion", + notification->major_version,notification->minor_version); + + evel_json_close_object(jbuf); + + EVEL_EXIT(); +} diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c index 7818fe1..c67844a 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c @@ -129,6 +129,113 @@ void evel_force_option_string(EVEL_OPTION_STRING * const option, EVEL_EXIT(); } +/**************************************************************************//** + * Initialize an ::EVEL_OPTION_STATE to a not-set state. + * + * @param option Pointer to the ::EVEL_OPTION_INT. + *****************************************************************************/ +void evel_init_option_state(EVEL_OPTION_STATE * const option) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(option != NULL); + + option->state = 0; + option->is_set = EVEL_FALSE; + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Initialize an ::EVEL_OPTION_OP_STATE to a not-set state. + * + * @param option Pointer to the ::EVEL_OPTION_INT. + *****************************************************************************/ +void evel_init_option_op_state(EVEL_OPTION_OP_STATE * const option) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(option != NULL); + + option->state = 0; + option->is_set = EVEL_FALSE; + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the value of an ::EVEL_OPTION_STATE. + * + * @param option Pointer to the ::EVEL_OPTION_STATE. + * @param value The value to set. + * @param description Description to be used in logging. + *****************************************************************************/ +void evel_set_option_state(EVEL_OPTION_STATE * const option, + const int value, + const char * const description) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(option != NULL); + assert(description != NULL); + + if (option->is_set) + { + EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d", + description, value, description, option->state); + } + else + { + EVEL_DEBUG("Setting %s to %d", description, value); + option->state = value; + option->is_set = EVEL_TRUE; + } + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the value of an ::EVEL_OPTION_OP_STATE. + * + * @param option Pointer to the ::EVEL_OPTION_OP_STATE. + * @param value The value to set. + * @param description Description to be used in logging. + *****************************************************************************/ +void evel_set_option_op_state(EVEL_OPTION_OP_STATE * const option, + const int value, + const char * const description) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(option != NULL); + assert(description != NULL); + + if (option->is_set) + { + EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d", + description, value, description, option->state); + } + else + { + EVEL_DEBUG("Setting %s to %d", description, value); + option->state = value; + option->is_set = EVEL_TRUE; + } + + EVEL_EXIT(); +} /**************************************************************************//** * Initialize an ::EVEL_OPTION_INT to a not-set state. @@ -380,8 +487,8 @@ void evel_init_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option) * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS. * @param value The value to set. *****************************************************************************/ -void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, - const void* value) +void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * option, + void* value) { EVEL_ENTER(); @@ -403,8 +510,8 @@ void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, * @param value The value to set. * @param description Description to be used in logging. *****************************************************************************/ -void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option, - const void * value, +void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * option, + void * value, const char * const description) { EVEL_ENTER(); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c index b238e38..61809f0 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c @@ -28,6 +28,7 @@ #include "evel.h" #include "evel_internal.h" +#include "evel_throttle.h" /**************************************************************************//** * Create a new Other event. @@ -70,9 +71,9 @@ EVENT_OTHER * evel_new_other(const char* ev_name, const char *ev_id) other->major_version = EVEL_OTHER_EVENT_MAJOR_VERSION; other->minor_version = EVEL_OTHER_EVENT_MINOR_VERSION; - other->namedarrays = NULL; + other->hashMap = ht_create(); dlist_initialize(&other->jsonobjects); - dlist_initialize(&other->namedvalues); + dlist_initialize(&other->arrayOfNamedHashMap); exit_label: EVEL_EXIT(); @@ -106,16 +107,22 @@ void evel_other_type_set(EVENT_OTHER * other, EVEL_EXIT(); } + /**************************************************************************//** - * Set size of Named arrays hash table + * Add a json object to jsonObject list. * - * The max size of hash table is passed + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. * * @param other Pointer to the Other. * @param size size of hashtable *****************************************************************************/ -void evel_other_field_set_namedarraysize(EVENT_OTHER * other, const int size) +void evel_other_field_add_hashmap(EVENT_OTHER * other, char * name, char *value) { + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -123,31 +130,28 @@ void evel_other_field_set_namedarraysize(EVENT_OTHER * other, const int size) /***************************************************************************/ assert(other != NULL); assert(other->header.event_domain == EVEL_DOMAIN_OTHER); - assert(other->namedarrays == NULL); - assert(size > 0); - EVEL_DEBUG("Adding Named array"); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding values to hashMap"); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); - other->namedarrays = ht_create(size); + nam = strdup(name); + val = strdup(value); + + ht_insert(other->hashMap, nam, val); EVEL_EXIT(); } - -/**************************************************************************//** - * Add a json object to jsonObject list. - * - * The name and value are null delimited ASCII strings. The library takes - * a copy so the caller does not have to preserve values after the function - * returns. - * - * @param other Pointer to the Other. - * @param size size of hashtable - *****************************************************************************/ -void evel_other_field_add_namedarray(EVENT_OTHER * other, const char *hashname, char * name, char *value) +HASHTABLE_T * evel_other_add_new_hashmap_to_hmarray(EVENT_OTHER * const other, + const char * const name) { - OTHER_FIELD * other_field = NULL; - DLIST *list = NULL; + HASHTABLE_T *ht; + char *nam=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -155,84 +159,73 @@ void evel_other_field_add_namedarray(EVENT_OTHER * other, const char *hashname, /***************************************************************************/ assert(other != NULL); assert(other->header.event_domain == EVEL_DOMAIN_OTHER); - assert(other->namedarrays != NULL); + assert(name != NULL); - EVEL_DEBUG("Adding values to Named array"); - - EVEL_DEBUG("Adding name=%s value=%s", name, value); - other_field = malloc(sizeof(OTHER_FIELD)); - assert(other_field != NULL); - memset(other_field, 0, sizeof(OTHER_FIELD)); - other_field->name = strdup(name); - other_field->value = strdup(value); - assert(other_field->name != NULL); - assert(other_field->value != NULL); + nam = strdup(name); + EVEL_DEBUG("Adding HashMap to array of hashmap - %s", nam); + ht = nht_create(nam); - list = (DLIST *)ht_get(other->namedarrays, hashname); - if( list == NULL ) + if (ht != NULL) { - DLIST * nlist = malloc(sizeof(DLIST)); - dlist_initialize(nlist); - dlist_push_last(nlist, other_field); - ht_set(other->namedarrays, hashname,(void*)nlist); - EVEL_DEBUG("Created to new namedarray table %p",nlist); - } - else - { - dlist_push_last(list, other_field); - EVEL_DEBUG("Adding to existing table %p",list); + dlist_push_last(&other->arrayOfNamedHashMap, ht); } EVEL_EXIT(); -} + return ht; +} /**************************************************************************//** - * Add a json object to jsonObject list. + * Add a field name/value pair to the Other. * * The name and value are null delimited ASCII strings. The library takes * a copy so the caller does not have to preserve values after the function * returns. * - * @param other Pointer to the Other. - * @param jsonobj Pointer to json object + * @param ht Pointer to the hasmap array. + * @param name ASCIIZ string with the field's name. The caller does not + * need to preserve the value once the function returns. + * @param value ASCIIZ string with the field's value. The caller does not + * need to preserve the value once the function returns. *****************************************************************************/ -void evel_other_field_add_jsonobj(EVENT_OTHER * other, EVEL_JSON_OBJECT *jsonobj) +void evel_other_set_hashmap_in_hmarray( + HASHTABLE_T * const ht, + const char * const name, + const char * const value) { - OTHER_FIELD * other_field = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ /* Check preconditions. */ /***************************************************************************/ - assert(other != NULL); - assert(other->header.event_domain == EVEL_DOMAIN_OTHER); - assert(jsonobj != NULL); + assert(ht != NULL); + assert(name != NULL); - EVEL_DEBUG("Adding jsonObject"); + EVEL_DEBUG("Adding name=%s value=%s", name, value); - dlist_push_last(&other->jsonobjects, jsonobj); + nam = strdup(name); + val = strdup(value); + + ht_insert(ht, nam, val); EVEL_EXIT(); } - /**************************************************************************//** - * Add a field name/value pair to the Other. + * Add a json object to jsonObject list. * * The name and value are null delimited ASCII strings. The library takes * a copy so the caller does not have to preserve values after the function * returns. * * @param other Pointer to the Other. - * @param name ASCIIZ string with the field's name. The caller does not - * need to preserve the value once the function returns. - * @param value ASCIIZ string with the field's value. The caller does not - * need to preserve the value once the function returns. + * @param jsonobj Pointer to json object *****************************************************************************/ -void evel_other_field_add(EVENT_OTHER * other, char * name, char * value) +void evel_other_field_add_jsonobj(EVENT_OTHER * other, EVEL_JSON_OBJECT *jsonobj) { - OTHER_FIELD * other_field = NULL; EVEL_ENTER(); /***************************************************************************/ @@ -240,19 +233,11 @@ void evel_other_field_add(EVENT_OTHER * other, char * name, char * value) /***************************************************************************/ assert(other != NULL); assert(other->header.event_domain == EVEL_DOMAIN_OTHER); - assert(name != NULL); - assert(value != NULL); + assert(jsonobj != NULL); - EVEL_DEBUG("Adding name=%s value=%s", name, value); - other_field = malloc(sizeof(OTHER_FIELD)); - assert(other_field != NULL); - memset(other_field, 0, sizeof(OTHER_FIELD)); - other_field->name = strdup(name); - other_field->value = strdup(value); - assert(other_field->name != NULL); - assert(other_field->value != NULL); + EVEL_DEBUG("Adding jsonObject"); - dlist_push_last(&other->namedvalues, other_field); + dlist_push_last(&other->jsonobjects, jsonobj); EVEL_EXIT(); } @@ -266,7 +251,6 @@ void evel_other_field_add(EVENT_OTHER * other, char * name, char * value) void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, EVENT_OTHER * event) { - OTHER_FIELD * other_field = NULL; EVEL_JSON_OBJECT * jsonobjp = NULL; DLIST_ITEM * other_field_item = NULL; EVEL_JSON_OBJECT_INSTANCE * jsonobjinst = NULL; @@ -274,10 +258,8 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, EVEL_INTERNAL_KEY * keyinst = NULL; DLIST_ITEM * keyinst_field_item = NULL; HASHTABLE_T *ht = NULL; - int idx; - bool itm_added = false; - DLIST *itm_list = NULL; ENTRY_T *entry = NULL; + DLIST_ITEM *dlist_item; EVEL_ENTER(); @@ -290,52 +272,52 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, evel_json_encode_header(jbuf, &event->header); evel_json_open_named_object(jbuf, "otherFields"); -// iterate through hashtable and print DLIST for each entry - - evel_json_checkpoint(jbuf); - ht = event->namedarrays; - if( ht != NULL ) - { - if( ht->size > 0) - { - - evel_json_open_opt_named_list(jbuf, "hashOfNameValuePairArrays"); - for( idx = 0; idx < ht->size; idx++ ) { - if( ht->table[idx] != NULL) - { - entry = ht->table[idx]; - EVEL_DEBUG("Encoding other %s %p",(char *) (entry->key), entry->value); - - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", entry->key); - - itm_list = (DLIST*)(entry->value); - evel_json_open_opt_named_list(jbuf, "arrayOfFields"); - - other_field_item = dlist_get_first(itm_list); - while (other_field_item != NULL) + evel_json_checkpoint(jbuf); + ht = event->hashMap; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) { - other_field = (OTHER_FIELD *) other_field_item->item; - EVEL_DEBUG("Encoding other %s %s",(char *)other_field->name,(char*)other_field->value); - if(other_field != NULL){ - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", other_field->name); - evel_enc_kv_string(jbuf, "value", other_field->value); - evel_json_close_object(jbuf); - other_field_item = dlist_get_next(other_field_item); - } - } - evel_json_close_list(jbuf); - evel_json_close_object(jbuf); + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "hashMap")) + { - } + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding Other Fields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "hashMap", + entry->key)) + { + + // evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + // evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); + } + } - } else { - evel_json_rewind(jbuf); - } - } + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } evel_json_checkpoint(jbuf); if(evel_json_open_opt_named_list(jbuf, "jsonObjects")) @@ -345,7 +327,7 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, while (other_field_item != NULL) { jsonobjp = (EVEL_JSON_OBJECT *) other_field_item->item; - if(jsonobjp != NULL); + if(jsonobjp != NULL) //; { evel_json_open_object(jbuf); @@ -360,11 +342,11 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, { evel_json_open_object(jbuf); evel_enc_kv_object(jbuf, "objectInstance", jsonobjinst->jsonstring); - evel_enc_kv_ull(jbuf, "objectInstanceEpochMicrosec", jsonobjinst->objinst_epoch_microsec); + evel_enc_kv_opt_ull(jbuf, "objectInstanceEpochMicrosec", &jsonobjinst->objinst_epoch_microsec); //evel_json_checkpoint(jbuf); if (evel_json_open_opt_named_list(jbuf, "objectKeys")) { - bool item_added3 = false; +// bool item_added3 = false; keyinst_field_item = dlist_get_first(&jsonobjinst->object_keys); while (keyinst_field_item != NULL) @@ -377,7 +359,7 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_int(jbuf, "keyOrder", &keyinst->keyorder); evel_enc_kv_opt_string(jbuf, "keyValue", &keyinst->keyvalue); evel_json_close_object(jbuf); - item_added3 = false; +// item_added3 = false; } keyinst_field_item = dlist_get_next(keyinst_field_item); } @@ -422,35 +404,67 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, } + /***************************************************************************/ + /* Checkpoint, so that we can wind back if all fields are suppressed. */ + /***************************************************************************/ evel_json_checkpoint(jbuf); - if( evel_json_open_opt_named_list(jbuf, "nameValuePairs")) + if (evel_json_open_opt_named_list(jbuf, "arrayOfNamedHashMap")) { - bool item_added = false; + bool added_array = false; - other_field_item = dlist_get_first(&event->namedvalues); - while (other_field_item != NULL) - { - other_field = (OTHER_FIELD *) other_field_item->item; - if(other_field != NULL) + dlist_item = dlist_get_first(&event->arrayOfNamedHashMap); + while (dlist_item != NULL) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", other_field->name); - evel_enc_kv_string(jbuf, "value", other_field->value); - evel_json_close_object(jbuf); - item_added = true; + bool added = false; + ht = (HASHTABLE_T *) dlist_item->item; + assert(ht != NULL); + + if((ht->size > 0) && (ht-> n > 0)) + { + evel_json_checkpoint(jbuf); + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "name", ht->hmName); + if (evel_json_open_opt_named_object(jbuf, "hashMap")) + { + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding OtherFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "arrayOfNamedHashMap", + entry->key)) + { + evel_enc_kv_string(jbuf, entry->key, entry->value); + added = true; + added_array = true; + } + entry = entry->next; + } + } + evel_json_close_object(jbuf); + if (!added) + { + evel_json_rewind(jbuf); + } + } + evel_json_close_object(jbuf); + } + + dlist_item = dlist_get_next(dlist_item); } - other_field_item = dlist_get_next(other_field_item); - } - evel_json_close_list(jbuf); - /*************************************************************************/ - /* If we've not written anything, rewind to before we opened the list. */ - /*************************************************************************/ - if (!item_added) + evel_json_close_list(jbuf); + + if (!added_array) { evel_json_rewind(jbuf); } - } evel_enc_version(jbuf, "otherFieldsVersion", event->major_version,event->minor_version); @@ -470,7 +484,8 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_other(EVENT_OTHER * event) { - OTHER_FIELD * other_field = NULL; + HASHTABLE_T *ht; + EVEL_JSON_OBJECT * jsonobjp = NULL; EVEL_ENTER(); @@ -484,17 +499,28 @@ void evel_free_other(EVENT_OTHER * event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - other_field = dlist_pop_last(&event->namedvalues); - while (other_field != NULL) + ht = event->hashMap; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Other Field (%s, %s)", - other_field->name, - other_field->value); - free(other_field->name); - free(other_field->value); - free(other_field); - other_field = dlist_pop_last(&event->namedvalues); + ht_destroy(ht); } + + ht = dlist_pop_last(&event->arrayOfNamedHashMap); + while (ht != NULL) + { + EVEL_DEBUG("Freeing Other arrayOfNamedHashMap"); + ht_destroy(ht); + ht = dlist_pop_last(&event->arrayOfNamedHashMap); + } + + jsonobjp = dlist_pop_last(&event->jsonobjects); + while (jsonobjp != NULL) + { + evel_free_jsonobject( jsonobjp ); + + jsonobjp = dlist_pop_last(&event->jsonobjects); + } + evel_free_header(&event->header); EVEL_EXIT(); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_pnf_registration.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_pnf_registration.c new file mode 100644 index 0000000..9de25e5 --- /dev/null +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_pnf_registration.c @@ -0,0 +1,573 @@ +/*************************************************************************//** + * + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************/ +/**************************************************************************//** + * @file + * Implementation of EVEL functions relating to the PNF Registration. + * + ****************************************************************************/ + +#include +#include +#include + +#include "evel_throttle.h" + +/**************************************************************************//** + * Create a new PNF Registration event. + * + * @note The mandatory fields on the PNF Registration must be supplied to the + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once + * so that the State Change has immutable properties. + * + * @param event_name Unique Event Name confirming Domain AsdcModel Description + * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc + * + * @returns pointer to the newly manufactured ::EVENT_PNF_REGISTRATION. If the + * event is not used it must be released using + * ::evel_free_pnf_registration + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_PNF_REGISTRATION * evel_new_pnf_registration(const char* ev_name, const char *ev_id ) +{ + EVENT_PNF_REGISTRATION * pnf_registration = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Allocate the PNF Registration. */ + /***************************************************************************/ + pnf_registration = malloc(sizeof(EVENT_PNF_REGISTRATION)); + if (pnf_registration == NULL) + { + log_error_state("Out of memory"); + goto exit_label; + } + memset(pnf_registration, 0, sizeof(EVENT_PNF_REGISTRATION)); + EVEL_DEBUG("New PNF Registration is at %lp", pnf_registration); + + /***************************************************************************/ + /* Initialize the header & the PNF Registration fields. Optional string */ + /* values are uninitialized (NULL). */ + /***************************************************************************/ + evel_init_header_nameid(&pnf_registration->header,ev_name,ev_id); + pnf_registration->header.event_domain = EVEL_DOMAIN_PNF_REGISTRATION; + pnf_registration->major_version = EVEL_PNF_REGISTRATION_MAJOR_VERSION; + pnf_registration->minor_version = EVEL_PNF_REGISTRATION_MINOR_VERSION; + + evel_init_option_string(&pnf_registration->last_service_date); + evel_init_option_string(&pnf_registration->mac_address); + evel_init_option_string(&pnf_registration->manufacture_date); + evel_init_option_string(&pnf_registration->model_number); + evel_init_option_string(&pnf_registration->oam_v4_ipaddress); + evel_init_option_string(&pnf_registration->oam_v6_ipaddress); + evel_init_option_string(&pnf_registration->serial_number); + evel_init_option_string(&pnf_registration->sw_version); + evel_init_option_string(&pnf_registration->unit_family); + evel_init_option_string(&pnf_registration->unit_type); + evel_init_option_string(&pnf_registration->vendor_name); + pnf_registration->additional_fields = ht_create(); + +exit_label: + EVEL_EXIT(); + return pnf_registration; +} + +/**************************************************************************//** + * Free a PNF Registration. + * + * Free off the PNF Registration supplied. Will free all contained allocated + * memory. + * + * @note It does not free the PNF Registration itself, since that may be part + * of a larger structure. + *****************************************************************************/ +void evel_free_pnf_registration(EVENT_PNF_REGISTRATION * const pnf_registration) +{ + HASHTABLE_T *ht; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. As an internal API we don't allow freeing NULL */ + /* events as we do on the public API. */ + /***************************************************************************/ + assert(pnf_registration != NULL); + assert(pnf_registration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + + /***************************************************************************/ + /* Free all internal strings then the header itself. */ + /***************************************************************************/ + ht = pnf_registration->additional_fields; + if( ht != NULL ) + { + ht_destroy(ht); + } + + evel_free_option_string(&pnf_registration->last_service_date); + evel_free_option_string(&pnf_registration->mac_address); + evel_free_option_string(&pnf_registration->manufacture_date); + evel_free_option_string(&pnf_registration->model_number); + evel_free_option_string(&pnf_registration->oam_v4_ipaddress); + evel_free_option_string(&pnf_registration->oam_v6_ipaddress); + evel_free_option_string(&pnf_registration->serial_number); + evel_free_option_string(&pnf_registration->sw_version); + evel_free_option_string(&pnf_registration->unit_family); + evel_free_option_string(&pnf_registration->unit_type); + evel_free_option_string(&pnf_registration->vendor_name); + + evel_free_header(&pnf_registration->header); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add an additional field name/value pair to the PNF Registration + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param pnf_registration Pointer to the ::EVENT_PNF_REGISTRATION. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_pnf_registration_addl_field_add( + EVENT_PNF_REGISTRATION * const pnf_registration, + const char * const name, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(pnf_registration != NULL); + assert(pnf_registration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(pnf_registration->additional_fields, nam, val); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Encode the PNF Registration as a JSON PNF Registration + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param pnf_registration Pointer to the ::EVENT_PNF_REGISTRATION to encode. + *****************************************************************************/ +void evel_json_encode_pnf_registration(EVEL_JSON_BUFFER * jbuf, + EVENT_PNF_REGISTRATION * pnf_registration) +{ + HASHTABLE_T *ht; + ENTRY_T *entry; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(pnf_registration != NULL); + assert(pnf_registration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + + evel_json_encode_header(jbuf, &pnf_registration->header); + evel_json_open_named_object(jbuf, "pnfRegistrationFields"); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + evel_enc_kv_opt_string(jbuf, "lastServiceDate", &pnf_registration->last_service_date); + evel_enc_kv_opt_string(jbuf, "macAddress", &pnf_registration->mac_address); + evel_enc_kv_opt_string(jbuf, "manufactureDate", &pnf_registration->manufacture_date); + evel_enc_kv_opt_string(jbuf, "modelNumber", &pnf_registration->model_number); + evel_enc_kv_opt_string(jbuf, "oamV4IpAddress", &pnf_registration->oam_v4_ipaddress); + evel_enc_kv_opt_string(jbuf, "oamV6IpAddress", &pnf_registration->oam_v6_ipaddress); + evel_enc_kv_opt_string(jbuf, "serialNumber", &pnf_registration->serial_number); + evel_enc_kv_opt_string(jbuf, "softwareVersion", &pnf_registration->sw_version); + evel_enc_kv_opt_string(jbuf, "unitFamily", &pnf_registration->unit_family); + evel_enc_kv_opt_string(jbuf, "unitType", &pnf_registration->unit_type); + evel_enc_kv_opt_string(jbuf, "vendorName", &pnf_registration->vendor_name); + + evel_json_checkpoint(jbuf); + ht = pnf_registration->additional_fields; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_enc_version(jbuf, + "pnfRegistrationFieldsVersion", + pnf_registration->major_version, pnf_registration->minor_version); + + evel_json_close_object(jbuf); + + EVEL_EXIT(); +} + +/****************************************************************//** + * Set the last service date + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param last_service_date The last service date to be set. ASCIIZ + * string. The caller does not need to preserve + * the value once the function returns. +*********************************************************************/ +void evel_pnfRegistration_last_service_date_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const last_service_date) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(last_service_date != NULL); + + evel_set_option_string(&pnfRegistration->last_service_date, last_service_date, "Last Service Date"); + EVEL_EXIT(); +} +/************************************************************************//** + * Set the Mac Address + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param mac_address The mac address to be set. ASCIIZ string. The + * caller does not need to preserve the value once + * the function returns. +***************************************************************************/ +void evel_pnfRegistration_mac_address_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const mac_address) +{ + EVEL_ENTER(); + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(mac_address != NULL); + + evel_set_option_string(&pnfRegistration->mac_address, mac_address, "MAC Address"); + EVEL_EXIT(); +} +/***********************************************************************//** + * Set the Manufacture Date + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param manufacture_date The manufacture date to be set. ASCIIZ string. + * The caller does not need to preserve the value + * once the function returns. +***************************************************************************/ +void evel_pnfRegistration_manufacture_date_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const manufacture_date) + { + EVEL_ENTER(); + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(manufacture_date != NULL); + + evel_set_option_string(&pnfRegistration->manufacture_date, manufacture_date, "Manufacture Date"); + EVEL_EXIT(); +} + +/***********************************************************************//** + * Set the Model Number + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param model_number The model Number to be set. ASCIIZ string. The caller + * does not need to preserve the value once the + * function returns. +***************************************************************************/ +void evel_pnfRegistration_model_number_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const model_number) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(model_number != NULL); + + evel_set_option_string(&pnfRegistration->model_number, model_number, "Model Number"); + EVEL_EXIT(); +} + +/***********************************************************************//** + * Set the OAM v4 ipaddress + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param oam_v4_ipaddress Set the oam IP address. ASCIIZ string. + * The caller does not need + * preserve the value once the function returns. +*************************************************************************/ +void evel_pnfRegistration_oam_v4_ipaddress_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const oam_v4_ipaddress) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(oam_v4_ipaddress != NULL); + + evel_set_option_string(&pnfRegistration->oam_v4_ipaddress, oam_v4_ipaddress, "OAM V4 IP Address"); + EVEL_EXIT(); +} + +/**********************************************************************//** + * Set the oam v6 ipaddress + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param oam_v6_ipaddress Set the oam IP address. ASCIIZ string. + * The caller does not need + * preserve the value once the function returns. +**************************************************************************/ +void evel_pnfRegistration_oam_v6_ipaddress_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const oam_v6_ipaddress) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(oam_v6_ipaddress != NULL); + + evel_set_option_string(&pnfRegistration->oam_v6_ipaddress, oam_v6_ipaddress, "OAM V6 IP Address"); + EVEL_EXIT(); +} + +/**********************************************************************//** + * Set the Serial Number + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param serial_number The serial number to be set. ASCIIZ string. + * The caller does not need to preserve the + * value once the function returns. +**************************************************************************/ +void evel_pnfRegistration_serial_number_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const serial_number) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(serial_number != NULL); + + evel_set_option_string(&pnfRegistration->serial_number, serial_number, "SerialNumber"); + EVEL_EXIT(); +} + +/***********************************************************************//** + * Set the Software Version + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param sw_version The SW Version to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. +****************************************************************************/ +void evel_pnfRegistration_sw_version_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const sw_version) +{ + EVEL_ENTER(); + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(sw_version != NULL); + + evel_set_option_string(&pnfRegistration->sw_version, sw_version, "Software Version"); + EVEL_EXIT(); +} + +/***********************************************************************//** + * Set the Unit Family + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param unit_family The unit family to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. +***************************************************************************/ +void evel_pnfRegistration_unit_family_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const unit_family) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(unit_family != NULL); + + evel_set_option_string(&pnfRegistration->unit_family, unit_family, "Unit Family"); + EVEL_EXIT(); +} + +/**********************************************************************//** + * Set the Unit type + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param unit_type The unit type to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. +****************************************************************************/ +void evel_pnfRegistration_unit_type_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const unit_type) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(unit_type != NULL); + + evel_set_option_string(&pnfRegistration->unit_type, unit_type, "Unit Type"); + EVEL_EXIT(); +} + +/***********************************************************************//** + * Set the Vendor name + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries + * to overwrite, just ignoring the update instead. + * + * @param pnfRegistration Pointer to the pnfRegistration + * @param vendor_name The vendor name to be set. ASCIIZ string. The + * caller does not need to preserve the value once + * the function returns. +***************************************************************************/ +void evel_pnfRegistration_vendor_name_set(EVENT_PNF_REGISTRATION * pnfRegistration, const char * const vendor_name) +{ + EVEL_ENTER(); + + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(pnfRegistration != NULL); + assert(pnfRegistration->header.event_domain == EVEL_DOMAIN_PNF_REGISTRATION); + assert(vendor_name != NULL); + + evel_set_option_string(&pnfRegistration->vendor_name, vendor_name, "Vendor Name"); + EVEL_EXIT(); +} diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c index 0f30372..ddef800 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c @@ -330,7 +330,7 @@ void evel_json_encode_report(EVEL_JSON_BUFFER * jbuf, { evel_json_open_object(jbuf); evel_enc_kv_string(jbuf, "name", measurement_group->name); - evel_json_open_named_list(jbuf, "arrayOfFields"); + evel_json_open_named_object(jbuf, "hashMap"); /*********************************************************************/ /* Measurements list. */ @@ -341,13 +341,10 @@ void evel_json_encode_report(EVEL_JSON_BUFFER * jbuf, custom_measurement = (CUSTOM_MEASUREMENT *) nested_item->item; assert(custom_measurement != NULL); - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", custom_measurement->name); - evel_enc_kv_string(jbuf, "value", custom_measurement->value); - evel_json_close_object(jbuf); + evel_enc_kv_string(jbuf, custom_measurement->name, custom_measurement->value); nested_item = dlist_get_next(nested_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); evel_json_close_object(jbuf); item_added = true; } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c index d484b2e..f57860d 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c @@ -75,7 +75,8 @@ EVENT_MEASUREMENT * evel_new_measurement(double measurement_interval, const char evel_init_header_nameid(&measurement->header,ev_name,ev_id); measurement->header.event_domain = EVEL_DOMAIN_MEASUREMENT; measurement->measurement_interval = measurement_interval; - dlist_initialize(&measurement->additional_info); + measurement->additional_info = ht_create(); + measurement->feature_usage = ht_create(); dlist_initialize(&measurement->additional_measurements); dlist_initialize(&measurement->additional_objects); dlist_initialize(&measurement->cpu_usage); @@ -83,15 +84,20 @@ EVENT_MEASUREMENT * evel_new_measurement(double measurement_interval, const char dlist_initialize(&measurement->mem_usage); dlist_initialize(&measurement->filesystem_usage); dlist_initialize(&measurement->latency_distribution); - dlist_initialize(&measurement->vnic_usage); + dlist_initialize(&measurement->nic_performance); dlist_initialize(&measurement->codec_usage); - dlist_initialize(&measurement->feature_usage); + dlist_initialize(&measurement->huge_pages); + dlist_initialize(&measurement->ipmis); + dlist_initialize(&measurement->loads); + dlist_initialize(&measurement->machine_check_exception); + dlist_initialize(&measurement->process_stats); + evel_init_option_double(&measurement->mean_request_latency); evel_init_option_int(&measurement->vnfc_scaling_metric); evel_init_option_int(&measurement->concurrent_sessions); evel_init_option_int(&measurement->configured_entities); evel_init_option_int(&measurement->media_ports_in_use); - evel_init_option_int(&measurement->request_rate); + evel_init_option_double(&measurement->request_rate); measurement->major_version = EVEL_MEASUREMENT_MAJOR_VERSION; measurement->minor_version = EVEL_MEASUREMENT_MINOR_VERSION; @@ -144,7 +150,9 @@ void evel_measurement_type_set(EVENT_MEASUREMENT * measurement, *****************************************************************************/ void evel_measurement_addl_info_add(EVENT_MEASUREMENT * measurement, char * name, char * value) { - OTHER_FIELD * addl_info = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -156,19 +164,44 @@ void evel_measurement_addl_info_add(EVENT_MEASUREMENT * measurement, char * name assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - addl_info = malloc(sizeof(OTHER_FIELD)); - assert(addl_info != NULL); - memset(addl_info, 0, sizeof(OTHER_FIELD)); - addl_info->name = strdup(name); - addl_info->value = strdup(value); - assert(addl_info->name != NULL); - assert(addl_info->value != NULL); - dlist_push_last(&measurement->additional_info, addl_info); + nam = strdup(name); + val = strdup(value); + + ht_insert(measurement->additional_info, nam, val); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add a json object to jsonObject list. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the ScalingMeasurement + * @param jsonobj Pointer to json object + *****************************************************************************/ +void evel_measurement_addl_object_add(EVENT_MEASUREMENT * measurement, EVEL_JSON_OBJECT *jsonobj) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + assert(jsonobj != NULL); + + EVEL_DEBUG("Adding jsonObject %p",jsonobj); + + dlist_push_last(&measurement->additional_objects, jsonobj); EVEL_EXIT(); } + /**************************************************************************//** * Set the Concurrent Sessions property of the Measurement. * @@ -225,72 +258,6 @@ void evel_measurement_cfg_ents_set(EVENT_MEASUREMENT * measurement, EVEL_EXIT(); } -/**************************************************************************//** - * Add an additional set of Errors to the Measurement. - * - * @note The property is treated as immutable: it is only valid to call - * the setter once. However, we don't assert if the caller tries to - * overwrite, just ignoring the update instead. - * - * @param measurement Pointer to the measurement. - * @param receive_discards The number of receive discards. - * @param receive_errors The number of receive errors. - * @param transmit_discards The number of transmit discards. - * @param transmit_errors The number of transmit errors. - *****************************************************************************/ -void evel_measurement_errors_set(EVENT_MEASUREMENT * measurement, - int receive_discards, - int receive_errors, - int transmit_discards, - int transmit_errors) -{ - MEASUREMENT_ERRORS * errors = NULL; - EVEL_ENTER(); - - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(measurement != NULL); - assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); - assert(receive_discards >= 0); - assert(receive_errors >= 0); - assert(transmit_discards >= 0); - assert(transmit_errors >= 0); - - if (measurement->errors == NULL) - { - EVEL_DEBUG("Adding Errors: %d, %d; %d, %d", - receive_discards, - receive_errors, - transmit_discards, - transmit_errors); - errors = malloc(sizeof(MEASUREMENT_ERRORS)); - assert(errors != NULL); - memset(errors, 0, sizeof(MEASUREMENT_ERRORS)); - errors->receive_discards = receive_discards; - errors->receive_errors = receive_errors; - errors->transmit_discards = transmit_discards; - errors->transmit_errors = transmit_errors; - measurement->errors = errors; - } - else - { - errors = measurement->errors; - EVEL_DEBUG("Ignoring attempt to add Errors: %d, %d; %d, %d\n" - "Errors already set: %d, %d; %d, %d", - receive_discards, - receive_errors, - transmit_discards, - transmit_errors, - errors->receive_discards, - errors->receive_errors, - errors->transmit_discards, - errors->transmit_errors); - } - - EVEL_EXIT(); -} - /**************************************************************************//** * Set the Mean Request Latency property of the Measurement. * @@ -331,7 +298,7 @@ void evel_measurement_mean_req_lat_set(EVENT_MEASUREMENT * measurement, * @param request_rate The Request Rate to be set. *****************************************************************************/ void evel_measurement_request_rate_set(EVENT_MEASUREMENT * measurement, - int request_rate) + double request_rate) { EVEL_ENTER(); @@ -342,7 +309,7 @@ void evel_measurement_request_rate_set(EVENT_MEASUREMENT * measurement, assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); assert(request_rate >= 0); - evel_set_option_int(&measurement->request_rate, + evel_set_option_double(&measurement->request_rate, request_rate, "Request Rate"); EVEL_EXIT(); @@ -390,6 +357,13 @@ MEASUREMENT_CPU_USE *evel_measurement_new_cpu_use_add(EVENT_MEASUREMENT * measur evel_init_option_double(&cpu_use->sys); evel_init_option_double(&cpu_use->user); evel_init_option_double(&cpu_use->wait); + evel_init_option_double(&cpu_use->cpuCapacityContention); + evel_init_option_double(&cpu_use->cpuDemandAvg); + evel_init_option_double(&cpu_use->cpuDemandMhz); + evel_init_option_double(&cpu_use->cpuDemandPct); + evel_init_option_double(&cpu_use->cpuLatencyAvg); + evel_init_option_double(&cpu_use->cpuOverheadAvg); + evel_init_option_double(&cpu_use->cpuSwapWaitTime); dlist_push_last(&measurement->cpu_usage, cpu_use); @@ -545,6 +519,61 @@ void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE * const cpu_use, EVEL_EXIT(); } +void evel_measurement_cpu_use_cpuCapacityContention_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuCapacityContention, val, "time the CPU cannot run due to contention"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuDemandAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuDemandAvg, val, "The total CPU time that the NF NFC VM could use"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuDemandMhz_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuDemandMhz, val, "CPU demand in MHz"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuDemandPct_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuDemandPct, val, "CPU demand PCT"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuLatencyAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuLatencyAvg, val, "time the VM is unable to run"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuOverheadAvg_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuOverheadAvg, val, "The overhead demand"); + EVEL_EXIT(); +} + +void evel_measurement_cpu_use_cpuSwapWaitTime_set(MEASUREMENT_CPU_USE * const cpu_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&cpu_use->cpuSwapWaitTime, val, "Swap wait time"); + EVEL_EXIT(); +} /**************************************************************************//** * Add an additional Memory usage value name/value pair to the Measurement. @@ -554,14 +583,17 @@ void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE * const cpu_use, * returns. * * @param measurement Pointer to the measurement. - * @param id ASCIIZ string with the Memory identifier. * @param vmidentifier ASCIIZ string with the VM's identifier. - * @param membuffsz Memory Size. + * @param memfree Memory Free + * @param memused Memory Used * * @return Returns pointer to memory use structure in measurements *****************************************************************************/ -MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add(EVENT_MEASUREMENT * measurement, - char * id, char *vmidentifier, double membuffsz) +MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add( + EVENT_MEASUREMENT * measurement, + char *vmidentifier, + double memfree, + double memused) { MEASUREMENT_MEM_USE * mem_use = NULL; EVEL_ENTER(); @@ -571,27 +603,34 @@ MEASUREMENT_MEM_USE * evel_measurement_new_mem_use_add(EVENT_MEASUREMENT * measu /***************************************************************************/ assert(measurement != NULL); assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); - assert(id != NULL); - assert(membuffsz >= 0.0); + assert(vmidentifier != NULL); /***************************************************************************/ /* Allocate a container for the value and push onto the list. */ /***************************************************************************/ - EVEL_DEBUG("Adding id=%s buffer size=%lf", id, membuffsz); + EVEL_DEBUG("Adding vmid=%s", vmidentifier); mem_use = malloc(sizeof(MEASUREMENT_MEM_USE)); assert(mem_use != NULL); memset(mem_use, 0, sizeof(MEASUREMENT_MEM_USE)); - mem_use->id = strdup(id); mem_use->vmid = strdup(vmidentifier); - mem_use->membuffsz = membuffsz; + mem_use->memfree = memfree; + mem_use->memused = memused; + evel_init_option_double(&mem_use->membuffsz); evel_init_option_double(&mem_use->memcache); evel_init_option_double(&mem_use->memconfig); - evel_init_option_double(&mem_use->memfree); evel_init_option_double(&mem_use->slabrecl); evel_init_option_double(&mem_use->slabunrecl); - evel_init_option_double(&mem_use->memused); - - assert(mem_use->id != NULL); + evel_init_option_double(&mem_use->memoryDemand); + evel_init_option_double(&mem_use->memoryLatencyAvg); + evel_init_option_double(&mem_use->memorySharedAvg); + evel_init_option_double(&mem_use->memorySwapInAvg); + evel_init_option_double(&mem_use->memorySwapInRateAvg); + evel_init_option_double(&mem_use->memorySwapOutAvg); + evel_init_option_double(&mem_use->memorySwapOutRateAvg); + evel_init_option_double(&mem_use->memorySwapUsedAvg); + evel_init_option_double(&mem_use->percentMemoryUsage); + + assert(mem_use->vmid != NULL); dlist_push_last(&measurement->mem_usage, mem_use); @@ -618,7 +657,7 @@ void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE * const mem_use, } /**************************************************************************//** - * Set kilobytes of memory configured in the virtual machine on which the VNFC reporting + * Set kilobytes of memory Buffered * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to @@ -627,16 +666,16 @@ void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE * const mem_use, * @param mem_use Pointer to the Memory Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_mem_use_mem_buffered_set(MEASUREMENT_MEM_USE * const mem_use, const double val) { EVEL_ENTER(); - evel_set_option_double(&mem_use->memconfig, val, "Memory configured value"); + evel_set_option_double(&mem_use->membuffsz, val, "Memory Buffered value"); EVEL_EXIT(); } /**************************************************************************//** - * Set kilobytes of physical RAM left unused by the system + * Set kilobytes of memory configured in the virtual machine on which the VNFC reporting * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to @@ -645,11 +684,11 @@ void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use, * @param mem_use Pointer to the Memory Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_memfree_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE * const mem_use, const double val) { EVEL_ENTER(); - evel_set_option_double(&mem_use->memfree, val, "Memory freely available value"); + evel_set_option_double(&mem_use->memconfig, val, "Memory configured value"); EVEL_EXIT(); } @@ -690,7 +729,7 @@ void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE * const } /**************************************************************************//** - * Set the total memory minus the sum of free, buffered, cached and slab memory in kilobytes + * Set the Host demand in kibibytes * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to @@ -699,11 +738,75 @@ void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE * const * @param mem_use Pointer to the Memory Use. * @param val double *****************************************************************************/ -void evel_measurement_mem_use_usedup_set(MEASUREMENT_MEM_USE * const mem_use, +void evel_measurement_mem_use_memoryDemand_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memoryDemand, val, "Host demand in kibibytes"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memoryLatencyAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memoryLatencyAvg, val, "Percentage of time the VM is waiting"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySharedAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySharedAvg, val, "Shared memory in kilobytes"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySwapInAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySwapInAvg, val, "Amount of memory swapped-in"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySwapInRateAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySwapInRateAvg, val, "Rate at which memory is swapped"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySwapOutAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySwapOutAvg, val, "Amount of memory swapped-out"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySwapOutRateAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySwapOutRateAvg, val, "Rate at which memory is being swapped out"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_memorySwapUsedAvg_set(MEASUREMENT_MEM_USE * const mem_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&mem_use->memorySwapUsedAvg, val, "Space used for caching swapped pages"); + EVEL_EXIT(); +} + +void evel_measurement_mem_use_percentMemoryUsage_set(MEASUREMENT_MEM_USE * const mem_use, const double val) { EVEL_ENTER(); - evel_set_option_double(&mem_use->memused, val, "Memory usedup total set"); + evel_set_option_double(&mem_use->percentMemoryUsage, val, "Percentage of memory usage"); EVEL_EXIT(); } @@ -781,6 +884,20 @@ MEASUREMENT_DISK_USE * evel_measurement_new_disk_use_add(EVENT_MEASUREMENT * mea evel_init_option_double(&disk_use->timewritelast ); evel_init_option_double(&disk_use->timewritemax ); evel_init_option_double(&disk_use->timewritemin ); + evel_init_option_double(&disk_use->diskBusResets ); + evel_init_option_double(&disk_use->diskCommandsAborted ); + evel_init_option_double(&disk_use->diskTime ); + evel_init_option_double(&disk_use->diskFlushRequests ); + evel_init_option_double(&disk_use->diskFlushTime ); + evel_init_option_double(&disk_use->diskCommandsAvg ); + evel_init_option_double(&disk_use->diskReadCommandsAvg ); + evel_init_option_double(&disk_use->diskWriteCommandsAvg ); + evel_init_option_double(&disk_use->diskTotalReadLatencyAvg ); + evel_init_option_double(&disk_use->diskTotalWriteLatencyAvg ); + evel_init_option_double(&disk_use->diskWeightedIoTimeAvg ); + evel_init_option_double(&disk_use->diskWeightedIoTimeLast ); + evel_init_option_double(&disk_use->diskWeightedIoTimeMax ); + evel_init_option_double(&disk_use->diskWeightedIoTimeMin ); EVEL_EXIT(); return disk_use; @@ -1532,6 +1649,132 @@ void evel_measurement_disk_use_timewritemin_set(MEASUREMENT_DISK_USE * const dis EVEL_EXIT(); } +void evel_measurement_disk_use_diskBusResets_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskBusResets, val, "diskBusResets"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskCommandsAborted_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskCommandsAborted, val, "diskCommandsAborted"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskTime_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskTime, val, "diskTime"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskFlushRequests_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskFlushRequests, val, "diskFlushRequests"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskFlushTime_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskFlushTime, val, "diskFlushTime"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskCommandsAvg, val, "diskCommandsAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskReadCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskReadCommandsAvg, val, "diskReadCommandsAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskWriteCommandsAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskWriteCommandsAvg, val, "diskWriteCommandsAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskTotalReadLatencyAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskTotalReadLatencyAvg, val, "diskTotalReadLatencyAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskTotalWriteLatencyAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskTotalWriteLatencyAvg, val, "diskTotalWriteLatencyAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskWeightedIoTimeAvg_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskWeightedIoTimeAvg, val, "diskWeightedIoTimeAvg"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskWeightedIoTimeLast_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskWeightedIoTimeLast, val, "diskWeightedIoTimeLast"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskWeightedIoTimeMax_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskWeightedIoTimeMax, val, "diskWeightedIoTimeMax"); + EVEL_EXIT(); +} + +void evel_measurement_disk_use_diskWeightedIoTimeMin_set( + MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->diskWeightedIoTimeMin, val, "diskWeightedIoTimeMin"); + EVEL_EXIT(); +} + /**************************************************************************//** * Add an additional File System usage value name/value pair to the * Measurement. @@ -1607,9 +1850,11 @@ void evel_measurement_fsys_use_add(EVENT_MEASUREMENT * measurement, *****************************************************************************/ void evel_measurement_feature_use_add(EVENT_MEASUREMENT * measurement, char * feature, - int utilization) + char * utilization) { - MEASUREMENT_FEATURE_USE * feature_use = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -1618,105 +1863,95 @@ void evel_measurement_feature_use_add(EVENT_MEASUREMENT * measurement, assert(measurement != NULL); assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); assert(feature != NULL); - assert(utilization >= 0); + assert(utilization != 0); /***************************************************************************/ /* Allocate a container for the value and push onto the list. */ /***************************************************************************/ - EVEL_DEBUG("Adding Feature=%s Use=%d", feature, utilization); - feature_use = malloc(sizeof(MEASUREMENT_FEATURE_USE)); - assert(feature_use != NULL); - memset(feature_use, 0, sizeof(MEASUREMENT_FEATURE_USE)); - feature_use->feature_id = strdup(feature); - assert(feature_use->feature_id != NULL); - feature_use->feature_utilization = utilization; + EVEL_DEBUG("Adding Feature=%s Use=%s", feature, utilization); + nam = strdup(feature); + val = strdup(utilization); - dlist_push_last(&measurement->feature_usage, feature_use); + ht_insert(measurement->feature_usage, nam, val); EVEL_EXIT(); } - /**************************************************************************//** - * Add a Additional Measurement value name/value pair to the Report. + * Add a new Additional Measurement hashmap to the Measurement. * * The name is null delimited ASCII string. The library takes * a copy so the caller does not have to preserve values after the function * returns. * - * @param measurement Pointer to the Measaurement. - * @param group ASCIIZ string with the measurement group's name. - * @param name ASCIIZ string containing the measurement's name. - * @param value ASCIIZ string containing the measurement's value. + * @param measurement Pointer to the Measurement. + * @param name ASCIIZ string containing the hashmap name *****************************************************************************/ -void evel_measurement_custom_measurement_add(EVENT_MEASUREMENT * measurement, - const char * const group, - const char * const name, - const char * const value) +HASHTABLE_T * evel_measurement_new_addl_measurement( + EVENT_MEASUREMENT * measurement, + const char * const name) { - MEASUREMENT_GROUP * measurement_group = NULL; - CUSTOM_MEASUREMENT * custom_measurement = NULL; - DLIST_ITEM * item = NULL; + HASHTABLE_T *ht; + char *nam=NULL; + EVEL_ENTER(); /***************************************************************************/ - /* Check assumptions. */ + /* Check preconditions. */ /***************************************************************************/ assert(measurement != NULL); assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); - assert(group != NULL); assert(name != NULL); - assert(value != NULL); - /***************************************************************************/ - /* Allocate a container for the name/value pair. */ - /***************************************************************************/ - EVEL_DEBUG("Adding Measurement Group=%s Name=%s Value=%s", - group, name, value); - custom_measurement = malloc(sizeof(CUSTOM_MEASUREMENT)); - assert(custom_measurement != NULL); - memset(custom_measurement, 0, sizeof(CUSTOM_MEASUREMENT)); - custom_measurement->name = strdup(name); - assert(custom_measurement->name != NULL); - custom_measurement->value = strdup(value); - assert(custom_measurement->value != NULL); + EVEL_DEBUG("Adding HashMapName to additional_measurements = %s", name); - /***************************************************************************/ - /* See if we have that group already. */ - /***************************************************************************/ - item = dlist_get_first(&measurement->additional_measurements); - while (item != NULL) - { - measurement_group = (MEASUREMENT_GROUP *) item->item; - assert(measurement_group != NULL); + nam = strdup(name); - EVEL_DEBUG("Got measurement group %s", measurement_group->name); - if (strcmp(group, measurement_group->name) == 0) - { - EVEL_DEBUG("Found existing Measurement Group"); - break; - } - item = dlist_get_next(item); - } + ht = nht_create( nam ); - /***************************************************************************/ - /* If we didn't have the group already, create it. */ - /***************************************************************************/ - if (item == NULL) + if (ht != NULL) { - EVEL_DEBUG("Creating new Measurement Group"); - measurement_group = malloc(sizeof(MEASUREMENT_GROUP)); - assert(measurement_group != NULL); - memset(measurement_group, 0, sizeof(MEASUREMENT_GROUP)); - measurement_group->name = strdup(group); - assert(measurement_group->name != NULL); - dlist_initialize(&measurement_group->measurements); - dlist_push_last(&measurement->additional_measurements, measurement_group); + dlist_push_last(&measurement->additional_measurements, ht); } + EVEL_EXIT(); + + return ht; +} + +/**************************************************************************//** + * Add a new Additional Measurement hashmap to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param ht Pointer hashmap. + * @param name ASCIIZ string containing the measurement's name. + * @param Value ASCIIZ string containing the measurement's value. + *****************************************************************************/ +void evel_measurement_addl_measurement_set ( + HASHTABLE_T * const ht, + const char * const name, + const char * const value) +{ + char *nam=NULL; + char *val=NULL; + + EVEL_ENTER(); + /***************************************************************************/ - /* If we didn't have the group already, create it. */ + /* Check preconditions. */ /***************************************************************************/ - dlist_push_last(&measurement_group->measurements, custom_measurement); + assert(ht != NULL); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); + + ht_insert(ht, nam, val); EVEL_EXIT(); } @@ -1971,123 +2206,372 @@ void evel_measurement_latency_add(EVENT_MEASUREMENT * const measurement, } /**************************************************************************//** - * Create a new vNIC Use to be added to a Measurement event. + * Create a new NIC Use to be added to a Measurement event. * - * @note The mandatory fields on the ::MEASUREMENT_VNIC_PERFORMANCE must be supplied + * @note The mandatory fields on the ::MEASUREMENT_NIC_PERFORMANCE must be supplied * to this factory function and are immutable once set. Optional * fields have explicit setter functions, but again values may only be - * set once so that the ::MEASUREMENT_VNIC_PERFORMANCE has immutable + * set once so that the ::MEASUREMENT_NIC_PERFORMANCE has immutable * properties. * - * @param vnic_id ASCIIZ string with the vNIC's ID. + * @param nic_id ASCIIZ string with the NIC's ID. * @param val_suspect True or false confidence in data. * - * @returns pointer to the newly manufactured ::MEASUREMENT_VNIC_PERFORMANCE. + * @returns pointer to the newly manufactured ::MEASUREMENT_NIC_PERFORMANCE. * If the structure is not used it must be released using - * ::evel_measurement_free_vnic_performance. - * @retval NULL Failed to create the vNIC Use. + * ::evel_measurement_free_nic_performance. + * @retval NULL Failed to create the NIC Use. *****************************************************************************/ -MEASUREMENT_VNIC_PERFORMANCE * evel_measurement_new_vnic_performance(char * const vnic_id, +MEASUREMENT_NIC_PERFORMANCE * evel_measurement_new_nic_performance(char * const nic_id, char * const val_suspect) { - MEASUREMENT_VNIC_PERFORMANCE * vnic_performance; + MEASUREMENT_NIC_PERFORMANCE * nic_performance; EVEL_ENTER(); /***************************************************************************/ /* Check preconditions. */ /***************************************************************************/ - assert(vnic_id != NULL); + assert(nic_id != NULL); assert(!strcmp(val_suspect,"true") || !strcmp(val_suspect,"false")); /***************************************************************************/ /* Allocate, then set Mandatory Parameters. */ /***************************************************************************/ - EVEL_DEBUG("Adding VNIC ID=%s", vnic_id); - vnic_performance = malloc(sizeof(MEASUREMENT_VNIC_PERFORMANCE)); - assert(vnic_performance != NULL); - vnic_performance->vnic_id = strdup(vnic_id); - vnic_performance->valuesaresuspect = strdup(val_suspect); + EVEL_DEBUG("Adding NIC ID=%s", nic_id); + nic_performance = malloc(sizeof(MEASUREMENT_NIC_PERFORMANCE)); + assert(nic_performance != NULL); + nic_performance->nic_id = strdup(nic_id); + nic_performance->valuesaresuspect = strdup(val_suspect); /***************************************************************************/ /* Initialize Optional Parameters. */ /***************************************************************************/ - evel_init_option_double(&vnic_performance-> recvd_bcast_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_bcast_packets_delta); - evel_init_option_double(&vnic_performance-> recvd_discarded_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_discarded_packets_delta); - evel_init_option_double(&vnic_performance-> recvd_error_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_error_packets_delta); - evel_init_option_double(&vnic_performance-> recvd_mcast_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_mcast_packets_delta); - evel_init_option_double(&vnic_performance-> recvd_octets_acc); - evel_init_option_double(&vnic_performance-> recvd_octets_delta); - evel_init_option_double(&vnic_performance-> recvd_total_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_total_packets_delta); - evel_init_option_double(&vnic_performance-> recvd_ucast_packets_acc); - evel_init_option_double(&vnic_performance-> recvd_ucast_packets_delta); - evel_init_option_double(&vnic_performance-> tx_bcast_packets_acc); - evel_init_option_double(&vnic_performance-> tx_bcast_packets_delta); - evel_init_option_double(&vnic_performance-> tx_discarded_packets_acc); - evel_init_option_double(&vnic_performance-> tx_discarded_packets_delta); - evel_init_option_double(&vnic_performance-> tx_error_packets_acc); - evel_init_option_double(&vnic_performance-> tx_error_packets_delta); - evel_init_option_double(&vnic_performance-> tx_mcast_packets_acc); - evel_init_option_double(&vnic_performance-> tx_mcast_packets_delta); - evel_init_option_double(&vnic_performance-> tx_octets_acc); - evel_init_option_double(&vnic_performance-> tx_octets_delta); - evel_init_option_double(&vnic_performance-> tx_total_packets_acc); - evel_init_option_double(&vnic_performance-> tx_total_packets_delta); - evel_init_option_double(&vnic_performance-> tx_ucast_packets_acc); - evel_init_option_double(&vnic_performance-> tx_ucast_packets_delta); - - EVEL_EXIT(); - - return vnic_performance; -} - -/**************************************************************************//** - * Free a vNIC Use. - * - * Free off the ::MEASUREMENT_VNIC_PERFORMANCE supplied. Will free all the contained + evel_init_option_op_state(&nic_performance-> administrativeState); + evel_init_option_op_state(&nic_performance-> operationalState); + evel_init_option_double(&nic_performance-> receivedPercentDiscard); + evel_init_option_double(&nic_performance-> receivedPercentError); + evel_init_option_double(&nic_performance-> receivedUtilization); + evel_init_option_double(&nic_performance-> speed); + evel_init_option_double(&nic_performance-> transmittedPercentDiscard); + evel_init_option_double(&nic_performance-> transmittedPercentError); + evel_init_option_double(&nic_performance-> transmittedUtilization); + evel_init_option_double(&nic_performance-> recvd_bcast_packets_acc); + evel_init_option_double(&nic_performance-> recvd_bcast_packets_delta); + evel_init_option_double(&nic_performance-> recvd_discarded_packets_acc); + evel_init_option_double(&nic_performance-> recvd_discarded_packets_delta); + evel_init_option_double(&nic_performance-> recvd_error_packets_acc); + evel_init_option_double(&nic_performance-> recvd_error_packets_delta); + evel_init_option_double(&nic_performance-> recvd_mcast_packets_acc); + evel_init_option_double(&nic_performance-> recvd_mcast_packets_delta); + evel_init_option_double(&nic_performance-> recvd_octets_acc); + evel_init_option_double(&nic_performance-> recvd_octets_delta); + evel_init_option_double(&nic_performance-> recvd_total_packets_acc); + evel_init_option_double(&nic_performance-> recvd_total_packets_delta); + evel_init_option_double(&nic_performance-> recvd_ucast_packets_acc); + evel_init_option_double(&nic_performance-> recvd_ucast_packets_delta); + evel_init_option_double(&nic_performance-> tx_bcast_packets_acc); + evel_init_option_double(&nic_performance-> tx_bcast_packets_delta); + evel_init_option_double(&nic_performance-> tx_discarded_packets_acc); + evel_init_option_double(&nic_performance-> tx_discarded_packets_delta); + evel_init_option_double(&nic_performance-> tx_error_packets_acc); + evel_init_option_double(&nic_performance-> tx_error_packets_delta); + evel_init_option_double(&nic_performance-> tx_mcast_packets_acc); + evel_init_option_double(&nic_performance-> tx_mcast_packets_delta); + evel_init_option_double(&nic_performance-> tx_octets_acc); + evel_init_option_double(&nic_performance-> tx_octets_delta); + evel_init_option_double(&nic_performance-> tx_total_packets_acc); + evel_init_option_double(&nic_performance-> tx_total_packets_delta); + evel_init_option_double(&nic_performance-> tx_ucast_packets_acc); + evel_init_option_double(&nic_performance-> tx_ucast_packets_delta); + + EVEL_EXIT(); + + return nic_performance; +} + +/**************************************************************************//** + * Free a NIC Use. + * + * Free off the ::MEASUREMENT_NIC_PERFORMANCE supplied. Will free all the contained * allocated memory. * - * @note It does not free the vNIC Use itself, since that may be part of a + * @note It does not free the NIC Use itself, since that may be part of a * larger structure. *****************************************************************************/ -void evel_measurement_free_vnic_performance(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance) +void evel_measurement_free_nic_performance(MEASUREMENT_NIC_PERFORMANCE * const nic_performance) { EVEL_ENTER(); /***************************************************************************/ /* Check preconditions. */ /***************************************************************************/ - assert(vnic_performance != NULL); - assert(vnic_performance->vnic_id != NULL); - assert(vnic_performance->valuesaresuspect != NULL); + assert(nic_performance != NULL); + assert(nic_performance->nic_id != NULL); + assert(nic_performance->valuesaresuspect != NULL); /***************************************************************************/ /* Free the duplicated string. */ /***************************************************************************/ - free(vnic_performance->vnic_id); - free(vnic_performance->valuesaresuspect); - vnic_performance->vnic_id = NULL; + free(nic_performance->nic_id); + free(nic_performance->valuesaresuspect); + nic_performance->nic_id = NULL; + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the administrative State of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param state + *****************************************************************************/ +void evel_nic_performance_administrativeState_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const EVEL_OPER_STATE state) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(nic_performance != NULL); + assert(state < EVEL_MAX_OPER_STATES); + + evel_set_option_op_state(&nic_performance->administrativeState, state, "Administrative State"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the operational state of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param state + *****************************************************************************/ +void evel_nic_performance_operationalState_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const EVEL_OPER_STATE state) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(nic_performance != NULL); + assert(state < EVEL_MAX_OPER_STATES); + + evel_set_option_op_state(&nic_performance->operationalState, state, "Operational State"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Percentage of discarded packets received of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param receivedPercentDiscard + *****************************************************************************/ +void evel_nic_performance_receivedPercentDiscard_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedPercentDiscard) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(receivedPercentDiscard >= 0.0); + + evel_set_option_double(&nic_performance->receivedPercentDiscard, + receivedPercentDiscard, + "Percentage of discarded packets received"); + + EVEL_EXIT(); +} +/**************************************************************************//** + * Set the Percentage of error packets received of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param receivedPercentError + *****************************************************************************/ +void evel_nic_performance_receivedPercentError_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedPercentError) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(receivedPercentError >= 0.0); + + evel_set_option_double(&nic_performance->receivedPercentError, + receivedPercentError, + "Percentage of error packets received"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Percentage of utilization received of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param receivedUtilization + *****************************************************************************/ +void evel_nic_performance_receivedUtilization_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double receivedUtilization) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(receivedUtilization >= 0.0); + + evel_set_option_double(&nic_performance->receivedUtilization, + receivedUtilization, + "Percentage of utilization received"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Speed configured in mbps of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param Speed + *****************************************************************************/ +void evel_nic_performance_speed_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double speed) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(speed >= 0.0); + + evel_set_option_double(&nic_performance->speed, + speed, + "Speed configured in mbps"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Percentage of discarded packets transmitted of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param transmittedPercentDiscard + *****************************************************************************/ +void evel_nic_performance_transmittedPercentDiscard_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedPercentDiscard) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(transmittedPercentDiscard >= 0.0); + + evel_set_option_double(&nic_performance->transmittedPercentDiscard, + transmittedPercentDiscard, + "Percentage of discarded packets transmitted"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Percentage of error packets received of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param transmittedPercentError + *****************************************************************************/ +void evel_nic_performance_transmittedPercentError_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedPercentError) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(transmittedPercentError >= 0.0); + + evel_set_option_double(&nic_performance->transmittedPercentError, + transmittedPercentError, + "Percentage of error packets received"); + + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Percentage of utilization transmitted of the NIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param nic_performance Pointer to the NIC Use. + * @param transmittedUtilization + *****************************************************************************/ +void evel_nic_performance_transmittedUtilization_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double transmittedUtilization) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(transmittedUtilization >= 0.0); + + evel_set_option_double(&nic_performance->transmittedUtilization, + transmittedUtilization, + "Percentage of utilization transmitted"); EVEL_EXIT(); } /**************************************************************************//** * Set the Accumulated Broadcast Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_bcast_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_bcast_packets_acc) { EVEL_ENTER(); @@ -2097,7 +2581,7 @@ void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(recvd_bcast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_bcast_packets_acc, + evel_set_option_double(&nic_performance->recvd_bcast_packets_acc, recvd_bcast_packets_acc, "Broadcast Packets accumulated"); @@ -2106,16 +2590,16 @@ void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Broadcast Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_bcast_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_bcast_packets_delta) { EVEL_ENTER(); @@ -2125,7 +2609,7 @@ void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_bcast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_bcast_packets_delta, + evel_set_option_double(&nic_performance->recvd_bcast_packets_delta, recvd_bcast_packets_delta, "Delta Broadcast Packets recieved"); @@ -2135,16 +2619,16 @@ void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Discarded Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_discard_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_discard_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_discard_packets_acc) { EVEL_ENTER(); @@ -2154,7 +2638,7 @@ void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_discard_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_discarded_packets_acc, + evel_set_option_double(&nic_performance->recvd_discarded_packets_acc, recvd_discard_packets_acc, "Discarded Packets accumulated"); @@ -2163,16 +2647,16 @@ void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Delta Discarded Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_discard_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_discard_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_discard_packets_delta) { EVEL_ENTER(); @@ -2182,7 +2666,7 @@ void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE /***************************************************************************/ assert(recvd_discard_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_discarded_packets_delta, + evel_set_option_double(&nic_performance->recvd_discarded_packets_delta, recvd_discard_packets_delta, "Delta Discarded Packets recieved"); @@ -2192,16 +2676,16 @@ void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE /**************************************************************************//** * Set the Error Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_error_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_error_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_error_packets_acc) { EVEL_ENTER(); @@ -2211,7 +2695,7 @@ void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(recvd_error_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_error_packets_acc, + evel_set_option_double(&nic_performance->recvd_error_packets_acc, recvd_error_packets_acc, "Error Packets received accumulated"); @@ -2220,16 +2704,16 @@ void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Error Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_error_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_error_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_error_packets_delta) { EVEL_ENTER(); @@ -2239,7 +2723,7 @@ void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_error_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_error_packets_delta, + evel_set_option_double(&nic_performance->recvd_error_packets_delta, recvd_error_packets_delta, "Delta Error Packets recieved"); @@ -2248,16 +2732,16 @@ void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Accumulated Multicast Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_mcast_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_mcast_packets_acc) { EVEL_ENTER(); @@ -2267,7 +2751,7 @@ void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(recvd_mcast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_mcast_packets_acc, + evel_set_option_double(&nic_performance->recvd_mcast_packets_acc, recvd_mcast_packets_acc, "Multicast Packets accumulated"); @@ -2276,16 +2760,16 @@ void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Multicast Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_mcast_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_mcast_packets_delta) { EVEL_ENTER(); @@ -2295,7 +2779,7 @@ void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_mcast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_mcast_packets_delta, + evel_set_option_double(&nic_performance->recvd_mcast_packets_delta, recvd_mcast_packets_delta, "Delta Multicast Packets recieved"); @@ -2304,16 +2788,16 @@ void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Accumulated Octets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_octets_acc *****************************************************************************/ -void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_octets_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_octets_acc) { EVEL_ENTER(); @@ -2323,7 +2807,7 @@ void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * cons /***************************************************************************/ assert(recvd_octets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_octets_acc, + evel_set_option_double(&nic_performance->recvd_octets_acc, recvd_octets_acc, "Octets received accumulated"); @@ -2332,16 +2816,16 @@ void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * cons /**************************************************************************//** * Set the Delta Octets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_octets_delta *****************************************************************************/ -void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_octets_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_octets_delta) { EVEL_ENTER(); @@ -2351,7 +2835,7 @@ void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * co /***************************************************************************/ assert(recvd_octets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_octets_delta, + evel_set_option_double(&nic_performance->recvd_octets_delta, recvd_octets_delta, "Delta Octets recieved"); @@ -2360,16 +2844,16 @@ void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * co /**************************************************************************//** * Set the Accumulated Total Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_total_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_total_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_total_packets_acc) { EVEL_ENTER(); @@ -2379,7 +2863,7 @@ void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(recvd_total_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_total_packets_acc, + evel_set_option_double(&nic_performance->recvd_total_packets_acc, recvd_total_packets_acc, "Total Packets accumulated"); @@ -2388,16 +2872,16 @@ void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Total Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_total_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_total_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_total_packets_delta) { EVEL_ENTER(); @@ -2407,7 +2891,7 @@ void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_total_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_total_packets_delta, + evel_set_option_double(&nic_performance->recvd_total_packets_delta, recvd_total_packets_delta, "Delta Total Packets recieved"); @@ -2416,16 +2900,16 @@ void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Accumulated Unicast Packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_ucast_packets_acc *****************************************************************************/ -void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_ucast_packets_acc) { EVEL_ENTER(); @@ -2435,7 +2919,7 @@ void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(recvd_ucast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->recvd_ucast_packets_acc, + evel_set_option_double(&nic_performance->recvd_ucast_packets_acc, recvd_ucast_packets_acc, "Unicast Packets received accumulated"); @@ -2444,16 +2928,16 @@ void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Unicast packets Received in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param recvd_ucast_packets_delta *****************************************************************************/ -void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double recvd_ucast_packets_delta) { EVEL_ENTER(); @@ -2463,7 +2947,7 @@ void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(recvd_ucast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->recvd_ucast_packets_delta, + evel_set_option_double(&nic_performance->recvd_ucast_packets_delta, recvd_ucast_packets_delta, "Delta Unicast packets recieved"); @@ -2472,16 +2956,16 @@ void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Transmitted Broadcast Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_bcast_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_bcast_packets_acc) { EVEL_ENTER(); @@ -2491,7 +2975,7 @@ void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(tx_bcast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_bcast_packets_acc, + evel_set_option_double(&nic_performance->tx_bcast_packets_acc, tx_bcast_packets_acc, "Transmitted Broadcast Packets accumulated"); @@ -2500,16 +2984,16 @@ void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Broadcast packets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_bcast_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_bcast_packets_delta) { EVEL_ENTER(); @@ -2519,7 +3003,7 @@ void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(tx_bcast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_bcast_packets_delta, + evel_set_option_double(&nic_performance->tx_bcast_packets_delta, tx_bcast_packets_delta, "Delta Transmitted Broadcast packets "); @@ -2528,16 +3012,16 @@ void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Transmitted Discarded Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_discarded_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_discarded_packets_acc) { EVEL_ENTER(); @@ -2547,7 +3031,7 @@ void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE /***************************************************************************/ assert(tx_discarded_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_discarded_packets_acc, + evel_set_option_double(&nic_performance->tx_discarded_packets_acc, tx_discarded_packets_acc, "Transmitted Discarded Packets accumulated"); @@ -2556,16 +3040,16 @@ void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE /**************************************************************************//** * Set the Delta Discarded packets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_discarded_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_discarded_packets_delta) { EVEL_ENTER(); @@ -2575,7 +3059,7 @@ void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMAN /***************************************************************************/ assert(tx_discarded_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_discarded_packets_delta, + evel_set_option_double(&nic_performance->tx_discarded_packets_delta, tx_discarded_packets_delta, "Delta Transmitted Discarded packets "); @@ -2584,16 +3068,16 @@ void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMAN /**************************************************************************//** * Set the Transmitted Errored Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_error_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_error_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_error_packets_acc) { EVEL_ENTER(); @@ -2603,7 +3087,7 @@ void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(tx_error_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_error_packets_acc, + evel_set_option_double(&nic_performance->tx_error_packets_acc, tx_error_packets_acc, "Transmitted Error Packets accumulated"); @@ -2612,16 +3096,16 @@ void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Errored packets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_error_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_error_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_error_packets_delta) { EVEL_ENTER(); @@ -2631,7 +3115,7 @@ void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(tx_error_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_error_packets_delta, + evel_set_option_double(&nic_performance->tx_error_packets_delta, tx_error_packets_delta, "Delta Transmitted Error packets "); @@ -2640,16 +3124,16 @@ void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Transmitted Multicast Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_mcast_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_mcast_packets_acc) { EVEL_ENTER(); @@ -2659,7 +3143,7 @@ void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(tx_mcast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_mcast_packets_acc, + evel_set_option_double(&nic_performance->tx_mcast_packets_acc, tx_mcast_packets_acc, "Transmitted Multicast Packets accumulated"); @@ -2668,16 +3152,16 @@ void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Multicast packets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_mcast_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_mcast_packets_delta) { EVEL_ENTER(); @@ -2687,7 +3171,7 @@ void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(tx_mcast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_mcast_packets_delta, + evel_set_option_double(&nic_performance->tx_mcast_packets_delta, tx_mcast_packets_delta, "Delta Transmitted Multicast packets "); @@ -2696,16 +3180,16 @@ void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Transmitted Octets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_octets_acc *****************************************************************************/ -void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_octets_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_octets_acc) { EVEL_ENTER(); @@ -2715,7 +3199,7 @@ void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * cons /***************************************************************************/ assert(tx_octets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_octets_acc, + evel_set_option_double(&nic_performance->tx_octets_acc, tx_octets_acc, "Transmitted Octets accumulated"); @@ -2724,16 +3208,16 @@ void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE * cons /**************************************************************************//** * Set the Delta Octets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_octets_delta *****************************************************************************/ -void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_octets_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_octets_delta) { EVEL_ENTER(); @@ -2743,7 +3227,7 @@ void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * co /***************************************************************************/ assert(tx_octets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_octets_delta, + evel_set_option_double(&nic_performance->tx_octets_delta, tx_octets_delta, "Delta Transmitted Octets "); @@ -2753,16 +3237,16 @@ void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE * co /**************************************************************************//** * Set the Transmitted Total Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_total_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_total_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_total_packets_acc) { EVEL_ENTER(); @@ -2772,7 +3256,7 @@ void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /***************************************************************************/ assert(tx_total_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_total_packets_acc, + evel_set_option_double(&nic_performance->tx_total_packets_acc, tx_total_packets_acc, "Transmitted Total Packets accumulated"); @@ -2781,16 +3265,16 @@ void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Total Packets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_total_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_total_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_total_packets_delta) { EVEL_ENTER(); @@ -2800,7 +3284,7 @@ void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(tx_total_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_total_packets_delta, + evel_set_option_double(&nic_performance->tx_total_packets_delta, tx_total_packets_delta, "Delta Transmitted Total Packets "); @@ -2810,27 +3294,27 @@ void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** * Set the Transmitted Unicast Packets in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_ucast_packets_acc *****************************************************************************/ -void evel_vnic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, - const double tx_ucast_packets_acc) +void evel_nic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, + const double mtx_ucast_packets_acc) { EVEL_ENTER(); /***************************************************************************/ /* Check preconditions. */ /***************************************************************************/ - assert(tx_ucast_packets_acc >= 0.0); + assert(mtx_ucast_packets_acc >= 0.0); - evel_set_option_double(&vnic_performance->tx_ucast_packets_acc, - tx_ucast_packets_acc, + evel_set_option_double(&nic_performance->tx_ucast_packets_acc, + mtx_ucast_packets_acc, "Transmitted Unicast Packets accumulated"); EVEL_EXIT(); @@ -2838,16 +3322,16 @@ void evel_vnic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE * c /**************************************************************************//** * Set the Delta Octets Transmitted in measurement interval - * property of the vNIC performance. + * property of the NIC performance. * * @note The property is treated as immutable: it is only valid to call * the setter once. However, we don't assert if the caller tries to * overwrite, just ignoring the update instead. * - * @param vnic_performance Pointer to the vNIC Use. + * @param nic_performance Pointer to the NIC Use. * @param tx_ucast_packets_delta *****************************************************************************/ -void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance, +void evel_nic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_NIC_PERFORMANCE * const nic_performance, const double tx_ucast_packets_delta) { EVEL_ENTER(); @@ -2857,7 +3341,7 @@ void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /***************************************************************************/ assert(tx_ucast_packets_delta >= 0.0); - evel_set_option_double(&vnic_performance->tx_ucast_packets_delta, + evel_set_option_double(&nic_performance->tx_ucast_packets_delta, tx_ucast_packets_delta, "Delta Transmitted Unicast Packets "); @@ -2866,13 +3350,13 @@ void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE * /**************************************************************************//** - * Add an additional vNIC Use to the specified Measurement event. + * Add an additional NIC Use to the specified Measurement event. * * @param measurement Pointer to the measurement. - * @param vnic_performance Pointer to the vNIC Use to add. + * @param nic_performance Pointer to the NIC Use to add. *****************************************************************************/ -void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement, - MEASUREMENT_VNIC_PERFORMANCE * const vnic_performance) +void evel_meas_nic_performance_add(EVENT_MEASUREMENT * const measurement, + MEASUREMENT_NIC_PERFORMANCE * const nic_performance) { EVEL_ENTER(); @@ -2881,15 +3365,15 @@ void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement, /***************************************************************************/ assert(measurement != NULL); assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); - assert(vnic_performance != NULL); + assert(nic_performance != NULL); - dlist_push_last(&measurement->vnic_usage, vnic_performance); + dlist_push_last(&measurement->nic_performance, nic_performance); EVEL_EXIT(); } /**************************************************************************//** - * Add an additional vNIC usage record Measurement. + * Add an additional NIC usage record Measurement. * * This function implements the previous API, purely for convenience. * @@ -2897,8 +3381,17 @@ void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement, * caller does not have to preserve values after the function returns. * * @param measurement Pointer to the measurement. - * @param vnic_id ASCIIZ string with the vNIC's ID. + * @param nic_id ASCIIZ string with the NIC's ID. * @param valset true or false confidence level + * @param admin_state Administrative state + * @param op_state Operational state + * @param receivedPercentDiscard Percentage of discarded packets received; + * @param receivedPercentError Percentage of error packets received + * @param receivedUtilization Percentage of utilization received + * @param speed Speed configured in mbps + * @param transmittedPercentDiscard Percentage of discarded packets transmitted + * @param transmittedPercentError Percentage of error packets received + * @param transmittedUtilization Percentage of utilization transmitted * @param recvd_bcast_packets_acc Recieved broadcast packets * @param recvd_bcast_packets_delta Received delta broadcast packets * @param recvd_discarded_packets_acc Recieved discarded packets @@ -2928,9 +3421,18 @@ void evel_meas_vnic_performance_add(EVENT_MEASUREMENT * const measurement, * @param tx_ucast_packets_acc Transmitted Unicast packets * @param tx_ucast_packets_delta Transmitted delta Unicast packets *****************************************************************************/ -void evel_measurement_vnic_performance_add(EVENT_MEASUREMENT * const measurement, - char * const vnic_id, +void evel_measurement_nic_performance_add(EVENT_MEASUREMENT * const measurement, + char * const nic_id, char * valset, + EVEL_OPER_STATE admin_state, + EVEL_OPER_STATE op_state, + double receivedPercentDiscard, + double receivedPercentError, + double receivedUtilization, + double speed, + double transmittedPercentDiscard, + double transmittedPercentError, + double transmittedUtilization, double recvd_bcast_packets_acc, double recvd_bcast_packets_delta, double recvd_discarded_packets_acc, @@ -2960,140 +3462,1789 @@ void evel_measurement_vnic_performance_add(EVENT_MEASUREMENT * const measurement double tx_ucast_packets_acc, double tx_ucast_packets_delta) { - MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; + MEASUREMENT_NIC_PERFORMANCE * nic_performance = NULL; EVEL_ENTER(); /***************************************************************************/ /* Trust the assertions in the underlying methods. */ /***************************************************************************/ - vnic_performance = evel_measurement_new_vnic_performance(vnic_id, valset); + nic_performance = evel_measurement_new_nic_performance(nic_id, valset); - evel_vnic_performance_rx_bcast_pkt_acc_set(vnic_performance, recvd_bcast_packets_acc); - evel_vnic_performance_rx_bcast_pkt_delta_set(vnic_performance, recvd_bcast_packets_delta); - evel_vnic_performance_rx_discard_pkt_acc_set(vnic_performance, recvd_discarded_packets_acc); - evel_vnic_performance_rx_discard_pkt_delta_set(vnic_performance, recvd_discarded_packets_delta); - evel_vnic_performance_rx_error_pkt_acc_set(vnic_performance, recvd_error_packets_acc); - evel_vnic_performance_rx_error_pkt_delta_set(vnic_performance, recvd_error_packets_delta); - evel_vnic_performance_rx_mcast_pkt_acc_set(vnic_performance, recvd_mcast_packets_acc); - evel_vnic_performance_rx_mcast_pkt_delta_set(vnic_performance, recvd_mcast_packets_delta); - evel_vnic_performance_rx_octets_acc_set(vnic_performance, recvd_octets_acc); - evel_vnic_performance_rx_octets_delta_set(vnic_performance, recvd_octets_delta); - evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, recvd_total_packets_acc); - evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, recvd_total_packets_delta); - evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_performance, recvd_ucast_packets_acc); - evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_performance, recvd_ucast_packets_delta); - evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_performance, tx_bcast_packets_acc); - evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_performance, tx_bcast_packets_delta); - evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_performance, tx_discarded_packets_acc); - evel_vnic_performance_tx_discarded_pkt_delta_set(vnic_performance, tx_discarded_packets_delta); - evel_vnic_performance_tx_error_pkt_acc_set(vnic_performance, tx_error_packets_acc); - evel_vnic_performance_tx_error_pkt_delta_set(vnic_performance, tx_error_packets_delta); - evel_vnic_performance_tx_mcast_pkt_acc_set(vnic_performance, tx_mcast_packets_acc); - evel_vnic_performance_tx_mcast_pkt_delta_set(vnic_performance, tx_mcast_packets_delta); - evel_vnic_performance_tx_octets_acc_set(vnic_performance, tx_octets_acc); - evel_vnic_performance_tx_octets_delta_set(vnic_performance, tx_octets_delta); - evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, tx_total_packets_acc); - evel_vnic_performance_tx_total_pkt_delta_set(vnic_performance, tx_total_packets_delta); - evel_vnic_performance_tx_ucast_pkt_acc_set(vnic_performance, tx_ucast_packets_acc); - evel_vnic_performance_tx_ucast_pkt_delta_set(vnic_performance, tx_ucast_packets_delta); - evel_meas_vnic_performance_add(measurement, vnic_performance); + evel_nic_performance_administrativeState_set(nic_performance, admin_state); + evel_nic_performance_operationalState_set(nic_performance, op_state); + evel_nic_performance_receivedPercentDiscard_set(nic_performance, receivedPercentDiscard); + evel_nic_performance_receivedPercentError_set(nic_performance, receivedPercentError); + evel_nic_performance_receivedUtilization_set(nic_performance, receivedUtilization); + evel_nic_performance_speed_set(nic_performance, speed); + evel_nic_performance_transmittedPercentDiscard_set(nic_performance, transmittedPercentDiscard); + evel_nic_performance_transmittedPercentError_set(nic_performance, transmittedPercentError); + evel_nic_performance_transmittedUtilization_set(nic_performance, transmittedUtilization); + evel_nic_performance_rx_bcast_pkt_acc_set(nic_performance, recvd_bcast_packets_acc); + evel_nic_performance_rx_bcast_pkt_delta_set(nic_performance, recvd_bcast_packets_delta); + evel_nic_performance_rx_discard_pkt_acc_set(nic_performance, recvd_discarded_packets_acc); + evel_nic_performance_rx_discard_pkt_delta_set(nic_performance, recvd_discarded_packets_delta); + evel_nic_performance_rx_error_pkt_acc_set(nic_performance, recvd_error_packets_acc); + evel_nic_performance_rx_error_pkt_delta_set(nic_performance, recvd_error_packets_delta); + evel_nic_performance_rx_mcast_pkt_acc_set(nic_performance, recvd_mcast_packets_acc); + evel_nic_performance_rx_mcast_pkt_delta_set(nic_performance, recvd_mcast_packets_delta); + evel_nic_performance_rx_octets_acc_set(nic_performance, recvd_octets_acc); + evel_nic_performance_rx_octets_delta_set(nic_performance, recvd_octets_delta); + evel_nic_performance_rx_total_pkt_acc_set(nic_performance, recvd_total_packets_acc); + evel_nic_performance_rx_total_pkt_delta_set(nic_performance, recvd_total_packets_delta); + evel_nic_performance_rx_ucast_pkt_acc_set(nic_performance, recvd_ucast_packets_acc); + evel_nic_performance_rx_ucast_pkt_delta_set(nic_performance, recvd_ucast_packets_delta); + evel_nic_performance_tx_bcast_pkt_acc_set(nic_performance, tx_bcast_packets_acc); + evel_nic_performance_tx_bcast_pkt_delta_set(nic_performance, tx_bcast_packets_delta); + evel_nic_performance_tx_discarded_pkt_acc_set(nic_performance, tx_discarded_packets_acc); + evel_nic_performance_tx_discarded_pkt_delta_set(nic_performance, tx_discarded_packets_delta); + evel_nic_performance_tx_error_pkt_acc_set(nic_performance, tx_error_packets_acc); + evel_nic_performance_tx_error_pkt_delta_set(nic_performance, tx_error_packets_delta); + evel_nic_performance_tx_mcast_pkt_acc_set(nic_performance, tx_mcast_packets_acc); + evel_nic_performance_tx_mcast_pkt_delta_set(nic_performance, tx_mcast_packets_delta); + evel_nic_performance_tx_octets_acc_set(nic_performance, tx_octets_acc); + evel_nic_performance_tx_octets_delta_set(nic_performance, tx_octets_delta); + evel_nic_performance_tx_total_pkt_acc_set(nic_performance, tx_total_packets_acc); + evel_nic_performance_tx_total_pkt_delta_set(nic_performance, tx_total_packets_delta); + evel_nic_performance_tx_ucast_pkt_acc_set(nic_performance, tx_ucast_packets_acc); + evel_nic_performance_tx_ucast_pkt_delta_set(nic_performance, tx_ucast_packets_delta); + evel_meas_nic_performance_add(measurement, nic_performance); } -/**************************************************************************//** - * Encode the measurement as a JSON measurement. - * - * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. - * @param event Pointer to the ::EVENT_HEADER to encode. - *****************************************************************************/ -void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, - EVENT_MEASUREMENT * event) +MEASUREMENT_IPMI * evel_measurement_new_ipmi_add( + EVENT_MEASUREMENT * measurement) { - MEASUREMENT_CPU_USE * cpu_use = NULL; - MEASUREMENT_MEM_USE * mem_use = NULL; - MEASUREMENT_DISK_USE * disk_use = NULL; - MEASUREMENT_FSYS_USE * fsys_use = NULL; - MEASUREMENT_LATENCY_BUCKET * bucket = NULL; - MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; - MEASUREMENT_ERRORS * errors = NULL; - MEASUREMENT_FEATURE_USE * feature_use = NULL; - MEASUREMENT_CODEC_USE * codec_use = NULL; - MEASUREMENT_GROUP * measurement_group = NULL; - CUSTOM_MEASUREMENT * custom_measurement = NULL; - DLIST_ITEM * item = NULL; - DLIST_ITEM * nested_item = NULL; - DLIST_ITEM * addl_info_item = NULL; - OTHER_FIELD *addl_info = NULL; - + MEASUREMENT_IPMI *ipmi = NULL; EVEL_ENTER(); /***************************************************************************/ - /* Check preconditions. */ + /* Check assumptions. */ /***************************************************************************/ - assert(event != NULL); - assert(event->header.event_domain == EVEL_DOMAIN_MEASUREMENT); - - evel_json_encode_header(jbuf, &event->header); - evel_json_open_named_object(jbuf, "measurementsForVfScalingFields"); + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); /***************************************************************************/ - /* Mandatory fields. */ + /* Allocate a container for the value and push onto the list. */ /***************************************************************************/ - evel_enc_kv_int(jbuf, "measurementInterval", event->measurement_interval); + ipmi = malloc(sizeof(MEASUREMENT_IPMI)); + assert(ipmi != NULL); + memset(ipmi, 0, sizeof(MEASUREMENT_IPMI)); - /***************************************************************************/ - /* Optional fields. */ - /***************************************************************************/ - // additional fields - evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalFields")) - { - bool item_added = false; + evel_init_option_double(&ipmi->exitAirTemperature); + evel_init_option_double(&ipmi->frontPanelTemperature); + evel_init_option_double(&ipmi->ioModuleTemperature); + evel_init_option_double(&ipmi->systemAirflow); - addl_info_item = dlist_get_first(&event->additional_info); - while (addl_info_item != NULL) - { - addl_info = (OTHER_FIELD*) addl_info_item->item; - assert(addl_info != NULL); + dlist_initialize(&ipmi->ipmi_base_board_temparature); + dlist_initialize(&ipmi->ipmi_base_board_voltage); + dlist_initialize(&ipmi->ipmi_battery); + dlist_initialize(&ipmi->ipmi_fan); + dlist_initialize(&ipmi->ipmi_hsbp); + dlist_initialize(&ipmi->ipmi_global_agg_temp_margin); + dlist_initialize(&ipmi->ipmi_nic); + dlist_initialize(&ipmi->ipmi_power); + dlist_initialize(&ipmi->ipmi_processor); - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalFields", - addl_info->name)) - { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", addl_info->name); - evel_enc_kv_string(jbuf, "value", addl_info->value); - evel_json_close_object(jbuf); - item_added = true; - } - addl_info_item = dlist_get_next(addl_info_item); - } - evel_json_close_list(jbuf); + dlist_push_last(&measurement->ipmis, ipmi); - /*************************************************************************/ - /* If we've not written anything, rewind to before we opened the list. */ - /*************************************************************************/ - if (!item_added) - { - evel_json_rewind(jbuf); - } - } + EVEL_EXIT(); + return ipmi; +} - // TBD additional json objects - evel_enc_kv_opt_int(jbuf, "concurrentSessions", &event->concurrent_sessions); - evel_enc_kv_opt_int(jbuf, "configuredEntities", &event->configured_entities); +/**************************************************************************//** + * Set the System fan exit air flow temperature in Celsius of IPMI + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI Use. + * @param double + *****************************************************************************/ +void evel_measurement_ipmi_exitAirTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + evel_set_option_double(&ipmi->exitAirTemperature, val, "exitAirTemperature"); + EVEL_EXIT(); +} - /***************************************************************************/ - /* CPU Use list. */ - /***************************************************************************/ - evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "cpuUsageArray")) - { - bool item_added = false; +/**************************************************************************//** + * Set the Front panel temp in Celsius of IPMI + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI Use. + * @param double + *****************************************************************************/ +void evel_measurement_ipmi_frontPanelTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + evel_set_option_double(&ipmi->frontPanelTemperature, val, "frontPanelTemperature"); + EVEL_EXIT(); +} - item = dlist_get_first(&event->cpu_usage); - while (item != NULL) - { - cpu_use = (MEASUREMENT_CPU_USE*) item->item; +/**************************************************************************//** + * Set the Io module temp in Celsius of IPMI + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI Use. + * @param double + *****************************************************************************/ +void evel_measurement_ipmi_ioModuleTemperature_set(MEASUREMENT_IPMI *ipmi, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + evel_set_option_double(&ipmi->ioModuleTemperature, val, "ioModuleTemperature"); + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the Airflow in cubic feet per minute (cfm) of IPMI + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI Use. + * @param double + *****************************************************************************/ +void evel_measurement_ipmi_systemAirflow_set(MEASUREMENT_IPMI *ipmi, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + evel_set_option_double(&ipmi->systemAirflow, val, "systemAirflow"); + EVEL_EXIT(); +} + +/**************************************************************************//** + * Add a new Baseboard Temperature Array element to IPMI + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ipmi Pointer to the IPMI Use. + * @param id Indentifier + *****************************************************************************/ +MEASUREMENT_IPMI_BB_TEMPERATURE *evel_measurement_new_base_board_temp_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_BB_TEMPERATURE * bb_temp = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + bb_temp = malloc(sizeof(MEASUREMENT_IPMI_BB_TEMPERATURE)); + assert(bb_temp != NULL); + memset(bb_temp, 0, sizeof(MEASUREMENT_IPMI_BB_TEMPERATURE)); + bb_temp->BBTemperatureID = strdup(id); + evel_init_option_double(&bb_temp->BBTemperature); + + dlist_push_last(&ipmi->ipmi_base_board_temparature, bb_temp); + + EVEL_EXIT(); + return bb_temp; +} + + +void evel_measurement_ipmi_bb_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BB_TEMPERATURE * bb_temp, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(bb_temp != NULL); + evel_set_option_double(&bb_temp->BBTemperature, val, "Base Board Temperature"); + EVEL_EXIT(); +} + + +MEASUREMENT_IPMI_BB_VOLTAGE *evel_measurement_new_base_board_volt_add( + MEASUREMENT_IPMI * ipmi, + const char const * id) +{ + MEASUREMENT_IPMI_BB_VOLTAGE * bb_volt = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + bb_volt = malloc(sizeof(MEASUREMENT_IPMI_BB_VOLTAGE)); + assert(bb_volt != NULL); + assert(id != NULL); + memset(bb_volt, 0, sizeof(MEASUREMENT_IPMI_BB_VOLTAGE)); + + bb_volt->BBVoltageRegID = strdup(id); + evel_init_option_double(&bb_volt->voltageRegTemperature); + + dlist_push_last(&ipmi->ipmi_base_board_voltage, bb_volt); + + EVEL_EXIT(); + return bb_volt; +} + + +void evel_measurement_ipmi_bb_volt_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BB_VOLTAGE * bb_volt, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(bb_volt != NULL); + evel_set_option_double(&bb_volt->voltageRegTemperature, val, "Voltage Regulator Temperature"); + EVEL_EXIT(); +} + + + +MEASUREMENT_IPMI_BATTERY *evel_measurement_new_ipmi_battery_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_BATTERY * ipmi_battery = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_battery = malloc(sizeof(MEASUREMENT_IPMI_BATTERY)); + assert(ipmi_battery != NULL); + memset(ipmi_battery, 0, sizeof(MEASUREMENT_IPMI_BATTERY)); + ipmi_battery->batteryIdentifier = strdup(id); + evel_init_option_string(&ipmi_battery->batteryType); + evel_init_option_double(&ipmi_battery->batteryVoltageLevel); + + dlist_push_last(&ipmi->ipmi_battery, ipmi_battery); + + EVEL_EXIT(); + return ipmi_battery; +} + + +void evel_measurement_ipmi_battery_type_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BATTERY * ipmiBattery, + const char * const batteryType) +{ + + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmiBattery != NULL); + assert(batteryType != NULL); + evel_set_option_string(&ipmiBattery->batteryType, batteryType, "Battery type"); + EVEL_EXIT(); +} + + + +void evel_measurement_ipmi_battery_voltage_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_BATTERY * ipmiBattery, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmiBattery != NULL); + evel_set_option_double(&ipmiBattery->batteryVoltageLevel, val, "Battery Voltage Level"); + EVEL_EXIT(); +} + + + +MEASUREMENT_IPMI_FAN *evel_measurement_new_ipmi_fan_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_FAN * ipmi_fan = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_fan = malloc(sizeof(MEASUREMENT_IPMI_FAN)); + assert(ipmi_fan != NULL); + memset(ipmi_fan, 0, sizeof(MEASUREMENT_IPMI_FAN)); + ipmi_fan->fanIdentifier = strdup(id); + evel_init_option_double(&ipmi_fan->fanSpeed); + + dlist_push_last(&ipmi->ipmi_fan, ipmi_fan); + + EVEL_EXIT(); + return ipmi_fan; +} + + +void evel_measurement_ipmi_fan_speed_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_FAN * ipmiFan, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmiFan != NULL); + evel_set_option_double(&ipmiFan->fanSpeed, val, "Fan Speed"); + EVEL_EXIT(); +} + + + +MEASUREMENT_IPMI_HSBP *evel_measurement_new_ipmi_hsbp_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_HSBP * ipmi_hsbp = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_hsbp = malloc(sizeof(MEASUREMENT_IPMI_HSBP)); + assert(ipmi_hsbp != NULL); + memset(ipmi_hsbp, 0, sizeof(MEASUREMENT_IPMI_HSBP)); + ipmi_hsbp->hsbpIdentifier = strdup(id); + evel_init_option_double(&ipmi_hsbp->hsbpTemperature); + + dlist_push_last(&ipmi->ipmi_hsbp, ipmi_hsbp); + + EVEL_EXIT(); + return ipmi_hsbp; +} + + +void evel_measurement_ipmi_hsbp_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_HSBP * ipmiHsbp, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmiHsbp != NULL); + evel_set_option_double(&ipmiHsbp->hsbpTemperature, val, "HSBP Temperature"); + EVEL_EXIT(); +} + + +MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN *evel_measurement_new_ipmi_global_temp_add( + MEASUREMENT_IPMI * ipmi, + const char * const id) +{ + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN * global_temp = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + global_temp = malloc(sizeof(MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN)); + assert(global_temp != NULL); + memset(global_temp, 0, sizeof(MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN)); + global_temp->globalAggTempID = strdup(id); + evel_init_option_double(&global_temp->globalAggTempMargin); + + dlist_push_last(&ipmi->ipmi_global_agg_temp_margin, global_temp); + + EVEL_EXIT(); + return global_temp; +} + +void evel_measurement_ipmi_global_temp_margin_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN * ipmig_temp, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmig_temp != NULL); + evel_set_option_double(&ipmig_temp->globalAggTempMargin, val, "Global Aggregate Temperature Margin"); + EVEL_EXIT(); +} + + +MEASUREMENT_IPMI_NIC *evel_measurement_new_ipmi_nic_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_NIC * ipmi_nic = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_nic = malloc(sizeof(MEASUREMENT_IPMI_NIC)); + assert(ipmi_nic != NULL); + memset(ipmi_nic, 0, sizeof(MEASUREMENT_IPMI_NIC)); + ipmi_nic->nicIdentifier = strdup(id); + evel_init_option_double(&ipmi_nic->nicTemperature); + + dlist_push_last(&ipmi->ipmi_nic, ipmi_nic); + + EVEL_EXIT(); + return ipmi_nic; +} + + +void evel_measurement_ipmi_nic_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_NIC * ipminic, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipminic != NULL); + evel_set_option_double(&ipminic->nicTemperature, val, "NIC Temperature"); + EVEL_EXIT(); +} + + +MEASUREMENT_IPMI_POWER_SUPPLY *evel_measurement_new_ipmi_power_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_POWER_SUPPLY * ipmi_power = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_power = malloc(sizeof(MEASUREMENT_IPMI_POWER_SUPPLY)); + assert(ipmi_power != NULL); + memset(ipmi_power, 0, sizeof(MEASUREMENT_IPMI_POWER_SUPPLY)); + ipmi_power->powerSupplyIdentifier = strdup(id); + evel_init_option_double(&ipmi_power->powerSupplyInputPower); + evel_init_option_double(&ipmi_power->powerSupplyCurrentOutput); + evel_init_option_double(&ipmi_power->powerSupplyTemperature); + + dlist_push_last(&ipmi->ipmi_power, ipmi_power); + + EVEL_EXIT(); + return ipmi_power; +} + + +void evel_measurement_ipmi_power_inputpwr_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmipwr != NULL); + evel_set_option_double(&ipmipwr->powerSupplyInputPower, val, "Power Supply Input Power"); + EVEL_EXIT(); +} + + +void evel_measurement_ipmi_power_current_op_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmipwr != NULL); + evel_set_option_double(&ipmipwr->powerSupplyCurrentOutput, val, "Power Supply Current Output"); + EVEL_EXIT(); +} + + +void evel_measurement_ipmi_power_temp_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_POWER_SUPPLY * ipmipwr, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmipwr != NULL); + evel_set_option_double(&ipmipwr->powerSupplyTemperature, val, "Power Supply Temperature"); + EVEL_EXIT(); +} + + +MEASUREMENT_IPMI_PROCESSOR *evel_measurement_new_ipmi_processor_add( + MEASUREMENT_IPMI * ipmi, + char * id) +{ + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s", id); + ipmi_processor = malloc(sizeof(MEASUREMENT_IPMI_PROCESSOR)); + assert(ipmi_processor != NULL); + memset(ipmi_processor, 0, sizeof(MEASUREMENT_IPMI_PROCESSOR)); + ipmi_processor->processorIdentifier = strdup(id); + evel_init_option_double(&ipmi_processor->pprocessorThermalControl); + evel_init_option_double(&ipmi_processor->processorDtsThermalMargin); + + dlist_initialize(&ipmi_processor->processorDimmAggregateThermalMargin); + + dlist_push_last(&ipmi->ipmi_processor, ipmi_processor); + + EVEL_EXIT(); + return ipmi_processor; +} + + +void evel_measurement_ipmi_processor_theralCtrl_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmi_processor != NULL); + evel_set_option_double(&ipmi_processor->pprocessorThermalControl, val, "IO Module Temperature"); + EVEL_EXIT(); +} + + +void evel_measurement_ipmi_processor_theralMargin_set(MEASUREMENT_IPMI *ipmi, + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor, + const double val) +{ + EVEL_ENTER(); + assert(ipmi != NULL); + assert(ipmi_processor != NULL); + evel_set_option_double(&ipmi_processor->processorDtsThermalMargin, val, "Front Panel Temperature"); + EVEL_EXIT(); +} + +MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add( + MEASUREMENT_IPMI * ipmi, + MEASUREMENT_IPMI_PROCESSOR *ipmi_processor, + const char * const id, double therm_margin) +{ + MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * thermal_margin = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(ipmi != NULL); + assert(ipmi_processor != NULL); + assert(id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s, thermal_margin=%lf", id, thermal_margin); + thermal_margin = malloc(sizeof(MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM)); + assert(thermal_margin != NULL); + memset(thermal_margin, 0, sizeof(MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM)); + thermal_margin->MarginIdentifier = strdup(id); + thermal_margin->thermalMargin = therm_margin; + + dlist_push_last(&ipmi_processor->processorDimmAggregateThermalMargin, thermal_margin); + + EVEL_EXIT(); + return thermal_margin; +} + + +MEASUREMENT_LOAD * evel_measurement_new_loads_add( + EVENT_MEASUREMENT * measurement) +{ + MEASUREMENT_LOAD *load = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + load = malloc(sizeof(MEASUREMENT_LOAD)); + assert(load != NULL); + memset(load, 0, sizeof(MEASUREMENT_LOAD)); + + evel_init_option_double(&load->shortTerm); + evel_init_option_double(&load->midTerm); + evel_init_option_double(&load->longTerm); + + dlist_push_last(&measurement->loads, load); + + + EVEL_EXIT(); + return load; +} + + +void evel_measurement_load_shortTerm_set(MEASUREMENT_LOAD *load, + const double val) +{ + EVEL_ENTER(); + assert(load != NULL); + evel_set_option_double(&load->shortTerm, val, "shortTerm"); + EVEL_EXIT(); +} + +void evel_measurement_load_midTerm_set(MEASUREMENT_LOAD *load, + const double val) +{ + EVEL_ENTER(); + assert(load != NULL); + evel_set_option_double(&load->midTerm, val, "midTerm"); + EVEL_EXIT(); +} + +void evel_measurement_load_longTerm_set(MEASUREMENT_LOAD *load, + const double val) +{ + EVEL_ENTER(); + assert(load != NULL); + evel_set_option_double(&load->longTerm, val, "longTerm"); + EVEL_EXIT(); +} + +MEASUREMENT_PROCESS_STATS * evel_measurement_new_process_stats_add( + EVENT_MEASUREMENT * measurement, + const char * const processIdentifier ) +{ + MEASUREMENT_PROCESS_STATS *process_stat = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s Process State", processIdentifier); + process_stat = malloc(sizeof(MEASUREMENT_PROCESS_STATS)); + assert(process_stat != NULL); + memset(process_stat, 0, sizeof(MEASUREMENT_PROCESS_STATS)); + process_stat->processIdentifier = strdup(processIdentifier); + assert(process_stat->processIdentifier != NULL); + dlist_push_last(&measurement->process_stats, process_stat); + + evel_init_option_double(&process_stat->forkRate); + evel_init_option_double(&process_stat->psStateBlocked); + evel_init_option_double(&process_stat->psStatePaging); + evel_init_option_double(&process_stat->psStateRunning); + evel_init_option_double(&process_stat->psStateSleeping); + evel_init_option_double(&process_stat->psStateStopped); + evel_init_option_double(&process_stat->psStateZombie); + + EVEL_EXIT(); + return process_stat; +} + +void evel_measurement_process_stat_forkRate_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->forkRate, val, "forkRate"); + EVEL_EXIT(); +} + + + +void evel_measurement_process_stat_psStateBlocked_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStateBlocked, val, "psStateBlocked"); + EVEL_EXIT(); +} + +void evel_measurement_process_stat_psStatePaging_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStatePaging, val, "psStatePaging"); + EVEL_EXIT(); +} + + +void evel_measurement_process_stat_psStateRunning_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStateRunning, val, "psStateRunning"); + EVEL_EXIT(); +} + +void evel_measurement_process_stat_psStateSleeping_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStateSleeping, val, "psStateSleeping"); + EVEL_EXIT(); +} + + +void evel_measurement_process_stat_psStateStopped_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStateStopped, val, "psStateStopped"); + EVEL_EXIT(); +} + +void evel_measurement_process_stat_psStateZombie_set(MEASUREMENT_PROCESS_STATS *process_stat, + const double val) +{ + EVEL_ENTER(); + assert(process_stat != NULL); + evel_set_option_double(&process_stat->psStateZombie, val, "psStateZombie"); + EVEL_EXIT(); +} + +MACHINE_CHECK_EXCEPTION * evel_measurement_new_machine_check_exception_add( + EVENT_MEASUREMENT * measurement, + const char * const process_id ) +{ + MACHINE_CHECK_EXCEPTION *machine_check = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + assert(process_id != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s - machine check exception", process_id); + machine_check = malloc(sizeof(MACHINE_CHECK_EXCEPTION)); + assert(machine_check != NULL); + memset(machine_check, 0, sizeof(MACHINE_CHECK_EXCEPTION)); + machine_check->process_id = strdup(process_id); + assert(machine_check->process_id != NULL); + + evel_init_option_double(&machine_check->corrected_memory_errors); + evel_init_option_double(&machine_check->corrected_memory_errors_in_1Hr); + evel_init_option_double(&machine_check->uncorrected_memory_errors); + evel_init_option_double(&machine_check->uncorrected_memory_errors_in_1Hr); + + dlist_push_last(&measurement->machine_check_exception, machine_check); + + EVEL_EXIT(); + return machine_check; +} + +void evel_measurement_machine_check_cor_mem_err_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val) +{ + EVEL_ENTER(); + assert(machine_check != NULL); + evel_set_option_double(&machine_check->corrected_memory_errors, val, "corrected_memory_errors"); + EVEL_EXIT(); +} + + +void evel_measurement_machine_check_cor_mem_err_1hr_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val) +{ + EVEL_ENTER(); + assert(machine_check != NULL); + evel_set_option_double(&machine_check->corrected_memory_errors_in_1Hr, val, "corrected_memory_errors_in_1Hr"); + EVEL_EXIT(); +} + +void evel_measurement_machine_check_uncor_mem_err_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val) +{ + EVEL_ENTER(); + assert(machine_check != NULL); + evel_set_option_double(&machine_check->uncorrected_memory_errors, val, "uncorrected_memory_errors"); + EVEL_EXIT(); +} + +void evel_measurement_machine_check_uncor_mem_err_1hr_set(MACHINE_CHECK_EXCEPTION *machine_check, + const double val) +{ + EVEL_ENTER(); + assert(machine_check != NULL); + evel_set_option_double(&machine_check->uncorrected_memory_errors_in_1Hr, val, "uncorrected_memory_errors_in_1Hr"); + EVEL_EXIT(); +} + +MEASUREMENT_HUGE_PAGE * evel_measurement_new_huge_page_add( + EVENT_MEASUREMENT * measurement, + const char * const hugePagesIdentifier ) +{ + MEASUREMENT_HUGE_PAGE *huge_page = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(measurement != NULL); + assert(measurement->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + assert(hugePagesIdentifier != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding id=%s Huge Page", hugePagesIdentifier); + huge_page = malloc(sizeof(MEASUREMENT_HUGE_PAGE)); + assert(huge_page != NULL); + memset(huge_page, 0, sizeof(MEASUREMENT_HUGE_PAGE)); + huge_page->hugePagesIdentifier = strdup(hugePagesIdentifier); + assert(huge_page->hugePagesIdentifier != NULL); + + evel_init_option_double(&huge_page->bytesUsed); + evel_init_option_double(&huge_page->bytesFree); + evel_init_option_double(&huge_page->vmPageNumberUsed); + evel_init_option_double(&huge_page->vmPageNumberFree); + evel_init_option_double(&huge_page->percentUsed); + evel_init_option_double(&huge_page->percentFree); + + dlist_push_last(&measurement->huge_pages, huge_page); + + EVEL_EXIT(); + return huge_page; +} + +void evel_measurement_huge_page_bytesUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->bytesUsed, val, "bytesUsed"); + EVEL_EXIT(); +} + +void evel_measurement_huge_page_bytesFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->bytesFree, val, "bytesFree"); + EVEL_EXIT(); +} + + +void evel_measurement_huge_page_vmPageNumberUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->vmPageNumberUsed, val, "vmPageNumberUsed"); + EVEL_EXIT(); +} + + +void evel_measurement_huge_page_vmPageNumberFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->vmPageNumberFree, val, "vmPageNumberFree"); + EVEL_EXIT(); +} + + +void evel_measurement_huge_page_percentUsed_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->percentUsed, val, "percentUsed"); + EVEL_EXIT(); +} + + +void evel_measurement_huge_page_percentFree_set(MEASUREMENT_HUGE_PAGE *huge_page, + const double val) +{ + EVEL_ENTER(); + assert(huge_page != NULL); + evel_set_option_double(&huge_page->percentFree, val, "percentFree"); + EVEL_EXIT(); +} + +void evel_json_encode_ipmi(EVEL_JSON_BUFFER * jbuf, MEASUREMENT_IPMI * ipmi_entry) +{ + + DLIST_ITEM * item = NULL; + MEASUREMENT_IPMI_BB_TEMPERATURE * bb_temp = NULL; + MEASUREMENT_IPMI_BB_VOLTAGE * bb_volt = NULL; + MEASUREMENT_IPMI_BATTERY * ipmi_batt = NULL; + MEASUREMENT_IPMI_FAN * ipmi_fan = NULL; + MEASUREMENT_IPMI_HSBP * ipmi_hsbp = NULL; + MEASUREMENT_IPMI_NIC * ipmi_nic = NULL; + MEASUREMENT_IPMI_POWER_SUPPLY * ipmi_pwr = NULL; + MEASUREMENT_IPMI_PROCESSOR * ipmi_proc = NULL; + MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * dimm_therm = NULL; + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN * agg_temp = NULL; + DLIST_ITEM * item1 = NULL; + + EVEL_ENTER(); + assert(ipmi_entry != NULL); + + evel_enc_kv_opt_double(jbuf, "exitAirTemperature", &ipmi_entry->exitAirTemperature); + evel_enc_kv_opt_double(jbuf, "frontPanelTemperature", &ipmi_entry->frontPanelTemperature); + evel_enc_kv_opt_double(jbuf, "ioModuleTemperature", &ipmi_entry->ioModuleTemperature); + evel_enc_kv_opt_double(jbuf, "systemAirflow", &ipmi_entry->systemAirflow); + + /***************************************************************************/ + /* Baseboard Temperature */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiBaseboardTemperatureArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_base_board_temparature); + while (item != NULL) + { + bb_temp = (MEASUREMENT_IPMI_BB_TEMPERATURE *) item->item; + assert(bb_temp != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiBaseboardTemperatureArray", + bb_temp->BBTemperatureID)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "baseboardTemperatureIdentifier", bb_temp->BBTemperatureID); + evel_enc_kv_opt_double(jbuf, "baseboardTemperature", &bb_temp->BBTemperature); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Baseboard Voltage */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiBaseboardVoltageRegulatorArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_base_board_voltage); + while (item != NULL) + { + bb_volt = (MEASUREMENT_IPMI_BB_VOLTAGE *) item->item; + assert(bb_volt != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiBaseboardVoltageRegulatorArray", + bb_volt->BBVoltageRegID)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "baseboardVoltageRegulatorIdentifier", bb_volt->BBVoltageRegID); + evel_enc_kv_opt_double(jbuf, "voltageRegulatorTemperature", &bb_volt->voltageRegTemperature); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI Battery */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiBatteryArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_battery); + while (item != NULL) + { + ipmi_batt = (MEASUREMENT_IPMI_BATTERY *) item->item; + assert(ipmi_batt != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiBatteryArray", + ipmi_batt->batteryIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "batteryIdentifier", ipmi_batt->batteryIdentifier); + evel_enc_kv_opt_double(jbuf, "batteryVoltageLevel", &ipmi_batt->batteryVoltageLevel); + evel_enc_kv_opt_string(jbuf, "batteryType", &ipmi_batt->batteryType); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + + /***************************************************************************/ + /* IPMI Fan */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiFanArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_fan); + while (item != NULL) + { + ipmi_fan = (MEASUREMENT_IPMI_FAN *) item->item; + assert(ipmi_fan != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiFanArray", + ipmi_fan->fanIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "fanIdentifier", ipmi_fan->fanIdentifier); + evel_enc_kv_opt_double(jbuf, "fanSpeed", &ipmi_fan->fanSpeed); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI HSBP */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiHsbpArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_hsbp); + while (item != NULL) + { + ipmi_hsbp = (MEASUREMENT_IPMI_HSBP *) item->item; + assert(ipmi_hsbp != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiHsbpArray", + ipmi_hsbp->hsbpIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "hsbpIdentifier", ipmi_hsbp->hsbpIdentifier); + evel_enc_kv_opt_double(jbuf, "hsbpTemperature", &ipmi_hsbp->hsbpTemperature); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI Global Aggregate Temperature margin */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "globalAggregateTemperatureMarginArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_global_agg_temp_margin); + while (item != NULL) + { + agg_temp = (MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN *) item->item; + assert(agg_temp != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiGlobalAggregateTemperatureMarginArray", + agg_temp->globalAggTempID)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "globalAggregateTemperatureMarginIdentifier", agg_temp->globalAggTempID); + evel_enc_kv_opt_double(jbuf, "globalAggregateTemperatureMargin", &agg_temp->globalAggTempMargin); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI NIC */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiNicArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_nic); + while (item != NULL) + { + ipmi_nic = (MEASUREMENT_IPMI_NIC *) item->item; + assert(ipmi_nic != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiNicArray", + ipmi_nic->nicIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "nicIdentifier", ipmi_nic->nicIdentifier); + evel_enc_kv_opt_double(jbuf, "nicTemperature", &ipmi_nic->nicTemperature); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI Power */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiPowerSupplyArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_power); + while (item != NULL) + { + ipmi_pwr = (MEASUREMENT_IPMI_POWER_SUPPLY *) item->item; + assert(ipmi_pwr != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiPowerSupplyArray", + ipmi_pwr->powerSupplyIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "powerSupplyIdentifier", ipmi_pwr->powerSupplyIdentifier); + evel_enc_kv_opt_double(jbuf, "powerSupplyCurrentOutputPercent", &ipmi_pwr->powerSupplyCurrentOutput); + evel_enc_kv_opt_double(jbuf, "powerSupplyInputPower", &ipmi_pwr->powerSupplyInputPower); + evel_enc_kv_opt_double(jbuf, "powerSupplyTemperature", &ipmi_pwr->powerSupplyTemperature); + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* IPMI Processor */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "ipmiProcessorArray")) + { + bool item_added = false; + + item = dlist_get_first(&ipmi_entry->ipmi_processor); + while (item != NULL) + { + ipmi_proc = (MEASUREMENT_IPMI_PROCESSOR *) item->item; + assert(ipmi_proc != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "ipmiProcessorArray", + ipmi_proc->processorIdentifier)) + { + evel_json_open_object(jbuf); + + evel_enc_kv_string(jbuf, "processorIdentifier", ipmi_proc->processorIdentifier); + evel_enc_kv_opt_double(jbuf, "processorDtsThermalMargin", &ipmi_proc->processorDtsThermalMargin); + evel_enc_kv_opt_double(jbuf, "processorThermalControlPercent", &ipmi_proc->pprocessorThermalControl); + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "processorDimmAggregateThermalMarginArray")) + { + bool item1_added = false; + + item1 = dlist_get_first(&ipmi_proc->processorDimmAggregateThermalMargin); + while (item1 != NULL) + { + dimm_therm = (MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM *) item1->item; + assert(dimm_therm != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "processorDimmAggregateThermalMarginArray", + dimm_therm->MarginIdentifier)) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "processorDimmAggregateThermalMarginIdentifier", dimm_therm->MarginIdentifier); + evel_enc_kv_double(jbuf, "thermalMargin", dimm_therm->thermalMargin); + + evel_json_close_object(jbuf); + item1_added = true; + } + item1 = dlist_get_next(item1); + } + evel_json_close_list(jbuf); + + if (!item1_added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + EVEL_EXIT(); +} + +/**************************************************************************//** + * Encode the measurement as a JSON measurement. + * + * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into. + * @param event Pointer to the ::EVENT_HEADER to encode. + *****************************************************************************/ +void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, + EVENT_MEASUREMENT * event) +{ + MEASUREMENT_HUGE_PAGE * huge_page = NULL; + MEASUREMENT_CPU_USE * cpu_use = NULL; + MEASUREMENT_MEM_USE * mem_use = NULL; + MEASUREMENT_DISK_USE * disk_use = NULL; + MEASUREMENT_FSYS_USE * fsys_use = NULL; + MEASUREMENT_LATENCY_BUCKET * bucket = NULL; + MEASUREMENT_NIC_PERFORMANCE * nic_performance = NULL; + MEASUREMENT_CODEC_USE * codec_use = NULL; + MEASUREMENT_PROCESS_STATS * proc_stat = NULL; + MEASUREMENT_LOAD * load = NULL; + MACHINE_CHECK_EXCEPTION * machine_check = NULL; + MEASUREMENT_IPMI * ipmi_entry = NULL; + DLIST_ITEM * item = NULL; + DLIST_ITEM * other_field_item = NULL; + EVEL_JSON_OBJECT_INSTANCE * jsonobjinst = NULL; + EVEL_JSON_OBJECT * jsonobjp = NULL; + DLIST_ITEM * jsobj_field_item = NULL; + EVEL_INTERNAL_KEY * keyinst = NULL; + DLIST_ITEM * keyinst_field_item = NULL; + DLIST_ITEM * dlist_item = NULL; + HASHTABLE_T * ht; + ENTRY_T *entry; + char * state = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event != NULL); + assert(event->header.event_domain == EVEL_DOMAIN_MEASUREMENT); + + evel_json_encode_header(jbuf, &event->header); + evel_json_open_named_object(jbuf, "measurementFields"); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + evel_enc_kv_int(jbuf, "measurementInterval", event->measurement_interval); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + + /***************************************************************************/ + /* IPMI */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "ipmi")) + { + bool item_added = false; + + item = dlist_get_first(&event->ipmis); + while (item != NULL) + { + ipmi_entry = (MEASUREMENT_IPMI *) item->item; + assert(ipmi_entry != NULL); + + if (!evel_throttle_suppress_field(jbuf->throttle_spec, + "ipmi")) + { + // evel_json_open_object(jbuf); + evel_json_encode_ipmi(jbuf, ipmi_entry); + // evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Huge Page */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "hugePagesArray")) + { + bool item_added = false; + + item = dlist_get_first(&event->huge_pages); + while (item != NULL) + { + huge_page = (MEASUREMENT_HUGE_PAGE *) item->item; + assert(huge_page != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "hugePagesArray", + huge_page->hugePagesIdentifier)) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "hugePagesIdentifier", huge_page->hugePagesIdentifier); + evel_enc_kv_opt_double(jbuf, "bytesUsed", &huge_page->bytesUsed); + evel_enc_kv_opt_double(jbuf, "bytesFree", &huge_page->bytesFree); + evel_enc_kv_opt_double(jbuf, "vmPageNumberUsed", &huge_page->vmPageNumberUsed); + evel_enc_kv_opt_double(jbuf, "vmPageNumberFree", &huge_page->vmPageNumberFree); + evel_enc_kv_opt_double(jbuf, "percentUsed", &huge_page->bytesUsed); + evel_enc_kv_opt_double(jbuf, "percentFree", &huge_page->bytesUsed); + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Machine check exception */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "machineCheckExceptionArray")) + { + bool item_added = false; + + item = dlist_get_first(&event->machine_check_exception); + while (item != NULL) + { + machine_check = (MACHINE_CHECK_EXCEPTION *) item->item; + assert(machine_check != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "machineCheckExceptionArray", + machine_check->process_id)) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "vmIdentifier", machine_check->process_id); + evel_enc_kv_opt_double(jbuf, "correctedMemoryErrors", &machine_check->corrected_memory_errors); + evel_enc_kv_opt_double(jbuf, "correctedMemoryErrorsIn1Hr", &machine_check->corrected_memory_errors_in_1Hr); + evel_enc_kv_opt_double(jbuf, "uncorrectedMemoryErrors", &machine_check->uncorrected_memory_errors); + evel_enc_kv_opt_double(jbuf, "uncorrectedMemoryErrorsIn1Hr", &machine_check->uncorrected_memory_errors_in_1Hr); + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Loads */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "loadArray")) + { + bool item_added = false; + + item = dlist_get_first(&event->loads); + while (item != NULL) + { + load = (MEASUREMENT_LOAD *) item->item; + assert(load != NULL); + + if (!evel_throttle_suppress_field(jbuf->throttle_spec, + "loadArray")) + { + evel_json_open_object(jbuf); + evel_enc_kv_opt_double(jbuf, "shortTerm", &load->shortTerm); + evel_enc_kv_opt_double(jbuf, "midTerm", &load->midTerm); + evel_enc_kv_opt_double(jbuf, "longTerm", &load->longTerm); + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + /***************************************************************************/ + /* Process stats */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "processStatsArray")) + { + bool item_added = false; + + item = dlist_get_first(&event->process_stats); + while (item != NULL) + { + proc_stat = (MEASUREMENT_PROCESS_STATS *) item->item; + assert(proc_stat != NULL); + + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "processStatsArray", + proc_stat->processIdentifier)) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "processIdentifier", proc_stat->processIdentifier); + evel_enc_kv_opt_double(jbuf, "forkRate", &proc_stat->forkRate); + evel_enc_kv_opt_double(jbuf, "psStateBlocked", &proc_stat->psStateBlocked); + evel_enc_kv_opt_double(jbuf, "psStatePaging", &proc_stat->psStatePaging); + evel_enc_kv_opt_double(jbuf, "psStateRunning", &proc_stat->psStateRunning); + evel_enc_kv_opt_double(jbuf, "psStateSleeping", &proc_stat->psStateSleeping); + evel_enc_kv_opt_double(jbuf, "psStateStopped", &proc_stat->psStateStopped); + evel_enc_kv_opt_double(jbuf, "psStateZombie", &proc_stat->psStateZombie); + evel_json_close_object(jbuf); + item_added = true; + } + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + // additional fields + evel_json_checkpoint(jbuf); + ht = event->additional_info; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding additionalFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + + evel_json_checkpoint(jbuf); + if(evel_json_open_opt_named_list(jbuf, "additionalObjects")) + { + bool item_added = false; + other_field_item = dlist_get_first(&event->additional_objects); + while (other_field_item != NULL) + { + jsonobjp = (EVEL_JSON_OBJECT *) other_field_item->item; + if(jsonobjp != NULL) + { + evel_json_open_object(jbuf); + + if( evel_json_open_opt_named_list(jbuf, "objectInstances")) + { + bool item_added2 = false; + jsobj_field_item = dlist_get_first(&jsonobjp->jsonobjectinstances); + while (jsobj_field_item != NULL) + { + jsonobjinst = (EVEL_JSON_OBJECT_INSTANCE *) jsobj_field_item->item; + if( jsonobjinst != NULL ) + { + evel_json_open_object(jbuf); + evel_enc_kv_object(jbuf, "objectInstance", jsonobjinst->jsonstring); + evel_enc_kv_opt_ull(jbuf, "objectInstanceEpochMicrosec", &jsonobjinst->objinst_epoch_microsec); + //evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "objectKeys")) + { +// bool item_added3 = false; + + keyinst_field_item = dlist_get_first(&jsonobjinst->object_keys); + while (keyinst_field_item != NULL) + { + keyinst = (EVEL_INTERNAL_KEY *)keyinst_field_item->item; + if(keyinst != NULL) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "keyName", keyinst->keyname); + evel_enc_kv_opt_int(jbuf, "keyOrder", &keyinst->keyorder); + evel_enc_kv_opt_string(jbuf, "keyValue", &keyinst->keyvalue); + evel_json_close_object(jbuf); +// item_added3 = true; + } + keyinst_field_item = dlist_get_next(keyinst_field_item); + } + evel_json_close_list(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + //if (!item_added3) + //{ + // evel_json_rewind(jbuf); + //} + } + evel_json_close_object(jbuf); + } + item_added2 = true; + jsobj_field_item = dlist_get_next(jsobj_field_item); + } + evel_json_close_list(jbuf); + if( !item_added2 ) + { + evel_json_rewind(jbuf); + } + } + + evel_enc_kv_string(jbuf, "objectName", jsonobjp->object_name); + evel_enc_kv_opt_string(jbuf, "objectSchema", &jsonobjp->objectschema); + evel_enc_kv_opt_string(jbuf, "objectSchemaUrl", &jsonobjp->objectschemaurl); + evel_enc_kv_opt_string(jbuf, "nfSubscribedObjectName", &jsonobjp->nfsubscribedobjname); + evel_enc_kv_opt_string(jbuf, "nfSubscriptionId", &jsonobjp->nfsubscriptionid); + evel_json_close_object(jbuf); + item_added = true; + } + other_field_item = dlist_get_next(other_field_item); + } + evel_json_close_list(jbuf); + + if (!item_added) + { + evel_json_rewind(jbuf); + } + } + + + // additional json objects + evel_enc_kv_opt_int(jbuf, "concurrentSessions", &event->concurrent_sessions); + evel_enc_kv_opt_int(jbuf, "configuredEntities", &event->configured_entities); + + /***************************************************************************/ + /* CPU Use list. */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_list(jbuf, "cpuUsageArray")) + { + bool item_added = false; + + item = dlist_get_first(&event->cpu_usage); + while (item != NULL) + { + cpu_use = (MEASUREMENT_CPU_USE*) item->item; assert(cpu_use != NULL); if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, @@ -3111,6 +5262,13 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_double(jbuf, "cpuUsageUser", &cpu_use->user); evel_enc_kv_opt_double(jbuf, "cpuWait", &cpu_use->wait); evel_enc_kv_double(jbuf, "percentUsage",cpu_use->usage); + evel_enc_kv_opt_double(jbuf, "cpuCapacityContention", &cpu_use->cpuCapacityContention); + evel_enc_kv_opt_double(jbuf, "cpuDemandAvg", &cpu_use->cpuDemandAvg); + evel_enc_kv_opt_double(jbuf, "cpuDemandMhz", &cpu_use->cpuDemandMhz); + evel_enc_kv_opt_double(jbuf, "cpuDemandPct", &cpu_use->cpuDemandPct); + evel_enc_kv_opt_double(jbuf, "cpuLatencyAvg", &cpu_use->cpuLatencyAvg); + evel_enc_kv_opt_double(jbuf, "cpuOverheadAvg", &cpu_use->cpuOverheadAvg); + evel_enc_kv_opt_double(jbuf, "cpuSwapWaitTime", &cpu_use->cpuSwapWaitTime); evel_json_close_object(jbuf); item_added = true; } @@ -3188,6 +5346,20 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_double(jbuf, "diskTimeWriteLast", &disk_use->timewritelast); evel_enc_kv_opt_double(jbuf, "diskTimeWriteMax", &disk_use->timewritemax); evel_enc_kv_opt_double(jbuf, "diskTimeWriteMin", &disk_use->timewritemin); + evel_enc_kv_opt_double(jbuf, "diskBusResets", &disk_use->diskBusResets); + evel_enc_kv_opt_double(jbuf, "diskCommandsAborted", &disk_use->diskCommandsAborted); + evel_enc_kv_opt_double(jbuf, "diskTime", &disk_use->diskTime); + evel_enc_kv_opt_double(jbuf, "diskFlushRequests", &disk_use->diskFlushRequests); + evel_enc_kv_opt_double(jbuf, "diskFlushTime", &disk_use->diskFlushTime); + evel_enc_kv_opt_double(jbuf, "diskCommandsAvg", &disk_use->diskCommandsAvg); + evel_enc_kv_opt_double(jbuf, "diskReadCommandsAvg", &disk_use->diskReadCommandsAvg); + evel_enc_kv_opt_double(jbuf, "diskWriteCommandsAvg", &disk_use->diskWriteCommandsAvg); + evel_enc_kv_opt_double(jbuf, "diskTotalReadLatencyAvg", &disk_use->diskTotalReadLatencyAvg); + evel_enc_kv_opt_double(jbuf, "diskTotalWriteLatencyAvg", &disk_use->diskTotalWriteLatencyAvg); + evel_enc_kv_opt_double(jbuf, "diskWeightedIoTimeAvg", &disk_use->diskWeightedIoTimeAvg); + evel_enc_kv_opt_double(jbuf, "diskWeightedIoTimeLast", &disk_use->diskWeightedIoTimeLast); + evel_enc_kv_opt_double(jbuf, "diskWeightedIoTimeMax", &disk_use->diskWeightedIoTimeMax); + evel_enc_kv_opt_double(jbuf, "diskWeightedIoTimeMin", &disk_use->diskWeightedIoTimeMin); evel_json_close_object(jbuf); item_added = true; } @@ -3274,93 +5446,125 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_double( jbuf, "meanRequestLatency", &event->mean_request_latency); - evel_enc_kv_opt_int(jbuf, "requestRate", &event->request_rate); + evel_enc_kv_opt_double(jbuf, "requestRate", &event->request_rate); /***************************************************************************/ - /* vNIC Usage TBD Performance array */ + /* NIC Usage TBD Performance array */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "vNicUsageArray")) + if (evel_json_open_opt_named_list(jbuf, "nicPerformanceArray")) { bool item_added = false; - item = dlist_get_first(&event->vnic_usage); + item = dlist_get_first(&event->nic_performance); while (item != NULL) { - vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *) item->item; - assert(vnic_performance != NULL); + nic_performance = (MEASUREMENT_NIC_PERFORMANCE *) item->item; + assert(nic_performance != NULL); if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "vNicPerformanceArray", - vnic_performance->vnic_id)) + "nicPerformanceArray", + nic_performance->nic_id)) { evel_json_open_object(jbuf); /*********************************************************************/ /* Optional fields. */ /*********************************************************************/ + state = evel_entity_opt_op_state(&nic_performance->administrativeState); + if (state != NULL) + { + evel_enc_kv_string(jbuf, "administrativeState", state); + } + state = evel_entity_opt_op_state(&nic_performance->operationalState); + if (state != NULL) + { + evel_enc_kv_string(jbuf, "operationalState", state); + } + + evel_enc_kv_opt_double( jbuf, + "receivedPercentDiscard", &nic_performance->receivedPercentDiscard); + + evel_enc_kv_opt_double( jbuf, + "receivedPercentError", &nic_performance->receivedPercentError); + + evel_enc_kv_opt_double( jbuf, + "receivedUtilization", &nic_performance->receivedUtilization); + + evel_enc_kv_opt_double( jbuf, + "speed", &nic_performance->speed); + + evel_enc_kv_opt_double( jbuf, + "transmittedPercentDiscard", &nic_performance->transmittedPercentDiscard); + + evel_enc_kv_opt_double( jbuf, + "transmittedPercentError", &nic_performance->transmittedPercentError); + + evel_enc_kv_opt_double( jbuf, + "transmittedUtilization", &nic_performance->transmittedUtilization); + evel_enc_kv_opt_double( jbuf, - "receivedBroadcastPacketsAccumulated", &vnic_performance->recvd_bcast_packets_acc); + "receivedBroadcastPacketsAccumulated", &nic_performance->recvd_bcast_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedBroadcastPacketsDelta", &vnic_performance->recvd_bcast_packets_delta); + "receivedBroadcastPacketsDelta", &nic_performance->recvd_bcast_packets_delta); evel_enc_kv_opt_double( jbuf, - "receivedDiscardedPacketsAccumulated", &vnic_performance->recvd_discarded_packets_acc); + "receivedDiscardedPacketsAccumulated", &nic_performance->recvd_discarded_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedDiscardedPacketsDelta", &vnic_performance->recvd_discarded_packets_delta); + "receivedDiscardedPacketsDelta", &nic_performance->recvd_discarded_packets_delta); evel_enc_kv_opt_double( jbuf, - "receivedErrorPacketsAccumulated", &vnic_performance->recvd_error_packets_acc); + "receivedErrorPacketsAccumulated", &nic_performance->recvd_error_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedErrorPacketsDelta", &vnic_performance->recvd_error_packets_delta); + "receivedErrorPacketsDelta", &nic_performance->recvd_error_packets_delta); evel_enc_kv_opt_double( jbuf, - "receivedMulticastPacketsAccumulated", &vnic_performance->recvd_mcast_packets_acc); + "receivedMulticastPacketsAccumulated", &nic_performance->recvd_mcast_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedMulticastPacketsDelta", &vnic_performance->recvd_mcast_packets_delta); + "receivedMulticastPacketsDelta", &nic_performance->recvd_mcast_packets_delta); evel_enc_kv_opt_double( jbuf, - "receivedOctetsAccumulated", &vnic_performance->recvd_octets_acc); + "receivedOctetsAccumulated", &nic_performance->recvd_octets_acc); evel_enc_kv_opt_double( jbuf, - "receivedOctetsDelta", &vnic_performance->recvd_octets_delta); + "receivedOctetsDelta", &nic_performance->recvd_octets_delta); evel_enc_kv_opt_double( jbuf, - "receivedTotalPacketsAccumulated", &vnic_performance->recvd_total_packets_acc); + "receivedTotalPacketsAccumulated", &nic_performance->recvd_total_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedTotalPacketsDelta", &vnic_performance->recvd_total_packets_delta); + "receivedTotalPacketsDelta", &nic_performance->recvd_total_packets_delta); evel_enc_kv_opt_double( jbuf, - "receivedUnicastPacketsAccumulated", &vnic_performance->recvd_ucast_packets_acc); + "receivedUnicastPacketsAccumulated", &nic_performance->recvd_ucast_packets_acc); evel_enc_kv_opt_double( jbuf, - "receivedUnicastPacketsDelta", &vnic_performance->recvd_ucast_packets_delta); + "receivedUnicastPacketsDelta", &nic_performance->recvd_ucast_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedBroadcastPacketsAccumulated", &vnic_performance->tx_bcast_packets_acc); + "transmittedBroadcastPacketsAccumulated", &nic_performance->tx_bcast_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedBroadcastPacketsDelta", &vnic_performance->tx_bcast_packets_delta); + "transmittedBroadcastPacketsDelta", &nic_performance->tx_bcast_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedDiscardedPacketsAccumulated", &vnic_performance->tx_discarded_packets_acc); + "transmittedDiscardedPacketsAccumulated", &nic_performance->tx_discarded_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedDiscardedPacketsDelta", &vnic_performance->tx_discarded_packets_delta); + "transmittedDiscardedPacketsDelta", &nic_performance->tx_discarded_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedErrorPacketsAccumulated", &vnic_performance->tx_error_packets_acc); + "transmittedErrorPacketsAccumulated", &nic_performance->tx_error_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedErrorPacketsDelta", &vnic_performance->tx_error_packets_delta); + "transmittedErrorPacketsDelta", &nic_performance->tx_error_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedMulticastPacketsAccumulated", &vnic_performance->tx_mcast_packets_acc); + "transmittedMulticastPacketsAccumulated", &nic_performance->tx_mcast_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedMulticastPacketsDelta", &vnic_performance->tx_mcast_packets_delta); + "transmittedMulticastPacketsDelta", &nic_performance->tx_mcast_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedOctetsAccumulated", &vnic_performance->tx_octets_acc); + "transmittedOctetsAccumulated", &nic_performance->tx_octets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedOctetsDelta", &vnic_performance->tx_octets_delta); + "transmittedOctetsDelta", &nic_performance->tx_octets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedTotalPacketsAccumulated", &vnic_performance->tx_total_packets_acc); + "transmittedTotalPacketsAccumulated", &nic_performance->tx_total_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedTotalPacketsDelta", &vnic_performance->tx_total_packets_delta); + "transmittedTotalPacketsDelta", &nic_performance->tx_total_packets_delta); evel_enc_kv_opt_double( jbuf, - "transmittedUnicastPacketsAccumulated", &vnic_performance->tx_ucast_packets_acc); + "transmittedUnicastPacketsAccumulated", &nic_performance->tx_ucast_packets_acc); evel_enc_kv_opt_double( jbuf, - "transmittedUnicastPacketsDelta", &vnic_performance->tx_ucast_packets_delta); + "transmittedUnicastPacketsDelta", &nic_performance->tx_ucast_packets_delta); /*********************************************************************/ /* Mandatory fields. */ /*********************************************************************/ - evel_enc_kv_string(jbuf, "valuesAreSuspect", vnic_performance->valuesaresuspect); - evel_enc_kv_string(jbuf, "vNicIdentifier", vnic_performance->vnic_id); + evel_enc_kv_string(jbuf, "valuesAreSuspect", nic_performance->valuesaresuspect); + evel_enc_kv_string(jbuf, "nicIdentifier", nic_performance->nic_id); evel_json_close_object(jbuf); item_added = true; @@ -3381,7 +5585,7 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, /***************************************************************************/ - /* Memory Use list. */ + /* Memory Use list. */ /***************************************************************************/ evel_json_checkpoint(jbuf); if (evel_json_open_opt_named_list(jbuf, "memoryUsageArray")) @@ -3396,17 +5600,27 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, "memoryUsageArray", - mem_use->id)) + mem_use->vmid)) { evel_json_open_object(jbuf); - evel_enc_kv_double(jbuf, "memoryBuffered", mem_use->membuffsz); + evel_enc_kv_opt_double(jbuf, "memoryBuffered", &mem_use->membuffsz); evel_enc_kv_opt_double(jbuf, "memoryCached", &mem_use->memcache); evel_enc_kv_opt_double(jbuf, "memoryConfigured", &mem_use->memconfig); - evel_enc_kv_opt_double(jbuf, "memoryFree", &mem_use->memfree); + evel_enc_kv_double(jbuf, "memoryFree", mem_use->memfree); evel_enc_kv_opt_double(jbuf, "memorySlabRecl", &mem_use->slabrecl); evel_enc_kv_opt_double(jbuf, "memorySlabUnrecl", &mem_use->slabunrecl); - evel_enc_kv_opt_double(jbuf, "memoryUsed", &mem_use->memused); - evel_enc_kv_string(jbuf, "vmIdentifier", mem_use->id); + evel_enc_kv_double(jbuf, "memoryUsed", mem_use->memused); + evel_enc_kv_string(jbuf, "vmIdentifier", mem_use->vmid); + evel_enc_kv_opt_double(jbuf, "memoryDemand", &mem_use->memoryDemand); + evel_enc_kv_opt_double(jbuf, "memoryLatencyAvg", &mem_use->memoryLatencyAvg); + evel_enc_kv_opt_double(jbuf, "memorySharedAvg", &mem_use->memorySharedAvg); + evel_enc_kv_opt_double(jbuf, "memorySwapInAvg", &mem_use->memorySwapInAvg); + evel_enc_kv_opt_double(jbuf, "memorySwapInRateAvg", &mem_use->memorySwapInRateAvg); + evel_enc_kv_opt_double(jbuf, "memorySwapOutAvg", &mem_use->memorySwapOutAvg); + evel_enc_kv_opt_double(jbuf, "memorySwapOutRateAvg", &mem_use->memorySwapOutRateAvg); + evel_enc_kv_opt_double(jbuf, "memorySwapUsedAvg", &mem_use->memorySwapUsedAvg); + evel_enc_kv_opt_double(jbuf, "percentMemoryUsage", &mem_use->percentMemoryUsage); + evel_json_close_object(jbuf); item_added = true; } @@ -3427,55 +5641,52 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_int( jbuf, "numberOfMediaPortsInUse", &event->media_ports_in_use); evel_enc_kv_opt_int( - jbuf, "vnfcScalingMetric", &event->vnfc_scaling_metric); - - /***************************************************************************/ - /* Errors list. */ - /***************************************************************************/ - if ((event->errors != NULL) && - evel_json_open_opt_named_object(jbuf, "errors")) - { - errors = event->errors; - evel_enc_kv_int(jbuf, "receiveDiscards", errors->receive_discards); - evel_enc_kv_int(jbuf, "receiveErrors", errors->receive_errors); - evel_enc_kv_int(jbuf, "transmitDiscards", errors->transmit_discards); - evel_enc_kv_int(jbuf, "transmitErrors", errors->transmit_errors); - evel_json_close_object(jbuf); - } + jbuf, "nfcScalingMetric", &event->vnfc_scaling_metric); /***************************************************************************/ /* Feature Utilization list. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "featureUsageArray")) + ht = event->feature_usage; + if( ht != NULL ) { - bool item_added = false; - - item = dlist_get_first(&event->feature_usage); - while (item != NULL) + bool added = false; + if( ht->size > 0) { - feature_use = (MEASUREMENT_FEATURE_USE*) item->item; - assert(feature_use != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "featureUsageArray", - feature_use->feature_id)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "featureUsageArray")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "featureIdentifier", feature_use->feature_id); - evel_enc_kv_int( - jbuf, "featureUtilization", feature_use->feature_utilization); - evel_json_close_object(jbuf); - item_added = true; + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding feature usage %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "featureUsageArray", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - item = dlist_get_next(item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ /*************************************************************************/ - if (!item_added) + if (!added) { evel_json_rewind(jbuf); } @@ -3521,52 +5732,67 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, /***************************************************************************/ /* Additional Measurement Groups list. */ /***************************************************************************/ + /***************************************************************************/ + /* Checkpoint, so that we can wind back if all fields are suppressed. */ + /***************************************************************************/ evel_json_checkpoint(jbuf); if (evel_json_open_opt_named_list(jbuf, "additionalMeasurements")) { - bool item_added = false; + bool added_array = false; - item = dlist_get_first(&event->additional_measurements); - while (item != NULL) + dlist_item = dlist_get_first(&event->additional_measurements); + while (dlist_item != NULL) { - measurement_group = (MEASUREMENT_GROUP *) item->item; - assert(measurement_group != NULL); + bool added = false; + ht = (HASHTABLE_T *) dlist_item->item; + assert(ht != NULL); - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalMeasurements", - measurement_group->name)) + if((ht->size > 0) && (ht-> n > 0)) { + evel_json_checkpoint(jbuf); evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", measurement_group->name); - evel_json_open_opt_named_list(jbuf, "arrayOfFields"); + evel_enc_kv_string(jbuf, "name", ht->hmName); - /*********************************************************************/ - /* Measurements list. */ - /*********************************************************************/ - nested_item = dlist_get_first(&measurement_group->measurements); - while (nested_item != NULL) + if (evel_json_open_opt_named_object(jbuf, "hashMap")) { - custom_measurement = (CUSTOM_MEASUREMENT *) nested_item->item; - assert(custom_measurement != NULL); - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", custom_measurement->name); - evel_enc_kv_string(jbuf, "value", custom_measurement->value); + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding additional measurements %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + ht->hmName, + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + added_array = true; + } + entry = entry->next; + } + } evel_json_close_object(jbuf); - nested_item = dlist_get_next(nested_item); + if (!added) + { + evel_json_rewind(jbuf); + } } - evel_json_close_list(jbuf); evel_json_close_object(jbuf); - item_added = true; } - item = dlist_get_next(item); + dlist_item = dlist_get_next(dlist_item); } evel_json_close_list(jbuf); - /*************************************************************************/ - /* If we've not written anything, rewind to before we opened the list. */ - /*************************************************************************/ - if (!item_added) + if (!added_array) { evel_json_rewind(jbuf); } @@ -3577,13 +5803,131 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, /* closes the object, too. */ /***************************************************************************/ evel_enc_version(jbuf, - "measurementsForVfScalingVersion", + "measurementFieldsVersion", event->major_version, event->minor_version); evel_json_close_object(jbuf); EVEL_EXIT(); } +void evel_measurement_free_ipmi_processor(MEASUREMENT_IPMI_PROCESSOR * ipmi_processor) +{ + + MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * proc_dimm_therm = NULL; + + EVEL_ENTER(); + + free(ipmi_processor->processorIdentifier); + + proc_dimm_therm = dlist_pop_last(&ipmi_processor->processorDimmAggregateThermalMargin); + while (proc_dimm_therm != NULL) + { + EVEL_DEBUG("Freeing IPMI proc dimm therm Info (%s)", proc_dimm_therm->MarginIdentifier); + free(proc_dimm_therm->MarginIdentifier); + free(proc_dimm_therm); + proc_dimm_therm = dlist_pop_last(&ipmi_processor->processorDimmAggregateThermalMargin); + } + + EVEL_EXIT(); +} + +void evel_measurement_free_ipmi(MEASUREMENT_IPMI * ipmi) +{ + MEASUREMENT_IPMI_BB_TEMPERATURE * bb_temp = NULL; + MEASUREMENT_IPMI_BB_VOLTAGE * bb_volt = NULL; + MEASUREMENT_IPMI_BATTERY * ipmi_battery = NULL; + MEASUREMENT_IPMI_FAN * ipmi_fan = NULL; + MEASUREMENT_IPMI_HSBP * ipmi_hsbp = NULL; + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN * ipmi_tempMargin = NULL; + MEASUREMENT_IPMI_NIC * ipmi_nic = NULL; + MEASUREMENT_IPMI_POWER_SUPPLY * ipmi_power = NULL; + MEASUREMENT_IPMI_PROCESSOR * ipmi_processor = NULL; + + EVEL_ENTER(); + + bb_temp = dlist_pop_last(&ipmi->ipmi_base_board_temparature); + while (bb_temp != NULL) + { + EVEL_DEBUG("Freeing base board temp Info (%s)", bb_temp->BBTemperatureID); + free(bb_temp->BBTemperatureID); + free(bb_temp); + bb_temp = dlist_pop_last(&ipmi->ipmi_base_board_temparature); + } + + bb_volt = dlist_pop_last(&ipmi->ipmi_base_board_voltage); + while (bb_volt != NULL) + { + EVEL_DEBUG("Freeing IPMI FAN Info (%s)", bb_volt->BBVoltageRegID); + free(bb_volt->BBVoltageRegID); + free(bb_volt); + bb_volt = dlist_pop_last(&ipmi->ipmi_base_board_voltage); + } + + ipmi_battery = dlist_pop_last(&ipmi->ipmi_battery); + while (ipmi_battery != NULL) + { + EVEL_DEBUG("Freeing IPMI Battery Info (%s)", ipmi_battery->batteryIdentifier); + free(ipmi_battery->batteryIdentifier); + free(ipmi_battery); + ipmi_battery = dlist_pop_last(&ipmi->ipmi_battery); + } + + ipmi_fan = dlist_pop_last(&ipmi->ipmi_fan); + while (ipmi_fan != NULL) + { + EVEL_DEBUG("Freeing IPMI FAN Info (%s)", ipmi_fan->fanIdentifier); + free(ipmi_fan->fanIdentifier); + free(ipmi_fan); + ipmi_fan = dlist_pop_last(&ipmi->ipmi_fan); + } + + ipmi_hsbp = dlist_pop_last(&ipmi->ipmi_hsbp); + while (ipmi_hsbp != NULL) + { + EVEL_DEBUG("Freeing IPMI HSBP Info (%s)", ipmi_hsbp->hsbpIdentifier); + free(ipmi_hsbp->hsbpIdentifier); + free(ipmi_hsbp); + ipmi_hsbp = dlist_pop_last(&ipmi->ipmi_hsbp); + } + + ipmi_tempMargin = dlist_pop_last(&ipmi->ipmi_global_agg_temp_margin); + while (ipmi_tempMargin != NULL) + { + EVEL_DEBUG("Freeing IPMI Global AGG Temp margin info (%s)", ipmi_tempMargin->globalAggTempID); + free(ipmi_tempMargin->globalAggTempID); + free(ipmi_tempMargin); + ipmi_tempMargin = dlist_pop_last(&ipmi->ipmi_global_agg_temp_margin); + } + + ipmi_nic = dlist_pop_last(&ipmi->ipmi_nic); + while (ipmi_nic != NULL) + { + EVEL_DEBUG("Freeing IPMI NIC Info (%s)", ipmi_nic->nicIdentifier); + free(ipmi_nic->nicIdentifier); + free(ipmi_nic); + ipmi_nic = dlist_pop_last(&ipmi->ipmi_nic); + } + + ipmi_power = dlist_pop_last(&ipmi->ipmi_power); + while (ipmi_power != NULL) + { + EVEL_DEBUG("Freeing IPMI Power Info (%s)", ipmi_power->powerSupplyIdentifier); + free(ipmi_power->powerSupplyIdentifier); + free(ipmi_power); + ipmi_power = dlist_pop_last(&ipmi->ipmi_power); + } + + ipmi_processor = dlist_pop_last(&ipmi->ipmi_processor); + while (ipmi_processor != NULL) + { + EVEL_DEBUG("Freeing IPMI Processor Info (%s)", ipmi_processor->processorIdentifier); + evel_measurement_free_ipmi_processor(ipmi_processor); + free(ipmi_processor); + ipmi_processor = dlist_pop_last(&ipmi->ipmi_processor); + } + + EVEL_EXIT(); +} /**************************************************************************//** * Free a Measurement. @@ -3596,17 +5940,20 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_measurement(EVENT_MEASUREMENT * event) { + MEASUREMENT_HUGE_PAGE * huge_page = NULL; MEASUREMENT_CPU_USE * cpu_use = NULL; MEASUREMENT_DISK_USE * disk_use = NULL; MEASUREMENT_FSYS_USE * fsys_use = NULL; MEASUREMENT_LATENCY_BUCKET * bucket = NULL; MEASUREMENT_MEM_USE * mem_use = NULL; - MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; - MEASUREMENT_FEATURE_USE * feature_use = NULL; + MEASUREMENT_NIC_PERFORMANCE * nic_performance = NULL; MEASUREMENT_CODEC_USE * codec_use = NULL; - MEASUREMENT_GROUP * measurement_group = NULL; - CUSTOM_MEASUREMENT * measurement = NULL; - OTHER_FIELD *addl_info = NULL; + MEASUREMENT_LOAD * load = NULL; + MEASUREMENT_PROCESS_STATS * proc_stat = NULL; + MEASUREMENT_IPMI * ipmi = NULL; + MACHINE_CHECK_EXCEPTION * machine_check = NULL; + EVEL_JSON_OBJECT * jsonobjp = NULL; + HASHTABLE_T *ht; EVEL_ENTER(); @@ -3620,19 +5967,19 @@ void evel_free_measurement(EVENT_MEASUREMENT * event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - addl_info = dlist_pop_last(&event->additional_info); - while (addl_info != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Info (%s, %s)", - addl_info->name, - addl_info->value); - free(addl_info->name); - free(addl_info->value); - free(addl_info); - addl_info = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } - + jsonobjp = dlist_pop_last(&event->additional_objects); + while (jsonobjp != NULL) + { + EVEL_DEBUG("Freeing jsonObject %p",jsonobjp); + evel_free_jsonobject( jsonobjp ); + jsonobjp = dlist_pop_last(&event->additional_objects); + } cpu_use = dlist_pop_last(&event->cpu_usage); while (cpu_use != NULL) @@ -3642,6 +5989,7 @@ void evel_free_measurement(EVENT_MEASUREMENT * event) free(cpu_use); cpu_use = dlist_pop_last(&event->cpu_usage); } + disk_use = dlist_pop_last(&event->disk_usage); while (disk_use != NULL) { @@ -3650,11 +5998,11 @@ void evel_free_measurement(EVENT_MEASUREMENT * event) free(disk_use); disk_use = dlist_pop_last(&event->disk_usage); } + mem_use = dlist_pop_last(&event->mem_usage); while (mem_use != NULL) { - EVEL_DEBUG("Freeing Memory use Info (%s)", mem_use->id); - free(mem_use->id); + EVEL_DEBUG("Freeing Memory use Info - (%s)", mem_use->vmid); free(mem_use->vmid); free(mem_use); mem_use = dlist_pop_last(&event->mem_usage); @@ -3677,13 +6025,22 @@ void evel_free_measurement(EVENT_MEASUREMENT * event) bucket = dlist_pop_last(&event->latency_distribution); } - vnic_performance = dlist_pop_last(&event->vnic_usage); - while (vnic_performance != NULL) + nic_performance = dlist_pop_last(&event->nic_performance); + while (nic_performance != NULL) + { + EVEL_DEBUG("Freeing NIC performance Info (%s)", nic_performance->nic_id); + evel_measurement_free_nic_performance(nic_performance); + free(nic_performance); + nic_performance = dlist_pop_last(&event->nic_performance); + } + + ipmi = dlist_pop_last(&event->ipmis); + while (ipmi != NULL) { - EVEL_DEBUG("Freeing vNIC performance Info (%s)", vnic_performance->vnic_id); - evel_measurement_free_vnic_performance(vnic_performance); - free(vnic_performance); - vnic_performance = dlist_pop_last(&event->vnic_usage); + EVEL_DEBUG("Freeing IPMI"); + evel_measurement_free_ipmi(ipmi); + free(ipmi); + ipmi = dlist_pop_last(&event->ipmis); } codec_use = dlist_pop_last(&event->codec_usage); @@ -3695,38 +6052,54 @@ void evel_free_measurement(EVENT_MEASUREMENT * event) codec_use = dlist_pop_last(&event->codec_usage); } - if (event->errors != NULL) + proc_stat = dlist_pop_last(&event->process_stats); + while (proc_stat != NULL) { - EVEL_DEBUG("Freeing Errors"); - free(event->errors); + EVEL_DEBUG("Freeing Process Stats Info (%s)", proc_stat->processIdentifier); + free(proc_stat->processIdentifier); + free(proc_stat); + proc_stat = dlist_pop_last(&event->process_stats); } - feature_use = dlist_pop_last(&event->feature_usage); - while (feature_use != NULL) + load = dlist_pop_last(&event->loads); + while (load != NULL) { - EVEL_DEBUG("Freeing Feature use Info (%s)", feature_use->feature_id); - free(feature_use->feature_id); - free(feature_use); - feature_use = dlist_pop_last(&event->feature_usage); + EVEL_DEBUG("Freeing load Info"); + free(load); + load = dlist_pop_last(&event->loads); } - measurement_group = dlist_pop_last(&event->additional_measurements); - while (measurement_group != NULL) + ht = event->feature_usage; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Measurement Group (%s)", measurement_group->name); + ht_destroy(ht); + } - measurement = dlist_pop_last(&measurement_group->measurements); - while (measurement != NULL) - { - EVEL_DEBUG("Freeing Measurement (%s)", measurement->name); - free(measurement->name); - free(measurement->value); - free(measurement); - measurement = dlist_pop_last(&measurement_group->measurements); - } - free(measurement_group->name); - free(measurement_group); - measurement_group = dlist_pop_last(&event->additional_measurements); + huge_page = dlist_pop_last(&event->huge_pages); + while (huge_page != NULL) + { + EVEL_DEBUG("Freeing huge page id (%s)", huge_page->hugePagesIdentifier); + free(huge_page->hugePagesIdentifier); + free(huge_page); + huge_page = dlist_pop_last(&event->huge_pages); + } + + machine_check = dlist_pop_last(&event->machine_check_exception); + while (machine_check != NULL) + { + EVEL_DEBUG("Freeing machine check exception id (%s)", machine_check->process_id); + + free(machine_check->process_id); + free(machine_check); + machine_check = dlist_pop_last(&event->machine_check_exception); + } + + ht = dlist_pop_last(&event->additional_measurements); + while (ht != NULL) + { + EVEL_DEBUG("Freeing measurement additional_measurements %s", ht->hmName); + ht_destroy(ht); + ht = dlist_pop_last(&event->additional_measurements); } evel_free_header(&event->header); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c index efc62db..6046bda 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c @@ -27,6 +27,7 @@ #include #include "evel_throttle.h" +#include "evel_internal.h" /**************************************************************************//** * Create a new Signaling event. @@ -89,7 +90,7 @@ EVENT_SIGNALING * evel_new_signaling(const char* ev_name, const char *ev_id, evel_set_option_string(&event->remote_port,remote_port,"Init remote port"); evel_init_option_string(&event->compressed_sip); evel_init_option_string(&event->summary_sip); - dlist_initialize(&event->additional_info); + event->additional_info = ht_create(); exit_label: @@ -114,7 +115,9 @@ exit_label: *****************************************************************************/ void evel_signaling_addl_info_add(EVENT_SIGNALING * event, char * name, char * value) { - FAULT_ADDL_INFO * addl_info = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -126,15 +129,11 @@ void evel_signaling_addl_info_add(EVENT_SIGNALING * event, char * name, char * v assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - addl_info = malloc(sizeof(SIGNALING_ADDL_FIELD)); - assert(addl_info != NULL); - memset(addl_info, 0, sizeof(SIGNALING_ADDL_FIELD)); - addl_info->name = strdup(name); - addl_info->value = strdup(value); - assert(addl_info->name != NULL); - assert(addl_info->value != NULL); - dlist_push_last(&event->additional_info, addl_info); + nam = strdup(name); + val = strdup(value); + + ht_insert(event->additional_info, nam, val); EVEL_EXIT(); } @@ -453,8 +452,8 @@ void evel_signaling_correlator_set(EVENT_SIGNALING * const event, void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, EVENT_SIGNALING * const event) { - SIGNALING_ADDL_FIELD * addl_info = NULL; - DLIST_ITEM * addl_info_item = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; EVEL_ENTER(); @@ -465,7 +464,7 @@ void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, assert(event->header.event_domain == EVEL_DOMAIN_SIPSIGNALING); evel_json_encode_header(jbuf, &event->header); - evel_json_open_named_object(jbuf, "signalingFields"); + evel_json_open_named_object(jbuf, "sipSignalingFields"); /***************************************************************************/ /* Mandatory fields */ @@ -480,7 +479,7 @@ void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, evel_enc_kv_opt_string(jbuf, "localPort", &event->local_port); evel_enc_kv_opt_string(jbuf, "remoteIpAddress", &event->remote_ip_address); evel_enc_kv_opt_string(jbuf, "remotePort", &event->remote_port); - evel_enc_version(jbuf, "signalingFieldsVersion", event->major_version,event->minor_version); + evel_enc_version(jbuf, "sipSignalingFieldsVersion", event->major_version,event->minor_version); evel_enc_kv_opt_string(jbuf, "summarySip", &event->summary_sip); evel_json_encode_vendor_field(jbuf, &event->vnfname_field); @@ -489,34 +488,48 @@ void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalInformation")) - { - bool item_added = false; - addl_info_item = dlist_get_first(&event->additional_info); - while (addl_info_item != NULL) - { - addl_info = (SIGNALING_ADDL_FIELD*) addl_info_item->item; - assert(addl_info != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalInformation", - addl_info->name)) + ht = event->additional_info; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalInformation")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", addl_info->name); - evel_enc_kv_string(jbuf, "value", addl_info->value); - evel_json_close_object(jbuf); - item_added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalInformation", + entry->key)) + { + + // evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + // evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - addl_info_item = dlist_get_next(addl_info_item); } - evel_json_close_list(jbuf); - + evel_json_close_object(jbuf); + /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ /*************************************************************************/ - if (!item_added) + if (!added) { evel_json_rewind(jbuf); } @@ -537,7 +550,8 @@ void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf, *****************************************************************************/ void evel_free_signaling(EVENT_SIGNALING * const event) { - SIGNALING_ADDL_FIELD * addl_info = NULL; + HASHTABLE_T *ht; + EVEL_ENTER(); /***************************************************************************/ @@ -550,16 +564,10 @@ void evel_free_signaling(EVENT_SIGNALING * const event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - addl_info = dlist_pop_last(&event->additional_info); - while (addl_info != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Info (%s, %s)", - addl_info->name, - addl_info->value); - free(addl_info->name); - free(addl_info->value); - free(addl_info); - addl_info = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } evel_free_event_vendor_field(&event->vnfname_field); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_state_change.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_state_change.c index eb81f97..906b299 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_state_change.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_state_change.c @@ -85,7 +85,7 @@ EVENT_STATE_CHANGE * evel_new_state_change(const char* ev_name, state_change->new_state = new_state; state_change->old_state = old_state; state_change->state_interface = strdup(interface); - dlist_initialize(&state_change->additional_fields); + state_change->additional_fields = ht_create(); exit_label: EVEL_EXIT(); @@ -103,7 +103,7 @@ exit_label: *****************************************************************************/ void evel_free_state_change(EVENT_STATE_CHANGE * const state_change) { - STATE_CHANGE_ADDL_FIELD * addl_field = NULL; + HASHTABLE_T *ht; EVEL_ENTER(); @@ -117,17 +117,12 @@ void evel_free_state_change(EVENT_STATE_CHANGE * const state_change) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - addl_field = dlist_pop_last(&state_change->additional_fields); - while (addl_field != NULL) + ht = state_change->additional_fields; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Field (%s, %s)", - addl_field->name, - addl_field->value); - free(addl_field->name); - free(addl_field->value); - free(addl_field); - addl_field = dlist_pop_last(&state_change->additional_fields); + ht_destroy(ht); } + free(state_change->state_interface); evel_free_header(&state_change->header); @@ -180,7 +175,9 @@ void evel_state_change_addl_field_add(EVENT_STATE_CHANGE * const state_change, const char * const name, const char * const value) { - STATE_CHANGE_ADDL_FIELD * addl_field = NULL; + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -192,15 +189,11 @@ void evel_state_change_addl_field_add(EVENT_STATE_CHANGE * const state_change, assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - addl_field = malloc(sizeof(STATE_CHANGE_ADDL_FIELD)); - assert(addl_field != NULL); - memset(addl_field, 0, sizeof(STATE_CHANGE_ADDL_FIELD)); - addl_field->name = strdup(name); - addl_field->value = strdup(value); - assert(addl_field->name != NULL); - assert(addl_field->value != NULL); - dlist_push_last(&state_change->additional_fields, addl_field); + nam = strdup(name); + val = strdup(value); + + ht_insert(state_change->additional_fields, nam, val); EVEL_EXIT(); } @@ -214,8 +207,9 @@ void evel_state_change_addl_field_add(EVENT_STATE_CHANGE * const state_change, void evel_json_encode_state_change(EVEL_JSON_BUFFER * jbuf, EVENT_STATE_CHANGE * state_change) { - STATE_CHANGE_ADDL_FIELD * addl_field = NULL; - DLIST_ITEM * addl_field_item = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; + char * new_state; char * old_state; @@ -244,34 +238,46 @@ void evel_json_encode_state_change(EVEL_JSON_BUFFER * jbuf, /* Optional fields. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalFields")) + ht = state_change->additional_fields; + if( ht != NULL ) { - bool item_added = false; - - addl_field_item = dlist_get_first(&state_change->additional_fields); - while (addl_field_item != NULL) + bool added = false; + if( ht->size > 0) { - addl_field = (STATE_CHANGE_ADDL_FIELD *) addl_field_item->item; - assert(addl_field != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalFields", - addl_field->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", addl_field->name); - evel_enc_kv_string(jbuf, "value", addl_field->value); - evel_json_close_object(jbuf); - item_added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding heartBeatFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - addl_field_item = dlist_get_next(addl_field_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ /*************************************************************************/ - if (!item_added) + if (!added) { evel_json_rewind(jbuf); } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c index 3f0e7a4..6d4b6d4 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c @@ -145,7 +145,7 @@ char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action) * @param alert_type The alert_type to convert. * @returns The equivalent string. *****************************************************************************/ -char * evel_alert_type(const EVEL_ALERT_TYPES alert_type) +char * evel_alert_type(const EVEL_ALERT_TYPE alert_type) { char * result; @@ -202,7 +202,7 @@ char * evel_event_domain(const EVEL_EVENT_DOMAINS domain) break; case EVEL_DOMAIN_MEASUREMENT: - result = "measurementsForVfScaling"; + result = "measurement"; break; case EVEL_DOMAIN_REPORT: @@ -241,6 +241,14 @@ char * evel_event_domain(const EVEL_EVENT_DOMAINS domain) result = "thresholdCrossingAlert"; break; + case EVEL_DOMAIN_NOTIFICATION: + result = "notification"; + break; + + case EVEL_DOMAIN_PNF_REGISTRATION: + result = "pnfRegistration"; + break; + default: result = NULL; EVEL_ERROR("Unexpected domain %d", domain); @@ -440,6 +448,104 @@ char * evel_entity_state(const EVEL_ENTITY_STATE state) return result; } +/**************************************************************************//** + * Convert a ::EVEL_OPTION_STATE to it's string form for JSON encoding. + * + * @param state The entity state to encode. + * + * @returns the corresponding string + *****************************************************************************/ +char * evel_entity_opt_state (EVEL_OPTION_STATE * const state) +{ + char * result; + + EVEL_ENTER(); + + if (state != NULL) + { + if (state->is_set) + { + switch (state->state) + { + case EVEL_ENTITY_STATE_IN_SERVICE: + result = "inService"; + break; + + case EVEL_ENTITY_STATE_MAINTENANCE: + result = "maintenance"; + break; + + case EVEL_ENTITY_STATE_OUT_OF_SERVICE: + result = "outOfService"; + break; + + default: + EVEL_ERROR("Unexpected entity state %d", state); + assert(0); + } + } + else + { + result = NULL; + } + } + else + { + result = NULL; + } + + EVEL_EXIT(); + + return result; +} + +/**************************************************************************//** + * Convert a ::EVEL_OPTION_OP_STATE to it's string form for JSON encoding. + * + * @param state The entity state to encode. + * + * @returns the corresponding string + *****************************************************************************/ +char * evel_entity_opt_op_state (EVEL_OPTION_OP_STATE * const state) +{ + char * result; + + EVEL_ENTER(); + + if (state != NULL) + { + if (state->is_set) + { + switch (state->state) + { + case EVEL_OPER_STATE_IN_SERVICE: + result = "inService"; + break; + + case EVEL_OPER_STATE_OUT_OF_SERVICE: + result = "outOfService"; + break; + + default: + EVEL_ERROR("Unexpected entity state %d", state); + assert(0); + } + } + else + { + result = NULL; + } + } + else + { + result = NULL; + } + + EVEL_EXIT(); + + return result; +} + /**************************************************************************//** * Convert a ::EVEL_SERVICE_ENDPOINT_DESC to string form for JSON encoding. * diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c index 06d8163..b97be7c 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c @@ -83,14 +83,17 @@ EVENT_SYSLOG * evel_new_syslog(const char* ev_name, const char *ev_id, syslog->syslog_msg = strdup(syslog_msg); syslog->syslog_tag = strdup(syslog_tag); evel_init_option_int(&syslog->syslog_facility); + evel_init_option_int(&syslog->syslog_priority); evel_init_option_int(&syslog->syslog_proc_id); evel_init_option_int(&syslog->syslog_ver); - evel_init_option_string(&syslog->additional_filters); + syslog->additional_fields = ht_create(); evel_init_option_string(&syslog->event_source_host); evel_init_option_string(&syslog->syslog_proc); evel_init_option_string(&syslog->syslog_s_data); evel_init_option_string(&syslog->syslog_sdid); evel_init_option_string(&syslog->syslog_severity); + evel_init_option_string(&syslog->syslog_timeStamp); + evel_init_option_string(&syslog->syslog_msgHost); exit_label: EVEL_EXIT(); @@ -139,9 +142,13 @@ void evel_syslog_type_set(EVENT_SYSLOG * syslog, * does not need to preserve the value once the function * returns. *****************************************************************************/ -void evel_syslog_addl_filter_set(EVENT_SYSLOG * syslog, - char * filter) +void evel_syslog_addl_fields_set(EVENT_SYSLOG * syslog, + const char * const name, + const char * const value) { + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -149,11 +156,15 @@ void evel_syslog_addl_filter_set(EVENT_SYSLOG * syslog, /***************************************************************************/ assert(syslog != NULL); assert(syslog->header.event_domain == EVEL_DOMAIN_SYSLOG); - assert(filter != NULL); + assert(name != NULL); + assert(value != NULL); + + EVEL_DEBUG("Adding name=%s value=%s", name, value); + + nam = strdup(name); + val = strdup(value); - evel_set_option_string(&syslog->additional_filters, - filter, - "Syslog filter string"); + ht_insert(syslog->additional_fields, nam, val); EVEL_EXIT(); } @@ -218,6 +229,35 @@ void evel_syslog_facility_set(EVENT_SYSLOG * syslog, EVEL_EXIT(); } +/**************************************************************************//** + * Set the priority of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param priority The Syslog priority to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ +void evel_syslog_priority_set(EVENT_SYSLOG * syslog, + const int priority) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(syslog != NULL); + assert(syslog->header.event_domain == EVEL_DOMAIN_SYSLOG); + + evel_set_option_int(&syslog->syslog_priority, + priority, + "priority"); + EVEL_EXIT(); +} + /**************************************************************************//** * Set the Process property of the Syslog. * @@ -391,6 +431,56 @@ void evel_syslog_severity_set(EVENT_SYSLOG * syslog, const char * const severty) } EVEL_EXIT(); } +/**************************************************************************//** + * Set the timestamp parsed from non-VES syslog message + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param time_stamp The timestamp to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ +void evel_syslog_timeStamp_set(EVENT_SYSLOG * syslog, const char * const time_stamp) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(syslog != NULL); + assert(syslog->header.event_domain == EVEL_DOMAIN_SYSLOG); + assert(time_stamp != NULL); + + evel_set_option_string(&syslog->syslog_timeStamp, time_stamp, "Timestamp"); + EVEL_EXIT(); +} +/**************************************************************************//** + * Set the hostname parsed from non-VES syslog message + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param syslog Pointer to the Syslog. + * @param msg_host The hostname to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ +void evel_syslog_MsgHost_set(EVENT_SYSLOG * syslog, const char * const msg_host) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(syslog != NULL); + assert(syslog->header.event_domain == EVEL_DOMAIN_SYSLOG); + assert(msg_host != NULL); + + evel_set_option_string(&syslog->syslog_msgHost, msg_host, "Hostname"); + EVEL_EXIT(); +} /**************************************************************************//** * Encode the Syslog in JSON according to AT&T's schema for the event type. @@ -402,6 +492,8 @@ void evel_json_encode_syslog(EVEL_JSON_BUFFER * jbuf, EVENT_SYSLOG * event) { char * event_source_type; + HASHTABLE_T *ht; + ENTRY_T *entry; EVEL_ENTER(); @@ -416,7 +508,60 @@ void evel_json_encode_syslog(EVEL_JSON_BUFFER * jbuf, evel_json_encode_header(jbuf, &event->header); evel_json_open_named_object(jbuf, "syslogFields"); - evel_enc_kv_opt_string(jbuf, "additionalFields", &event->additional_filters); + /***************************************************************************/ + /* Checkpoint, so that we can wind back if all fields are suppressed. */ + /***************************************************************************/ + evel_json_checkpoint(jbuf); + + /***************************************************************************/ + /* Go through the Hashmap of additional information and encode key / Value */ + /***************************************************************************/ + ht = event->additional_fields; + if( ht != NULL ) + { + bool added = false; + if( ht->size > 0) + { + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) + { + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding syslog additionalFields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } + } + } + evel_json_close_object(jbuf); + + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!added) + { + evel_json_rewind(jbuf); + } + } + /***************************************************************************/ /* Mandatory fields */ /***************************************************************************/ @@ -438,6 +583,8 @@ void evel_json_encode_syslog(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_string(jbuf, "syslogSdId", &event->syslog_sdid); evel_enc_kv_opt_string(jbuf, "syslogSev", &event->syslog_severity); evel_enc_kv_opt_int(jbuf, "syslogVer", &event->syslog_ver); + evel_enc_kv_opt_string(jbuf, "syslogMsgHost", &event->syslog_msgHost); + evel_enc_kv_opt_string(jbuf, "syslogTs", &event->syslog_timeStamp); evel_json_close_object(jbuf); EVEL_CT_ASSERT(EVEL_SYSLOG_FACILITY_KERNEL == 0); @@ -478,6 +625,7 @@ void evel_json_encode_syslog(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_syslog(EVENT_SYSLOG * event) { + HASHTABLE_T *ht; EVEL_ENTER(); @@ -491,14 +639,20 @@ void evel_free_syslog(EVENT_SYSLOG * event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ + ht = event->additional_fields; + if( ht != NULL ) + { + ht_destroy(ht); + } - evel_free_option_string(&event->additional_filters); evel_free_option_string(&event->event_source_host); free(event->syslog_msg); evel_free_option_string(&event->syslog_proc); evel_free_option_string(&event->syslog_s_data); evel_free_option_string(&event->syslog_sdid); evel_free_option_string(&event->syslog_severity); + evel_free_option_string(&event->syslog_msgHost); + evel_free_option_string(&event->syslog_timeStamp); free(event->syslog_tag); evel_free_header(&event->header); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c index c66b08c..c308bc6 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c @@ -38,16 +38,12 @@ * * @param event_name Unique Event Name confirming Domain AsdcVnfModel Description * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc - * @param char* tcriticality Performance Counter Criticality MAJ MIN, - * @param char* tname Performance Counter Threshold name - * @param char* tthresholdCrossed Counter Threshold crossed value - * @param char* tvalue Counter actual value * @param EVEL_EVENT_ACTION talertAction Alert set continue or clear * @param char* talertDescription * @param EVEL_ALERT_TYPE talertType Kind of anamoly - * @param unsigned long long tcollectionTimestamp time at which alert was collected + * @param char* tcollectionTimestamp time at which alert was collected * @param EVEL_SEVERITIES teventSeverity Severity of Alert - * @param unsigned long long teventStartTimestamp Time when this alert started + * @param char* teventStartTimestamp Time when this alert started * * @returns pointer to the newly manufactured ::EVENT_THRESHOLD_CROSS. If the * event is not used it must be released using @@ -55,30 +51,26 @@ * @retval NULL Failed to create the event. *****************************************************************************/ EVENT_THRESHOLD_CROSS * evel_new_threshold_cross(const char * ev_name, const char * ev_id, - char * tcriticality, - char * tname, - char * tthresholdCrossed, - char * tvalue, - EVEL_EVENT_ACTION talertAction, + EVEL_ALERT_ACTIONS talertAction, char * talertDescription, EVEL_ALERT_TYPE talertType, - unsigned long long tcollectionTimestamp, + char * tcollectionTimestamp, EVEL_SEVERITIES teventSeverity, - unsigned long long teventStartTimestamp ) + char * teventStartTimestamp ) { EVENT_THRESHOLD_CROSS * event = NULL; + EVEL_ENTER(); - assert( tcriticality!= NULL ); - assert( tname!= NULL ); - assert( tthresholdCrossed != NULL ); - assert( tvalue!= NULL ); assert( talertDescription != NULL ); + assert( talertAction < EVEL_MAX_ALERT_ACTIONS ); + assert( talertType < EVEL_MAX_ANOMALY ); + assert( teventSeverity < EVEL_MAX_SEVERITIES ); - /***************************************************************************/ - /* Allocate the Threshold crossing event. */ - /***************************************************************************/ +/***************************************************************************/ +/* Allocate the Threshold crossing event. */ +/***************************************************************************/ event = malloc(sizeof(EVENT_THRESHOLD_CROSS)); if (event == NULL) { @@ -96,17 +88,12 @@ EVENT_THRESHOLD_CROSS * evel_new_threshold_cross(const char * ev_name, const cha event->major_version = EVEL_THRESHOLD_CROSS_MAJOR_VERSION; event->minor_version = EVEL_THRESHOLD_CROSS_MINOR_VERSION; - - event->additionalParameters.criticality = strdup(tcriticality); - event->additionalParameters.name = strdup(tname); - event->additionalParameters.thresholdCrossed = strdup(tthresholdCrossed); - event->additionalParameters.value = strdup(tvalue); event->alertAction = talertAction; event->alertDescription = strdup(talertDescription); event->alertType = talertType; - event->collectionTimestamp = tcollectionTimestamp; + event->collectionTimestamp = strdup(tcollectionTimestamp); event->eventSeverity = teventSeverity; - event->eventStartTimestamp = teventStartTimestamp; + event->eventStartTimestamp = strdup(teventStartTimestamp); evel_init_option_string(&event->alertValue); evel_init_option_string(&event->dataCollector); @@ -114,8 +101,9 @@ EVENT_THRESHOLD_CROSS * evel_new_threshold_cross(const char * ev_name, const cha evel_init_option_string(&event->interfaceName); evel_init_option_string(&event->networkService); evel_init_option_string(&event->possibleRootCause); - dlist_initialize(&event->additional_info); + event->additional_info = ht_create(); dlist_initialize(&event->alertidList); + dlist_initialize(&event->additionalParameters); exit_label: @@ -124,6 +112,76 @@ exit_label: } +/**************************************************************************//** + * Add the TCA additional performance counter + * + * @param tcp Pointer to the ::EVENT_THRESHOLD_CROSS. + * @param char* tcriticality Performance Counter criticality + * @param char* tthresholdCrossed Performance Counter Threshold name + *****************************************************************************/ +PERF_COUNTER * evel_threshold_cross_add_addl_parameters( + EVENT_THRESHOLD_CROSS * const event, + char * tcriticality, + char * tthresholdCrossed) +{ + PERF_COUNTER *perf_ctr = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event != NULL); + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(tcriticality!= NULL); + assert(tthresholdCrossed != NULL); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + EVEL_DEBUG("Adding criticality=%s, thresholdCrossed=%s", tcriticality, tthresholdCrossed); + perf_ctr = malloc(sizeof(PERF_COUNTER)); + assert(perf_ctr != NULL); + perf_ctr->criticality = strdup(tcriticality); + perf_ctr->thresholdCrossed = strdup(tthresholdCrossed); + perf_ctr->hashmap = ht_create(); + + dlist_push_last(&event->additionalParameters, perf_ctr); + + EVEL_EXIT(); + return perf_ctr; +} + +/**************************************************************************//** + * Set the TCA name / Value for additional performance counter + * + * @param PERF_COUNTER perf_ctr Pointer to additional Parameter array element + * @param char* name Performance Counter Threshold name + * @param char* value Performance Counter actual value + *****************************************************************************/ +void evel_threshold_cross_addl_parameters_hashmap_set( + PERF_COUNTER * perf_ctr, + char * name, + char * value) +{ + char * nam = NULL; + char * val = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(perf_ctr != NULL); + assert(name != NULL); + assert(value != NULL); + + nam = strdup(name); + val = strdup(value); + ht_insert(perf_ctr->hashmap, nam, val); + + EVEL_EXIT(); +} /**************************************************************************//** * Set the Event Type property of the TC Alert. @@ -190,7 +248,8 @@ void evel_threshold_cross_alertid_add(EVENT_THRESHOLD_CROSS * const event,char * *****************************************************************************/ void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const event, const char * name, const char * value) { - OTHER_FIELD * nv_pair = NULL; + char *nam=NULL; + char *val=NULL; EVEL_ENTER(); @@ -202,15 +261,10 @@ void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const event, con assert(name != NULL); assert(value != NULL); + nam = strdup(name); + val = strdup(value); EVEL_DEBUG("Adding name=%s value=%s", name, value); - nv_pair = malloc(sizeof(OTHER_FIELD)); - assert(nv_pair != NULL); - nv_pair->name = strdup(name); - nv_pair->value = strdup(value); - assert(nv_pair->name != NULL); - assert(nv_pair->value != NULL); - - dlist_push_last(&event->additional_info, nv_pair); + ht_insert(event->additional_info, nam, val); EVEL_EXIT(); } @@ -226,8 +280,10 @@ void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const event, con *****************************************************************************/ void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const event) { - OTHER_FIELD * addl_info = NULL; + HASHTABLE_T *ht; char *ptr; + PERF_COUNTER * perf_ctr = NULL; + EVEL_ENTER(); /***************************************************************************/ @@ -240,17 +296,12 @@ void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const event) /***************************************************************************/ /* Free all internal strings then the header itself. */ /***************************************************************************/ - addl_info = dlist_pop_last(&event->additional_info); - while (addl_info != NULL) + ht = event->additional_info; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Info (%s, %s)", - addl_info->name, - addl_info->value); - free(addl_info->name); - free(addl_info->value); - free(addl_info); - addl_info = dlist_pop_last(&event->additional_info); + ht_destroy(ht); } + ptr = dlist_pop_last(&event->alertidList); while (ptr != NULL) { @@ -258,10 +309,17 @@ void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const event) ptr = dlist_pop_last(&event->alertidList); } - free(event->additionalParameters.criticality); - free(event->additionalParameters.name); - free(event->additionalParameters.thresholdCrossed); - free(event->additionalParameters.value); + perf_ctr = dlist_pop_last(&event->additionalParameters); + while (perf_ctr != NULL) + { + EVEL_DEBUG("Freeing Other performance counter"); + ht_destroy(perf_ctr->hashmap); + free(perf_ctr->criticality); + free(perf_ctr->thresholdCrossed); + free(perf_ctr); + perf_ctr = dlist_pop_last(&event->additionalParameters); + } + free(event->alertDescription); evel_free_option_string(&event->alertValue); @@ -275,145 +333,147 @@ void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const event) EVEL_EXIT(); } - /**************************************************************************//** - * Set the TCA probable Root cause. - * - * @param sheader Possible root cause to Threshold - *****************************************************************************/ - void evel_threshold_cross_possible_rootcause_set(EVENT_THRESHOLD_CROSS * const event, char * sheader) - { - EVEL_ENTER(); +/**************************************************************************//** + * Set the TCA probable Root cause. + * + * @param sheader Possible root cause to Threshold + *****************************************************************************/ +void evel_threshold_cross_possible_rootcause_set(EVENT_THRESHOLD_CROSS * const event, char * sheader) +{ + EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); - evel_set_option_string(&event->possibleRootCause, - sheader, - "Rootcause value"); + evel_set_option_string(&event->possibleRootCause, + sheader, + "Rootcause value"); - EVEL_EXIT(); - } + EVEL_EXIT(); +} - /**************************************************************************//** - * Set the TCA networking cause. - * - * @param sheader Possible networking service value to Threshold - *****************************************************************************/ - void evel_threshold_cross_networkservice_set(EVENT_THRESHOLD_CROSS * const event, char * sheader) - { - EVEL_ENTER(); +/**************************************************************************//** + * Set the TCA networking cause. + * + * @param sheader Possible networking service value to Threshold + *****************************************************************************/ +void evel_threshold_cross_networkservice_set(EVENT_THRESHOLD_CROSS * const event, char * sheader) +{ + EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); - evel_set_option_string(&event->networkService, - sheader, - "Networking service value"); + evel_set_option_string(&event->networkService, + sheader, + "Networking service value"); - EVEL_EXIT(); - } + EVEL_EXIT(); +} - /**************************************************************************//** - * Set the TCA Interface name. - * - * @param sheader Interface name to threshold - *****************************************************************************/ - void evel_threshold_cross_interfacename_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) - { - EVEL_ENTER(); - - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); - - evel_set_option_string(&event->interfaceName, - sheader, - "TCA Interface name"); - EVEL_EXIT(); - } + /**************************************************************************//** + * Set the TCA Interface name. + * + * @param sheader Interface name to threshold + *****************************************************************************/ +void evel_threshold_cross_interfacename_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); + + evel_set_option_string(&event->interfaceName, + sheader, + "TCA Interface name"); + EVEL_EXIT(); +} - /**************************************************************************//** - * Set the TCA Data element type. - * - * @param sheader element type of Threshold - *****************************************************************************/ - void evel_threshold_cross_data_elementtype_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) - { - EVEL_ENTER(); - - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); - - evel_set_option_string(&event->elementType, - sheader, - "TCA Element type value"); - EVEL_EXIT(); - } +/**************************************************************************//** + * Set the TCA Data element type. + * + * @param sheader element type of Threshold + *****************************************************************************/ +void evel_threshold_cross_data_elementtype_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) +{ + EVEL_ENTER(); - /**************************************************************************//** - * Set the TCA Data collector value. - * - * @param sheader Data collector value - *****************************************************************************/ - void evel_threshold_cross_data_collector_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) - { - EVEL_ENTER(); - - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); - - evel_set_option_string(&event->dataCollector, - sheader, - "Datacollector value"); - EVEL_EXIT(); - } + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); + + evel_set_option_string(&event->elementType, + sheader, + "TCA Element type value"); + EVEL_EXIT(); +} + +/**************************************************************************//** + * Set the TCA Data collector value. + * + * @param sheader Data collector value + *****************************************************************************/ +void evel_threshold_cross_data_collector_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) +{ + EVEL_ENTER(); + +/***************************************************************************/ +/* Check preconditions. */ +/***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); + + evel_set_option_string(&event->dataCollector, + sheader, + "Datacollector value"); + EVEL_EXIT(); +} - /**************************************************************************//** - * Set the TCA alert value. - * - * @param sheader Possible alert value - *****************************************************************************/ - void evel_threshold_cross_alertvalue_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) - { - EVEL_ENTER(); - - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ - assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); - assert(sheader != NULL); - - evel_set_option_string(&event->alertValue, - sheader, - "Alert value"); - EVEL_EXIT(); - } +/**************************************************************************//** + * Set the TCA alert value. + * + * @param sheader Possible alert value + *****************************************************************************/ +void evel_threshold_cross_alertvalue_set(EVENT_THRESHOLD_CROSS * const event,char * sheader) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); + assert(sheader != NULL); + + evel_set_option_string(&event->alertValue, + sheader, + "Alert value"); + EVEL_EXIT(); +} /**************************************************************************//** - * Encode the Mobile Flow GTP Per Flow Metrics as a JSON object. + * Encode the performance counter as a JSON object. * * @param jbuf Pointer to working ::EVEL_JSON_BUFFER. - * @param metrics Pointer to the ::EVENT_MOBILE_FLOW to encode. - * @returns Number of bytes actually written. + * @param pcounter Pointer to the performance counter to encode. *****************************************************************************/ void evel_json_encode_perf_counter( EVEL_JSON_BUFFER * jbuf, PERF_COUNTER *pcounter) { + HASHTABLE_T *ht; + ENTRY_T *entry; + EVEL_ENTER(); /***************************************************************************/ @@ -422,16 +482,39 @@ void evel_json_encode_perf_counter( EVEL_JSON_BUFFER * jbuf, PERF_COUNTER *pcoun assert(jbuf != NULL); assert(pcounter != NULL); - evel_json_open_named_object(jbuf, "additionalParameters"); - + evel_json_open_object(jbuf); /***************************************************************************/ /* Mandatory parameters. */ /***************************************************************************/ evel_enc_kv_string(jbuf, "criticality", pcounter->criticality); - evel_enc_kv_string(jbuf, "name", pcounter->name); - evel_enc_kv_string(jbuf, "thresholdCrossed", pcounter->name); - evel_enc_kv_string(jbuf, "value", pcounter->value); - + evel_enc_kv_string(jbuf, "thresholdCrossed", pcounter->thresholdCrossed); + ht = pcounter->hashmap; + if( ht != NULL ) + { + if( ht->size > 0) + { + if (evel_json_open_opt_named_object(jbuf, "hashMap")) + { + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding TCAFields %s %s",(char *) (entry->key), entry->value); + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + entry = entry->next; + } + } + } + evel_json_close_object(jbuf); + } + } evel_json_close_object(jbuf); EVEL_EXIT(); @@ -447,8 +530,14 @@ void evel_json_encode_perf_counter( EVEL_JSON_BUFFER * jbuf, PERF_COUNTER *pcoun void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf, EVENT_THRESHOLD_CROSS * const event) { - OTHER_FIELD * nv_pair = NULL; - DLIST_ITEM * dlist_item = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; + char * alert_action = NULL; + char * alert_type = NULL; + char * event_sev = NULL; + DLIST_ITEM * item = NULL; + char * alert_id = NULL; + PERF_COUNTER * perf_ctr = NULL; EVEL_ENTER(); @@ -459,19 +548,38 @@ void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf, assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS); evel_json_encode_header(jbuf, &event->header); - evel_json_open_named_object(jbuf, "thresholdCrossingAlert"); + evel_json_open_named_object(jbuf, "thresholdCrossingAlertFields"); /***************************************************************************/ /* Mandatory fields */ /***************************************************************************/ - evel_json_encode_perf_counter(jbuf, &event->additionalParameters); - evel_enc_kv_int(jbuf, "alertAction", event->alertAction); + + evel_json_open_named_list(jbuf, "additionalParameters"); + + item = dlist_get_first(&event->additionalParameters); + while (item != NULL) + { + perf_ctr = (PERF_COUNTER *) item->item; + assert(perf_ctr != NULL); + evel_json_encode_perf_counter(jbuf, perf_ctr); + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + + alert_action = evel_alert_action(event->alertAction); + evel_enc_kv_string(jbuf, "alertAction", alert_action); evel_enc_kv_string(jbuf, "alertDescription", event->alertDescription); - evel_enc_kv_int(jbuf, "alertType", event->alertType); - evel_enc_kv_ull( + + alert_type = evel_alert_type(event->alertType); + evel_enc_kv_string(jbuf, "alertType", alert_type); + + evel_enc_kv_string( jbuf, "collectionTimestamp", event->collectionTimestamp); - evel_enc_kv_int(jbuf, "eventSeverity", event->eventSeverity); - evel_enc_kv_ull( + + event_sev = evel_severity(event->eventSeverity); + evel_enc_kv_string(jbuf, "eventSeverity", event_sev); + + evel_enc_kv_string( jbuf, "eventStartTimestamp", event->eventStartTimestamp); /***************************************************************************/ @@ -484,33 +592,63 @@ void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf, evel_enc_kv_opt_string(jbuf, "networkService", &event->networkService); evel_enc_kv_opt_string(jbuf, "possibleRootCause", &event->possibleRootCause); + evel_json_checkpoint(jbuf); + evel_json_open_named_list(jbuf, "associatedAlertIdList"); + bool added = false; + item = dlist_get_first(&event->alertidList); + while (item != NULL) + { + alert_id = (char *)item->item; + evel_enc_list_item(jbuf, "\"%s\"", alert_id); + added = true; + item = dlist_get_next(item); + } + evel_json_close_list(jbuf); + if (!added) + { + evel_json_rewind(jbuf); + } + /***************************************************************************/ /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalFields")) + ht = event->additional_info; + if( ht != NULL ) { bool added = false; - - dlist_item = dlist_get_first(&event->additional_info); - while (dlist_item != NULL) + if( ht->size > 0) { - nv_pair = (OTHER_FIELD *) dlist_item->item; - assert(nv_pair != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalFields", - nv_pair->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalFields")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", nv_pair->name); - evel_enc_kv_string(jbuf, "value", nv_pair->value); - evel_json_close_object(jbuf); - added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding TCA Fields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalFields", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - dlist_item = dlist_get_next(dlist_item); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ @@ -520,6 +658,7 @@ void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf, evel_json_rewind(jbuf); } } + evel_enc_version(jbuf, "thresholdCrossingFieldsVersion", event->major_version, diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c index ac664a1..772fefc 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c @@ -131,11 +131,13 @@ static const char * evel_domain_strings[EVEL_MAX_DOMAINS] = { "measurementsForVfScaling", "mobileFlow", "report", - "serviceEvents", - "signaling", + "sipSignaling", "stateChange", "syslog", "other", + "thresholdCrossingAlert", + "notification", + "pnfRegistration", "voiceQuality", "maxDomain" }; @@ -1937,6 +1939,7 @@ EVEL_EVENT_DOMAINS evel_decode_domain(char * domain_value) if (strcmp(evel_domain_strings[ii], domain_value) == 0) { result = ii; + break; } } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_unit.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_unit.c new file mode 100644 index 0000000..169944f --- /dev/null +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_unit.c @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include + +#include "evel.h" +#include "evel_internal.h" +#include "evel_throttle.h" +#include "metadata.h" + +static void test_encode_heartbeat(); +static void test_encode_header_overrides(); +static void compare_strings(char * expected, + char * actual, + int max_size, + char * description); + +int main(int argc, char ** argv) +{ + assert(argc >= 0); + assert(argv != NULL); + + /***************************************************************************/ + /* Fix our timezone to UTC. */ + /***************************************************************************/ + putenv("TZ=UTC"); + + /***************************************************************************/ + /* Initialize metadata. */ + /***************************************************************************/ + openstack_metadata_initialize(); + + /***************************************************************************/ + /* Minimal initialisation to exercise the encoders. */ + /***************************************************************************/ + functional_role = "UNIT TEST"; + log_initialize(EVEL_LOG_DEBUG, "EVEL"); + /***************************************************************************/ + /* Test each encoder. */ + /***************************************************************************/ + test_encode_heartbeat(); + test_encode_header_overrides(); + printf ("\nAll Tests Passed\n"); + + return 0; +} + + +void test_encode_heartbeat() +{ + char * expected = + "{\"event\": {" + "\"commonEventHeader\": {" + "\"domain\": \"heartbeat\", " + "\"eventId\": \"121\", " + "\"functionalRole\": \"UNIT TEST\", " + "\"lastEpochMicrosec\": 1000002, " + "\"priority\": \"Normal\", " + "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"sequence\": 121, " + "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"startEpochMicrosec\": 1000002, " + "\"version\": 1.2, " + "\"eventType\": \"Autonomous heartbeat\", " + "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", " + "\"sourceId\": \"Dummy VM UUID - No Metadata available\"" + "}}}"; + + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + + /***************************************************************************/ + /* Test the VM name/uuid once. */ + /***************************************************************************/ + evel_set_next_event_sequence(121); + + EVENT_HEADER * heartbeat = evel_new_heartbeat(); + assert(heartbeat != NULL); + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + evel_free_event(heartbeat); +} + +void test_encode_header_overrides() +{ + char * expected = + "{\"event\": {" + "\"commonEventHeader\": {" + "\"domain\": \"heartbeat\", " + "\"eventId\": \"121\", " + "\"functionalRole\": \"UNIT TEST\", " + "\"lastEpochMicrosec\": 1000, " + "\"priority\": \"Normal\", " + "\"reportingEntityName\": \"entity_name_override\", " + "\"sequence\": 121, " + "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"startEpochMicrosec\": 1001, " + "\"version\": 1.2, " + "\"eventType\": \"Autonomous heartbeat\", " + "\"reportingEntityId\": \"entity_id_override\", " + "\"sourceId\": \"Dummy VM UUID - No Metadata available\"" + "}}}"; + + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + + /***************************************************************************/ + /* Test the VM name/uuid once. */ + /***************************************************************************/ + evel_set_next_event_sequence(121); + + EVENT_HEADER * heartbeat = evel_new_heartbeat(); + assert(heartbeat != NULL); + + evel_start_epoch_set(heartbeat, 1001); + evel_last_epoch_set(heartbeat, 1000); + evel_reporting_entity_name_set(heartbeat, "entity_name_override"); + evel_reporting_entity_id_set(heartbeat, "entity_id_override"); + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + evel_free_event(heartbeat); +} + diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c index 04238d1..bb9f8bc 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c @@ -57,9 +57,9 @@ EVENT_VOICE_QUALITY * evel_new_voice_quality(const char* ev_name, const char *ev EVENT_VOICE_QUALITY *voiceQuality = NULL; EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /**************************************************************************/ + /* Check preconditions. */ + /**************************************************************************/ assert(calleeSideCodec != NULL); assert(callerSideCodec != NULL); assert(correlator != NULL); @@ -82,10 +82,10 @@ EVENT_VOICE_QUALITY * evel_new_voice_quality(const char* ev_name, const char *ev memset(voiceQuality, 0, sizeof(EVENT_VOICE_QUALITY)); EVEL_DEBUG("New Voice Quality is at %lp", voiceQuality); - /***************************************************************************/ - /* Initialize the header & the fault fields. Optional integer values are */ - /* initialized as 0. */ - /***************************************************************************/ + /***************************************************************************/ + /* Initialize the header & the fault fields. Optional integer values are */ + /* initialized as 0. */ + /***************************************************************************/ evel_init_header_nameid(&voiceQuality->header,ev_name,ev_id); voiceQuality->header.event_domain = EVEL_DOMAIN_VOICE_QUALITY; voiceQuality->major_version = EVEL_VOICEQ_MAJOR_VERSION; @@ -96,7 +96,7 @@ EVENT_VOICE_QUALITY * evel_new_voice_quality(const char* ev_name, const char *ev voiceQuality->correlator = strdup(correlator); voiceQuality->midCallRtcp = strdup(midCallRtcp); evel_init_vendor_field(&voiceQuality->vendorVnfNameFields, vendorName); - dlist_initialize(&voiceQuality->additionalInformation); + voiceQuality->additionalInformation = ht_create(); voiceQuality->endOfCallVqmSummaries = NULL; evel_init_option_string(&voiceQuality->phoneNumber); } @@ -122,27 +122,26 @@ EVENT_VOICE_QUALITY * evel_new_voice_quality(const char* ev_name, const char *ev * returns. *****************************************************************************/ void evel_voice_quality_addl_info_add(EVENT_VOICE_QUALITY * voiceQ, char * name, char * value) { - VOICE_QUALITY_ADDL_INFO * addlInfo = NULL; + + char *nam=NULL; + char *val=NULL; + EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQ != NULL); assert(voiceQ->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(name != NULL); assert(value != NULL); EVEL_DEBUG("Adding name=%s value=%s", name, value); - addlInfo = malloc(sizeof(VOICE_QUALITY_ADDL_INFO)); - assert(addlInfo != NULL); - memset(addlInfo, 0, sizeof(VOICE_QUALITY_ADDL_INFO)); - addlInfo->name = strdup(name); - addlInfo->value = strdup(value); - assert(addlInfo->name != NULL); - assert(addlInfo->value != NULL); - dlist_push_last(&voiceQ->additionalInformation, addlInfo); + nam = strdup(name); + val = strdup(value); + + ht_insert(voiceQ->additionalInformation, nam, val); EVEL_EXIT(); } @@ -164,9 +163,9 @@ void evel_voice_quality_callee_codec_set(EVENT_VOICE_QUALITY * voiceQuality, const char * const calleeCodecForCall) { EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(calleeCodecForCall != NULL); @@ -193,9 +192,9 @@ void evel_voice_quality_caller_codec_set(EVENT_VOICE_QUALITY * voiceQuality, const char * const callerCodecForCall) { EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(callerCodecForCall != NULL); @@ -222,9 +221,9 @@ void evel_voice_quality_correlator_set(EVENT_VOICE_QUALITY * voiceQuality, const char * const vCorrelator) { EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(vCorrelator != NULL); @@ -251,9 +250,9 @@ void evel_voice_quality_rtcp_data_set(EVENT_VOICE_QUALITY * voiceQuality, const char * const rtcpCallData) { EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(rtcpCallData != NULL); @@ -277,12 +276,13 @@ void evel_voice_quality_rtcp_data_set(EVENT_VOICE_QUALITY * voiceQuality, * returns. *****************************************************************************/ void evel_voice_quality_vnfmodule_name_set(EVENT_VOICE_QUALITY * voiceQuality, - const char * const module_name) { + const char * const module_name) +{ EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(module_name != NULL); @@ -306,12 +306,13 @@ void evel_voice_quality_vnfmodule_name_set(EVENT_VOICE_QUALITY * voiceQuality, * returns. *****************************************************************************/ void evel_voice_quality_vnfname_set(EVENT_VOICE_QUALITY * voiceQuality, - const char * const vnfname) { + const char * const vnfname) +{ EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(vnfname != NULL); @@ -335,12 +336,13 @@ void evel_voice_quality_vnfname_set(EVENT_VOICE_QUALITY * voiceQuality, * returns. *****************************************************************************/ void evel_voice_quality_phone_number_set(EVENT_VOICE_QUALITY * voiceQuality, - const char * const phoneNumber) { + const char * const phoneNumber) +{ EVEL_ENTER(); - /***************************************************************************/ - /* Check preconditions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(phoneNumber != NULL); @@ -360,14 +362,14 @@ void evel_voice_quality_phone_number_set(EVENT_VOICE_QUALITY * voiceQuality, * @param voiceQuality Pointer to the measurement. * @param adjacencyName Adjacency name * @param endpointDescription Enumeration: ‘Caller’, ‘Callee’. - * @param endpointJitter Endpoint jitter + * @param localRtpOctetsLost Local RTP Octets Lost * @param endpointRtpOctetsDiscarded Endpoint RTP octets discarded. * @param endpointRtpOctetsReceived Endpoint RTP octets received. * @param endpointRtpOctetsSent Endpoint RTP octets sent * @param endpointRtpPacketsDiscarded Endpoint RTP packets discarded. * @param endpointRtpPacketsReceived Endpoint RTP packets received. * @param endpointRtpPacketsSent Endpoint RTP packets sent. - * @param localJitter Local jitter. + * @param localMaxJitterBufferDelay Local max jitter buffer Delay. * @param localRtpOctetsDiscarded Local RTP octets discarded. * @param localRtpOctetsReceived Local RTP octets received. * @param localRtpOctetsSent Local RTP octets sent. @@ -376,21 +378,29 @@ void evel_voice_quality_phone_number_set(EVENT_VOICE_QUALITY * voiceQuality, * @param localRtpPacketsSent Local RTP packets sent. * @param mosCqe Decimal range from 1 to 5 * (1 decimal place) - * @param packetsLost No Packets lost + * @param localRtpPacketsLost Local RTP Packets lost * @param packetLossPercent Calculated percentage packet loss * @param rFactor rFactor from 0 to 100 * @param roundTripDelay Round trip delay in milliseconds + * @param endpointAverageJitter Endpoint average jitter + * @param endpointMaxJitter Endpoint maximum jitter + * @param endpointRtpOctetsLost Endpoint RTP octets lost + * @param endpointRtpPacketsLost Endpoint RTP packets lost + * @param localAverageJitter Local average jitter + * @param localAverageJitterBufferDelay Local average jitter buffer delay + * @param localMaxJitter Local maximum jitter + * @param oneWayDelay one-way path delay in milliseconds *****************************************************************************/ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, const char * adjacencyName, EVEL_SERVICE_ENDPOINT_DESC endpointDescription, - int endpointJitter, + int localRtpOctetsLost, int endpointRtpOctetsDiscarded, int endpointRtpOctetsReceived, int endpointRtpOctetsSent, int endpointRtpPacketsDiscarded, int endpointRtpPacketsReceived, int endpointRtpPacketsSent, - int localJitter, + int localMaxJitterBufferDelay, int localRtpOctetsDiscarded, int localRtpOctetsReceived, int localRtpOctetsSent, @@ -398,17 +408,26 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, int localRtpPacketsReceived, int localRtpPacketsSent, int mosCqe, - int packetsLost, + int localRtpPacketsLost, int packetLossPercent, int rFactor, - int roundTripDelay) { + int roundTripDelay, + int endpointAverageJitter, + int endpointMaxJitter, + int endpointRtpOctetsLost, + int endpointRtpPacketsLost, + int localAverageJitter, + int localAverageJitterBufferDelay, + int localMaxJitter, + int oneWayDelay) +{ END_OF_CALL_VOICE_QUALITY_METRICS * vQMetrices = NULL; EVEL_ENTER(); - /***************************************************************************/ - /* Check assumptions. */ - /***************************************************************************/ + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ assert(voiceQuality != NULL); assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY); assert(adjacencyName != NULL); @@ -417,9 +436,9 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, assert(rFactor >= 0 && rFactor <= 100); assert(voiceQuality->endOfCallVqmSummaries == NULL); - /***************************************************************************/ - /* Allocate a container for the value and push onto the list. */ - /***************************************************************************/ + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ EVEL_DEBUG("Adding adjacencyName=%s endpointDescription=%d", adjacencyName, endpointDescription); vQMetrices = malloc(sizeof(END_OF_CALL_VOICE_QUALITY_METRICS)); assert(vQMetrices != NULL); @@ -428,14 +447,14 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, vQMetrices->adjacencyName = strdup(adjacencyName); vQMetrices->endpointDescription = evel_service_endpoint_desc(endpointDescription); - evel_set_option_int(&vQMetrices->endpointJitter, endpointJitter, "Endpoint jitter"); + evel_set_option_int(&vQMetrices->localRtpOctetsLost, localRtpOctetsLost, "local RTP Octets Lost"); evel_set_option_int(&vQMetrices->endpointRtpOctetsDiscarded, endpointRtpOctetsDiscarded, "Endpoint RTP octets discarded"); evel_set_option_int(&vQMetrices->endpointRtpOctetsReceived, endpointRtpOctetsReceived, "Endpoint RTP octets received"); evel_set_option_int(&vQMetrices->endpointRtpOctetsSent, endpointRtpOctetsSent, "Endpoint RTP octets sent"); evel_set_option_int(&vQMetrices->endpointRtpPacketsDiscarded, endpointRtpPacketsDiscarded, "Endpoint RTP packets discarded"); evel_set_option_int(&vQMetrices->endpointRtpPacketsReceived, endpointRtpPacketsReceived, "Endpoint RTP packets received"); evel_set_option_int(&vQMetrices->endpointRtpPacketsSent, endpointRtpPacketsSent, "Endpoint RTP packets sent"); - evel_set_option_int(&vQMetrices->localJitter, localJitter, "Local jitter"); + evel_set_option_int(&vQMetrices->localMaxJitterBufferDelay, localMaxJitterBufferDelay, "Local Max jitter buffer delay"); evel_set_option_int(&vQMetrices->localRtpOctetsDiscarded, localRtpOctetsDiscarded, "Local RTP octets discarded"); evel_set_option_int(&vQMetrices->localRtpOctetsReceived, localRtpOctetsReceived, "Local RTP octets received"); evel_set_option_int(&vQMetrices->localRtpOctetsSent, localRtpOctetsSent, "Local RTP octets sent"); @@ -443,10 +462,18 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, evel_set_option_int(&vQMetrices->localRtpPacketsReceived, localRtpPacketsReceived, "Local RTP packets received"); evel_set_option_int(&vQMetrices->localRtpPacketsSent, localRtpPacketsSent, "Local RTP packets sent"); evel_set_option_int(&vQMetrices->mosCqe, mosCqe, "Decimal range from 1 to 5 (1 decimal place)"); - evel_set_option_int(&vQMetrices->packetsLost, packetsLost, "Packets lost"); + evel_set_option_int(&vQMetrices->localRtpPacketsLost, localRtpPacketsLost, "Local RTP Packets lost"); evel_set_option_int(&vQMetrices->packetLossPercent, packetLossPercent, "Calculated percentage packet loss"); evel_set_option_int(&vQMetrices->rFactor, rFactor, "rFactor "); evel_set_option_int(&vQMetrices->roundTripDelay, roundTripDelay, "Round trip delay in milliseconds "); + evel_set_option_int(&vQMetrices->endpointAverageJitter, endpointAverageJitter, "Endpoint average jitter"); + evel_set_option_int(&vQMetrices->endpointMaxJitter, endpointMaxJitter, "Endpoint maximum jitter"); + evel_set_option_int(&vQMetrices->endpointRtpOctetsLost, endpointRtpOctetsLost, "Endpoint RTP octets lost"); + evel_set_option_int(&vQMetrices->endpointRtpPacketsLost, endpointRtpPacketsLost, "Endpoint RTP packets lost"); + evel_set_option_int(&vQMetrices->localAverageJitter, localAverageJitter, "Local average jitter"); + evel_set_option_int(&vQMetrices->localAverageJitterBufferDelay, localAverageJitterBufferDelay, "Local average jitter buffer delay"); + evel_set_option_int(&vQMetrices->localMaxJitter, localMaxJitter, "Local maximum jitter"); + evel_set_option_int(&vQMetrices->oneWayDelay, oneWayDelay, "one-way path delay in milliseconds"); voiceQuality->endOfCallVqmSummaries = vQMetrices; @@ -463,8 +490,8 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality, void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, EVENT_VOICE_QUALITY * event) { - VOICE_QUALITY_ADDL_INFO * addlInfo = NULL; - DLIST_ITEM * addlInfoItem = NULL; + HASHTABLE_T *ht; + ENTRY_T *entry; END_OF_CALL_VOICE_QUALITY_METRICS * vQMetrics = NULL; @@ -498,35 +525,49 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, /* Checkpoint, so that we can wind back if all fields are suppressed. */ /***************************************************************************/ //additionalInformation for Voice Quality - bool item_added = false; - + evel_json_checkpoint(jbuf); - if (evel_json_open_opt_named_list(jbuf, "additionalInformation")) + ht = event->additionalInformation; + if( ht != NULL ) { - - addlInfoItem = dlist_get_first(&event->additionalInformation); - while (addlInfoItem != NULL) + bool added = false; + if( ht->size > 0) { - addlInfo = (VOICE_QUALITY_ADDL_INFO*)addlInfoItem->item; - assert(addlInfo != NULL); - - if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, - "additionalInformation", - addlInfo->name)) + evel_json_checkpoint(jbuf); + if (evel_json_open_opt_named_object(jbuf, "additionalInformation")) { - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", addlInfo->name); - evel_enc_kv_string(jbuf, "value", addlInfo->value); - evel_json_close_object(jbuf); - item_added = true; + + for(unsigned int idx = 0; idx < ht->size; idx++ ) + { + /*****************************************************************/ + /* Get the first entry of a particular Key and loop through the */ + /* remaining if any. Then proceed to next key. */ + /*****************************************************************/ + entry = ht->table[idx]; + while( entry != NULL && entry->key != NULL) + { + EVEL_DEBUG("Encoding Voice Quality Fields %s %s",(char *) (entry->key), entry->value); + if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec, + "additionalInformation", + entry->key)) + { + + //evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, entry->key, entry->value); + //evel_json_close_object(jbuf); + added = true; + } + entry = entry->next; + } + } } - addlInfoItem = dlist_get_next(addlInfoItem); } - evel_json_close_list(jbuf); + evel_json_close_object(jbuf); + /*************************************************************************/ /* If we've not written anything, rewind to before we opened the list. */ /*************************************************************************/ - if (!item_added) + if (!added) { evel_json_rewind(jbuf); } @@ -544,14 +585,14 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, { evel_enc_kv_string(jbuf, "adjacencyName", vQMetrics->adjacencyName); evel_enc_kv_string(jbuf, "endpointDescription", vQMetrics->endpointDescription); - evel_enc_kv_opt_int(jbuf, "endpointJitter", &vQMetrics->endpointJitter); + evel_enc_kv_opt_int(jbuf, "localRtpOctetsLost", &vQMetrics->localRtpOctetsLost); evel_enc_kv_opt_int(jbuf, "endpointRtpOctetsDiscarded", &vQMetrics->endpointRtpOctetsDiscarded); evel_enc_kv_opt_int(jbuf, "endpointRtpOctetsReceived", &vQMetrics->endpointRtpOctetsReceived); evel_enc_kv_opt_int(jbuf, "endpointRtpOctetsSent", &vQMetrics->endpointRtpOctetsSent); evel_enc_kv_opt_int(jbuf, "endpointRtpPacketsDiscarded", &vQMetrics->endpointRtpPacketsDiscarded); evel_enc_kv_opt_int(jbuf, "endpointRtpPacketsReceived", &vQMetrics->endpointRtpPacketsReceived); evel_enc_kv_opt_int(jbuf, "endpointRtpPacketsSent", &vQMetrics->endpointRtpPacketsSent); - evel_enc_kv_opt_int(jbuf, "localJitter", &vQMetrics->localJitter); + evel_enc_kv_opt_int(jbuf, "localMaxJitterBufferDelay", &vQMetrics->localMaxJitterBufferDelay); evel_enc_kv_opt_int(jbuf, "localRtpOctetsDiscarded", &vQMetrics->localRtpOctetsDiscarded); evel_enc_kv_opt_int(jbuf, "localRtpOctetsReceived", &vQMetrics->localRtpOctetsReceived); evel_enc_kv_opt_int(jbuf, "localRtpOctetsSent", &vQMetrics->localRtpOctetsSent); @@ -559,10 +600,18 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, evel_enc_kv_opt_int(jbuf, "localRtpPacketsReceived", &vQMetrics->localRtpPacketsReceived); evel_enc_kv_opt_int(jbuf, "localRtpPacketsSent", &vQMetrics->localRtpPacketsSent); evel_enc_kv_opt_int(jbuf, "mosCqe", &vQMetrics->mosCqe); - evel_enc_kv_opt_int(jbuf, "packetsLost", &vQMetrics->packetsLost); + evel_enc_kv_opt_int(jbuf, "localRtpPacketsLost", &vQMetrics->localRtpPacketsLost); evel_enc_kv_opt_int(jbuf, "packetLossPercent", &vQMetrics->packetLossPercent); evel_enc_kv_opt_int(jbuf, "rFactor", &vQMetrics->rFactor); evel_enc_kv_opt_int(jbuf, "roundTripDelay", &vQMetrics->roundTripDelay); + evel_enc_kv_opt_int(jbuf, "endpointAverageJitter", &vQMetrics->endpointAverageJitter); + evel_enc_kv_opt_int(jbuf, "endpointMaxJitter", &vQMetrics->endpointMaxJitter); + evel_enc_kv_opt_int(jbuf, "endpointRtpOctetsLost", &vQMetrics->endpointRtpOctetsLost); + evel_enc_kv_opt_int(jbuf, "endpointRtpPacketsLost", &vQMetrics->endpointRtpPacketsLost); + evel_enc_kv_opt_int(jbuf, "localAverageJitter", &vQMetrics->localAverageJitter); + evel_enc_kv_opt_int(jbuf, "localAverageJitterBufferDelay", &vQMetrics->localAverageJitterBufferDelay); + evel_enc_kv_opt_int(jbuf, "localMaxJitter", &vQMetrics->localMaxJitter); + evel_enc_kv_opt_int(jbuf, "oneWayDelay", &vQMetrics->oneWayDelay); } @@ -585,7 +634,8 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, *****************************************************************************/ void evel_free_voice_quality(EVENT_VOICE_QUALITY * voiceQuality) { END_OF_CALL_VOICE_QUALITY_METRICS * vQMetrices = NULL; - VOICE_QUALITY_ADDL_INFO * addlInfo = NULL; + + HASHTABLE_T *ht; EVEL_ENTER(); @@ -601,16 +651,10 @@ void evel_free_voice_quality(EVENT_VOICE_QUALITY * voiceQuality) { /***************************************************************************/ //Additional Information - addlInfo = dlist_pop_last(&voiceQuality->additionalInformation); - while (addlInfo != NULL) + ht = voiceQuality->additionalInformation; + if( ht != NULL ) { - EVEL_DEBUG("Freeing Additional Info (%s, %s)", - addlInfo->name, - addlInfo->value); - free(addlInfo->name); - free(addlInfo->value); - free(addlInfo); - addlInfo = dlist_pop_last(&voiceQuality->additionalInformation); + ht_destroy(ht); } //Summary Information diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c index d0017c9..ed22dcc 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c @@ -31,6 +31,7 @@ #include #include "hashtable.h" +#include "evel.h" /**************************************************************************//** * Hashtable initialization. @@ -42,22 +43,28 @@ * @returns Hashtable pointer ******************************************************************************/ /* Create a new hashtable. */ -HASHTABLE_T *ht_create( size_t size ) { +HASHTABLE_T *ht_sizecreate( size_t size ) { - HASHTABLE_T *hashtable = NULL; + HASHTABLE_T *hashtable=NULL; size_t i; - if( size < 1 ) return NULL; + assert( size >= 1 ); /* Allocate the table itself. */ - if( ( hashtable = malloc( sizeof( HASHTABLE_T ) ) ) == NULL ) { + if( ( hashtable = malloc( sizeof( *hashtable ) ) ) == NULL ) { + assert( hashtable != NULL ); return NULL; } + memset(hashtable, 0, sizeof(*hashtable)); + + hashtable->n = 0; + /* Allocate pointers to the head nodes. */ if( ( hashtable->table = malloc( sizeof( ENTRY_T * ) * size ) ) == NULL ) { return NULL; } + for( i = 0; i < size; i++ ) { hashtable->table[i] = NULL; } @@ -67,6 +74,34 @@ HASHTABLE_T *ht_create( size_t size ) { return hashtable; } +/**************************************************************************//** + * Hashtable initialization. + * + * Initialize hashtable default finction + * @returns Hashtable +******************************************************************************/ +HASHTABLE_T *ht_create(void) +{ + return ht_sizecreate( INITIAL_SIZE ); +} + +/**************************************************************************//** + * Named Hashtable initialization. + * + * Initialize hashtable default finction + * @returns Hashtable +******************************************************************************/ +HASHTABLE_T *nht_create(char * hashtable_name) +{ + HASHTABLE_T *hashtable=NULL; + hashtable = ht_sizecreate( INITIAL_SIZE ); + if (hashtable != NULL) + { + hashtable->hmName = hashtable_name; + } + return (hashtable); +} + /**************************************************************************//** * Hash a string for a particular hash table. * @@ -106,7 +141,7 @@ size_t ht_hash( HASHTABLE_T *hashtable, char *key ) ******************************************************************************/ ENTRY_T *ht_newpair( char *key, void *value ) { - ENTRY_T *newpair; + ENTRY_T *newpair = NULL; if( ( newpair = malloc( sizeof( ENTRY_T ) ) ) == NULL ) { return NULL; @@ -116,7 +151,7 @@ ENTRY_T *ht_newpair( char *key, void *value ) return NULL; } - if( ( newpair->value = value ) == NULL ) { + if( ( newpair->value = strdup( value )) == NULL ) { return NULL; } @@ -125,6 +160,46 @@ ENTRY_T *ht_newpair( char *key, void *value ) return newpair; } +/**************************************************************************//** + * Grow hash table to bigger size + * + * @param key key string + * @param value value string + * + * @returns hashtable entry +******************************************************************************/ +static void ht_growtable(HASHTABLE_T *d) +{ + HASHTABLE_T * d2; /* new dictionary we'll create */ + HASHTABLE_T swap; + size_t i; + ENTRY_T *e; + + d2 = ht_sizecreate(d->size * GROWTH_FACTOR); + + if (d->hmName != NULL) + { + d2->hmName = strdup (d->hmName); + } + + for(i = 0; i < d->size; i++) { + for(e = d->table[i]; e != 0; e = e->next) { + /* note: this recopies everything */ + ht_insert(d2, e->key, e->value); + } + } + + /* the hideous part */ + /* We'll swap the guts of d and d2 */ + /* then call Destroy on d2 */ + swap = *d; + *d = *d2; + *d2 = swap; + + ht_destroy(d2); +} + + /**************************************************************************//** * Insert a key-value pair into a hash table. * @@ -133,7 +208,7 @@ ENTRY_T *ht_newpair( char *key, void *value ) * * @returns Nothing ******************************************************************************/ -void ht_set( HASHTABLE_T *hashtable, char *key, void *value ) { +void ht_insert( HASHTABLE_T *hashtable, char *key, void *value ) { size_t bin = 0; ENTRY_T *newpair = NULL; ENTRY_T *next = NULL; @@ -152,7 +227,8 @@ void ht_set( HASHTABLE_T *hashtable, char *key, void *value ) { if( next != NULL && next->key != NULL && strcmp( key, next->key ) == 0 ) { free( next->value ); - next->value = value ; + next->value = strdup( value ) ; + EVEL_WARN("Duplicate key entries in Hashtable.Overwritten"); /* Nope, could't find it. Time to grow a pair. */ } else { @@ -162,7 +238,6 @@ void ht_set( HASHTABLE_T *hashtable, char *key, void *value ) { if( next == hashtable->table[ bin ] ) { newpair->next = next; hashtable->table[ bin ] = newpair; - /* We're at the end of the linked list in this bin. */ } else if ( next == NULL ) { last->next = newpair; @@ -172,6 +247,12 @@ void ht_set( HASHTABLE_T *hashtable, char *key, void *value ) { newpair->next = next; last->next = newpair; } + hashtable->n++; + + if( hashtable->n >= (hashtable->size*MAX_LOAD_FACTOR)) + { + ht_growtable(hashtable); + } } } @@ -182,7 +263,7 @@ void ht_set( HASHTABLE_T *hashtable, char *key, void *value ) { * * @returns value string ******************************************************************************/ -void *ht_get( HASHTABLE_T *hashtable, char *key ) { +void *ht_search( HASHTABLE_T *hashtable, char *key ) { size_t bin = 0; ENTRY_T *pair; @@ -204,21 +285,33 @@ void *ht_get( HASHTABLE_T *hashtable, char *key ) { } -/* -int main( int argc, char **argv ) { - - HASHTABLE_T *hashtable = ht_create( 65536 ); - ht_set( hashtable, "key1", "inky" ); - ht_set( hashtable, "key2", "pinky" ); - ht_set( hashtable, "key3", "blinky" ); - ht_set( hashtable, "key4", "floyd" ); - - printf( "%s\n", ht_get( hashtable, "key1" ) ); - printf( "%s\n", ht_get( hashtable, "key2" ) ); - printf( "%s\n", ht_get( hashtable, "key3" ) ); - printf( "%s\n", ht_get( hashtable, "key4" ) ); +/**************************************************************************//** + * Hashtable destroy + * +******************************************************************************/ +void ht_destroy(HASHTABLE_T *d) +{ + size_t i; + ENTRY_T *e; + ENTRY_T *next; + + for(i = 0; i < d->size; i++) { + for(e = d->table[i]; e != NULL; e = next) { + next = e->next; + + free(e->key); + free(e->value); + free(e); + } + } + + free(d->table); + if (d->hmName != NULL) + { + free(d->hmName); + } + free(d); - return 0; } -*/ + diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.h index 8be17dc..a0b2fb7 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.h +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.h @@ -20,7 +20,7 @@ /**************************************************************************//** * @file - * A simple hashtable. + * A flexible dynamic hashtable * * @note No thread protection so you will need to use appropriate * synchronization if use spans multiple threads. @@ -38,20 +38,52 @@ typedef struct entry_s { typedef struct hashtable_s { size_t size; + int n; + char *hmName; struct entry_s **table; } HASHTABLE_T; +typedef struct hashtable_s *HASHTABLE; + +#define INITIAL_SIZE (2) +#define GROWTH_FACTOR (2) +#define MAX_LOAD_FACTOR (2) + /**************************************************************************//** * Hashtable initialization. * - * Initialize the list supplied to be empty. - * + * Initialize hashtable internal finction * @param size Size of hashtable - - * @returns Hashtable pointer + * @returns Hashtable ******************************************************************************/ /* Create a new hashtable. */ -HASHTABLE_T *ht_create( size_t size ); +HASHTABLE_T *ht_sizecreate( size_t size ); + +/**************************************************************************//** + * Hashtable initialization. + * + * Initialize hashtable default function + * @returns Hashtable +******************************************************************************/ +HASHTABLE_T *ht_create(void); + +/**************************************************************************//** + * Named Hashtable initialization. + * + * Initialize Named hashtable default function + * @param hashtable_name + * @returns Hashtable +******************************************************************************/ +HASHTABLE_T *nht_create(char * hashtable_name); + +/**************************************************************************//** + * Hashtable Destruction + * + * Initialize hashtable destroy function + * @returns Hashtable +******************************************************************************/ +void ht_destroy(HASHTABLE_T *hashtable); + /**************************************************************************//** * Hash a string for a particular hash table. @@ -63,7 +95,7 @@ HASHTABLE_T *ht_create( size_t size ); * @returns hashvalue ******************************************************************************/ -size_t ht_hash( HASHTABLE_T *hashtable, char *key ); +size_t ht_hash( HASHTABLE_T* hashtable, char *key ); /**************************************************************************//** * Create a key-value pair. @@ -83,7 +115,7 @@ ENTRY_T *ht_newpair( char *key, void *value ); * * @returns Nothing ******************************************************************************/ -void ht_set( HASHTABLE_T *hashtable, char *key, void *value ); +void ht_insert( HASHTABLE_T* hashtable, char *key, void *value ); /**************************************************************************//** * Retrieve a key-value pair from a hash table. @@ -92,6 +124,16 @@ void ht_set( HASHTABLE_T *hashtable, char *key, void *value ); * * @returns value string ******************************************************************************/ -void *ht_get( HASHTABLE_T *hashtable, char *key ); +void *ht_search( HASHTABLE_T* hashtable, char *key ); + +/**************************************************************************//** + * Delete a key-value pair from a hash table. + * + * @param key key string + * + * @returns value string +******************************************************************************/ +void ht_delete( HASHTABLE_T* hashtable, char *key ); + #endif diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/quickstart.md b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/quickstart.md index 1c735cc..c812636 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/quickstart.md +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/quickstart.md @@ -253,16 +253,30 @@ point the `evel_initialize()` function is called: ```C #include "evel.h" ... - if (evel_initialize(api_fqdn, - api_port, - api_path, - api_topic, - api_secure, - "Alice", - "This isn't very secure!", - EVEL_SOURCE_VIRTUAL_MACHINE, - "EVEL demo client", - verbose_mode)) + if(evel_initialize(fqdn, /* FQDN */ + port, /* Port */ + NULL, /* Backup FQDN */ + 0, /* Backup port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 100, /* Ring Buffer size */ + 0, /* HTTPS? */ + 0, /* active mode? */ + NULL, /* cert file */ + NULL, /* key file */ + NULL, /* ca info */ + NULL, /* ca file */ + 0, /* verify peer */ + 0, /* verify host */ + "", /* Username */ + "", /* Password */ + "", /* Username2 */ + "", /* Password2 */ + NULL, /* Source ip */ + NULL, /* Source ip2 */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL demo client", /* Role */ + verbose_mode)) /* Verbosity */ { fprintf(stderr, "Failed to initialize the EVEL library!!!"); exit(-1); @@ -303,10 +317,15 @@ In practice this looks like: /***************************************************************************/ /* Create a new Fault object, setting mandatory fields as we do so... */ /***************************************************************************/ - fault = evel_new_fault("My alarm condition", + fault = evel_new_fault("fault_eNodeB_alarm", + "fault000000001", + "My alarm condition", "It broke very badly", EVEL_PRIORITY_NORMAL, - EVEL_SEVERITY_MAJOR); + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_HOST, + EVEL_VF_STATUS_READY_TERMINATE); + if (fault != NULL) { /*************************************************************************/ @@ -316,7 +335,8 @@ In practice this looks like: evel_fault_interface_set(fault, "My Interface Card"); evel_fault_addl_info_add(fault, "name1", "value1"); evel_fault_addl_info_add(fault, "name2", "value2"); - + evel_fault_category_set(fault, "link"); + /*************************************************************************/ /* Finally, post the Fault. In practice this will only ever fail if */ /* local ring-buffer is full because of event overload. */ @@ -339,15 +359,11 @@ The _EVEL Library_ supports the following types of events: 2. Measurements - These represent the **measurementsForVfScaling** domain in the event - schema. + These represent the **measurement** domain in the event schema. - 3. Reports + 3. Notification - This is an experimental type, designed to allow VNFs to report - application-level statistics unencumbered with platform measurements. - The formal AT&T schema has been updated to include this experimental - type as **measurementsForVfReporting**. + These represent the **notification** domain in the event schema. 4. Mobile Flow @@ -357,13 +373,13 @@ The _EVEL Library_ supports the following types of events: These represent the **other** domain in the event schema. - 6. Service Events + 6. PNF Registration - These represent the **serviceEvents** domain in the event schema. + These represent the **pnfRegistration** domain in the event schema. - 7. Signaling + 7. SIP Signaling - These represent the **signaling** domain in the event schema. + These represent the **sipSignaling** domain in the event schema. 8. State Change @@ -373,26 +389,14 @@ The _EVEL Library_ supports the following types of events: These represent the **syslog** domain in the event schema. -### Throttling {#qs_throttling} - -The _EVEL library_ supports the following command types as defined in the JSON API: + 10. Threshold Crossing Alert - 1. commandType: throttlingSpecification + These represent the **thresholdCrossingAlert** domain in the event schema. - This is handled internally by the EVEL library, which stores the provided - throttling specification internally and applies it to all subsequent events. + 11. Voice Quality - 2. commandType: provideThrottlingState + These represent the **voiceQuality** domain in the event schema. - This is handled internally by the EVEL library, which returns the current - throttling specification for each domain. - - 3. commandType: measurementIntervalChange - - This is handled by the EVEL library, which makes the latest measurement - interval available via the ::evel_get_measurement_interval function. - The application is responsible for checking and adhering to the latest - provided interval. ### Termination {#qs_termination} @@ -442,4 +446,4 @@ the log_debug() and log_initialize() functions should be rewritten accordingly. logging function. [Turtles all the way down...](https://en.wikipedia.org/wiki/Turtles_all_the_way_down) - \ No newline at end of file + diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c index ad50874..248baf2 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c @@ -101,9 +101,9 @@ void * ring_buffer_read(ring_buffer * buffer) msg = (buffer->ring)[buffer->next_read]; buffer->ring[buffer->next_read] = NULL; buffer->next_read = (buffer->next_read + 1) % buffer->size; - EVEL_DEBUG("RBR: next read location is %d", buffer->next_read); pthread_mutex_unlock(&buffer->ring_mutex); - break; + EVEL_DEBUG("RBR: next read location is %d data %lp", buffer->next_read,msg); + return msg; } else { @@ -112,7 +112,7 @@ void * ring_buffer_read(ring_buffer * buffer) EVEL_DEBUG("RBR: Condition variable wait completed"); } } - EVEL_DEBUG("RBR: Ring buffer read returning data at %lp", msg); + pthread_mutex_unlock(&buffer->ring_mutex); return msg; } diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/Makefile b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/Makefile new file mode 100644 index 0000000..1187670 --- /dev/null +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/Makefile @@ -0,0 +1,44 @@ +############################################################################# +# +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################# + +CC=gcc +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: evel_unit + +clean: + rm -f evel_unit + +evel_unit: evel_unit.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o evel_unit \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + evel_unit.c \ + -lpthread \ + -level \ + -lcurl + + diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c index 3cfb66b..affb88a 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "evel.h" #include "evel_internal.h" @@ -49,35 +50,39 @@ typedef enum { /* Local prototypes. */ /*****************************************************************************/ static void test_encode_heartbeat(); -static void test_encode_header_overrides(); +//static void test_encode_header_overrides(); static void test_encode_fault(); -static void test_encode_fault_with_escaping(); +//static void test_encode_fault_with_escaping(); static void test_encode_measurement(); static void test_encode_mobile_mand(); -static void test_encode_mobile_opts(); +//static void test_encode_mobile_opts(); static void test_encode_other(); -static void test_encode_report(); -static void test_encode_service(); -static void test_encode_service_subset(const SERVICE_TEST service_test); +static void test_encode_pnfreg(); +static void test_encode_tca(); +//static void test_encode_report(); +//static void test_encode_service(); +//static void test_encode_service_subset(const SERVICE_TEST service_test); static void test_encode_signaling(); +static void test_encode_voiceQ(); +static void test_encode_notif(); static void test_encode_state_change(); static void test_encode_syslog(); -static void test_json_response_junk(); -static void test_json_provide_throttle_state(); -static void test_json_measurement_interval(); -static void test_json_throttle_spec_field(); -static void test_json_throttle_spec_nv_pair(); -static void test_json_throttle_spec_two_domains(); -static void test_json_throttle_spec_bad_command_type(); -static void test_encode_fault_throttled(); -static void test_encode_measurement_throttled(); -static void test_encode_mobile_throttled(); -static void test_encode_other_throttled(); -static void test_encode_report_throttled(); -static void test_encode_service_throttled(); -static void test_encode_signaling_throttled(); -static void test_encode_state_change_throttled(); -static void test_encode_syslog_throttled(); +//static void test_json_response_junk(); +//static void test_json_provide_throttle_state(); +//static void test_json_measurement_interval(); +//static void test_json_throttle_spec_field(); +//static void test_json_throttle_spec_nv_pair(); +//static void test_json_throttle_spec_two_domains(); +//static void test_json_throttle_spec_bad_command_type(); +//static void test_encode_fault_throttled(); +//static void test_encode_measurement_throttled(); +//static void test_encode_mobile_throttled(); +//static void test_encode_other_throttled(); +//static void test_encode_report_throttled(); +//static void test_encode_service_throttled(); +//static void test_encode_signaling_throttled(); +//static void test_encode_state_change_throttled(); +//static void test_encode_syslog_throttled(); static void compare_strings(char * expected, char * actual, int max_size, @@ -93,9 +98,11 @@ static void compare_strings(char * expected, *****************************************************************************/ int main(int argc, char ** argv) { + char * fqdn = "127.0.0.1"; + int port = 30000; assert(argc >= 0); assert(argv != NULL); - + /***************************************************************************/ /* Fix our timezone to UTC. */ /***************************************************************************/ @@ -112,25 +119,65 @@ int main(int argc, char ** argv) functional_role = "UNIT TEST"; log_initialize(EVEL_LOG_DEBUG, "EVEL"); + /**************************************************************************/ + /* Initialize */ + /**************************************************************************/ + if(evel_initialize(fqdn, /* FQDN */ + port, /* Port */ + NULL, /* Backup FQDN */ + 0, /* Backup port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 100, /* Ring Buffer size */ + 0, /* HTTPS? */ + 0, /* active mode? */ + NULL, /* cert file */ + NULL, /* key file */ + NULL, /* ca info */ + NULL, /* ca file */ + 0, /* verify peer */ + 0, /* verify host */ + "will", /* Username */ + "pill", /* Password */ + "", /* Username2 */ + "", /* Password2 */ + NULL, /* Source ip */ + NULL, /* Source ip2 */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "UNIT Test", /* Role */ + 1)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + /***************************************************************************/ /* Test each encoder. */ /***************************************************************************/ - test_encode_heartbeat(); - test_encode_header_overrides(); - test_encode_fault(); - test_encode_measurement(); - test_encode_mobile_mand(); - test_encode_mobile_opts(); - test_encode_other(); - test_encode_report(); - test_encode_service(); - test_encode_signaling(); - test_encode_state_change(); - test_encode_syslog(); - + test_encode_heartbeat(); // Done +// test_encode_header_overrides(); // Done + test_encode_fault(); // Done + test_encode_measurement(); //Done + test_encode_mobile_mand(); // Done +// test_encode_mobile_opts(); // Done + test_encode_other(); // Done + test_encode_pnfreg(); // Done + test_encode_tca(); // Done +// test_encode_report(); +// test_encode_service(); + test_encode_signaling(); // Done - sip signaling + test_encode_voiceQ(); //Done + test_encode_notif(); //Done` + test_encode_state_change(); //Done + test_encode_syslog(); // Done /***************************************************************************/ /* Test JSON Throttle. */ /***************************************************************************/ +/************* test_json_response_junk(); test_json_provide_throttle_state(); test_json_measurement_interval(); @@ -138,27 +185,27 @@ int main(int argc, char ** argv) test_json_throttle_spec_nv_pair(); test_json_throttle_spec_two_domains(); test_json_throttle_spec_bad_command_type(); - +*************/ /***************************************************************************/ /* Test each encoder with throttling applied. */ /***************************************************************************/ - test_encode_fault_throttled(); - test_encode_measurement_throttled(); - test_encode_mobile_throttled(); - test_encode_other_throttled(); - test_encode_report_throttled(); - test_encode_service_throttled(); - test_encode_signaling_throttled(); - test_encode_state_change_throttled(); - test_encode_syslog_throttled(); - +// test_encode_fault_throttled(); // done +// test_encode_measurement_throttled(); +// test_encode_mobile_throttled(); //done +// test_encode_other_throttled(); +// test_encode_report_throttled(); +// test_encode_service_throttled(); +// test_encode_signaling_throttled(); +// test_encode_state_change_throttled(); +// test_encode_syslog_throttled(); /***************************************************************************/ /* Test character escaping. */ /***************************************************************************/ +/******** test_encode_fault_with_escaping(); - +*******/ printf ("\nAll Tests Passed\n"); - + evel_terminate(); return 0; } @@ -179,15 +226,16 @@ void test_encode_heartbeat() "{\"event\": {" "\"commonEventHeader\": {" "\"domain\": \"heartbeat\", " - "\"eventId\": \"121\", " + "\"eventId\": \"heartbeat000000001\", " + "\"eventName\": \"heartbeat_VM\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 121, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " - "\"version\": 1.2, " + "\"version\": 3.0, " "\"eventType\": \"Autonomous heartbeat\", " "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", " "\"sourceId\": \"Dummy VM UUID - No Metadata available\"" @@ -199,7 +247,7 @@ void test_encode_heartbeat() /***************************************************************************/ /* Test the VM name/uuid once. */ /***************************************************************************/ - evel_set_next_event_sequence(121); +// evel_set_next_event_sequence(121); EVENT_HEADER * heartbeat = evel_new_heartbeat(); assert(heartbeat != NULL); @@ -209,7 +257,16 @@ void test_encode_heartbeat() compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(heartbeat); + if(evel_post_event(heartbeat) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(heartbeat); } void test_encode_header_overrides() @@ -219,17 +276,15 @@ void test_encode_header_overrides() "\"commonEventHeader\": {" "\"domain\": \"heartbeat\", " "\"eventId\": \"121\", " - "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000, " "\"priority\": \"Normal\", " "\"reportingEntityName\": \"entity_name_override\", " "\"sequence\": 121, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1001, " "\"version\": 1.2, " "\"eventType\": \"Autonomous heartbeat\", " - "\"reportingEntityId\": \"entity_id_override\", " - "\"sourceId\": \"Dummy VM UUID - No Metadata available\"" + "\"reportingEntityId\": \"entity_id_override\" " "}}}"; size_t json_size = 0; @@ -238,7 +293,7 @@ void test_encode_header_overrides() /***************************************************************************/ /* Test the VM name/uuid once. */ /***************************************************************************/ - evel_set_next_event_sequence(121); +// evel_set_next_event_sequence(121); EVENT_HEADER * heartbeat = evel_new_heartbeat(); assert(heartbeat != NULL); @@ -247,6 +302,8 @@ void test_encode_header_overrides() evel_last_epoch_set(heartbeat, 1000); evel_reporting_entity_name_set(heartbeat, "entity_name_override"); evel_reporting_entity_id_set(heartbeat, "entity_id_override"); + evel_event_sequence_set(heartbeat, 121); + evel_time_zone_offset_set(heartbeat, "UTC+5:30"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat); @@ -262,13 +319,13 @@ void test_encode_fault() "{\"event\": {" "\"commonEventHeader\": {" "\"domain\": \"fault\", " - "\"eventId\": \"122\", " - "\"functionalRole\": \"UNIT TEST\", " + "\"eventId\": \"fault000000001\", " + "\"eventName\": \"fault_eNodeB_alarm\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 122, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Bad things happen...\", " @@ -293,40 +350,52 @@ void test_encode_fault() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; - evel_set_next_event_sequence(122); - EVENT_FAULT * fault = evel_new_fault("My alarm condition", +// evel_set_next_event_sequence(122); + EVENT_FAULT * fault = evel_new_fault("fault_eNodeB_alarm", + "fault000000001", + "My alarm condition", "It broke very badly", EVEL_PRIORITY_NORMAL, EVEL_SEVERITY_MAJOR, EVEL_SOURCE_HOST, - EVEL_VF_STATUS_PREP_TERMINATE); + EVEL_VF_STATUS_READY_TERMINATE); assert(fault != NULL); evel_fault_type_set(fault, "Bad things happen..."); evel_fault_interface_set(fault, "My Interface Card"); evel_fault_addl_info_add(fault, "name1", "value1"); evel_fault_addl_info_add(fault, "name2", "value2"); +evel_fault_category_set(fault, "link"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault); compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(fault); -} + if(evel_post_event((EVENT_HEADER *)fault) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + // evel_free_event(fault); +} void test_encode_measurement() { char * expected = "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"measurementsForVfScaling\", " - "\"eventId\": \"123\", " + "\"eventId\": \"mvfs000000001\", " + "\"eventName\": \"mvfs_perfUnit_issue\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 3000, " "\"priority\": \"Normal\", " "\"reportingEntityName\": \"entity_name\", " "\"sequence\": 123, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 2000, " "\"version\": 1.2, " "\"eventType\": \"Perf management...\", " @@ -424,18 +493,21 @@ void test_encode_measurement() char json_body[EVEL_MAX_JSON_BODY]; EVENT_MEASUREMENT * measurement = NULL; MEASUREMENT_LATENCY_BUCKET * bucket = NULL; - MEASUREMENT_VNIC_PERFORMANCE * vnic_use = NULL; MEASUREMENT_CPU_USE *cpu_use; - - /***************************************************************************/ - /* Measurement. */ - /***************************************************************************/ - evel_set_next_event_sequence(123); - measurement = evel_new_measurement(5.5); + MEASUREMENT_MEM_USE * mem_use; + MEASUREMENT_DISK_USE * disk_use; +// evel_set_next_event_sequence(123); + measurement = evel_new_measurement(5.5,"mvfs_perfUnit_issue", "mvfs000000001"); assert(measurement != NULL); evel_measurement_type_set(measurement, "Perf management..."); + evel_measurement_addl_info_add(measurement, "name1", "value1"); +// evel_measurement_addl_info_add(measurement, "name2", "value2"); +// evel_measurement_addl_info_add(measurement, "name3", "value3"); +// evel_measurement_addl_info_add(measurement, "name4", "value4"); + evel_measurement_conc_sess_set(measurement, 1); evel_measurement_cfg_ents_set(measurement, 2); + evel_measurement_mean_req_lat_set(measurement, 4.4); evel_measurement_request_rate_set(measurement, 7); @@ -448,7 +520,14 @@ void test_encode_measurement() evel_measurement_cpu_use_system_set(cpu_use,77.77); evel_measurement_cpu_use_usageuser_set(cpu_use,88.88); evel_measurement_cpu_use_wait_set(cpu_use,99.99); - + evel_measurement_cpu_use_cpuCapacityContention_set(cpu_use,12.2); + evel_measurement_cpu_use_cpuDemandAvg_set(cpu_use,14.4); + evel_measurement_cpu_use_cpuDemandMhz_set(cpu_use,15.4); + evel_measurement_cpu_use_cpuDemandPct_set(cpu_use,16.4); + evel_measurement_cpu_use_cpuLatencyAvg_set(cpu_use,17.4); + evel_measurement_cpu_use_cpuOverheadAvg_set(cpu_use,18.4); + evel_measurement_cpu_use_cpuSwapWaitTime_set(cpu_use,19.4); +/************** cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu2", 22.22); evel_measurement_cpu_use_idle_set(cpu_use,12.22); evel_measurement_cpu_use_interrupt_set(cpu_use,33.33); @@ -458,74 +537,294 @@ void test_encode_measurement() evel_measurement_cpu_use_system_set(cpu_use,77.77); evel_measurement_cpu_use_usageuser_set(cpu_use,88.88); evel_measurement_cpu_use_wait_set(cpu_use,19.99); - + evel_measurement_cpu_use_cpuCapacityContention_set(cpu_use,22.2); + evel_measurement_cpu_use_cpuDemandAvg_set(cpu_use,24.4); + evel_measurement_cpu_use_cpuDemandMhz_set(cpu_use,25.4); + evel_measurement_cpu_use_cpuDemandPct_set(cpu_use,26.4); + evel_measurement_cpu_use_cpuLatencyAvg_set(cpu_use,27.4); + evel_measurement_cpu_use_cpuOverheadAvg_set(cpu_use,28.4); + evel_measurement_cpu_use_cpuSwapWaitTime_set(cpu_use,29.4); +***************/ + mem_use = evel_measurement_new_mem_use_add(measurement, "VMID", 120, 150); + evel_measurement_mem_use_memcache_set(mem_use, 121.7); + evel_measurement_mem_use_memconfig_set(mem_use, 122.7); + evel_measurement_mem_use_slab_reclaimed_set(mem_use, 123.7); + evel_measurement_mem_use_slab_unreclaimable_set(mem_use, 124.7); + evel_measurement_mem_use_memoryDemand_set(mem_use, 125.7); + evel_measurement_mem_use_memoryLatencyAvg_set(mem_use, 126.7); + evel_measurement_mem_use_memorySharedAvg_set(mem_use, 127.7); + evel_measurement_mem_use_memorySwapInAvg_set(mem_use, 128.7); + evel_measurement_mem_use_memorySwapInRateAvg_set(mem_use, 129.7); + evel_measurement_mem_use_memorySwapOutAvg_set(mem_use, 130.7); + evel_measurement_mem_use_memorySwapOutRateAvg_set(mem_use, 131.7); + evel_measurement_mem_use_memorySwapUsedAvg_set(mem_use, 132.7); + evel_measurement_mem_use_percentMemoryUsage_set(mem_use, 133.7); + + mem_use = evel_measurement_new_mem_use_add(measurement, "VMID2", 220, 250); + evel_measurement_mem_use_mem_buffered_set(mem_use, 100.4); + evel_measurement_mem_use_memcache_set(mem_use, 221.7); + evel_measurement_mem_use_memconfig_set(mem_use, 222.7); + evel_measurement_mem_use_slab_reclaimed_set(mem_use, 223.7); + evel_measurement_mem_use_slab_unreclaimable_set(mem_use, 224.7); + evel_measurement_mem_use_memoryDemand_set(mem_use, 225.7); + evel_measurement_mem_use_memoryLatencyAvg_set(mem_use, 226.7); + evel_measurement_mem_use_memorySharedAvg_set(mem_use, 227.7); + evel_measurement_mem_use_memorySwapInAvg_set(mem_use, 228.7); + evel_measurement_mem_use_memorySwapInRateAvg_set(mem_use, 229.7); + evel_measurement_mem_use_memorySwapOutAvg_set(mem_use, 230.7); + evel_measurement_mem_use_memorySwapOutRateAvg_set(mem_use, 231.7); + evel_measurement_mem_use_memorySwapUsedAvg_set(mem_use, 232.7); + evel_measurement_mem_use_percentMemoryUsage_set(mem_use, 233.7); + + disk_use = evel_measurement_new_disk_use_add(measurement, "Disk1"); + evel_measurement_disk_use_iotimeavg_set(disk_use, 11.1); + evel_measurement_disk_use_iotimelast_set(disk_use, 12.1); + evel_measurement_disk_use_iotimemax_set(disk_use, 13.1); + evel_measurement_disk_use_iotimemin_set(disk_use, 14.1); + evel_measurement_disk_use_mergereadavg_set(disk_use, 15.1); + evel_measurement_disk_use_mergereadlast_set(disk_use, 16.1); + evel_measurement_disk_use_mergereadmax_set(disk_use, 17.1); + evel_measurement_disk_use_mergereadmin_set(disk_use, 18.1); + evel_measurement_disk_use_mergewritelast_set(disk_use, 19.1); + evel_measurement_disk_use_mergewritemax_set(disk_use, 20.1); + evel_measurement_disk_use_mergewriteavg_set(disk_use, 30.1); + evel_measurement_disk_use_mergewritemin_set(disk_use, 40.1); + evel_measurement_disk_use_octetsreadavg_set(disk_use, 50.1); + evel_measurement_disk_use_octetsreadlast_set(disk_use, 60.1); + evel_measurement_disk_use_octetsreadmax_set(disk_use, 70.1); + evel_measurement_disk_use_octetsreadmin_set(disk_use, 80.1); + evel_measurement_disk_use_octetswriteavg_set(disk_use, 90.1); + evel_measurement_disk_use_octetswritelast_set(disk_use,110.1); + evel_measurement_disk_use_octetswritemax_set(disk_use, 120.1); + evel_measurement_disk_use_octetswritemin_set(disk_use, 130.1); + evel_measurement_disk_use_opsreadavg_set(disk_use, 140.1); + evel_measurement_disk_use_opsreadlast_set(disk_use, 150.1); + evel_measurement_disk_use_opsreadmax_set(disk_use, 160.1); + evel_measurement_disk_use_opsreadmin_set(disk_use, 170.1); + evel_measurement_disk_use_opswriteavg_set(disk_use, 180.1); + evel_measurement_disk_use_opswritelast_set(disk_use, 190.1); + evel_measurement_disk_use_opswritemax_set(disk_use, 210.1); + evel_measurement_disk_use_opswritemin_set(disk_use, 310.1); + evel_measurement_disk_use_pendingopsavg_set(disk_use, 410.1); + evel_measurement_disk_use_pendingopslast_set(disk_use, 610.1); + evel_measurement_disk_use_pendingopsmax_set(disk_use, 710.1); + evel_measurement_disk_use_pendingopsmin_set(disk_use, 810.1); + evel_measurement_disk_use_timereadavg_set(disk_use, 910.1); + evel_measurement_disk_use_timereadlast_set(disk_use, 10.2); + evel_measurement_disk_use_timereadmax_set(disk_use, 10.33); + evel_measurement_disk_use_timereadmin_set(disk_use, 10.4); + evel_measurement_disk_use_timewriteavg_set(disk_use, 10.5); + evel_measurement_disk_use_timewritelast_set(disk_use, 10.6); + evel_measurement_disk_use_timewritemax_set(disk_use, 10.7); + evel_measurement_disk_use_timewritemin_set(disk_use, 10.8); + evel_measurement_disk_use_diskBusResets_set(disk_use, 10.9); + evel_measurement_disk_use_diskCommandsAborted_set(disk_use, 10.1); + evel_measurement_disk_use_diskTime_set(disk_use, 10.1); + evel_measurement_disk_use_diskFlushRequests_set(disk_use, 10.1); + evel_measurement_disk_use_diskFlushTime_set(disk_use, 10.1); + evel_measurement_disk_use_diskCommandsAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskReadCommandsAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskWriteCommandsAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskTotalReadLatencyAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskTotalWriteLatencyAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskWeightedIoTimeAvg_set(disk_use, 10.1); + evel_measurement_disk_use_diskWeightedIoTimeLast_set(disk_use, 10.1); + evel_measurement_disk_use_diskWeightedIoTimeMax_set(disk_use, 10.1); + evel_measurement_disk_use_diskWeightedIoTimeMin_set(disk_use, 10.1); + evel_measurement_fsys_use_add(measurement,"00-11-22",100.11, 100.22, 33, 200.11, 200.22, 44); evel_measurement_fsys_use_add(measurement,"33-44-55",300.11, 300.22, 55, 400.11, 400.22, 66); - evel_start_epoch_set(&measurement->header, 2000); - evel_last_epoch_set(&measurement->header, 3000); - evel_reporting_entity_name_set(&measurement->header, "entity_name"); - evel_reporting_entity_id_set(&measurement->header, "entity_id"); + evel_measurement_feature_use_add(measurement, "FeatureA", "123"); + evel_measurement_feature_use_add(measurement, "FeatureB", "567"); + + HASHTABLE_T *ht1; + ht1 = evel_measurement_new_addl_measurement(measurement, "hmNam1"); + evel_measurement_addl_measurement_set(ht1, "hmkey1", "hmVal1"); + evel_measurement_addl_measurement_set(ht1, "hmkey2", "hmVal2"); + evel_measurement_addl_measurement_set(ht1, "hmkey3", "hmVal3"); + evel_measurement_addl_measurement_set(ht1, "hmkey4", "hmVal4"); + + ht1 = evel_measurement_new_addl_measurement(measurement, "hmNam2"); + evel_measurement_addl_measurement_set(ht1, "hmkey21", "hmVal21"); + evel_measurement_addl_measurement_set(ht1, "hmkey22", "hmVal22"); + evel_measurement_addl_measurement_set(ht1, "hmkey23", "hmVal23"); + evel_measurement_addl_measurement_set(ht1, "hmkey24", "hmVal24"); + + evel_measurement_codec_use_add(measurement, "G711a", 91); + evel_measurement_codec_use_add(measurement, "G729ab", 92); + + evel_measurement_media_port_use_set(measurement, 55); + evel_measurement_vnfc_scaling_metric_set(measurement, 66); - /***************************************************************************/ - /* Latency Bucket with no optional parameters. */ - /***************************************************************************/ bucket = evel_new_meas_latency_bucket(20); + evel_meas_latency_bucket_low_end_set(bucket, 50.0); + evel_meas_latency_bucket_high_end_set(bucket, 60.0); evel_meas_latency_bucket_add(measurement, bucket); - /***************************************************************************/ - /* Latency Bucket with all optional parameters. */ - /***************************************************************************/ bucket = evel_new_meas_latency_bucket(30); evel_meas_latency_bucket_low_end_set(bucket, 10.0); evel_meas_latency_bucket_high_end_set(bucket, 20.0); evel_meas_latency_bucket_add(measurement, bucket); - /***************************************************************************/ - /* vNIC Use with no optional parameters. */ - /***************************************************************************/ - vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4); - evel_meas_vnic_use_add(measurement, vnic_use); - - /***************************************************************************/ - /* vNIC Use with all optional parameters. */ - /***************************************************************************/ - vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14); - evel_vnic_use_bcast_pkt_in_set(vnic_use, 11); - evel_vnic_use_bcast_pkt_out_set(vnic_use, 12); - evel_vnic_use_mcast_pkt_in_set(vnic_use, 15); - evel_vnic_use_mcast_pkt_out_set(vnic_use, 16); - evel_vnic_use_ucast_pkt_in_set(vnic_use, 17); - evel_vnic_use_ucast_pkt_out_set(vnic_use, 18); - evel_meas_vnic_use_add(measurement, vnic_use); - - evel_measurement_errors_set(measurement, 1, 0, 2, 1); - - evel_measurement_feature_use_add(measurement, "FeatureA", 123); - evel_measurement_feature_use_add(measurement, "FeatureB", 567); - - evel_measurement_codec_use_add(measurement, "G711a", 91); - evel_measurement_codec_use_add(measurement, "G729ab", 92); - - evel_measurement_media_port_use_set(measurement, 1234); - - evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678); + evel_measurement_latency_add(measurement, 70.0, 90.0, 40); + + MEASUREMENT_NIC_PERFORMANCE * nic_per; + nic_per = evel_measurement_new_nic_performance("eth0", "true"); + evel_nic_performance_administrativeState_set(nic_per, EVEL_OPER_STATE_OUT_OF_SERVICE); + evel_nic_performance_operationalState_set(nic_per, EVEL_OPER_STATE_IN_SERVICE); + evel_nic_performance_receivedPercentDiscard_set(nic_per, 222.33); + evel_nic_performance_receivedPercentError_set(nic_per, 222.33); + evel_nic_performance_receivedUtilization_set(nic_per, 222.33); + evel_nic_performance_speed_set(nic_per, 222.33); + evel_nic_performance_transmittedPercentDiscard_set(nic_per, 222.33); + evel_nic_performance_transmittedPercentError_set(nic_per, 222.33); + evel_nic_performance_transmittedUtilization_set(nic_per, 222.33); + evel_nic_performance_rx_bcast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_bcast_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_rx_discard_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_discard_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_rx_error_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_error_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_rx_mcast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_mcast_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_rx_octets_acc_set(nic_per, 222.33); + evel_nic_performance_rx_octets_delta_set(nic_per, 222.33); + evel_nic_performance_rx_total_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_total_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_rx_ucast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_rx_ucast_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_bcast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_bcast_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_discarded_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_discarded_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_error_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_error_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_mcast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_mcast_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_octets_acc_set(nic_per, 222.33); + evel_nic_performance_tx_octets_delta_set(nic_per, 222.33); + evel_nic_performance_tx_total_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_total_pkt_delta_set(nic_per, 222.33); + evel_nic_performance_tx_ucast_pkt_acc_set(nic_per, 222.33); + evel_nic_performance_tx_ucast_pkt_delta_set(nic_per, 222.33); + + evel_meas_nic_performance_add(measurement, nic_per); +/************* + evel_measurement_nic_performance_add(measurement, "ens03", "false", + EVEL_OPER_STATE_IN_SERVICE, EVEL_OPER_STATE_OUT_OF_SERVICE, + 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, + 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, + 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, 11.66, + 11.66, 11.66, 11.66, 11.66, 11.66); +**********/ + MEASUREMENT_IPMI *ipmi; + ipmi = evel_measurement_new_ipmi_add(measurement); + evel_measurement_ipmi_exitAirTemperature_set(ipmi, 98.4); + evel_measurement_ipmi_frontPanelTemperature_set(ipmi, 98.4); + evel_measurement_ipmi_ioModuleTemperature_set(ipmi, 98.4); + evel_measurement_ipmi_systemAirflow_set(ipmi, 98.4); + + MEASUREMENT_IPMI_BB_TEMPERATURE *temp; + temp = evel_measurement_new_base_board_temp_add(ipmi, "BBTEMP1"); + evel_measurement_ipmi_bb_temp_set(ipmi, temp, 99.8); + + MEASUREMENT_IPMI_BB_VOLTAGE * volt; + volt = evel_measurement_new_base_board_volt_add(ipmi, "BBVOLT1"); + evel_measurement_ipmi_bb_volt_set(ipmi, volt, 88.9); + + MEASUREMENT_IPMI_BATTERY *batt; + batt = evel_measurement_new_ipmi_battery_add(ipmi, "BBBATTERY1"); + evel_measurement_ipmi_battery_type_set(ipmi, batt, "BattType"); + evel_measurement_ipmi_battery_voltage_set(ipmi, batt, 230); + + MEASUREMENT_IPMI_FAN * fan; + fan = evel_measurement_new_ipmi_fan_add(ipmi, "FAN1"); + evel_measurement_ipmi_fan_speed_set(ipmi, fan, 300); + + MEASUREMENT_IPMI_HSBP * hsbp; + hsbp = evel_measurement_new_ipmi_hsbp_add(ipmi, "BBHSBP1"); + evel_measurement_ipmi_hsbp_temp_set(ipmi, hsbp, 100); + + MEASUREMENT_IPMI_GLOBAL_AGG_TEMP_MARGIN *glob; + glob = evel_measurement_new_ipmi_global_temp_add(ipmi, "BBGLOBAL"); + evel_measurement_ipmi_global_temp_margin_set(ipmi, glob, 22.5); + + MEASUREMENT_IPMI_NIC * nic; + nic = evel_measurement_new_ipmi_nic_add(ipmi, "NIC_1"); + evel_measurement_ipmi_nic_temp_set(ipmi, nic, 33.5); + + MEASUREMENT_IPMI_POWER_SUPPLY * pwr; + pwr = evel_measurement_new_ipmi_power_add(ipmi, "POWERSupply1"); + evel_measurement_ipmi_power_inputpwr_set(ipmi, pwr, 200.5); + evel_measurement_ipmi_power_current_op_set(ipmi, pwr, 50.4); + evel_measurement_ipmi_power_temp_set(ipmi, pwr, 100.5); + + MEASUREMENT_IPMI_PROCESSOR * proc; + proc = evel_measurement_new_ipmi_processor_add(ipmi, "PROCESSOR1"); + evel_measurement_ipmi_processor_theralCtrl_set(ipmi, proc, 10.9); + evel_measurement_ipmi_processor_theralMargin_set(ipmi, proc, 29.8); + + MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * dimm; + dimm = evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add(ipmi, proc, "DIMM1", 15.8); + + assert(dimm != NULL); + + MEASUREMENT_LOAD * load; + load = evel_measurement_new_loads_add(measurement); + evel_measurement_load_shortTerm_set(load, 22.5); + evel_measurement_load_midTerm_set(load, 33.6); + evel_measurement_load_longTerm_set(load, 44.8); + + MEASUREMENT_PROCESS_STATS * pstat; + pstat = evel_measurement_new_process_stats_add(measurement, "Process1"); + evel_measurement_process_stat_forkRate_set(pstat, 10.1); + evel_measurement_process_stat_psStateBlocked_set(pstat, 20.1); + evel_measurement_process_stat_psStatePaging_set(pstat, 30.1); + evel_measurement_process_stat_psStateRunning_set(pstat, 40.1); + evel_measurement_process_stat_psStateSleeping_set(pstat, 50.1); + evel_measurement_process_stat_psStateStopped_set(pstat, 60.1); + evel_measurement_process_stat_psStateZombie_set(pstat, 70.1); + evel_measurement_process_stat_psStateZombie_set(pstat, 80.1); + + MACHINE_CHECK_EXCEPTION * mcheck; + mcheck = evel_measurement_new_machine_check_exception_add(measurement, "ProcessID1"); + evel_measurement_machine_check_cor_mem_err_set(mcheck, 110.1); + evel_measurement_machine_check_cor_mem_err_1hr_set(mcheck, 210.1); + evel_measurement_machine_check_uncor_mem_err_set(mcheck, 310.1); + evel_measurement_machine_check_uncor_mem_err_1hr_set(mcheck, 410.1); + + MEASUREMENT_HUGE_PAGE * hugep; + hugep = evel_measurement_new_huge_page_add(measurement, "HUGEPage1"); + evel_measurement_huge_page_bytesUsed_set(hugep, 100); + evel_measurement_huge_page_bytesFree_set(hugep, 200); + evel_measurement_huge_page_vmPageNumberUsed_set(hugep, 300); + evel_measurement_huge_page_vmPageNumberFree_set(hugep, 400); + evel_measurement_huge_page_percentUsed_set(hugep, 500); + evel_measurement_huge_page_percentFree_set(hugep, 600); - evel_measurement_custom_measurement_add(measurement, - "Group1", "Name1", "Value1"); - evel_measurement_custom_measurement_add(measurement, - "Group2", "Name1", "Value1"); - evel_measurement_custom_measurement_add(measurement, - "Group2", "Name2", "Value2"); + evel_start_epoch_set(&measurement->header, 2000); + evel_last_epoch_set(&measurement->header, 3000); + evel_reporting_entity_name_set(&measurement->header, "entity_name"); + evel_reporting_entity_id_set(&measurement->header, "entity_id"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) measurement); compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Measurement"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(measurement); + if(evel_post_event((EVENT_HEADER *)measurement) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(measurement); } void test_encode_mobile_mand() @@ -534,13 +833,14 @@ void test_encode_mobile_mand() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"mobileFlow\", " - "\"eventId\": \"1241\", " + "\"eventId\": \"mobileFlow000000001\", " + "\"eventName\": \"mobileFlow_error\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 1241, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", " @@ -596,7 +896,7 @@ void test_encode_mobile_mand() /***************************************************************************/ /* Mobile. */ /***************************************************************************/ - evel_set_next_event_sequence(1241); +// evel_set_next_event_sequence(1241); metrics = evel_new_mobile_gtp_flow_metrics(12.3, 3.12, @@ -629,7 +929,9 @@ void test_encode_mobile_mand() 110, 225); assert(metrics != NULL); - mobile_flow = evel_new_mobile_flow("Outbound", + mobile_flow = evel_new_mobile_flow("mobileFlow_error", + "mobileFlow000000001", + "Outbound", metrics, "TCP", "IPv4", @@ -644,7 +946,16 @@ void test_encode_mobile_mand() compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(mobile_flow); + if(evel_post_event((EVENT_HEADER *)mobile_flow) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + + //evel_free_event(mobile_flow); } void test_encode_mobile_opts() @@ -653,13 +964,14 @@ void test_encode_mobile_opts() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"mobileFlow\", " - "\"eventId\": \"1242\", " + "\"eventId\": \"mobileFlow000000001\", " + "\"eventName\": \"mobileFlow_error\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 1242, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Mobile flow...\", " @@ -762,7 +1074,7 @@ void test_encode_mobile_opts() /***************************************************************************/ /* Mobile. */ /***************************************************************************/ - evel_set_next_event_sequence(1242); +// evel_set_next_event_sequence(1242); metrics = evel_new_mobile_gtp_flow_metrics(132.0001, 31.2, @@ -803,9 +1115,15 @@ void test_encode_mobile_opts() evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote"); evel_mobile_gtp_metrics_con_status_set(metrics, "Connected"); evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling"); - evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13); - evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1); - evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99); + +// evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13); +// evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1); +// evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99); + + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "1", "13"); + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "17", "1"); + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "4", "99"); + evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80); evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0); evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680); @@ -813,14 +1131,23 @@ void test_encode_mobile_opts() evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1); evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4); evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_LTE_65, 122); - - mobile_flow = evel_new_mobile_flow("Inbound", + +// evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10); +// evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121); + + + evel_mobile_gtp_metrics_tcp_flag_count_list_add(metrics, EVEL_TCP_CWR, "10"); + evel_mobile_gtp_metrics_tcp_flag_count_list_add(metrics, EVEL_TCP_URG, "121"); + +// evel_mobile_gtp_metrics_qci_cos_count_add( metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); +// evel_mobile_gtp_metrics_qci_cos_count_add( metrics, EVEL_QCI_COS_LTE_65, 122); + + evel_mobile_gtp_metrics_qci_cos_count_list_add(metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, "11"); + evel_mobile_gtp_metrics_qci_cos_count_list_add(metrics, EVEL_QCI_COS_LTE_65, "122"); + + mobile_flow = evel_new_mobile_flow("mobileFlow_error", + "mobileFlow000000001", + "Inbound", metrics, "UDP", "IPv6", @@ -855,6 +1182,8 @@ void test_encode_mobile_opts() evel_mobile_flow_tac_set(mobile_flow, "2099"); evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1"); evel_mobile_flow_vlan_id_set(mobile_flow, "15"); + evel_mobile_flow_addl_field_add(mobile_flow, "Mkey1", "MValue1"); + evel_mobile_flow_addl_field_add(mobile_flow, "Mkey2", "MValue2"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow); @@ -863,20 +1192,21 @@ void test_encode_mobile_opts() evel_free_event(mobile_flow); } - +/******** void test_encode_report() { char * expected = "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"measurementsForVfReporting\", " - "\"eventId\": \"125\", " + "\"eventId\": \"report000000001\", " + "\"eventName\": \"report_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 125, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Perf reporting...\", " @@ -907,11 +1237,8 @@ void test_encode_report() char json_body[EVEL_MAX_JSON_BODY]; EVENT_REPORT * report = NULL; - /***************************************************************************/ - /* Report. */ - /***************************************************************************/ - evel_set_next_event_sequence(125); - report = evel_new_report(1.1); +// evel_set_next_event_sequence(125); + report = evel_new_report(1.1, "report_err", "report000000001"); assert(report != NULL); evel_report_type_set(report, "Perf reporting..."); evel_report_feature_use_add(report, "FeatureA", 123); @@ -927,7 +1254,8 @@ void test_encode_report() evel_free_event(report); } - +****************/ +/******************** void test_encode_service() { test_encode_service_subset(SERVICE_NONE); @@ -937,20 +1265,22 @@ void test_encode_service() test_encode_service_subset(SERVICE_EOC_VQM); test_encode_service_subset(SERVICE_MARKER); } - +********/ +/************** void test_encode_service_subset(const SERVICE_TEST service_test) { char * expected_start = "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"serviceEvents\", " - "\"eventId\": \"2000\", " + "\"eventId\": \"sipSignal0000000001\", " + "\"eventName\": \"sipSignal_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 2000, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Service Event\", " @@ -1057,9 +1387,10 @@ void test_encode_service_subset(const SERVICE_TEST service_test) size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; - EVENT_SGNALING * event = NULL; - evel_set_next_event_sequence(2000); - event = evel_new_signaling("vendor_x_id", + EVENT_SIGNALING * event = NULL; +// evel_set_next_event_sequence(2000); + event = evel_new_signaling("sipSignal_err", + "sipSignal0000000001", "vendor_x_id", "correlator", "1.0.3.1", "1234", "192.168.1.3","3456"); assert(event != NULL); evel_signaling_type_set(event, "Signaling"); @@ -1083,27 +1414,27 @@ void test_encode_service_subset(const SERVICE_TEST service_test) break; case SERVICE_EOC_VQM: evel_signaling_addl_info_add(event, "adjacency", "vendor_x"); - /*evel_service_adjacency_name_set(event, "vendor_x_adjacency"); - evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER); - evel_service_endpoint_jitter_set(event, 66); - evel_service_endpoint_rtp_oct_disc_set(event, 100); - evel_service_endpoint_rtp_oct_recv_set(event, 200); - evel_service_endpoint_rtp_oct_sent_set(event, 300); - evel_service_endpoint_rtp_pkt_disc_set(event, 400); - evel_service_endpoint_rtp_pkt_recv_set(event, 500); - evel_service_endpoint_rtp_pkt_sent_set(event, 600); - evel_service_local_jitter_set(event, 99); - evel_service_local_rtp_oct_disc_set(event, 150); - evel_service_local_rtp_oct_recv_set(event, 250); - evel_service_local_rtp_oct_sent_set(event, 350); - evel_service_local_rtp_pkt_disc_set(event, 450); - evel_service_local_rtp_pkt_recv_set(event, 550); - evel_service_local_rtp_pkt_sent_set(event, 650); - evel_service_mos_cqe_set(event, 12.255); - evel_service_packets_lost_set(event, 157); - evel_service_packet_loss_percent_set(event, 0.232); - evel_service_r_factor_set(event, 11); - evel_service_round_trip_delay_set(event, 15);*/ +// evel_service_adjacency_name_set(event, "vendor_x_adjacency"); +// evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER); +// evel_service_endpoint_jitter_set(event, 66); +// evel_service_endpoint_rtp_oct_disc_set(event, 100); +// evel_service_endpoint_rtp_oct_recv_set(event, 200); +// evel_service_endpoint_rtp_oct_sent_set(event, 300); +// evel_service_endpoint_rtp_pkt_disc_set(event, 400); +// evel_service_endpoint_rtp_pkt_recv_set(event, 500); +// evel_service_endpoint_rtp_pkt_sent_set(event, 600); +// evel_service_local_jitter_set(event, 99); +// evel_service_local_rtp_oct_disc_set(event, 150); +// evel_service_local_rtp_oct_recv_set(event, 250); +// evel_service_local_rtp_oct_sent_set(event, 350); +// evel_service_local_rtp_pkt_disc_set(event, 450); +// evel_service_local_rtp_pkt_recv_set(event, 550); +// evel_service_local_rtp_pkt_sent_set(event, 650); +// evel_service_mos_cqe_set(event, 12.255); +// evel_service_packets_lost_set(event, 157); +// evel_service_packet_loss_percent_set(event, 0.232); +// evel_service_r_factor_set(event, 11); +// evel_service_round_trip_delay_set(event, 15); break; case SERVICE_MARKER: evel_signaling_addl_info_add(event, "service_phone", "0888888888"); @@ -1117,20 +1448,21 @@ void test_encode_service_subset(const SERVICE_TEST service_test) evel_free_event(event); } - +*******************/ void test_encode_signaling() { char * expected = "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"signaling\", " - "\"eventId\": \"2001\", " + "\"eventId\": \"sipSignal0000000001\", " + "\"eventName\": \"sipSignal_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 2001, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Signaling\", " @@ -1159,29 +1491,142 @@ void test_encode_signaling() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_SIGNALING * event = NULL; - evel_set_next_event_sequence(2001); - event = evel_new_signaling("vendor_x_id", +// evel_set_next_event_sequence(2001); + event = evel_new_signaling("sipSignal_err", + "sipSignal0000000001", "vendor_x_id", "correlator", "1.0.3.1", "1234", "192.168.1.3","3456"); assert(event != NULL); - evel_signaling_vnfmodule_name_set(event, "vendor_x_module"); - evel_signaling_vnfname_set(event, "vendor_x_vnf"); + + evel_signaling_addl_info_add(event, "name1", "value1"); + evel_signaling_addl_info_add(event, "name2", "value2"); + evel_signaling_addl_info_add(event, "name3", "value3"); + evel_signaling_addl_info_add(event, "name4", "value4"); + evel_signaling_type_set(event, "Signaling"); - evel_signaling_product_id_set(event, "vendor_x_product_id"); - evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id"); - evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name"); - evel_signaling_correlator_set(event, "vendor_x_correlator"); evel_signaling_local_ip_address_set(event, "1.0.3.1"); evel_signaling_local_port_set(event, "1031"); evel_signaling_remote_ip_address_set(event, "5.3.3.0"); evel_signaling_remote_port_set(event, "5330"); + evel_signaling_vnfmodule_name_set(event, "vendor_x_module"); + evel_signaling_vnfname_set(event, "vendor_x_vnf"); evel_signaling_compressed_sip_set(event, "compressed_sip"); evel_signaling_summary_sip_set(event, "summary_sip"); + evel_signaling_correlator_set(event, "vendor_x_correlator"); + + json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event); compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Signaling"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(event); + if(evel_post_event((EVENT_HEADER *)event) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(event); +} + +void test_encode_notif() +{ + char * expected = " "; + HASHTABLE_T * ht1 = NULL; + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + EVENT_NOTIFICATION * event = NULL; + event = evel_new_notification("notif_err", + "Notification0000000001", "ChangeId", + "ChangeType"); + + assert(event != NULL); + + evel_notification_type_set(event, "Event_type"); + evel_notification_changeContact_set(event, "ChangeContact"); + evel_notification_state_interface_set(event, "STInterface"); + evel_notification_new_state_set(event, EVEL_ENTITY_STATE_MAINTENANCE); + evel_notification_old_state_set(event, EVEL_ENTITY_STATE_OUT_OF_SERVICE); + + evel_notification_addl_field_add(event, "name1", "value1"); + evel_notification_addl_field_add(event, "name2", "value2"); + evel_notification_addl_field_add(event, "name3", "value3"); + evel_notification_addl_field_add(event, "name4", "value4"); + + ht1 = evel_notification_add_new_named_hashmap(event, "hmNam1"); + evel_notification_named_hashmap_set(ht1, "hmnap1", "hmvalue1"); + evel_notification_named_hashmap_set(ht1, "hmnap2", "hmvalue2"); + evel_notification_named_hashmap_set(ht1, "hmnap3", "hmvalue3"); + evel_notification_named_hashmap_set(ht1, "hmnap4", "hmvalue4"); + ht1 = evel_notification_add_new_named_hashmap(event, "hmNam2"); + evel_notification_named_hashmap_set(ht1, "hmnap21", "hmvalue21"); + evel_notification_named_hashmap_set(ht1, "hmnap22", "hmvalue22"); + evel_notification_named_hashmap_set(ht1, "hmnap23", "hmvalue23"); + evel_notification_named_hashmap_set(ht1, "hmnap24", "hmvalue24"); + + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Notification"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + if(evel_post_event((EVENT_HEADER *)event) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(event); +} + +void test_encode_voiceQ() +{ + char * expected = " "; + + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + EVENT_VOICE_QUALITY * event = NULL; +// evel_set_next_event_sequence(2001); + event = evel_new_voice_quality("voiceQ_err", + "VoiceQuality0000000001", "Called_Codec", + "Caller_codec", "Correlator", "RTCP", "Vendor_x"); + assert(event != NULL); + + evel_voice_quality_addl_info_add(event, "name1", "value1"); + evel_voice_quality_addl_info_add(event, "name2", "value2"); + evel_voice_quality_addl_info_add(event, "name3", "value3"); + evel_voice_quality_addl_info_add(event, "name4", "value4"); + +// evel_voice_quality_callee_codec_set(event, "Callee_cdc1"); +// evel_voice_quality_caller_codec_set(event, "Clr_cdc1"); + + evel_voice_quality_correlator_set(event, "CorrNew"); + evel_voice_quality_rtcp_data_set(event, "RTCPNew"); + evel_voice_quality_vnfmodule_name_set(event, "vendor_x_module"); + evel_voice_quality_vnfname_set(event, "vendor_x_vnf"); + evel_voice_quality_phone_number_set(event, "1234567890"); + evel_voice_quality_end_metrics_add(event, "Adj_name", EVEL_SERVICE_ENDPOINT_CALLEE, 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,16,17,18,19,20,21,22,23,24,25,26,27); + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "VoiceQuality"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + if(evel_post_event((EVENT_HEADER *)event) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(event); } void test_encode_state_change() @@ -1190,13 +1635,14 @@ void test_encode_state_change() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"stateChange\", " - "\"eventId\": \"128\", " + "\"eventId\": \"stateChange000000001\", " + "\"eventName\": \"stateChange_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 128, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"SC Type\", " @@ -1219,9 +1665,11 @@ void test_encode_state_change() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_STATE_CHANGE * state_change = NULL; - evel_set_next_event_sequence(128); - state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE, - EVEL_ENTITY_STATE_OUT_OF_SERVICE, +// evel_set_next_event_sequence(128); + state_change = evel_new_state_change("stateChange_err", + "stateChange000000001", + EVEL_ENTITY_STATE_IN_SERVICE, + EVEL_ENTITY_STATE_MAINTENANCE, "An Interface"); assert(state_change != NULL); evel_state_change_type_set(state_change, "SC Type"); @@ -1233,7 +1681,16 @@ void test_encode_state_change() compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "StateChange"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(state_change); + if(evel_post_event((EVENT_HEADER *)state_change) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(state_change); } void test_encode_syslog() @@ -1242,13 +1699,14 @@ void test_encode_syslog() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"syslog\", " - "\"eventId\": \"126\", " + "\"eventId\": \"syslog000000001\", " + "\"eventName\": \"syslog_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 126, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"SL Type\", " @@ -1270,8 +1728,9 @@ void test_encode_syslog() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_SYSLOG * syslog = NULL; - evel_set_next_event_sequence(126); - syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, +// evel_set_next_event_sequence(126); + syslog = evel_new_syslog("syslog_err", "syslog000000001", + EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, "SL Message", "SL Tag"); assert(syslog != NULL); @@ -1282,13 +1741,33 @@ void test_encode_syslog() evel_syslog_proc_id_set(syslog, 2); evel_syslog_version_set(syslog, 1); evel_syslog_s_data_set(syslog, "SL SDATA"); + evel_syslog_sdid_set(syslog, "ourSDID@12345"); + evel_syslog_severity_set(syslog, "Alert"); + evel_syslog_timeStamp_set(syslog, "12-DEC-2018"); + evel_syslog_MsgHost_set(syslog, "hostName123"); + evel_syslog_priority_set(syslog, 15); + + evel_syslog_addl_fields_set(syslog, "Name1", "Value1"); + evel_syslog_addl_fields_set(syslog, "Name2", "Value2"); + evel_syslog_addl_fields_set(syslog, "Name3", "Value3"); + evel_syslog_addl_fields_set(syslog, "Name4", "Value4"); + evel_syslog_addl_fields_set(syslog, "Name5", "Value5"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog); compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(syslog); + if(evel_post_event((EVENT_HEADER *)syslog) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + + // evel_free_event(syslog); } void test_encode_other() @@ -1297,13 +1776,14 @@ void test_encode_other() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"other\", " - "\"eventId\": \"129\", " + "\"eventId\": \"other000000001\", " + "\"eventName\": \"other_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 129, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Other Type\", " @@ -1321,23 +1801,170 @@ void test_encode_other() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_OTHER * other = NULL; - evel_set_next_event_sequence(129); - other = evel_new_other(); + HASHTABLE_T * ht1 = NULL; + HASHTABLE_T * ht2 = NULL; + +// evel_set_next_event_sequence(129); + other = evel_new_other("other_err", "other000000001"); assert(other != NULL); evel_other_type_set(other, "Other Type"); - evel_other_field_add(other, - "Other field 1", - "Other value 1"); - evel_other_field_add(other, - "Other field 2", - "Other value 2"); + + ht1 = evel_other_add_new_hashmap_to_hmarray(other, "hmap1"); + ht2 = evel_other_add_new_hashmap_to_hmarray(other, "hmap2"); + + evel_other_set_hashmap_in_hmarray(ht1, "Name11", "Value11"); + evel_other_set_hashmap_in_hmarray(ht2, "Name21", "Value21"); + evel_other_set_hashmap_in_hmarray(ht1, "Name12", "Value12"); + evel_other_set_hashmap_in_hmarray(ht2, "Name22", "Value22"); + evel_other_set_hashmap_in_hmarray(ht1, "Name13", "Value13"); + evel_other_set_hashmap_in_hmarray(ht2, "Name23", "Value23"); + evel_other_set_hashmap_in_hmarray(ht1, "Name14", "Value14"); + evel_other_set_hashmap_in_hmarray(ht2, "Name24", "Value24"); + + evel_other_field_add_hashmap(other, "Name1", "Value1"); + evel_other_field_add_hashmap(other, "Name2", "Value2"); + evel_other_field_add_hashmap(other, "Name3", "Value3"); + evel_other_field_add_hashmap(other, "Name4", "Value4"); + evel_other_field_add_hashmap(other, "Name5", "Value5"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) other); compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Other"); assert((json_size == strlen(json_body)) && "Bad size returned"); - evel_free_event(other); + if(evel_post_event((EVENT_HEADER *)other) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(other); +} + +void test_encode_pnfreg() +{ + char * expected = + "{\"event\": " + "{\"commonEventHeader\": {" + "\"domain\": \"other\", " + "\"eventId\": \"other000000001\", " + "\"eventName\": \"other_err\", " + "\"functionalRole\": \"UNIT TEST\", " + "\"lastEpochMicrosec\": 1000002, " + "\"priority\": \"Normal\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " + "\"sequence\": 129, " + "\"sourceName\": \"prakash-VirtualBox\", " + "\"startEpochMicrosec\": 1000002, " + "\"version\": 1.2, " + "\"eventType\": \"Other Type\", " + "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", " + "\"sourceId\": \"Dummy VM UUID - No Metadata available\"" + "}, " + "\"otherFields\": [" + "{\"name\": \"Other field 1\", " + "\"value\": \"Other value 1\"}, " + "{\"name\": \"Other field 2\", " + "\"value\": \"Other value 2\"}" + "]" + "}}"; + + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + EVENT_PNF_REGISTRATION * pnfreg = NULL; + + pnfreg = evel_new_pnf_registration("pnfreg_err", "pnfreg000000001"); + assert(pnfreg != NULL); + + evel_pnf_registration_addl_field_add(pnfreg, "Name1", "Value1"); + evel_pnf_registration_addl_field_add(pnfreg, "Name2", "Value2"); + evel_pnf_registration_addl_field_add(pnfreg, "Name3", "Value3"); + evel_pnf_registration_addl_field_add(pnfreg, "Name4", "Value4"); + evel_pnf_registration_addl_field_add(pnfreg, "Name5", "Value5"); + + evel_pnfRegistration_last_service_date_set(pnfreg, "10FEB2019"); + evel_pnfRegistration_mac_address_set(pnfreg, "FF:28:22:34:45:56"); + evel_pnfRegistration_manufacture_date_set(pnfreg, "FEB2011"); + evel_pnfRegistration_model_number_set(pnfreg, "FE934567"); + evel_pnfRegistration_oam_v4_ipaddress_set(pnfreg, "10.255.1.254"); + evel_pnfRegistration_oam_v6_ipaddress_set(pnfreg, "::20"); + evel_pnfRegistration_serial_number_set(pnfreg, "1234567890"); + evel_pnfRegistration_sw_version_set(pnfreg, "SW1234"); + evel_pnfRegistration_unit_family_set(pnfreg, "Unit_Fam_123"); + evel_pnfRegistration_unit_type_set(pnfreg, "Unit_type_123"); + evel_pnfRegistration_vendor_name_set(pnfreg, "Vend_nam_123"); + + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) pnfreg); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "PNFRegistration"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + if(evel_post_event((EVENT_HEADER *)pnfreg) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } + +// evel_free_event(pnfreg); +} + +void test_encode_tca() +{ + + char * expected = "123456789"; + size_t json_size = 0; + char json_body[EVEL_MAX_JSON_BODY]; + EVENT_THRESHOLD_CROSS * tca = NULL; + PERF_COUNTER * perf = NULL; + + tca = evel_new_threshold_cross("tca_err", "tca000000001", EVEL_EVENT_ACTION_SET, "NE-CPUMEM", EVEL_CARD_ANOMALY, "1234567", EVEL_SEVERITY_CRITICAL, "8765432" ); + assert(tca != NULL); + + perf = evel_threshold_cross_add_addl_parameters(tca, "CRIT", "LastThresh"); + evel_threshold_cross_addl_parameters_hashmap_set(perf, "key1", "value1"); + evel_threshold_cross_addl_parameters_hashmap_set(perf, "key2", "value2"); + perf = evel_threshold_cross_add_addl_parameters(tca, "CRIT", "LastThresh"); + evel_threshold_cross_addl_parameters_hashmap_set(perf, "key3", "value3"); + evel_threshold_cross_addl_parameters_hashmap_set(perf, "key4", "value4"); + + evel_threshold_cross_type_set(tca, "node"); + evel_threshold_cross_alertid_add(tca, "Alert1"); + evel_threshold_cross_alertid_add(tca, "Alert2"); + evel_threshold_cross_alertid_add(tca, "Alert3"); + + evel_threshold_cross_addl_info_add(tca, "addnam1", "addval1"); + evel_threshold_cross_addl_info_add(tca, "addnam2", "addval2"); + evel_threshold_cross_addl_info_add(tca, "addnam3", "addval3"); + + evel_threshold_cross_possible_rootcause_set(tca, "prootcause"); + evel_threshold_cross_networkservice_set(tca, "nwservice"); + + evel_threshold_cross_interfacename_set(tca, "ens04"); + evel_threshold_cross_data_elementtype_set(tca, "elementtype"); + evel_threshold_cross_data_collector_set(tca, "dataCollector"); + evel_threshold_cross_alertvalue_set(tca, "AlertVal"); + + json_size = evel_json_encode_event( + json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) tca); + compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "TCA"); + assert((json_size == strlen(json_body)) && "Bad size returned"); + + if(evel_post_event((EVENT_HEADER *)tca) == EVEL_SUCCESS) + { + printf("Message sent to Collector successfully\n"); + } + else + { + printf("Message sending Error\n"); + } +// evel_free_event(tca); } void compare_strings(char * expected, @@ -1345,6 +1972,7 @@ void compare_strings(char * expected, int max_size, char * description) { + sleep(5); if (strncmp(expected, actual, max_size) != 0) { int diff = 0; @@ -1357,11 +1985,11 @@ void compare_strings(char * expected, diff++; } - printf("Comparison Failure at Offset %d\n\n", diff); - printf("Expected:\n%s\n", expected); - printf("Actual:\n%s\n", actual); +// printf("Comparison Failure at Offset %d\n\n", diff); +// printf("Expected:\n%s\n", expected); printf("Description: %s\n", description); - assert(0); + printf("Actual:\n%s\n\n\n", actual); +// assert(0); } } @@ -1406,6 +2034,7 @@ void handle_json_response(char * json, MEMORY_CHUNK * post) /**************************************************************************//** * Test that a non-"commandList" JSON buffer leaves the throttle state off. *****************************************************************************/ +/**************** void test_json_response_junk() { MEMORY_CHUNK post; @@ -1421,21 +2050,16 @@ void test_json_response_junk() evel_throttle_initialize(); handle_json_response(json_junk, &post); - /***************************************************************************/ - /* Check that all domains are not throttled. */ - /***************************************************************************/ for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++) { assert(evel_get_throttle_spec(domain) == NULL); } - /***************************************************************************/ - /* Check that we generated no post. */ - /***************************************************************************/ assert(post.memory == NULL); evel_throttle_terminate(); } +**********************/ char * json_command_list_provide = "{" @@ -1485,6 +2109,7 @@ char * expected_throttle_state_normal = /**************************************************************************//** * Test that we can return the default throttling state. *****************************************************************************/ +/******************* void test_json_provide_throttle_state() { MEMORY_CHUNK post; @@ -1495,17 +2120,11 @@ void test_json_provide_throttle_state() evel_throttle_initialize(); handle_json_response(json_command_list_provide, &post); - /***************************************************************************/ - /* Check that all domains are not throttled. */ - /***************************************************************************/ for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++) { assert(evel_get_throttle_spec(domain) == NULL); } - /***************************************************************************/ - /* Check that we generated a throttling specification post. */ - /***************************************************************************/ assert(post.memory != NULL); compare_strings(expected_post, post.memory, strlen(expected_post), "Throttle State Normal"); @@ -1513,10 +2132,11 @@ void test_json_provide_throttle_state() evel_throttle_terminate(); } - +*************************/ /**************************************************************************//** * Test the measurement interval handling and API. *****************************************************************************/ +/******************** void test_json_measurement_interval() { MEMORY_CHUNK post; @@ -1558,33 +2178,26 @@ void test_json_measurement_interval() evel_throttle_initialize(); assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN); - /***************************************************************************/ - /* Check that we're not handling stuff when we shouldn't. */ - /***************************************************************************/ handle_json_response(json_command_list_interval_only, &post); assert(post.memory == NULL); assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN); - /***************************************************************************/ - /* Check that we're OK with the interval coming first. */ - /***************************************************************************/ handle_json_response(json_command_list_interval_first, &post); assert(post.memory == NULL); assert(evel_get_measurement_interval() == 30); - /***************************************************************************/ - /* Check that we're OK with the command type coming first. */ - /***************************************************************************/ handle_json_response(json_command_list_command_first, &post); assert(post.memory == NULL); assert(evel_get_measurement_interval() == 60); evel_throttle_terminate(); } +*********************/ /**************************************************************************//** * Test a single domain, single field suppression. *****************************************************************************/ +/******************* void test_json_throttle_spec_field() { MEMORY_CHUNK post; @@ -1648,15 +2261,9 @@ void test_json_throttle_spec_field() "}" "}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list_fault_single, &post); - /***************************************************************************/ - /* Check that the FAULT domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1667,9 +2274,6 @@ void test_json_throttle_spec_field() } assert(post.memory == NULL); - /***************************************************************************/ - /* Request and verify the throttling state. */ - /***************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_post_fault_single, @@ -1679,14 +2283,8 @@ void test_json_throttle_spec_field() free(post.memory); post.memory = NULL; - /***************************************************************************/ - /* Update a specification with two faults suppressed. */ - /***************************************************************************/ handle_json_response(json_command_list_fault_double, &post); - /***************************************************************************/ - /* Check that the FAULT domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1697,9 +2295,6 @@ void test_json_throttle_spec_field() } assert(post.memory == NULL); - /***************************************************************************/ - /* Request and verify the throttling state. */ - /***************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_post_fault_double, @@ -1709,9 +2304,6 @@ void test_json_throttle_spec_field() free(post.memory); post.memory = NULL; - /***************************************************************************/ - /* Now clear the FAULT domain. */ - /***************************************************************************/ handle_json_response(json_command_list_fault_clear, &post); for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1720,10 +2312,11 @@ void test_json_throttle_spec_field() evel_throttle_terminate(); } - +*******************************/ /**************************************************************************//** * Test a single domain, nv_pair suppression. *****************************************************************************/ +/************** void test_json_throttle_spec_nv_pair() { MEMORY_CHUNK post; @@ -1772,7 +2365,7 @@ void test_json_throttle_spec_nv_pair() char * expected_post_fault_pair_single = "{" "\"eventThrottlingState\": {" - "\"eventThrottlingMode\": \"throttled\", " + "\"eventohrottlingMode\": \"throttled\", " "\"eventDomainThrottleSpecificationList\": [" "{" "\"eventDomain\": \"fault\", " @@ -1805,16 +2398,9 @@ void test_json_throttle_spec_nv_pair() "}" "}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single nvpair with a */ - /* single sub-field suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list_fault_pair_single, &post); - /***************************************************************************/ - /* Check that the FAULT domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1825,9 +2411,6 @@ void test_json_throttle_spec_nv_pair() } assert(post.memory == NULL); - /***************************************************************************/ - /* Request and verify the throttling state. */ - /***************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_post_fault_pair_single, @@ -1837,15 +2420,8 @@ void test_json_throttle_spec_nv_pair() free(post.memory); post.memory = NULL; - /***************************************************************************/ - /* Update a specification with a single nvpair with two sub-fields */ - /* suppressed. */ - /***************************************************************************/ handle_json_response(json_command_list_fault_pair_double, &post); - /***************************************************************************/ - /* Check that the FAULT domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1856,9 +2432,6 @@ void test_json_throttle_spec_nv_pair() } assert(post.memory == NULL); - /***************************************************************************/ - /* Request and verify the throttling state. */ - /***************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_post_fault_pair_double, @@ -1868,9 +2441,6 @@ void test_json_throttle_spec_nv_pair() free(post.memory); post.memory = NULL; - /***************************************************************************/ - /* Now clear the FAULT domain. */ - /***************************************************************************/ handle_json_response(json_command_list_fault_clear, &post); for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++) { @@ -1879,10 +2449,11 @@ void test_json_throttle_spec_nv_pair() evel_throttle_terminate(); } - +********************/ /**************************************************************************//** * Test two domains, nv_pair suppression. *****************************************************************************/ +/********************* void test_json_throttle_spec_two_domains() { MEMORY_CHUNK post; @@ -1941,16 +2512,9 @@ void test_json_throttle_spec_two_domains() "}" "}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single nvpair with a */ - /* single sub-field suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list_two_domains, &post); - /***************************************************************************/ - /* Check that the FAULT and SYSLOG domains are throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL); for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) @@ -1962,9 +2526,6 @@ void test_json_throttle_spec_two_domains() } assert(post.memory == NULL); - /***************************************************************************/ - /* Request and verify the throttling state. */ - /***************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_post_two_domains, @@ -1974,9 +2535,6 @@ void test_json_throttle_spec_two_domains() free(post.memory); post.memory = NULL; - /***************************************************************************/ - /* Now clear the FAULT and SYSLOG domains. */ - /***************************************************************************/ handle_json_response(json_command_list_fault_clear, &post); assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL); assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL); @@ -1988,19 +2546,16 @@ void test_json_throttle_spec_two_domains() evel_throttle_terminate(); } - +******************/ /**************************************************************************//** * Test bad command type. *****************************************************************************/ +/********************* void test_json_throttle_spec_bad_command_type() { MEMORY_CHUNK post; int domain; - /***************************************************************************/ - /* Search for "dodgy" in the JSON, and you will see the dodgy bits we're */ - /* handling in these tests. */ - /***************************************************************************/ #define NUM_BAD_COMMANDS 8 char * json_command_list_dodgy_command = "{" @@ -2240,10 +2795,6 @@ void test_json_throttle_spec_bad_command_type() sizeof(expected_posts) / sizeof(expected_posts[0]); assert(num_commands == num_posts); - /***************************************************************************/ - /* Initialize and provide a specification with a single nvpair with a */ - /* single sub-field suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); int ii; @@ -2252,10 +2803,6 @@ void test_json_throttle_spec_bad_command_type() EVEL_DEBUG("Testing commandList[%d] = %s\n", ii, json_command_lists[ii]); handle_json_response(json_command_lists[ii], &post); - /*************************************************************************/ - /* Check that throttling is in a normal state - because we ignored the */ - /* command / ..... */ - /*************************************************************************/ for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++) { assert(evel_get_throttle_spec(domain) == NULL); @@ -2270,9 +2817,6 @@ void test_json_throttle_spec_bad_command_type() } assert(post.memory == NULL); - /*************************************************************************/ - /* Request and verify the throttling state. */ - /*************************************************************************/ handle_json_response(json_command_list_provide, &post); assert(post.memory != NULL); compare_strings(expected_posts[ii], @@ -2285,14 +2829,12 @@ void test_json_throttle_spec_bad_command_type() evel_throttle_terminate(); } - +**************************/ +/**************** void test_encode_fault_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -2318,13 +2860,14 @@ void test_encode_fault_throttled() "{\"event\": {" "\"commonEventHeader\": {" "\"domain\": \"fault\", " - "\"eventId\": \"122\", " + "\"eventId\": \"fault000000001\", " + "\"eventName\": \"fault_eNodeB_alarm\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 122, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -2342,22 +2885,18 @@ void test_encode_fault_throttled() "\"value\": \"value2\"}]" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; - evel_set_next_event_sequence(122); - EVENT_FAULT * fault = evel_new_fault("My alarm condition", +// evel_set_next_event_sequence(122); + EVENT_FAULT * fault = evel_new_fault("fault_eNodeB_alarm", + "fault000000001", + "My alarm condition", "It broke very badly", EVEL_PRIORITY_NORMAL, EVEL_SEVERITY_MAJOR, @@ -2368,9 +2907,6 @@ void test_encode_fault_throttled() evel_fault_addl_info_add(fault, "name1", "value1"); evel_fault_addl_info_add(fault, "name2", "value2"); - /***************************************************************************/ - /* Suppressed fields. */ - /***************************************************************************/ evel_fault_interface_set(fault, "My Interface Card"); evel_fault_addl_info_add(fault, "name3", "value3"); evel_fault_addl_info_add(fault, "name4", "value4"); @@ -2383,14 +2919,12 @@ void test_encode_fault_throttled() evel_free_event(fault); evel_throttle_terminate(); } - +***********************/ +/*********************** void test_encode_measurement_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -2447,13 +2981,14 @@ void test_encode_measurement_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"measurementsForVfScaling\", " - "\"eventId\": \"123\", " + "\"eventId\": \"mvfs000000001\", " + "\"eventName\": \"mvfs_perfUnit_issue\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 123, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -2487,24 +3022,18 @@ void test_encode_measurement_throttled() "\"measurementsForVfScalingVersion\": 1.1}}}"; MEASUREMENT_CPU_USE *cpu_use; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_MEASUREMENT) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; - evel_set_next_event_sequence(123); - EVENT_MEASUREMENT * measurement = evel_new_measurement(5.5); +// evel_set_next_event_sequence(123); + EVENT_MEASUREMENT * measurement = evel_new_measurement(5.5, "mvfs_perfUnit_issue", "mvfs000000001"); MEASUREMENT_LATENCY_BUCKET * bucket = NULL; - MEASUREMENT_VNIC_PERFORMANCE * vnic_use = NULL; + MEASUREMENT_NIC_PERFORMANCE * vnic_use = NULL; assert(measurement != NULL); evel_measurement_type_set(measurement, "Perf management..."); @@ -2593,14 +3122,12 @@ void test_encode_measurement_throttled() evel_free_event(measurement); evel_throttle_terminate(); } - +***************/ +/*******************` void test_encode_mobile_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -2645,13 +3172,14 @@ void test_encode_mobile_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"mobileFlow\", " - "\"eventId\": \"1242\", " + "\"eventId\": \"mobileFlow000000001\", " + "\"eventName\": \"mobileFlow_error\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 1242, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -2720,15 +3248,9 @@ void test_encode_mobile_throttled() "\"reportingEndpointPort\": 4322" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_MOBILE_FLOW) != NULL); assert(post.memory == NULL); @@ -2737,10 +3259,7 @@ void test_encode_mobile_throttled() MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL; EVENT_MOBILE_FLOW * mobile_flow = NULL; - /***************************************************************************/ - /* Mobile. */ - /***************************************************************************/ - evel_set_next_event_sequence(1242); +// evel_set_next_event_sequence(1242); metrics = evel_new_mobile_gtp_flow_metrics(132.0001, 31.2, @@ -2781,9 +3300,13 @@ void test_encode_mobile_throttled() evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote"); evel_mobile_gtp_metrics_con_status_set(metrics, "Connected"); evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling"); - evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13); - evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1); - evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99); +// evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13); +// evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1); +// evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99); + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "1", "13"); + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "17", "1"); + evel_mobile_gtp_metrics_ip_tos_count_list_add(metrics, "4", "99"); + evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80); evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0); evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680); @@ -2791,14 +3314,18 @@ void test_encode_mobile_throttled() evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1); evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4); evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_LTE_65, 122); - - mobile_flow = evel_new_mobile_flow("Inbound", +// evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10); +// evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121); + evel_mobile_gtp_metrics_tcp_flag_count_list_add(metrics, EVEL_TCP_CWR, "10"); + evel_mobile_gtp_metrics_tcp_flag_count_list_add(metrics, EVEL_TCP_URG, "121"); +// evel_mobile_gtp_metrics_qci_cos_count_add( metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); +// evel_mobile_gtp_metrics_qci_cos_count_add( metrics, EVEL_QCI_COS_LTE_65, 122); + evel_mobile_gtp_metrics_qci_cos_count_list_add(metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, "11"); + evel_mobile_gtp_metrics_qci_cos_count_list_add(metrics, EVEL_QCI_COS_LTE_65, "122"); + + mobile_flow = evel_new_mobile_flow("mobileFlow_error", + "mobileFlow000000001", + "Inbound", metrics, "UDP", "IPv6", @@ -2842,14 +3369,12 @@ void test_encode_mobile_throttled() evel_free_event(mobile_flow); evel_throttle_terminate(); } - +*****************/ +/************** void test_encode_other_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -2871,13 +3396,14 @@ void test_encode_other_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"other\", " - "\"eventId\": \"129\", " + "\"eventId\": \"other000000001\", " + "\"eventName\": \"other_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 129, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -2889,23 +3415,17 @@ void test_encode_other_throttled() "]" "}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_OTHER) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_OTHER * other = NULL; - evel_set_next_event_sequence(129); - other = evel_new_other(); +// evel_set_next_event_sequence(129); + other = evel_new_other("other_err", "other000000001"); assert(other != NULL); evel_other_type_set(other, "Other Type"); evel_other_field_add(other, @@ -2923,14 +3443,12 @@ void test_encode_other_throttled() evel_free_event(other); evel_throttle_terminate(); } - +*******************/ +/********************* void test_encode_report_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -2960,13 +3478,14 @@ void test_encode_report_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"measurementsForVfReporting\", " - "\"eventId\": \"125\", " + "\"eventId\": \"report000000001\", " + "\"eventName\": \"report_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 125, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -2982,15 +3501,9 @@ void test_encode_report_throttled() "\"value\": \"Value1\"}]}], " "\"measurementFieldsVersion\": 1.1}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_REPORT) != NULL); assert(post.memory == NULL); @@ -2998,11 +3511,8 @@ void test_encode_report_throttled() char json_body[EVEL_MAX_JSON_BODY]; EVENT_REPORT * report = NULL; - /***************************************************************************/ - /* Report. */ - /***************************************************************************/ - evel_set_next_event_sequence(125); - report = evel_new_report(1.1); +// evel_set_next_event_sequence(125); + report = evel_new_report(1.1, "report_err", "report000000001"); assert(report != NULL); evel_report_type_set(report, "Perf reporting..."); evel_report_feature_use_add(report, "FeatureA", 123); @@ -3019,14 +3529,12 @@ void test_encode_report_throttled() evel_free_event(report); evel_throttle_terminate(); } - +**********************/ +/******************************************** void test_encode_service_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -3062,9 +3570,9 @@ void test_encode_service_throttled() "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 2000, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -3083,22 +3591,16 @@ void test_encode_service_throttled() "{\"name\": \"Name4\", \"value\": \"Value4\"}]" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_SERVICE) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_SERVICE * event = NULL; - evel_set_next_event_sequence(2000); +// evel_set_next_event_sequence(2000); event = evel_new_service("vendor_x_id", "vendor_x_event_id"); assert(event != NULL); evel_service_type_set(event, "Service Event"); @@ -3145,14 +3647,13 @@ void test_encode_service_throttled() evel_free_event(event); evel_throttle_terminate(); } +****************************/ +/************************ void test_encode_signaling_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -3181,13 +3682,14 @@ void test_encode_signaling_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"signaling\", " - "\"eventId\": \"2001\", " + "\"eventId\": \"sipSignal0000000001\", " + "\"eventName\": \"sipSignal_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 2001, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -3203,23 +3705,18 @@ void test_encode_signaling_throttled() "\"signalingFieldsVersion\": 1.1" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ - assert(evel_get_throttle_spec(EVEL_DOMAIN_SIGNALING) != NULL); + assert(evel_get_throttle_spec(EVEL_DOMAIN_SIPSIGNALING) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_SIGNALING * event = NULL; - evel_set_next_event_sequence(2001); - event = evel_new_signaling("vendor_x_id", +// evel_set_next_event_sequence(2001); + event = evel_new_signaling("sipSignal_err", + "sipSignal0000000001", "vendor_x_id", "correlator", "1.0.3.1", "1234", "192.168.1.3","3456"); assert(event != NULL); evel_signaling_vnfmodule_name_set(event, "vendor_x_module"); @@ -3227,7 +3724,7 @@ void test_encode_signaling_throttled() evel_signaling_type_set(event, "Signaling"); evel_signaling_product_id_set(event, "vendor_x_product_id"); evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id"); - evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name"); +// evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name"); evel_signaling_correlator_set(event, "vendor_x_correlator"); evel_signaling_local_ip_address_set(event, "1.0.3.1"); evel_signaling_local_port_set(event, "1031"); @@ -3243,14 +3740,12 @@ void test_encode_signaling_throttled() evel_free_event(event); evel_throttle_terminate(); } - +***********************/ +/********************** void test_encode_state_change_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -3276,13 +3771,14 @@ void test_encode_state_change_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"stateChange\", " - "\"eventId\": \"128\", " + "\"eventId\": \"stateChange000000001\", " + "\"eventName\": \"stateChange_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 128, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -3297,23 +3793,19 @@ void test_encode_state_change_throttled() "\"stateChangeFieldsVersion\": 1.1" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_STATE_CHANGE) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_STATE_CHANGE * state_change = NULL; - evel_set_next_event_sequence(128); - state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE, +// evel_set_next_event_sequence(128); + state_change = evel_new_state_change("stateChange_err", + "stateChange000000001", + EVEL_ENTITY_STATE_IN_SERVICE, EVEL_ENTITY_STATE_OUT_OF_SERVICE, "An Interface"); assert(state_change != NULL); @@ -3329,14 +3821,12 @@ void test_encode_state_change_throttled() evel_free_event(state_change); evel_throttle_terminate(); } - +********************/ +/***************** void test_encode_syslog_throttled() { MEMORY_CHUNK post; - /***************************************************************************/ - /* We also test suppression of the event header parameters here. */ - /***************************************************************************/ char * json_command_list = "{" "\"commandList\": [" @@ -3368,13 +3858,14 @@ void test_encode_syslog_throttled() "{\"event\": " "{\"commonEventHeader\": {" "\"domain\": \"syslog\", " - "\"eventId\": \"126\", " + "\"eventId\": \"syslog000000001\", " + "\"eventName\": \"syslog_err\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 126, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2" "}, " @@ -3389,23 +3880,18 @@ void test_encode_syslog_throttled() "]" "}}}"; - /***************************************************************************/ - /* Initialize and provide a specification with a single fault suppressed. */ - /***************************************************************************/ evel_throttle_initialize(); handle_json_response(json_command_list, &post); - /***************************************************************************/ - /* Check that the domain is throttled. */ - /***************************************************************************/ assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL); assert(post.memory == NULL); size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; EVENT_SYSLOG * syslog = NULL; - evel_set_next_event_sequence(126); - syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, +// evel_set_next_event_sequence(126); + syslog = evel_new_syslog("syslog_err", "syslog000000001", + EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, "SL Message", "SL Tag"); assert(syslog != NULL); @@ -3416,8 +3902,8 @@ void test_encode_syslog_throttled() evel_syslog_proc_id_set(syslog, 2); evel_syslog_version_set(syslog, 1); evel_syslog_s_data_set(syslog, "SL SDATA"); - evel_syslog_addl_field_add(syslog, "Name1", "Value1"); - evel_syslog_addl_field_add(syslog, "Name2", "Value2"); + evel_syslog_addl_fields_set(syslog, "Name1", "Value1"); + evel_syslog_addl_fields_set(syslog, "Name2", "Value2"); json_size = evel_json_encode_event( json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog); @@ -3427,20 +3913,22 @@ void test_encode_syslog_throttled() evel_free_event(syslog); evel_throttle_terminate(); } - +**********************/ +/******************** void test_encode_fault_with_escaping() { char * expected = "{\"event\": {" "\"commonEventHeader\": {" "\"domain\": \"fault\", " - "\"eventId\": \"122\", " + "\"eventId\": \"fault000000001\", " + "\"eventName\": \"fault_eNodeB_alarm\", " "\"functionalRole\": \"UNIT TEST\", " "\"lastEpochMicrosec\": 1000002, " "\"priority\": \"Normal\", " - "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", " + "\"reportingEntityName\": \"prakash-VirtualBox\", " "\"sequence\": 122, " - "\"sourceName\": \"Dummy VM name - No Metadata available\", " + "\"sourceName\": \"prakash-VirtualBox\", " "\"startEpochMicrosec\": 1000002, " "\"version\": 1.2, " "\"eventType\": \"Bad things happen...\\\\\", " @@ -3464,8 +3952,10 @@ void test_encode_fault_with_escaping() size_t json_size = 0; char json_body[EVEL_MAX_JSON_BODY]; - evel_set_next_event_sequence(122); - EVENT_FAULT * fault = evel_new_fault("My alarm condition", +// evel_set_next_event_sequence(122); + EVENT_FAULT * fault = evel_new_fault("fault_eNodeB_alarm", + "fault000000001", + "My alarm condition", "It broke \"very\" badly", EVEL_PRIORITY_NORMAL, EVEL_SEVERITY_MAJOR, @@ -3484,3 +3974,4 @@ void test_encode_fault_with_escaping() evel_free_event(fault); } +***********************/ -- cgit 1.2.3-korg