summaryrefslogtreecommitdiffstats
path: root/veslibrary
diff options
context:
space:
mode:
authorPrakashH <pbhandar@techmahindra.com>2019-01-29 20:41:28 +0000
committerPrakashH <pbhandar@techmahindra.com>2019-02-13 19:00:02 +0000
commite987dff7d71bf2255646df58bf22fa603f8d3935 (patch)
tree11d55c61f49f9c2712c7b42a9ecd10e98659865d /veslibrary
parent493ed75799223784bdd6f9363d3bc4d189ddb370 (diff)
VES 7.1 C Lib/Agent Enhancements
HB-Fault-Measurement-Syslog-2Collector enhancement Issue-ID: VNFSDK-364 Change-Id: Iba5dc8b0493431a23de4fb8e24b6fc3a6661c4e4 Signed-off-by: PrakashH <pbhandar@techmahindra.com>
Diffstat (limited to 'veslibrary')
-rwxr-xr-xveslibrary/ves_clibrary/VESreporting_vFW/go-client.sh8
-rw-r--r--veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c26
-rw-r--r--veslibrary/ves_clibrary/VESreporting_vLB/README.md26
-rw-r--r--veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c333
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swobin0 -> 12288 bytes
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swpbin0 -> 12288 bytes
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/LICENSE.TXT (renamed from veslibrary/ves_clibrary/VESreporting_vLB/LICENSE.TXT)0
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/Makefile52
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/README.md37
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/dep.xml (renamed from veslibrary/ves_clibrary/VESreporting_vLB/dep.xml)0
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client.sh6
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client_2_collectors.sh12
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/hb_config.json15
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.c615
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.h134
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/pom.xml (renamed from veslibrary/ves_clibrary/VESreporting_vLB/pom.xml)28
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/sample_heartbeat_event.txt29
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/ves_heartbeat_reporter.c262
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/LICENSE.TXT22
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/Makefile52
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/README.md37
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/dep.xml25
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/flt_config.json73
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client.sh6
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client_2_collectors.sh12
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.c672
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.h136
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/pom.xml83
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/sample_fault_events.txt140
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/ves_fault_reporter.c1352
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/LICENSE.TXT22
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/Makefile52
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/README.md37
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/dep.xml25
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client.sh6
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client_2_collectors.sh12
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.c672
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.h136
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/pom.xml83
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/sample_syslog_event.txt33
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/syslog_config.json20
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/ves_syslog_reporter.c381
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/.meas_config.json.swpbin0 -> 12288 bytes
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/LICENSE.TXT22
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/Makefile (renamed from veslibrary/ves_clibrary/VESreporting_vLB/Makefile)28
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/README.md37
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/dep.xml25
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client.sh (renamed from veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh)2
-rwxr-xr-xveslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client_2_collectors.sh12
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.c672
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.h136
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/meas_config.json52
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/pom.xml83
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/sample_measurement_event.txt65
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/vpp_measurement_reporter.c694
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c5
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h6
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c1
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c2
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c1814
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h1
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c2
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c2
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/quickstart.md5
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/readme.md120
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c2893
-rw-r--r--veslibrary/ves_clibrary/readme.md43
67 files changed, 7725 insertions, 4669 deletions
diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh b/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh
index b2b3a08..0aaed85 100755
--- a/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh
+++ b/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh
@@ -1,6 +1,12 @@
#!/bin/bash
-
export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+
+#Usage for 2 collectors:
+#./vpp_measurement_reporter <FQDN>|<IP address> <port> <FQDN>|<IP address> <port>
+# Usage for a collector:
+#./vpp_measurement_reporter <FQDN>|<IP address> <port>
+
DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT
+
diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c b/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c
index 42f9793..0b1719e 100644
--- a/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c
+++ b/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c
@@ -15,6 +15,7 @@
*
****************************************************************************/
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -603,15 +604,25 @@ int main(int argc, char** argv)
{
char* fqdn = argv[1];
int port = atoi(argv[2]);
+ char* fqdn2 = NULL;
+ int port2 = 0;
int i=0;
int rc;
pthread_attr_t attr;
pthread_t hb_thread;
pthread_t meas_thread;
pthread_t flt_thread;
+
+ if(argc == 5)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ }
- if (argc != 3)
+ if (!((argc == 3) || (argc == 5)))
{
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> \n", argv[0]);
+ fprintf(stderr, "OR\n");
fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> \n", argv[0]);
exit(-1);
}
@@ -621,23 +632,22 @@ int main(int argc, char** argv)
/**************************************************************************/
if(evel_initialize(fqdn, /* FQDN */
port, /* Port */
- NULL, /* Backup FQDN */
- 0, /* Backup port */
+ fqdn2, /* Backup FQDN */
+ port2, /* 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 */
+ "sample1", /* Username */
+ "sample1", /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
NULL, /* Source ip */
NULL, /* Source ip2 */
EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/README.md b/veslibrary/ves_clibrary/VESreporting_vLB/README.md
deleted file mode 100644
index 598b207..0000000
--- a/veslibrary/ves_clibrary/VESreporting_vLB/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-
-PROJECT DESCRIPTION
-
----
-This project contains the source code and scripts for the periodic generation of network measurement reports. The folder contains:
-
- - README.md: this file.
-
- - LICENSE.TXT: the license text.
-
- - vpp_measurement_reporter.c: source code that uses the ECOMP Vendor Event Listener Library (VES) to read metrics from the network interface and send periodic measurement reports to the VES collector in DCAE. The VES library used here has been cloned from the GitHub repository at https://github.com/att/evel-library on February 1, 2017.
-
- - Makefile: makefile that compiles vpp_measurement_reporter.c and generates vpp_measurement_reporter binary.
-
- - go-client.sh: bash script that starts up the vpp_measurement_reporter binary generated by Makefile. It reads input parameters like DCAE IP address and port from configuration files contained in /opt/config.
-
-
-USAGE
----
-To run the vpp_measurement_reporter, please execute the following steps:
-
- - Make the go-client.sh script executable
- chmod +x go-client.sh
-
- - Run the go-client.sh script
- ./go-client.sh
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c b/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c
deleted file mode 100644
index 14ca294..0000000
--- a/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c
+++ /dev/null
@@ -1,333 +0,0 @@
-
-/*************************************************************************//**
- *
- * 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.
- *
- ****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <math.h>
-
-#include "evel.h"
-
-#define BUFSIZE 128
-#define READ_INTERVAL 10
-
-typedef struct dummy_vpp_metrics_struct {
- int bytes_in;
- int bytes_out;
- int packets_in;
- int packets_out;
-} vpp_metrics_struct;
-
-void read_vpp_metrics(vpp_metrics_struct *, char *);
-
-unsigned long long epoch_start = 0;
-
-
-#ifdef DOCKER
-int measure_traffic()
-{
-
- EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
- FILE *fp;
- int status;
- char count[10];
- time_t rawtime;
- struct tm * timeinfo;
- char period [21];
- char cmd [100];
- int concurrent_sessions = 0;
- int configured_entities = 0;
- double mean_request_latency = 0;
- double measurement_interval = 1;
- double memory_configured = 0;
- double memory_used = 0;
- int request_rate=0;
- char secs [3];
- int sec;
- double loadavg;
-
- printf("Checking app traffic\n");
- time (&rawtime);
- timeinfo = localtime (&rawtime);
- strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo);
- strftime(secs,3,"%S",timeinfo);
- sec = atoi(secs);
- if (sec == 0) sec = 59;
- sprintf(secs, "%02d", sec);
- strncat(period, secs, 21);
- // ....x....1....x....2.
- // 15/Oct/2016:17:51:19
- strcpy(cmd, "sudo docker logs vHello | grep -c ");
- strncat(cmd, period, 100);
-
- fp = popen(cmd, "r");
- if (fp == NULL) {
- EVEL_ERROR("popen failed to execute command");
- }
-
- if (fgets(count, 10, fp) != NULL) {
- request_rate = atoi(count);
- printf("Reporting request rate for second: %s as %d\n", period, request_rate);
-
- }
- else {
- EVEL_ERROR("New Measurement failed");
- }
- printf("Processed measurement\n");
-
- status = pclose(fp);
- if (status == -1) {
- EVEL_ERROR("pclose returned an error");
- }
- return request_rate;
-}
-
-#endif
-
-
-int main(int argc, char** argv)
-{
- EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
- EVENT_MEASUREMENT* vpp_m = NULL;
- EVENT_HEADER* vpp_m_header = NULL;
- int bytes_in_this_round;
- int bytes_out_this_round;
- int packets_in_this_round;
- int packets_out_this_round;
- vpp_metrics_struct* last_vpp_metrics = malloc(sizeof(vpp_metrics_struct));
- vpp_metrics_struct* curr_vpp_metrics = malloc(sizeof(vpp_metrics_struct));
- struct timeval time_val;
- //time_t start_epoch;
- //time_t last_epoch;
- char hostname[BUFSIZE];
- char* fqdn = argv[1];
- int port = atoi(argv[2]);
- char* vnic = argv[3];
- MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
-
- printf("\nVector Packet Processing (VPP) measurement collection\n");
- fflush(stdout);
-
- if (argc != 4)
- {
- fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <interface>\n", argv[0]);
- exit(-1);
- }
- srand(time(NULL));
-
- /**************************************************************************/
- /* Initialize */
- /**************************************************************************/
- if(evel_initialize(fqdn, /* FQDN */
- port, /* Port */
- NULL, /* optional path */
- NULL, /* optional topic */
- 100, /* Ring buffer size */
- 0, /* HTTPS? */
- NULL, /* cert file */
- NULL, /* key file */
- NULL, /* ca info */
- NULL, /* ca file */
- 0, /* verify peer */
- 0, /* verify host */
- "", /* Username */
- "", /* Password */
- NULL, /* Source IP */
- EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
- "vLoadBalancer", /* Role */
- 1)) /* Verbosity */
- {
- fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
- exit(-1);
- }
- else
- {
- printf("\nInitialization completed\n");
- }
-
- gethostname(hostname, BUFSIZE);
- memset(last_vpp_metrics, 0, sizeof(vpp_metrics_struct));
- read_vpp_metrics(last_vpp_metrics, vnic);
- gettimeofday(&time_val, NULL);
- epoch_start = time_val.tv_sec * 1000000 + time_val.tv_usec;
- sleep(READ_INTERVAL);
-
- /***************************************************************************/
- /* Collect metrics from the VNIC */
- /***************************************************************************/
- while(1) {
- // Read the number of vDNSs currently active
- int active_dns = 0;
- FILE* fd = fopen("active_dns.txt", "r");
- while(!feof(fd)) {
- if(fscanf(fd, "%d", &active_dns) != 1) /* Avoid infinite loops if the file doesn't contain exactly one number */
- break;
- }
-
- if(fclose(fd)) {
- printf("Error when closing file\n");
- return 1;
- }
-
- memset(curr_vpp_metrics, 0, sizeof(vpp_metrics_struct));
- read_vpp_metrics(curr_vpp_metrics, vnic);
-
- if(active_dns > 0 && (curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in > 0)) {
- bytes_in_this_round = (int) round((curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in) / active_dns);
- }
- else {
- bytes_in_this_round = 0;
- }
- if(active_dns > 0 && (curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out > 0)) {
- bytes_out_this_round = (int) round((curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out) / active_dns);
- }
- else {
- bytes_out_this_round = 0;
- }
- if(active_dns > 0 && (curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in > 0)) {
- packets_in_this_round = (int) round((curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in) / active_dns);
- }
- else {
- packets_in_this_round = 0;
- }
- if(active_dns > 0 && (curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out > 0)) {
- packets_out_this_round = (int) round((curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out) / active_dns);
- }
- else {
- packets_out_this_round = 0;
- }
-
- vpp_m = evel_new_measurement(READ_INTERVAL,"vLoadBalancer","TrafficStats_1.2.3.4");
- vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance("eth0", "true");
- evel_meas_vnic_performance_add(vpp_m, vnic_performance);
-
- if(vpp_m != NULL) {
- printf("New measurement report created...\n");
-
- evel_measurement_type_set(vpp_m, "HTTP request rate");
- evel_measurement_request_rate_set(vpp_m, rand()%10000);
-
- evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, packets_in_this_round);
- evel_vnic_performance_tx_total_pkt_delta_set(vnic_performance, packets_out_this_round);
-
- evel_vnic_performance_rx_octets_delta_set(vnic_performance, bytes_in_this_round);
- evel_vnic_performance_tx_octets_delta_set(vnic_performance, bytes_out_this_round);
-
- /***************************************************************************/
- /* Set parameters in the MEASUREMENT header packet */
- /***************************************************************************/
- struct timeval tv_now;
- gettimeofday(&tv_now, NULL);
- unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
-
- //last_epoch = start_epoch + READ_INTERVAL * 1000000;
- vpp_m_header = (EVENT_HEADER *)vpp_m;
- //vpp_m_header->start_epoch_microsec = start_epoch;
- //vpp_m_header->last_epoch_microsec = last_epoch;
- evel_start_epoch_set(&vpp_m->header, epoch_start);
- evel_last_epoch_set(&vpp_m->header, epoch_now);
- epoch_start = epoch_now;
-
- evel_nfcnamingcode_set(&vpp_m->header, "vVNF");
- evel_nfnamingcode_set(&vpp_m->header, "vVNF");
- //strcpy(vpp_m_header->reporting_entity_id.value, "No UUID available");
- //strcpy(vpp_m_header->reporting_entity_name, hostname);
- evel_reporting_entity_name_set(&vpp_m->header, "lbll");
- evel_reporting_entity_id_set(&vpp_m->header, "No UUID available");
- evel_rc = evel_post_event(vpp_m_header);
-
- if(evel_rc == EVEL_SUCCESS) {
- printf("Measurement report correctly sent to the collector!\n");
- }
- else {
- printf("Post failed %d (%s)\n", evel_rc, evel_error_string());
- }
- }
- else {
- printf("New measurement report failed (%s)\n", evel_error_string());
- }
-
- last_vpp_metrics->bytes_in = curr_vpp_metrics->bytes_in;
- last_vpp_metrics->bytes_out = curr_vpp_metrics->bytes_out;
- last_vpp_metrics->packets_in = curr_vpp_metrics->packets_in;
- last_vpp_metrics->packets_out = curr_vpp_metrics->packets_out;
- //gettimeofday(&time_val, NULL);
- //start_epoch = time_val.tv_sec * 1000000 + time_val.tv_usec;
-
- sleep(READ_INTERVAL);
- }
-
- /***************************************************************************/
- /* Terminate */
- /***************************************************************************/
- sleep(1);
- evel_free_measurement(vpp_m);
- free(last_vpp_metrics);
- free(curr_vpp_metrics);
- evel_terminate();
- printf("Terminated\n");
-
- return 0;
-}
-
-void read_vpp_metrics(vpp_metrics_struct *vpp_metrics, char *vnic) {
- // Define an array of char that contains the parameters of the unix 'cut' command
- char* params[] = {"-f3", "-f11", "-f4", "-f12"};
- // Define the unix command to execute in order to read metrics from the vNIC
- char* cmd_prefix = "sudo cat /proc/net/dev | grep \"";
- char* cmd_mid = "\" | tr -s \' \' | cut -d\' \' ";
- char cmd[BUFSIZE];
- // Define other variables
- char buf[BUFSIZE]; /* buffer used to store VPP metrics */
- int temp[] = {0, 0, 0, 0}; /* temp array that contains VPP values */
- FILE *fp; /* file descriptor to pipe cmd to shell */
- int i;
-
- for(i = 0; i < 4; i++) {
- // Clear buffers
- memset(buf, 0, BUFSIZE);
- memset(cmd, 0, BUFSIZE);
- // Build shell command to read metrics from the vNIC
- strcat(cmd, cmd_prefix);
- strcat(cmd, vnic);
- strcat(cmd, cmd_mid);
- strcat(cmd, params[i]);
-
- // Open a pipe and read VPP values
- if ((fp = popen(cmd, "r")) == NULL) {
- printf("Error opening pipe!\n");
- return;
- }
-
- while (fgets(buf, BUFSIZE, fp) != NULL);
- temp[i] = atoi(buf);
-
- if(pclose(fp)) {
- printf("Command not found or exited with error status\n");
- return;
- }
- }
-
- // Store metrics read from the vNIC in the struct passed from the main function
- vpp_metrics->bytes_in = temp[0];
- vpp_metrics->bytes_out = temp[1];
- vpp_metrics->packets_in = temp[2];
- vpp_metrics->packets_out = temp[3];
-}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swo b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swo
new file mode 100644
index 0000000..c25519c
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swo
Binary files differ
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swp b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swp
new file mode 100644
index 0000000..ff0f26b
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/.flt_config.json.swp
Binary files differ
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/LICENSE.TXT
index 16285cd..16285cd 100644
--- a/veslibrary/ves_clibrary/VESreporting_vLB/LICENSE.TXT
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/LICENSE.TXT
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/Makefile b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/Makefile
new file mode 100644
index 0000000..e007759
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/Makefile
@@ -0,0 +1,52 @@
+#############################################################################
+#
+# Copyright © 2018 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)/../..
+#CODE_ROOT=../code/evel-library
+LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH)
+#LIBS_DIR=/usr/lib
+INCLUDE_DIR= -I $(CODE_ROOT)/code/evel_library -I .
+
+#******************************************************************************
+# Standard compiler flags. *
+#******************************************************************************
+CPPFLAGS=
+CFLAGS=-Wall -g -fPIC
+FILEOBJLIST= jsmn.o ves_heartbeat_reporter.o
+
+all: ves_heartbeat_reporter
+
+clean:
+ rm -f *.o ves_heartbeat_reporter
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
+
+jsmn.o: jsmn.c jsmn.h
+ves_heartbeat_reporter.o: ves_heartbeat_reporter.c
+
+ves_heartbeat_reporter: $(FILEOBJLIST)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o ves_heartbeat_reporter \
+ -L $(LIBS_DIR) \
+ $(FILEOBJLIST) \
+ -lpthread \
+ -level \
+ -lcurl
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/README.md b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/README.md
new file mode 100644
index 0000000..a0d8e76
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/README.md
@@ -0,0 +1,37 @@
+
+PROJECT DESCRIPTION
+
+---
+This project contains the source code and scripts for the periodic generation of heartbeat events. The folder contains:
+
+ - README.md: this file.
+
+ - LICENSE.TXT: the license text.
+
+ - ves_heartbeat_reporter.c and other .c files: source code that uses the ECOMP Vendor Event Listener Library (VES) to generate the periodic hertbeat events. It reads hb_config.json file for parameter values and poppulate the heartbeat event. If eventName parameter value is not given, the application terminates. If reportingEntityName and sourceName parameter values are not given, then it gets the hostname and poppulates it. If heartbeatInterval is not given, it defaults to 60 seconds.
+
+ - Makefile: makefile that compiles ves_heartbeat_reporter.c and generates ves_heartbeat_reporter binary.
+
+ - go-client.sh/go-client_2_collectors.sh: bash script that starts up the ves_heartbeat_reporter. It reads input parameters like DCAE IP address and port from configuration files contained in /opt/config. Based on the collector configuration, use go-client.sh for single collector configuration, or use go-client_2_collectors.sh for 2 collectors configuration.
+
+
+USAGE
+-----
+
+Update the configuration files with proper parameters values so that events generated would contain those values
+
+To run the ves_heartbeat_reporter in single collector configuration, please execute the following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client.sh
+
+ - Run the go-client.sh script
+ ./go-client.sh
+
+For 2 collectors configuration, please execute following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client_2_collectors.sh
+
+ - Run the go-client_2_collectors.sh script
+ ./go-client_2_collectors.sh
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/dep.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/dep.xml
index fc18229..fc18229 100644
--- a/veslibrary/ves_clibrary/VESreporting_vLB/dep.xml
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/dep.xml
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client.sh
new file mode 100755
index 0000000..22b930d
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+./ves_heartbeat_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client_2_collectors.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client_2_collectors.sh
new file mode 100755
index 0000000..b3747e2
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/go-client_2_collectors.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+
+#Usage for 2 collectors:
+#./ves_heartbeat_reporter <FQDN>|<IP address> <port> <FQDN>|<IP address> <port>
+
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+DCAE_COLLECTOR_IP2=$(cat /opt/config/dcae_collector_ip2.txt)
+DCAE_COLLECTOR_PORT2=$(cat /opt/config/dcae_collector_port2.txt)
+./ves_heartbeat_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT $DCAE_COLLECTOR_IP2 $DCAE_COLLECTOR_PORT2
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/hb_config.json b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/hb_config.json
new file mode 100644
index 0000000..4bc9759
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/hb_config.json
@@ -0,0 +1,15 @@
+{
+ "tmp_directParameters": {
+ "eventType": "platform",
+ "eventName": "Heartbeat_VNF-AT&T_heartbeat",
+ "nfcNamingCode": "ssc",
+ "nfNamingCode": "scfx",
+ "nfVendorName": "AT&T",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "timeZoneOffset": "UTC-05:30",
+ "heartbeatInterval": 10
+ }
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.c
new file mode 100644
index 0000000..f663403
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.c
@@ -0,0 +1,615 @@
+/*************************************************************************//**
+ *
+ * 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.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ****************************************************************************/
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include "jsmn.h"
+
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+ jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *tok;
+ if (parser->toknext >= num_tokens) {
+ return NULL;
+ }
+ tok = &tokens[parser->toknext++];
+ tok->start = tok->end = -1;
+ tok->size = 0;
+//#ifdef JSMN_PARENT_LINKS
+ tok->parent = -1;
+//#endif
+ return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+ int start, int end) {
+//printf("jsmn_fill_token:: start-%d, end-%d\n", start, end);
+ token->type = type;
+ token->start = start;
+ token->end = end;
+ token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+ int start;
+
+ start = parser->pos;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+//printf("jsmn_parse_primitive:: the char is - %c\n", js[parser->pos]);
+ switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+ /* In strict mode primitive must be followed by "," or "}" or "]" */
+ case ':':
+#endif
+ case '\t' : case '\r' : case '\n' : case ' ' :
+ case ',' : case ']' : case '}' :
+ goto found;
+ }
+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#ifdef JSMN_STRICT
+ /* In strict mode primitive must be followed by a comma/object/array */
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+#endif
+
+found:
+ if (tokens == NULL) {
+ parser->pos--;
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ parser->pos--;
+ return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+
+ int start = parser->pos;
+
+ parser->pos++;
+
+ /* Skip starting quote */
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c = js[parser->pos];
+ char d = js[parser->pos + 1];
+// char e = js[parser->pos + 2];
+//printf("jsmn_parse_string: value-%c, pos-%d\n", c,parser->pos);
+
+ /* Quote: end of string */
+// if (c == '\"') {
+ if (d == '\"') {
+// if ((d == '\"')&&((e == ' ')||(e == ','))) {
+parser->pos++;
+//printf("jsmn_parse_string: end of string\n");
+ if (tokens == NULL) {
+//printf("jsmn_parse_string: end tokens is NULL\n");
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+//printf("jsmn_parse_string: Allocated tokens \n");
+ if (token == NULL) {
+//printf("jsmn_parse_string: Allocated tokens is NULL\n");
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+//printf("jsmn_parse_string: Allocated tokens is filled\n");
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ return 0;
+ }
+
+ /* Backslash: Quoted symbol expected */
+ if (c == '\\' && parser->pos + 1 < len) {
+ int i;
+ parser->pos++;
+//printf("jsmn_parse_string: value - %c, POS-%3d \n",c, js[parser->pos]);
+ switch (js[parser->pos]) {
+ /* Allowed escaped symbols */
+ case '\"': case '/' : case '\\' : case 'b' :
+ case 'f' : case 'r' : case 'n' : case 't' :
+ break;
+ /* Allows escaped symbol \uXXXX */
+ case 'u':
+ parser->pos++;
+ for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+ /* If it isn't a hex character we have an error */
+ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ parser->pos++;
+ }
+ parser->pos--;
+ break;
+ /* Unexpected symbol */
+ default:
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+ }
+ parser->pos = start;
+printf("jsmn_parse_string: exiting with ERROR_PART, pos-%d", parser->pos);
+ return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens) {
+ int r;
+ int i;
+ jsmntok_t *token;
+ int count = parser->toknext;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c;
+ jsmntype_t type;
+
+ c = js[parser->pos];
+//printf("jsmn_parse: value of c - %c\n",c);
+ switch (c) {
+ case '{': case '[':
+ count++;
+ if (tokens == NULL) {
+ break;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL)
+ return JSMN_ERROR_NOMEM;
+ if (parser->toksuper != -1) {
+ tokens[parser->toksuper].size++;
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ }
+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+ token->start = parser->pos;
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case '}': case ']':
+ if (tokens == NULL)
+ break;
+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+//#ifdef JSMN_PARENT_LINKS
+ if (parser->toknext < 1) {
+ return JSMN_ERROR_INVAL;
+ }
+ token = &tokens[parser->toknext - 1];
+ for (;;) {
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ token->end = parser->pos + 1;
+ parser->toksuper = token->parent;
+ break;
+ }
+ if (token->parent == -1) {
+ break;
+ }
+ token = &tokens[token->parent];
+ }
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// if (token->type != type) {
+// return JSMN_ERROR_INVAL;
+// }
+// parser->toksuper = -1;
+// token->end = parser->pos + 1;
+// break;
+// }
+// }
+// /* Error if unmatched closing bracket */
+// if (i == -1) return JSMN_ERROR_INVAL;
+// for (; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+//#endif
+ break;
+ case '\"':
+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+ case '\t' : case '\r' : case '\n' : case ' ':
+ break;
+ case ':':
+ parser->toksuper = parser->toknext - 1;
+//printf("jsmn_parse: value of c is :: - %c\n",c);
+ break;
+ case ',':
+ if (tokens != NULL && parser->toksuper != -1 &&
+ tokens[parser->toksuper].type != JSMN_ARRAY &&
+ tokens[parser->toksuper].type != JSMN_OBJECT) {
+//#ifdef JSMN_PARENT_LINKS
+ parser->toksuper = tokens[parser->toksuper].parent;
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+// if (tokens[i].start != -1 && tokens[i].end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+// }
+//#endif
+ }
+ break;
+#ifdef JSMN_STRICT
+ /* In strict mode primitives are: numbers and booleans */
+ case '-': case '0': case '1' : case '2': case '3' : case '4':
+ case '5': case '6': case '7' : case '8': case '9':
+ case 't': case 'f': case 'n' :
+ /* And they must not be keys of the object */
+ if (tokens != NULL && parser->toksuper != -1) {
+ jsmntok_t *t = &tokens[parser->toksuper];
+ if (t->type == JSMN_OBJECT ||
+ (t->type == JSMN_STRING && t->size != 0)) {
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#else
+ /* In non-strict mode every unquoted value is a primitive */
+ default:
+#endif
+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+
+#ifdef JSMN_STRICT
+ /* Unexpected char in strict mode */
+ default:
+ return JSMN_ERROR_INVAL;
+#endif
+ }
+ }
+
+ if (tokens != NULL) {
+ for (i = parser->toknext - 1; i >= 0; i--) {
+//printf("index -%2d, start is %3d, end is %3d\n", i, tokens[i].start, tokens[i].end);
+ /* Unmatched opened object or array */
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ return JSMN_ERROR_PART;
+ }
+ }
+ }
+
+ return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+void jsmn_init(jsmn_parser *parser) {
+ parser->pos = 0;
+ parser->toknext = 0;
+ parser->toksuper = -1;
+}
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+ if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
+ strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+ return 0;
+ }
+ return -1;
+}
+
+void printToken(char * js, jsmntok_t * tokens, int numToken)
+{
+ for (int i = 1; i < numToken; i++)
+ {
+ printf("Token number-%2d, parent-%2d, type-%d size-%2d, parameter -", i, tokens[i].parent, tokens[i].type, tokens[i].size);
+ if (tokens[i].type == JSMN_STRING || tokens[i].type == JSMN_PRIMITIVE) {
+ printf("%.*s\n", tokens[i].end - tokens[i].start, js + tokens[i].start);
+ } else if (tokens[i].type == JSMN_ARRAY) {
+ printf("[%d elems]\n", tokens[i].size);
+ } else if (tokens[i].type == JSMN_OBJECT) {
+ printf("{%d elems}\n", tokens[i].size);
+ } else {
+ printf("value?? - ");
+ TOKEN_PRINT(tokens[i]);
+ }
+ }
+}
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ {
+ continue;
+ }
+
+ if(tokens[i+1].type != JSMN_PRIMITIVE)
+ return 3; //Wrong parameter type
+
+// printf("INT parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], val);
+ *value = atoi(val);
+// printf(" - %d\n", *value);
+
+ return 0; //success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+void parseDirectParameters(char * js, jsmntok_t * tokens, int numToken)
+{
+ int i = 0;
+ int dpToken = 0;
+ char param[128];
+ char value[128];
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], "directParameters") == 0)
+ break;
+ }
+
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+
+ for (int i = 1; i < numToken; i++)
+ {
+ memset(param, 0, 128);
+ memset(value, 0, 128);
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ TOKEN_COPY(js, tokens[i], param);
+// printf("parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], value);
+// printf(" - %s\n", value);
+ }
+ }
+}
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_ARRAY)
+ {
+ *numElements = tokens[i+1].size;
+// printf("[%d elems]\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k], arrayValue[k].arrayString);
+// printf(" - %s\n", arrayValue[k].arrayString);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ {
+ return 0; //Token present
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //Token Not present
+}
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_OBJECT)
+ {
+ *numElements = tokens[i+1].size;
+// printf("{%d elems}\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k*2], keyValueResultList[k].keyStr);
+// printf("Key - %s", keyValueResultList[k].keyStr);
+ TOKEN_COPY(js, tokens[i+3+k*2], keyValueResultList[k].valStr);
+// printf("Value - %s\n", keyValueResultList[k].valStr);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.h b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.h
new file mode 100644
index 0000000..6703494
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/jsmn.h
@@ -0,0 +1,134 @@
+/*************************************************************************//**
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __JSMN_H_
+#define __JSMN_H_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * o Object
+ * o Array
+ * o String
+ * o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+ JSMN_UNDEFINED = 0,
+ JSMN_OBJECT = 1,
+ JSMN_ARRAY = 2,
+ JSMN_STRING = 3,
+ JSMN_PRIMITIVE = 4
+} jsmntype_t;
+
+enum jsmnerr {
+ /* Not enough tokens were provided */
+ JSMN_ERROR_NOMEM = -1,
+ /* Invalid character inside JSON string */
+ JSMN_ERROR_INVAL = -2,
+ /* The string is not a full JSON packet, more bytes expected */
+ JSMN_ERROR_PART = -3
+};
+
+typedef struct arrayValues {
+ char arrayString[32];
+} ARRAYVAL;
+
+typedef struct keyValResult {
+ char keyStr[80];
+ char valStr[250];
+ char resultStr[80];
+} KEYVALRESULT;
+
+/**
+ * JSON token description.
+ * @param type type (object, array, string etc.)
+ * @param start start position in JSON data string
+ * @param end end position in JSON data string
+ */
+typedef struct {
+ jsmntype_t type;
+ int start;
+ int end;
+ int size;
+//#ifdef JSMN_PARENT_LINKS
+ int parent;
+//#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string
+ */
+typedef struct {
+ unsigned int pos; /* offset in the JSON string */
+ unsigned int toknext; /* next token to allocate */
+ int toksuper; /* superior token node, e.g parent object or array */
+} jsmn_parser;
+
+#define TOKEN_EQ(t, tok_start, tok_end, tok_type) \
+ ((t).start == tok_start \
+ && (t).end == tok_end \
+ && (t).type == (tok_type))
+
+#define TOKEN_STRING(js, t, s) \
+ (strncmp(js+(t).start, s, (t).end - (t).start) == 0 \
+ && strlen(s) == (t).end - (t).start)
+
+#define TOKEN_COPY(js, t, s) \
+ strncpy(s, js+(t).start, (t).end - (t).start)
+
+#define TOKEN_PRINT(t) \
+ printf("start: %d, end: %d, type: %d, size: %d\n", \
+ (t).start, (t).end, (t).type, (t).size)
+
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
+ * a single JSON object.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens);
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
+
+void printToken(char * js, jsmntok_t * tokens, int numToken);
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize);
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value);
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements);
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam);
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __JSMN_H_ */
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/pom.xml
index d0af18f..f9f42eb 100644
--- a/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/pom.xml
@@ -22,7 +22,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
+<parent>
<groupId>org.onap.demo.vnf</groupId>
<artifactId>demo-aggregator</artifactId>
<version>1.2.0-SNAPSHOT</version>
@@ -31,7 +31,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.demo.vnf.ves5</groupId>
- <artifactId>ves_vlb_reporting</artifactId>
+ <artifactId>ves_vfw_reporting</artifactId>
<build>
<plugins>
@@ -64,18 +64,18 @@
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>none</phase>
- </execution>
- </executions>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/sample_heartbeat_event.txt b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/sample_heartbeat_event.txt
new file mode 100644
index 0000000..2c31d60
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/sample_heartbeat_event.txt
@@ -0,0 +1,29 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "heartbeat",
+ "eventId": "heartbeat000000010",
+ "eventName": "Heartbeat_VNF-AT&T_heartbeat",
+ "eventType": "platform",
+ "lastEpochMicrosec": 1548735913346089,
+ "nfNamingCode": "scfx",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "ssc",
+ "priority": "Normal",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 0,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1548735903336030,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.1",
+ "vesEventListenerVersion": "7.1"
+ },
+ "heartbeatFields": {
+ "heartbeatFieldsVersion": "3.0",
+ "heartbeatInterval": 10
+ }
+ }
+}
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/ves_heartbeat_reporter.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/ves_heartbeat_reporter.c
new file mode 100644
index 0000000..9cff5d0
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB/ves_heartbeat_reporter.c
@@ -0,0 +1,262 @@
+/*************************************************************************//**
+ *
+ * Copyright © 2018 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.
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include "jsmn.h"
+#include "evel.h"
+
+#define BUFSIZE 128
+#define MAX_BUFFER_SIZE 4096
+#define MAX_TOKENS 1000
+
+void *HeartbeatThread(void *threadarg);
+
+unsigned long long epoch_start = 0;
+
+int main(int argc, char** argv)
+{
+ char* fqdn = argv[1];
+ int port = atoi(argv[2]);
+ int i=0;
+ int rc;
+ pthread_attr_t attr;
+ pthread_t hb_thread;
+ char* fqdn2 = NULL;
+ int port2 = 0;
+
+ if(argc == 5)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ }
+
+ if (!((argc == 3) || (argc == 5)))
+ {
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> \n", argv[0]);
+ fprintf(stderr, "OR\n");
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> \n", argv[0]);
+ exit(-1);
+ }
+
+ /**************************************************************************/
+ /* Initialize */
+ /**************************************************************************/
+ if(evel_initialize(fqdn, /* FQDN */
+ port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 0, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ NULL, /* ca info */
+ NULL, /* ca file */
+ 0, /* verify peer */
+ 0, /* verify host */
+ "sample1", /* Username */
+ "sample1", /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
+ NULL, /* Source ip */
+ NULL, /* Source ip2 */
+ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
+ "vHeartbeat", /* Role */
+ 1)) /* Verbosity */
+ {
+ fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
+ exit(-1);
+ }
+ else
+ {
+ printf("\nInitialization completed\n");
+ }
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ printf("Main:Creating thread \n");
+ rc = pthread_create(&hb_thread, NULL, HeartbeatThread, &i);
+ if (rc)
+ {
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ printf("Main:Created HB thread \n");
+
+ pthread_join(hb_thread, NULL);
+
+ evel_terminate();
+ printf("Terminated\n");
+ return 0;
+}
+
+void *HeartbeatThread(void *threadarg)
+{
+
+ EVENT_HEARTBEAT_FIELD * event = NULL;
+ EVENT_HEADER* hb_header = NULL;
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+ char stringVal[BUFSIZE];
+ char eName[BUFSIZE];
+ int hb_interval;
+
+ char event_id1[10] = "heartbeat";
+ char event_id2[15] = {0};
+ int event_id3 = 0;
+ char event_id[BUFSIZE] = {0};
+
+ sleep(1);
+ printf("Running HB thread \n");
+ fflush(stdout);
+
+ while(1)
+ {
+
+ FILE * file = fopen("hb_config.json", "r");
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+// printf("the file content is \n %s \n", js);
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+ printf("Token count-%d\n", numToken);
+
+// printToken(js,tokens, numToken);
+
+ ret = getStringToken(js, tokens, numToken, "eventName", "tmp_directParameters", eName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("Missing mandatory parameters - eventName is not there in tmp_directParameters. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getIntToken(js, tokens, numToken, "heartbeatInterval", "tmp_directParameters", &hb_interval);
+ if (ret != 0)
+ {
+ printf("The parameter heartbeatInterval is not defined, defaulted to 60 seconds\n");
+ hb_interval = 60;
+ }
+
+ /***************************************************************************/
+ /* Heartbeat */
+ /***************************************************************************/
+ memset(event_id, 0, BUFSIZE);
+ memset(event_id2, 0, 15);
+ sprintf(event_id2, "%09d", event_id3++);
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ event = evel_new_heartbeat_field(hb_interval, eName, event_id);
+
+ if (event != NULL)
+ {
+ hb_header = (EVENT_HEADER *)event;
+
+ ret = getStringToken(js, tokens, numToken, "eventType", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_header_type_set(&event->header, stringVal);
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+
+ evel_start_epoch_set(&event->header, epoch_start);
+ evel_last_epoch_set(&event->header, epoch_now);
+ epoch_start = epoch_now;
+
+ ret = getStringToken(js, tokens, numToken, "nfcNamingCode", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nfcnamingcode_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "nfNamingCode", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nfnamingcode_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_reporting_entity_name_set(&event->header, stringVal);
+ else
+ {
+ printf("Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("Defaulting reportingEntityName to hostname\n");
+ }
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityId", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_reporting_entity_id_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "timeZoneOffset", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_time_zone_offset_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "nfVendorName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nf_vendor_name_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "sourceId", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_source_id_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_source_name_set(&event->header, stringVal);
+ else
+ {
+ printf("Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("Defaulting sourceName to hostname\n");
+ }
+
+ evel_rc = evel_post_event(hb_header);
+ if (evel_rc != EVEL_SUCCESS)
+ {
+ EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string());
+ }
+ }
+ else
+ {
+ EVEL_ERROR("New Heartbeat failed");
+ }
+ printf(" Processed Heartbeat\n");
+
+ sleep(hb_interval);
+ }
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/LICENSE.TXT
new file mode 100644
index 0000000..16285cd
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/LICENSE.TXT
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is trademark and service mark of AT&T Intellectual Property.
+ *
+ */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/Makefile b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/Makefile
new file mode 100644
index 0000000..4837c7d
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/Makefile
@@ -0,0 +1,52 @@
+#############################################################################
+#
+# Copyright © 2019 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)/../..
+#CODE_ROOT=../code/evel-library
+LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH)
+#LIBS_DIR=/usr/lib
+INCLUDE_DIR= -I $(CODE_ROOT)/code/evel_library -I .
+
+#******************************************************************************
+# Standard compiler flags. *
+#******************************************************************************
+CPPFLAGS=
+CFLAGS=-Wall -g -fPIC
+FILEOBJLIST= jsmn.o ves_fault_reporter.o
+
+all: ves_fault_reporter
+
+clean:
+ rm -f *.o ves_fault_reporter
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
+
+jsmn.o: jsmn.c jsmn.h
+ves_fault_reporter.o: ves_fault_reporter.c
+
+ves_fault_reporter: $(FILEOBJLIST)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o ves_fault_reporter \
+ -L $(LIBS_DIR) \
+ $(FILEOBJLIST) \
+ -lpthread \
+ -level \
+ -lcurl
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/README.md b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/README.md
new file mode 100644
index 0000000..5a7ea41
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/README.md
@@ -0,0 +1,37 @@
+
+PROJECT DESCRIPTION
+
+---
+This project contains the source code and scripts for the generation of fault events. The folder contains:
+
+ - README.md: this file.
+
+ - LICENSE.TXT: the license text.
+
+ - ves_fault_reporter.c and other .c files: source code that uses the ECOMP Vendor Event Listener Library (VES) to generate the fault events. Fault is generated based on the link status. If number of bytes transmitted/received is less than the low water mark, the fault is generated. The application reads flt_config.json file for parameter values and poppulate the fault event. If eventName, eventSourceType, vfStatus, specificProblem or alarmCondition parameter value is not given, the application terminates. If reportingEntityName and sourceName parameter values are not given, then it gets the hostname and poppulates it. If tmp_faultCheckInterval is not given, it defaults to 60 seconds.
+
+ - Makefile: makefile that compiles ves_fault_reporter.c and generates ves_fault_reporter binary.
+
+ - go-client.sh/go-client_2_collectors.sh: bash script that starts up the ves_fault_reporter. It reads input parameters like DCAE IP address and port from configuration files contained in /opt/config. Based on the collector configuration, use go-client.sh for single collector configuration, or use go-client_2_collectors.sh for 2 collectors configuration.
+
+
+USAGE
+-----
+
+Update the configuration files with proper parameters values so that events generated would contain those values
+
+To run the ves_fault_reporter in single collector configuration, please execute the following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client.sh
+
+ - Run the go-client.sh script
+ ./go-client.sh
+
+For 2 collectors configuration, please execute following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client_2_collectors.sh
+
+ - Run the go-client_2_collectors.sh script
+ ./go-client_2_collectors.sh
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/dep.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/dep.xml
new file mode 100644
index 0000000..fc18229
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/dep.xml
@@ -0,0 +1,25 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>demo</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.sh</include>
+ <include>*.md</include>
+ <include>*.TXT</include>
+ <include>*.c</include>
+ <include>Makefile</include>
+ </includes>
+ </fileSet>
+
+ </fileSets>
+</assembly>
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/flt_config.json b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/flt_config.json
new file mode 100644
index 0000000..72dbe74
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/flt_config.json
@@ -0,0 +1,73 @@
+{
+ "tmp_directParameters": {
+ "eventType": "applicationVnf",
+ "nfcNamingCode": "AFX",
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "timeZoneOffset": "UTC-05:30",
+ "vfStatus": "Idle",
+ "tmp_device": ["lo", "enp0s3", "docker0"]
+
+ },
+ "tmp_indirectParameters": [
+ "tmp_faultInstance01": {
+ "eventName": "Fault_vFirewall-AT&T_linkDownError",
+ "eventCategory": "link",
+ "eventSourceType": "router",
+ "tmp_init":{
+ "tmp_t0BytesIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f2",
+ "tmp_t0BytesOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f10",
+ "tmp_t0PacketsIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f3",
+ "tmp_t0PacketsOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f11"
+ },
+ "alarmInterfaceA": "$tmp_device",
+ "tmp_faultCheckInterval": 20,
+ "tmp_lowWaterMark": 1,
+ "tmp_command": {
+ "tmp_t1BytesIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f2",
+ "tmp_t1BytesOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f10",
+ "tmp_t1PacketsIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f3",
+ "tmp_t1PacketsOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f11"
+ },
+ "tmp_BytesIn": "$(tmp_t1BytesIn - tmp_t0BytesIn)",
+ "tmp_PacketsIn": "$(tmp_t1PacketsIn - tmp_t0PacketsIn)",
+ "tmp_BytesOut": "$(tmp_t1BytesOut - tmp_t0BytesOut)",
+ "tmp_PacketsOut": "$(tmp_t1PacketsOut - tmp_t0PacketsOut)",
+ "tmp_alarmSetParameters": {
+ "specificProblem": "physical or logical connection to a remote router is down",
+ "eventSeverity": "MAJOR",
+ "alarmCondition": "link down trap_alarm"
+ },
+ "tmp_alarmClearParameters": {
+ "specificProblem": "physical or logical connection to a remote router is up",
+ "eventSeverity": "NORMAL",
+ "alarmCondition": "link up trap_alarm"
+ }
+ },
+ "tmp_faultInstance02": {
+ "eventName": "Fault_vFirewall-AT&T_serviceDownError",
+ "alarmInterfaceA": "afx@input.service",
+ "eventCategory": "other",
+ "eventSourceType": "virtualMachine",
+ "tmp_faultCheckInterval": 10,
+ "tmp_command": {
+ "tmp_cmd1": "/bin/systemctl is-active afx@input* |grep -E 'inactive|failed' | wc -l"
+ },
+ "tmp_alarmSetParameters": {
+ "specificProblem": "service is down",
+ "eventSeverity": "MAJOR",
+ "alarmCondition": "service down trap_alarm"
+ },
+ "tmp_alarmClearParameters": {
+ "specificProblem": "service is up",
+ "eventSeverity": "NORMAL",
+ "alarmCondition": "service up trap_alarm"
+ }
+ }
+ ]
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client.sh
new file mode 100755
index 0000000..5a59882
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+./ves_fault_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client_2_collectors.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client_2_collectors.sh
new file mode 100755
index 0000000..09d65f0
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/go-client_2_collectors.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+
+#Usage for 2 collectors:
+#./ves_fault_reporter <FQDN>|<IP address> <port> <FQDN>|<IP address> <port>
+
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+DCAE_COLLECTOR_IP2=$(cat /opt/config/dcae_collector_ip2.txt)
+DCAE_COLLECTOR_PORT2=$(cat /opt/config/dcae_collector_port2.txt)
+./ves_fault_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT $DCAE_COLLECTOR_IP2 $DCAE_COLLECTOR_PORT2
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.c
new file mode 100644
index 0000000..1d72ba4
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.c
@@ -0,0 +1,672 @@
+/*************************************************************************//**
+ *
+ * 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.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ****************************************************************************/
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include "jsmn.h"
+
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+ jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *tok;
+ if (parser->toknext >= num_tokens) {
+ return NULL;
+ }
+ tok = &tokens[parser->toknext++];
+ tok->start = tok->end = -1;
+ tok->size = 0;
+//#ifdef JSMN_PARENT_LINKS
+ tok->parent = -1;
+//#endif
+ return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+ int start, int end) {
+//printf("jsmn_fill_token:: start-%d, end-%d\n", start, end);
+ token->type = type;
+ token->start = start;
+ token->end = end;
+ token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+ int start;
+
+ start = parser->pos;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+//printf("jsmn_parse_primitive:: the char is - %c\n", js[parser->pos]);
+ switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+ /* In strict mode primitive must be followed by "," or "}" or "]" */
+ case ':':
+#endif
+ case '\t' : case '\r' : case '\n' : case ' ' :
+ case ',' : case ']' : case '}' :
+ goto found;
+ }
+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#ifdef JSMN_STRICT
+ /* In strict mode primitive must be followed by a comma/object/array */
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+#endif
+
+found:
+ if (tokens == NULL) {
+ parser->pos--;
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ parser->pos--;
+ return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+
+ int start = parser->pos;
+
+ parser->pos++;
+
+ /* Skip starting quote */
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c = js[parser->pos];
+ char d = js[parser->pos + 1];
+// char e = js[parser->pos + 2];
+//printf("jsmn_parse_string: value-%c, pos-%d\n", c,parser->pos);
+
+ /* Quote: end of string */
+// if (c == '\"') {
+ if (d == '\"') {
+// if ((d == '\"')&&((e == ' ')||(e == ','))) {
+parser->pos++;
+//printf("jsmn_parse_string: end of string\n");
+ if (tokens == NULL) {
+//printf("jsmn_parse_string: end tokens is NULL\n");
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+//printf("jsmn_parse_string: Allocated tokens \n");
+ if (token == NULL) {
+//printf("jsmn_parse_string: Allocated tokens is NULL\n");
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+//printf("jsmn_parse_string: Allocated tokens is filled\n");
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ return 0;
+ }
+
+ /* Backslash: Quoted symbol expected */
+ if (c == '\\' && parser->pos + 1 < len) {
+ int i;
+ parser->pos++;
+//printf("jsmn_parse_string: value - %c, POS-%3d \n",c, js[parser->pos]);
+ switch (js[parser->pos]) {
+ /* Allowed escaped symbols */
+ case '\"': case '/' : case '\\' : case 'b' :
+ case 'f' : case 'r' : case 'n' : case 't' :
+ break;
+ /* Allows escaped symbol \uXXXX */
+ case 'u':
+ parser->pos++;
+ for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+ /* If it isn't a hex character we have an error */
+ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ parser->pos++;
+ }
+ parser->pos--;
+ break;
+ /* Unexpected symbol */
+ default:
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+ }
+ parser->pos = start;
+printf("jsmn_parse_string: exiting with ERROR_PART, pos-%d", parser->pos);
+ return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens) {
+ int r;
+ int i;
+ jsmntok_t *token;
+ int count = parser->toknext;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c;
+ jsmntype_t type;
+
+ c = js[parser->pos];
+//printf("jsmn_parse: value of c - %c\n",c);
+ switch (c) {
+ case '{': case '[':
+ count++;
+ if (tokens == NULL) {
+ break;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL)
+ return JSMN_ERROR_NOMEM;
+ if (parser->toksuper != -1) {
+ tokens[parser->toksuper].size++;
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ }
+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+ token->start = parser->pos;
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case '}': case ']':
+ if (tokens == NULL)
+ break;
+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+//#ifdef JSMN_PARENT_LINKS
+ if (parser->toknext < 1) {
+ return JSMN_ERROR_INVAL;
+ }
+ token = &tokens[parser->toknext - 1];
+ for (;;) {
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ token->end = parser->pos + 1;
+ parser->toksuper = token->parent;
+ break;
+ }
+ if (token->parent == -1) {
+ break;
+ }
+ token = &tokens[token->parent];
+ }
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// if (token->type != type) {
+// return JSMN_ERROR_INVAL;
+// }
+// parser->toksuper = -1;
+// token->end = parser->pos + 1;
+// break;
+// }
+// }
+// /* Error if unmatched closing bracket */
+// if (i == -1) return JSMN_ERROR_INVAL;
+// for (; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+//#endif
+ break;
+ case '\"':
+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+ case '\t' : case '\r' : case '\n' : case ' ':
+ break;
+ case ':':
+ parser->toksuper = parser->toknext - 1;
+//printf("jsmn_parse: value of c is :: - %c\n",c);
+ break;
+ case ',':
+ if (tokens != NULL && parser->toksuper != -1 &&
+ tokens[parser->toksuper].type != JSMN_ARRAY &&
+ tokens[parser->toksuper].type != JSMN_OBJECT) {
+//#ifdef JSMN_PARENT_LINKS
+ parser->toksuper = tokens[parser->toksuper].parent;
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+// if (tokens[i].start != -1 && tokens[i].end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+// }
+//#endif
+ }
+ break;
+#ifdef JSMN_STRICT
+ /* In strict mode primitives are: numbers and booleans */
+ case '-': case '0': case '1' : case '2': case '3' : case '4':
+ case '5': case '6': case '7' : case '8': case '9':
+ case 't': case 'f': case 'n' :
+ /* And they must not be keys of the object */
+ if (tokens != NULL && parser->toksuper != -1) {
+ jsmntok_t *t = &tokens[parser->toksuper];
+ if (t->type == JSMN_OBJECT ||
+ (t->type == JSMN_STRING && t->size != 0)) {
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#else
+ /* In non-strict mode every unquoted value is a primitive */
+ default:
+#endif
+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+
+#ifdef JSMN_STRICT
+ /* Unexpected char in strict mode */
+ default:
+ return JSMN_ERROR_INVAL;
+#endif
+ }
+ }
+
+ if (tokens != NULL) {
+ for (i = parser->toknext - 1; i >= 0; i--) {
+//printf("index -%2d, start is %3d, end is %3d\n", i, tokens[i].start, tokens[i].end);
+ /* Unmatched opened object or array */
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ return JSMN_ERROR_PART;
+ }
+ }
+ }
+
+ return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+void jsmn_init(jsmn_parser *parser) {
+ parser->pos = 0;
+ parser->toknext = 0;
+ parser->toksuper = -1;
+}
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+ if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
+ strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+ return 0;
+ }
+ return -1;
+}
+
+void printToken(char * js, jsmntok_t * tokens, int numToken)
+{
+ for (int i = 1; i < numToken; i++)
+ {
+ printf("Token number-%2d, parent-%2d, type-%d size-%2d, parameter -", i, tokens[i].parent, tokens[i].type, tokens[i].size);
+ if (tokens[i].type == JSMN_STRING || tokens[i].type == JSMN_PRIMITIVE) {
+ printf("%.*s\n", tokens[i].end - tokens[i].start, js + tokens[i].start);
+ } else if (tokens[i].type == JSMN_ARRAY) {
+ printf("[%d elems]\n", tokens[i].size);
+ } else if (tokens[i].type == JSMN_OBJECT) {
+ printf("{%d elems}\n", tokens[i].size);
+ } else {
+ printf("value?? - ");
+ TOKEN_PRINT(tokens[i]);
+ }
+ }
+}
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * gParam,char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], gParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Grand Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 2; //Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ {
+ continue;
+ }
+
+ if(tokens[i+1].type != JSMN_PRIMITIVE)
+ return 3; //Wrong parameter type
+
+// printf("INT parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], val);
+ *value = atoi(val);
+// printf(" - %d\n", *value);
+
+ return 0; //success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+void parseDirectParameters(char * js, jsmntok_t * tokens, int numToken)
+{
+ int i = 0;
+ int dpToken = 0;
+ char param[128];
+ char value[128];
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], "directParameters") == 0)
+ break;
+ }
+
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+
+ for (int i = 1; i < numToken; i++)
+ {
+ memset(param, 0, 128);
+ memset(value, 0, 128);
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ TOKEN_COPY(js, tokens[i], param);
+// printf("parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], value);
+// printf(" - %s\n", value);
+ }
+ }
+}
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_ARRAY)
+ {
+ *numElements = tokens[i+1].size;
+// printf("[%d elems]\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k], arrayValue[k].arrayString);
+// printf(" - %s\n", arrayValue[k].arrayString);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING)
+ {
+ if(jsoneq(js, &tokens[i], param) == 0)
+ {
+ return 0; //Token present
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //Token Not present
+}
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_OBJECT)
+ {
+ *numElements = tokens[i+1].size;
+// printf("{%d elems}\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k*2], keyValueResultList[k].keyStr);
+// printf("Key - %s", keyValueResultList[k].keyStr);
+ TOKEN_COPY(js, tokens[i+3+k*2], keyValueResultList[k].valStr);
+// printf("Value - %s\n", keyValueResultList[k].valStr);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.h b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.h
new file mode 100644
index 0000000..f9d838b
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/jsmn.h
@@ -0,0 +1,136 @@
+/*************************************************************************//**
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __JSMN_H_
+#define __JSMN_H_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * o Object
+ * o Array
+ * o String
+ * o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+ JSMN_UNDEFINED = 0,
+ JSMN_OBJECT = 1,
+ JSMN_ARRAY = 2,
+ JSMN_STRING = 3,
+ JSMN_PRIMITIVE = 4
+} jsmntype_t;
+
+enum jsmnerr {
+ /* Not enough tokens were provided */
+ JSMN_ERROR_NOMEM = -1,
+ /* Invalid character inside JSON string */
+ JSMN_ERROR_INVAL = -2,
+ /* The string is not a full JSON packet, more bytes expected */
+ JSMN_ERROR_PART = -3
+};
+
+typedef struct arrayValues {
+ char arrayString[32];
+} ARRAYVAL;
+
+typedef struct keyValResult {
+ char keyStr[80];
+ char valStr[250];
+ char resultStr[80];
+} KEYVALRESULT;
+
+/**
+ * JSON token description.
+ * @param type type (object, array, string etc.)
+ * @param start start position in JSON data string
+ * @param end end position in JSON data string
+ */
+typedef struct {
+ jsmntype_t type;
+ int start;
+ int end;
+ int size;
+//#ifdef JSMN_PARENT_LINKS
+ int parent;
+//#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string
+ */
+typedef struct {
+ unsigned int pos; /* offset in the JSON string */
+ unsigned int toknext; /* next token to allocate */
+ int toksuper; /* superior token node, e.g parent object or array */
+} jsmn_parser;
+
+#define TOKEN_EQ(t, tok_start, tok_end, tok_type) \
+ ((t).start == tok_start \
+ && (t).end == tok_end \
+ && (t).type == (tok_type))
+
+#define TOKEN_STRING(js, t, s) \
+ (strncmp(js+(t).start, s, (t).end - (t).start) == 0 \
+ && strlen(s) == (t).end - (t).start)
+
+#define TOKEN_COPY(js, t, s) \
+ strncpy(s, js+(t).start, (t).end - (t).start)
+
+#define TOKEN_PRINT(t) \
+ printf("start: %d, end: %d, type: %d, size: %d\n", \
+ (t).start, (t).end, (t).type, (t).size)
+
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
+ * a single JSON object.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens);
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
+
+void printToken(char * js, jsmntok_t * tokens, int numToken);
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize);
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value);
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements);
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam);
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements);
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char *gParam, char * value, int maxValueSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __JSMN_H_ */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/pom.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/pom.xml
new file mode 100644
index 0000000..f9f42eb
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START==========================================
+ ===================================================================
+ 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.
+ ============LICENSE_END============================================
+
+ ECOMP and OpenECOMP are trademarks
+ and service marks of AT&T Intellectual Property.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+<parent>
+ <groupId>org.onap.demo.vnf</groupId>
+ <artifactId>demo-aggregator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.demo.vnf.ves5</groupId>
+ <artifactId>ves_vfw_reporting</artifactId>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>never</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <descriptor>dep.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-archive</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/sample_fault_events.txt b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/sample_fault_events.txt
new file mode 100644
index 0000000..b937271
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/sample_fault_events.txt
@@ -0,0 +1,140 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "fault",
+ "eventId": "fault000000001",
+ "eventName": "Fault_vFirewall-AT&T_serviceDownError",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1547036995590759,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 1,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1547036995590759,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.1",
+ "vesEventListenerVersion": "7.1"
+ },
+ "faultFields": {
+ "alarmCondition": "service down trap_alarm",
+ "alarmInterfaceA": "afx@input.service",
+ "eventCategory": "other",
+ "eventSeverity": "MAJOR",
+ "eventSourceType": "virtualMachine",
+ "faultFieldsVersion": "4.0",
+ "specificProblem": "service is down",
+ "vfStatus": "Idle"
+ }
+ }
+}
+
+===============================================
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "fault",
+ "eventId": "fault000000001",
+ "eventName": "Fault_vFirewall-AT&T_serviceDownError",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1547037005665702,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 0,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1547036995590759,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.0.2",
+ "vesEventListenerVersion": "7.0.2"
+ },
+ "faultFields": {
+ "alarmCondition": "service up trap_alarm",
+ "alarmInterfaceA": "afx@input.service",
+ "eventCategory": "other",
+ "eventSeverity": "NORMAL",
+ "eventSourceType": "virtualMachine",
+ "faultFieldsVersion": "4.0",
+ "specificProblem": "service is up",
+ "vfStatus": "Idle"
+ }
+ }
+}
+===============================================================
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "fault",
+ "eventId": "fault000000001",
+ "eventName": "Fault_vFirewall-AT&T_linkDownError",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1547037007342515,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 1,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1547037007342515,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.0.2",
+ "vesEventListenerVersion": "7.0.2"
+ },
+ "faultFields": {
+ "alarmCondition": "link down trap_alarm",
+ "alarmInterfaceA": "enps03",
+ "eventCategory": "link",
+ "eventSeverity": "MAJOR",
+ "eventSourceType": "router",
+ "faultFieldsVersion": "4.0",
+ "specificProblem": "physical or logical connection to a remote router is down",
+ "vfStatus": "Idle"
+ }
+ }
+}
+==================================================================
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "fault",
+ "eventId": "fault000000001",
+ "eventName": "Fault_vFirewall-AT&T_linkDownError",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1547037028498530,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 0,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1547037007722752,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.0.2",
+ "vesEventListenerVersion": "7.0.2"
+ },
+ "faultFields": {
+ "alarmCondition": "link up trap_alarm",
+ "alarmInterfaceA": "enps03",
+ "eventCategory": "link",
+ "eventSeverity": "NORMAL",
+ "eventSourceType": "router",
+ "faultFieldsVersion": "4.0",
+ "specificProblem": "physical or logical connection to a remote router is up",
+ "vfStatus": "Idle"
+ }
+ }
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/ves_fault_reporter.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/ves_fault_reporter.c
new file mode 100644
index 0000000..3b0c600
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault/ves_fault_reporter.c
@@ -0,0 +1,1352 @@
+/*************************************************************************//**
+ *
+ * Copyright © 2019 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.
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include "jsmn.h"
+#include "evel.h"
+
+#define BUFSIZE 128
+#define MAX_BUFFER_SIZE 4096
+#define MAX_TOKENS 1000
+#define MAX_INTERFACES 40
+
+void *FaultThread(void *threadarg);
+void *FaultThread01(void *threadarg);
+void *FaultThread02(void *threadarg);
+void *FaultThread03(void *threadarg);
+
+typedef struct dummy_vpp_metrics_struct {
+ int curr_bytes_in;
+ int curr_bytes_out;
+ int curr_packets_in;
+ int curr_packets_out;
+ int last_bytes_in;
+ int last_bytes_out;
+ int last_packets_in;
+ int last_packets_out;
+} vpp_metrics_struct;
+
+typedef struct linkstat {
+
+ char linkname[32];
+ char linkdescr[64];
+ char linkmode[64];
+ int speedmbps;
+ int fault_raised;
+ unsigned long long last_epoch;
+
+}LINKSTAT;
+
+//vpp_metrics_struct meas_intfstat[MAX_INTERFACES];
+//LINKSTAT meas_linkstat[MAX_INTERFACES];
+//int request_rate=0;
+vpp_metrics_struct fault_intfstat[MAX_INTERFACES];
+LINKSTAT fault_linkstat[MAX_INTERFACES];
+
+unsigned long long epoch_start = 0;
+
+int format_val_params(KEYVALRESULT * keyValArray, int numElements, const char *replace, const char *search)
+{
+ char *sp;
+ int i =0;
+ int search_len;
+ int replace_len;
+ int tail_len;
+
+ for (i=0; i<numElements; i++)
+ {
+ if ((sp = strstr(keyValArray[i].valStr, search)) == NULL) {
+ printf("\n String not found\n");
+ return 1; //Error search string not found
+ }
+
+ search_len = strlen(search);
+ replace_len = strlen(replace);
+ tail_len = strlen(sp+search_len);
+ memmove(sp+replace_len,sp+search_len,tail_len+1);
+ memcpy(sp, replace, replace_len);
+// printf("\n Changed value for i=%d is %s", i, keyValArray[i].valStr);
+ }
+ return 0; //search and replace is successful
+}
+
+void runCommands(KEYVALRESULT * commandArray, int numCommands)
+{
+
+ char buf[BUFSIZE]; /* buffer used to store VPP metrics */
+ FILE *fp; /* file descriptor to pipe cmd to shell */
+ int i;
+
+ for(i = 0; i < numCommands; i++)
+ {
+ memset(buf, 0, BUFSIZE);
+
+ // Open a pipe and read VPP values
+ if ((fp = popen(commandArray[i].valStr, "r")) == NULL) {
+ printf("Error opening pipe!\n");
+ return;
+ }
+
+ while (fgets(buf, BUFSIZE, fp) != NULL);
+ // printf("\n the vpp value is %d\n", atoi(buf));
+ strcpy(commandArray[i].resultStr, buf);
+
+ if(pclose(fp)) {
+ printf("Command not found or exited with error status\n");
+ return;
+ }
+ }
+ //for(i = 0; i < numCommands; i++)
+ // printf("\n commandArray[%d].resultStr is- %s\n", i, commandArray[i].resultStr);
+}
+
+
+void copy_vpp_metic_data(vpp_metrics_struct *intfstats, KEYVALRESULT * cmdArray, int numCmds, int linkNum)
+{
+ int i;
+
+ // Store the current metric in the last metric
+ intfstats[linkNum].last_bytes_in = intfstats[linkNum].curr_bytes_in;
+ intfstats[linkNum].last_bytes_out = intfstats[linkNum].curr_bytes_out;
+ intfstats[linkNum].last_packets_in = intfstats[linkNum].curr_packets_in;
+ intfstats[linkNum].last_packets_out = intfstats[linkNum].curr_packets_out;
+
+ // Store metrics read from the vNIC in the current
+ for(i=0; i<numCmds; i++)
+ {
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0BytesIn") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1BytesIn") == 0))
+ intfstats[linkNum].curr_bytes_in = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0BytesOut") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1BytesOut") == 0))
+ intfstats[linkNum].curr_bytes_out = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0PacketsIn") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1PacketsIn") == 0))
+ intfstats[linkNum].curr_packets_in = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0PacketsOut") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1PacketsOut") == 0))
+ intfstats[linkNum].curr_packets_out = atoi(cmdArray[i].resultStr);
+ }
+ // printf("intfstats[%d].curr_bytes_in = %d\n", linkNum, intfstats[linkNum].curr_bytes_in);
+ // printf("intfstats[%d].curr_bytes_out = %d\n", linkNum, intfstats[linkNum].curr_bytes_out);
+ // printf("intfstats[%d].curr_packets_in = %d\n", linkNum, intfstats[linkNum].curr_packets_in);
+ // printf("intfstats[%d].curr_packets_out = %d\n", linkNum, intfstats[linkNum].curr_packets_out);
+}
+
+int get_severity(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "CRITICAL") == 0)
+ result = EVEL_SEVERITY_CRITICAL;
+ else if(strcmp(inStr, "MAJOR") == 0)
+ result = EVEL_SEVERITY_MAJOR;
+ else if(strcmp(inStr, "MINOR") == 0)
+ result = EVEL_SEVERITY_MINOR;
+ else if(strcmp(inStr, "WARNING") == 0)
+ result = EVEL_SEVERITY_WARNING;
+ else if(strcmp(inStr, "NORMAL") == 0)
+ result = EVEL_SEVERITY_NORMAL;
+
+ return result;
+}
+
+int get_priority(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "High") == 0)
+ result = EVEL_PRIORITY_HIGH;
+ else if(strcmp(inStr, "Medium") == 0)
+ result = EVEL_PRIORITY_MEDIUM;
+ else if(strcmp(inStr, "Normal") == 0)
+ result = EVEL_PRIORITY_NORMAL;
+ else if(strcmp(inStr, "Low") == 0)
+ result = EVEL_PRIORITY_LOW;
+
+ return result;
+}
+
+int get_source(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "other") == 0)
+ result = EVEL_SOURCE_OTHER;
+ else if(strcmp(inStr, "router") == 0)
+ result = EVEL_SOURCE_ROUTER;
+ else if(strcmp(inStr, "switch") == 0)
+ result = EVEL_SOURCE_SWITCH;
+ else if(strcmp(inStr, "host") == 0)
+ result = EVEL_SOURCE_HOST;
+ else if(strcmp(inStr, "card") == 0)
+ result = EVEL_SOURCE_CARD;
+ else if(strcmp(inStr, "port") == 0)
+ result = EVEL_SOURCE_PORT;
+ else if(strcmp(inStr, "slotThreshold") == 0)
+ result = EVEL_SOURCE_SLOT_THRESHOLD;
+ else if(strcmp(inStr, "portThreshold") == 0)
+ result = EVEL_SOURCE_PORT_THRESHOLD;
+ else if(strcmp(inStr, "virtualMachine") == 0)
+ result = EVEL_SOURCE_VIRTUAL_MACHINE;
+ else if(strcmp(inStr, "virtualNetworkFunction") == 0)
+ result = EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION;
+
+ return result;
+}
+
+int get_vf_status(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "Active") == 0)
+ result = EVEL_VF_STATUS_ACTIVE;
+ else if(strcmp(inStr, "Idle") == 0)
+ result = EVEL_VF_STATUS_IDLE;
+ else if(strcmp(inStr, "Preparing to terminate") == 0)
+ result = EVEL_VF_STATUS_PREP_TERMINATE;
+ else if(strcmp(inStr, "Ready to terminate") == 0)
+ result = EVEL_VF_STATUS_READY_TERMINATE;
+ else if(strcmp(inStr, "Requesting termination") == 0)
+ result = EVEL_VF_STATUS_REQ_TERMINATE;
+
+ return result;
+}
+
+int main(int argc, char** argv)
+{
+ char* fqdn = argv[1];
+ int port = atoi(argv[2]);
+ int i=0;
+ int rc;
+ pthread_attr_t attr;
+ pthread_t flt_thread;
+ char* fqdn2 = NULL;
+ int port2 = 0;
+
+ if(argc == 5)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ }
+
+ if (!((argc == 3) || (argc == 5)))
+ {
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> \n", argv[0]);
+ fprintf(stderr, "OR\n");
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> \n", argv[0]);
+ exit(-1);
+ }
+
+ /**************************************************************************/
+ /* Initialize */
+ /**************************************************************************/
+ if(evel_initialize(fqdn, /* FQDN */
+ port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 0, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ NULL, /* ca info */
+ NULL, /* ca file */
+ 0, /* verify peer */
+ 0, /* verify host */
+ "sample1", /* Username */
+ "sample1", /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
+ NULL, /* Source ip */
+ NULL, /* Source ip2 */
+ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
+ "vFault", /* Role */
+ 1)) /* Verbosity */
+ {
+ fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
+ exit(-1);
+ }
+ else
+ {
+ printf("\nInitialization completed\n");
+ }
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ printf("Main:Creating thread \n");
+ rc = pthread_create(&flt_thread, NULL, FaultThread, &i);
+ if (rc)
+ {
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ printf("Main:Created Fault thread \n");
+
+ pthread_join(flt_thread, NULL);
+
+ evel_terminate();
+ printf("Terminated\n");
+ return 0;
+}
+
+void *FaultThread(void *mainFault)
+{
+
+ pthread_attr_t attr;
+ pthread_t flt_thread01;
+ pthread_t flt_thread02;
+ pthread_t flt_thread03;
+ int faultInstance01 = 0;
+ int faultInstance02 = 0;
+ int faultInstance03 = 0;
+ int rc;
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+
+ sleep(1);
+ printf("Running Main Fault thread \n");
+ fflush(stdout);
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ FILE * file = fopen("flt_config.json", "r");
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+ //printf("MainFaulThread::the file content is \n %s \n", js);
+ //printf("\n MainFaulThread::MMMMMMMMMMMMMMM\n");
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+ //printf("count-%d\n", numToken);
+
+ //printToken(js,tokens, numToken);
+
+ printf("Main Fault Thread: Creating other fault threads\n");
+
+ ret = isTokenPresent(js, tokens, numToken, "tmp_faultInstance01", "tmp_indirectParameters");
+ if (ret == 0)
+ {
+// rc = pthread_create(&flt_thread01, NULL, FaultThread01, "tmp_faultInstance01");
+ rc = pthread_create(&flt_thread01, NULL, FaultThread01, &ret);
+ if (rc)
+ {
+ printf("Main Fault Thread::ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ faultInstance01 = 1;
+ }
+
+ ret = isTokenPresent(js, tokens, numToken, "tmp_faultInstance02", "tmp_indirectParameters");
+ if (ret == 0)
+ {
+// rc = pthread_create(&flt_thread02, NULL, FaultThread02, "tmp_faultInstance02");
+ rc = pthread_create(&flt_thread02, NULL, FaultThread02, &ret);
+ if (rc)
+ {
+ printf("Main Fault Thread::ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ faultInstance02 = 1;
+ }
+
+ ret = isTokenPresent(js, tokens, numToken, "tmp_faultInstance03", "tmp_indirectParameters");
+ if (ret == 0)
+ {
+ rc = pthread_create(&flt_thread03, NULL, FaultThread03, &ret);
+ if (rc)
+ {
+ printf("Main Fault Thread::ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ faultInstance03 = 1;
+ }
+
+ if (faultInstance01 == 1)
+ {
+ pthread_join(flt_thread01, NULL);
+ }
+
+ if (faultInstance02 == 1)
+ {
+ pthread_join(flt_thread02, NULL);
+ }
+
+ if (faultInstance03 == 1)
+ {
+ pthread_join(flt_thread03, NULL);
+ }
+
+ while(1)
+ {
+ sleep(100);
+ }
+}
+
+void *FaultThread01(void *faultInstanceTag)
+{
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ EVENT_FAULT * fault = NULL;
+ EVENT_HEADER* fault_header = NULL;
+ int bytes_in;
+ int bytes_out;
+ int packets_in;
+ int packets_out;
+ unsigned long long epoch_now;
+ int lowWaterMark;
+
+ struct timeval time_val;
+ char event_id1[10] = "fault";
+ char event_id2[15] = {0};
+ char event_id[BUFSIZE] = {0};
+ int fault_event_id = 0;
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+ char eName[BUFSIZE];
+ char eType[BUFSIZE];
+ char nfcCode[BUFSIZE];
+ char nfCode[BUFSIZE];
+ char nfVendor[BUFSIZE];
+ char prio[BUFSIZE];
+ char reportEId[BUFSIZE];
+ char reportEName[BUFSIZE];
+ char srcId[BUFSIZE];
+ char srcName[BUFSIZE];
+ char timeZOff[BUFSIZE];
+ char eCategory[BUFSIZE];
+ char eventSrcTyp[BUFSIZE];
+ char specProb[BUFSIZE];
+ char alarmCondn[BUFSIZE];
+ char eventSev[BUFSIZE];
+ char vfStatus[BUFSIZE];
+
+ int priority;
+ int srcTyp;
+ int vfStat;
+ int eSev;
+
+ char hostname[BUFSIZE];
+
+ int flt_interval;
+ ARRAYVAL intfArray[MAX_INTERFACES];
+ KEYVALRESULT keyValResultArray[32];
+ KEYVALRESULT commandArray[32];
+ int numInitCommands = 0;
+ int numCommands = 0;
+ int linkCount = 0;
+ int i = 0;
+
+ memset(hostname, 0, BUFSIZE);
+ gethostname(hostname, BUFSIZE);
+ printf("FAULT01::The hostname is %s\n", hostname);
+
+ sleep(1);
+ printf("FAULT01::Running Fault thread \n");
+ fflush(stdout);
+
+ memset(&intfArray[0],0,(sizeof(ARRAYVAL) * MAX_INTERFACES));
+ memset(&keyValResultArray[0],0,(sizeof(KEYVALRESULT) * 32));
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+ memset(&fault_intfstat[0],0,(sizeof(vpp_metrics_struct)* MAX_INTERFACES));
+ memset(&fault_linkstat[0],0,(sizeof(LINKSTAT) * MAX_INTERFACES));
+
+ FILE * file = fopen("flt_config.json", "r");
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+// printf("FAULT01::the file content is \n %s \n", js);
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+ printf("FAULT01::count-%d\n", numToken);
+
+// printToken(js,tokens, numToken);
+
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance01", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+ ret = getIntToken(js, tokens, numToken, "tmp_lowWaterMark", "tmp_faultInstance01", &lowWaterMark);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_lowWaterMark is not defined, defaulted to 100\n");
+ lowWaterMark = 100;
+ }
+
+ ret = getArrayTokens(js, tokens, numToken, "tmp_device", "tmp_directParameters", intfArray, &linkCount);
+
+ printf("FAULT01::Array link count is %d\n", linkCount);
+
+ /* Copy the link information */
+ for(i=0;i<linkCount;i++)
+ {
+ strcpy(fault_linkstat[i].linkname, &intfArray[i]);
+// printf("FAULT01::Link name %s\n", fault_linkstat[i].linkname);
+ }
+
+ //read_fault_config_file();
+
+ read_keyVal_params(js, tokens, numToken, "tmp_init", "tmp_faultInstance01", keyValResultArray, &numInitCommands);
+
+ for(i=0;i<linkCount;i++)
+ {
+ memset(&commandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(commandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ format_val_params(commandArray, numInitCommands, fault_linkstat[i].linkname, "$tmp_device");
+ runCommands(commandArray, numInitCommands);
+ copy_vpp_metic_data(fault_intfstat, commandArray, numInitCommands, i);
+ }
+
+ gettimeofday(&time_val, NULL);
+
+ sleep(flt_interval);
+
+ /***************************************************************************/
+ /* Collect metrics from the VNIC */
+ /***************************************************************************/
+ while(1)
+ {
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance01", &flt_interval);
+ if (ret != 0)
+ {
+ flt_interval = 60;
+ }
+
+ ret = getIntToken(js, tokens, numToken, "tmp_lowWaterMark", "tmp_faultInstance01", &lowWaterMark);
+ if (ret != 0)
+ {
+ lowWaterMark = 100;
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventName", "tmp_faultInstance01", eName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - eventName is not there in tmp_faultInstance01. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventType", "tmp_directParameters", eType, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfcNamingCode", "tmp_directParameters", nfcCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfNamingCode", "tmp_directParameters", nfCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfVendorName", "tmp_directParameters", nfVendor, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "reportingEntityId", "tmp_directParameters", reportEId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "sourceId", "tmp_directParameters", srcId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "timeZoneOffset", "tmp_directParameters", timeZOff, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "eventCategory", "tmp_faultInstance01", eCategory, BUFSIZE);
+
+ ret = getStringToken(js, tokens, numToken, "eventSourceType", "tmp_faultInstance01", eventSrcTyp, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - eventSourceType is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+ srcTyp = get_source(eventSrcTyp);
+ if(srcTyp == -1)
+ {
+ printf("FAULT01::Fault eventSourceType value is not matching, eventSourceType-%s \n", eventSrcTyp);
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "vfStatus", "tmp_directParameters", vfStatus, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - vfStatus is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+ vfStat = get_vf_status(vfStatus);
+ if(vfStat == -1)
+ {
+ printf("FAULT01::Fault vfStatus value is not matching, vfStatus-%s \n", vfStatus);
+ exit(1);
+ }
+
+ read_keyVal_params(js, tokens, numToken, "tmp_command", "tmp_faultInstance01", keyValResultArray, &numCommands);
+
+ for(i=0;i<linkCount;i++)
+ {
+ memset(&commandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(commandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ format_val_params(commandArray, numCommands, fault_linkstat[i].linkname, "$tmp_device");
+ runCommands(commandArray, numCommands);
+ copy_vpp_metic_data(fault_intfstat, commandArray, numInitCommands, i);
+ }
+
+ for (int i = 0; i < linkCount; i++)
+ {
+ if(fault_intfstat[i].curr_bytes_in - fault_intfstat[i].last_bytes_in > 0) {
+ bytes_in = fault_intfstat[i].curr_bytes_in - fault_intfstat[i].last_bytes_in;
+ }
+ else {
+ bytes_in = 0;
+ }
+ if(fault_intfstat[i].curr_bytes_out - fault_intfstat[i].last_bytes_out > 0) {
+ bytes_out = fault_intfstat[i].curr_bytes_out - fault_intfstat[i].last_bytes_out;
+ }
+ else {
+ bytes_out = 0;
+ }
+ if(fault_intfstat[i].curr_packets_in - fault_intfstat[i].last_packets_in > 0) {
+ packets_in = fault_intfstat[i].curr_packets_in - fault_intfstat[i].last_packets_in;
+ }
+ else {
+ packets_in = 0;
+ }
+ if(fault_intfstat[i].curr_packets_out - fault_intfstat[i].last_packets_out > 0) {
+ packets_out = fault_intfstat[i].curr_packets_out - fault_intfstat[i].last_packets_out;
+ }
+ else {
+ packets_out = 0;
+ }
+ if (((bytes_in < lowWaterMark) || (bytes_out < lowWaterMark) ||
+ (packets_in < lowWaterMark) || (packets_out < lowWaterMark)) &&
+ (fault_linkstat[i].fault_raised == 0))
+ {
+ printf("\n%d - bytes in %d, ouot %d, packets in %d, out %d", i, bytes_in, bytes_out, packets_in, packets_out);
+ printf("\nFAULT01::Raising fault\n");
+ memset(event_id, 0, BUFSIZE);
+ fault_event_id = fault_event_id+1;
+ sprintf(event_id2, "%09d", fault_event_id);
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance01", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+ ret = getIntToken(js, tokens, numToken, "tmp_lowWaterMark", "tmp_faultInstance01", &lowWaterMark);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_lowWaterMark is not defined, defaulted to 100\n");
+ lowWaterMark = 100;
+ }
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", reportEName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("FAULT01::Defaulting reportingEntityName to hostname\n");
+ strcpy(reportEName, hostname);
+ }
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", srcName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("FAULT01::Defaulting sourceName to hostname\n");
+ strcpy(srcName, hostname);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "priority", "tmp_directParameters", prio, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - priority is not there in tmp_directParameters\nDefaulting priority to Low\n");
+ strcpy(prio, "Medium");
+ }
+ priority = get_priority(prio);
+ if(priority == -1)
+ {
+ printf("FAULT01::Fault priority value is not matching, prioirty-%s \n", prio);
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "specificProblem", "tmp_alarmSetParameters", "tmp_faultInstance01", specProb, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - specificProblem is not there in tmp_alarmSetParameters, exiting ...\n");
+ exit(1);
+ }
+ ret = getStringTokenV2(js, tokens, numToken, "alarmCondition", "tmp_alarmSetParameters", "tmp_faultInstance01", alarmCondn, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - alarmCondition is not there in tmp_alarmSetParameters, exiting ...\n");
+ exit(1);
+ }
+ ret = getStringTokenV2(js, tokens, numToken, "eventSeverity", "tmp_alarmSetParameters", "tmp_faultInstance01", eventSev, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - eventSeverity is not there in tmp_alarmSetParameters\n");
+ printf("FAULT01::Defaulting eventSeverity to MAJOR\n");
+ strcpy(eventSev, "MAJOR");
+ }
+ eSev = get_severity(eventSev);
+ if(eSev == -1)
+ {
+ printf("FAULT01::Fault eventSeverity value is not matching, eventSeverity-%s \n", eventSev);
+ exit(1);
+ }
+
+ fault = evel_new_fault(eName, event_id, alarmCondn,
+ specProb, priority, eSev, srcTyp,vfStat);
+ if (fault != NULL)
+ {
+ fault_linkstat[i].fault_raised = 1;
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+ fault_linkstat[i].last_epoch = epoch_now;
+
+ fault_header = (EVENT_HEADER *)fault;
+
+ evel_fault_category_set(fault, eCategory);
+ evel_fault_interface_set(fault, fault_linkstat[i].linkname);
+
+ if (eType != NULL)
+ evel_fault_type_set(fault, eType);
+
+ evel_start_epoch_set(&fault->header, epoch_now);
+ evel_last_epoch_set(&fault->header, epoch_now);
+ if(nfcCode != NULL)
+ evel_nfcnamingcode_set(&fault->header, nfcCode);
+ if(nfCode != NULL)
+ evel_nfnamingcode_set(&fault->header, nfCode);
+ evel_reporting_entity_name_set(&fault->header, reportEName);
+ if(reportEId != NULL)
+ evel_reporting_entity_id_set(&fault->header, reportEId);
+ if(timeZOff != NULL)
+ evel_time_zone_offset_set(&fault->header, timeZOff);
+ if(nfVendor != NULL)
+ evel_nf_vendor_name_set(&fault->header, nfVendor);
+ if(srcId != NULL )
+ evel_source_id_set(&fault->header, srcId);
+ if(srcName!= NULL )
+ evel_source_name_set(&fault->header, srcName);
+
+ evel_rc = evel_post_event(fault_header);
+
+ if(evel_rc == EVEL_SUCCESS)
+ printf("FAULT01::Fault event is correctly sent to the collector!\n");
+ else
+ printf("FAULT01::Post failed %d (%s)\n", evel_rc, evel_error_string());
+ }
+ else
+ {
+ printf("FAULT01::New new fault failed (%s)\n", evel_error_string());
+ }
+ }
+ else if (((bytes_in > lowWaterMark) && (bytes_out > lowWaterMark) &&
+ (packets_in > lowWaterMark) && (packets_out > lowWaterMark)) &&
+ (fault_linkstat[i].fault_raised == 1))
+ {
+ printf("\nFAULT01:: Clearing fault\n");
+ memset(event_id, 0, BUFSIZE);
+ sprintf(event_id2, "%09d", (i+1));
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance01", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+ ret = getIntToken(js, tokens, numToken, "tmp_lowWaterMark", "tmp_faultInstance01", &lowWaterMark);
+ if (ret != 0)
+ {
+ printf("FAULT01::The parameter tmp_lowWaterMark is not defined, defaulted to 100\n");
+ lowWaterMark = 100;
+ }
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", reportEName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("FAULT01::Defaulting reportingEntityName to hostname\n");
+ strcpy(reportEName, hostname);
+ }
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", srcName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("FAULT01::Defaulting sourceName to hostname\n");
+ strcpy(srcName, hostname);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "priority", "tmp_directParameters", prio, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - priority is not there in tmp_directParameters\nDefaulting priority to Low\n");
+ strcpy(prio, "Medium");
+ }
+ priority = get_priority(prio);
+ if(priority == -1)
+ {
+ printf("FAULT01::Fault priority value is not matching, prioirty-%s \n", prio);
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "specificProblem", "tmp_alarmClearParameters", "tmp_faultInstance01", specProb, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - specificProblem is not there in tmp_alarmClearParameters, exiting ...\n");
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "alarmCondition", "tmp_alarmClearParameters", "tmp_faultInstance01", alarmCondn, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - alarmCondition is not there in tmp_alarmClearParameters, exiting ...\n");
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "eventSeverity", "tmp_alarmClearParameters", "tmp_faultInstance01", eventSev, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT01::Missing mandatory parameters - eventSeverity is not there in tmp_alarmClearParameters\n");
+ printf("FAULT01::Defaulting eventSeverity to MAJOR\n");
+ strcpy(eventSev, "NORMAL");
+ }
+ eSev = get_severity(eventSev);
+ if(eSev == -1)
+ {
+ printf("FAULT01::Fault eventSeverity value is not matching, eventSeverity-%s \n", eventSev);
+ exit(1);
+ }
+
+ fault = evel_new_fault(eName, event_id, alarmCondn,
+ specProb, priority, eSev, srcTyp,vfStat);
+ if (fault != NULL)
+ {
+ fault_linkstat[i].fault_raised = 0;
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+
+ fault_header = (EVENT_HEADER *)fault;
+ evel_fault_category_set(fault, eCategory);
+ evel_fault_interface_set(fault, fault_linkstat[i].linkname);
+
+ if (eType != NULL)
+ evel_fault_type_set(fault, eType);
+
+ evel_start_epoch_set(&fault->header, fault_linkstat[i].last_epoch);
+ evel_last_epoch_set(&fault->header, epoch_now);
+ fault_linkstat[i].last_epoch = 0;
+
+ if(nfcCode != NULL)
+ evel_nfcnamingcode_set(&fault->header, nfcCode);
+ if(nfCode != NULL)
+ evel_nfnamingcode_set(&fault->header, nfCode);
+ evel_reporting_entity_name_set(&fault->header, reportEName);
+ if(reportEId != NULL)
+ evel_reporting_entity_id_set(&fault->header, reportEId);
+ if(timeZOff != NULL)
+ evel_time_zone_offset_set(&fault->header, timeZOff);
+ if(nfVendor != NULL)
+ evel_nf_vendor_name_set(&fault->header, nfVendor);
+ if(srcId != NULL )
+ evel_source_id_set(&fault->header, srcId);
+ if(srcName!= NULL )
+ evel_source_name_set(&fault->header, srcName);
+
+ evel_rc = evel_post_event(fault_header);
+
+ if(evel_rc == EVEL_SUCCESS)
+ printf("FAULT01::Fault event is correctly sent to the collector!\n");
+ else
+ printf("FAULT01::Post failed %d (%s)\n", evel_rc, evel_error_string());
+ }
+ else
+ printf("FAULT01::New fault failed (%s)\n", evel_error_string());
+ }
+ }
+
+ sleep(flt_interval);
+ }
+
+ /***************************************************************************/
+ /* Terminate */
+ /***************************************************************************/
+ sleep(1);
+}
+
+void *FaultThread02(void *faultInstanceTag)
+{
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ EVENT_FAULT * fault = NULL;
+ EVENT_HEADER* fault_header = NULL;
+ unsigned long long epoch_now;
+ unsigned long long last_epoch;
+
+ struct timeval time_val;
+ char event_id1[10] = "fault";
+ char event_id2[15] = {0};
+ char event_id[BUFSIZE] = {0};
+ int fault_event_id = 0;
+ int i=0;
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+ char eName[BUFSIZE];
+ char eType[BUFSIZE];
+ char aInterface[BUFSIZE];
+ char nfcCode[BUFSIZE];
+ char nfCode[BUFSIZE];
+ char nfVendor[BUFSIZE];
+ char prio[BUFSIZE];
+ char reportEId[BUFSIZE];
+ char reportEName[BUFSIZE];
+ char srcId[BUFSIZE];
+ char srcName[BUFSIZE];
+ char timeZOff[BUFSIZE];
+ char eCategory[BUFSIZE];
+ char eventSrcTyp[BUFSIZE];
+ char specProb[BUFSIZE];
+ char alarmCondn[BUFSIZE];
+ char eventSev[BUFSIZE];
+ char vfStatus[BUFSIZE];
+
+ int priority;
+ int srcTyp;
+ int vfStat;
+ int eSev;
+
+ char hostname[BUFSIZE];
+
+ int flt_interval;
+ KEYVALRESULT keyValResultArray[32];
+ KEYVALRESULT commandArray[32];
+ int numInitCommands = 0;
+ int numCommands = 0;
+ int fault_raised = 0;
+
+ memset(hostname, 0, BUFSIZE);
+ gethostname(hostname, BUFSIZE);
+ printf("FAULT02::The hostname is %s\n", hostname);
+
+ sleep(1);
+ printf("FAULT02::Running Fault thread \n");
+ fflush(stdout);
+
+ memset(&keyValResultArray[0],0,(sizeof(KEYVALRESULT) * 32));
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+
+ FILE * file = fopen("flt_config.json", "r");
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+// printf("FAULT02::the file content is \n %s \n", js);
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+ printf("FAULT02::count-%d\n", numToken);
+
+// printToken(js,tokens, numToken);
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance02", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT02::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+
+ read_keyVal_params(js, tokens, numToken, "tmp_init", "tmp_faultInstance02", keyValResultArray, &numInitCommands);
+
+ memset(&commandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(commandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ runCommands(commandArray, numInitCommands);
+
+ gettimeofday(&time_val, NULL);
+
+ sleep(flt_interval);
+
+ /***************************************************************************/
+ /* Collect metrics from the VNIC */
+ /***************************************************************************/
+ while(1) {
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance02", &flt_interval);
+ if (ret != 0)
+ {
+ flt_interval = 60;
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventName", "tmp_faultInstance02", eName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - eventName is not there in tmp_faultInstance02. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventType", "tmp_directParameters", eType, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfcNamingCode", "tmp_directParameters", nfcCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfNamingCode", "tmp_directParameters", nfCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfVendorName", "tmp_directParameters", nfVendor, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "reportingEntityId", "tmp_directParameters", reportEId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "sourceId", "tmp_directParameters", srcId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "timeZoneOffset", "tmp_directParameters", timeZOff, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "eventCategory", "tmp_faultInstance02", eCategory, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "alarmInterfaceA", "tmp_faultInstance02", aInterface, BUFSIZE);
+
+ ret = getStringToken(js, tokens, numToken, "eventSourceType", "tmp_faultInstance02", eventSrcTyp, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - eventSourceType is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+ srcTyp = get_source(eventSrcTyp);
+ if(srcTyp == -1)
+ {
+ printf("FAULT02::Fault eventSourceType value is not matching, eventSourceType-%s \n", eventSrcTyp);
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "vfStatus", "tmp_directParameters", vfStatus, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - vfStatus is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+ vfStat = get_vf_status(vfStatus);
+ if(vfStat == -1)
+ {
+ printf("FAULT02::Fault vfStatus value is not matching, vfStatus-%s \n", vfStatus);
+ exit(1);
+ }
+
+ read_keyVal_params(js, tokens, numToken, "tmp_command", "tmp_faultInstance02", keyValResultArray, &numCommands);
+
+ memset(&commandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(commandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ runCommands(commandArray, numCommands);
+
+ /********************************************************************************
+ * Put the condition to set the fault here
+ *******************************************************************************/
+ if ((atoi(commandArray[0].resultStr) == 1) && (fault_raised == 0))
+ {
+ printf("\nFAULT02::Raising fault\n");
+ memset(event_id, 0, BUFSIZE);
+ fault_event_id = fault_event_id+1;
+ sprintf(event_id2, "%09d", fault_event_id);
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance02", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT02::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", reportEName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("FAULT02::Defaulting reportingEntityName to hostname\n");
+ strcpy(reportEName, hostname);
+ }
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", srcName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("FAULT02::Defaulting sourceName to hostname\n");
+ strcpy(srcName, hostname);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "priority", "tmp_directParameters", prio, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - priority is not there in tmp_directParameters\nDefaulting priority to Low\n");
+ strcpy(prio, "Medium");
+ }
+ priority = get_priority(prio);
+ if(priority == -1)
+ {
+ printf("FAULT02::Fault priority value is not matching, prioirty-%s \n", prio);
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "specificProblem", "tmp_alarmSetParameters", "tmp_faultInstance02", specProb, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - specificProblem is not there in tmp_alarmSetParameters, exiting ...\n");
+ exit(1);
+ }
+ ret = getStringTokenV2(js, tokens, numToken, "alarmCondition", "tmp_alarmSetParameters", "tmp_faultInstance02", alarmCondn, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - alarmCondition is not there in tmp_alarmSetParameters, exiting ...\n");
+ exit(1);
+ }
+ ret = getStringTokenV2(js, tokens, numToken, "eventSeverity", "tmp_alarmSetParameters", "tmp_faultInstance02", eventSev, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - eventSeverity is not there in tmp_alarmSetParameters\n");
+ printf("FAULT02::Defaulting eventSeverity to MAJOR\n");
+ strcpy(eventSev, "MAJOR");
+ }
+ eSev = get_severity(eventSev);
+ if(eSev == -1)
+ {
+ printf("FAULT02::Fault eventSeverity value is not matching, eventSeverity-%s \n", eventSev);
+ exit(1);
+ }
+
+ fault = evel_new_fault(eName, event_id, alarmCondn,
+ specProb, priority, eSev, srcTyp,vfStat);
+ if (fault != NULL)
+ {
+ fault_raised = 1;
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+ last_epoch = epoch_now;
+
+ fault_header = (EVENT_HEADER *)fault;
+
+ evel_fault_category_set(fault, eCategory);
+ if (aInterface != NULL)
+ evel_fault_interface_set(fault, aInterface);
+
+ if (eType != NULL)
+ evel_fault_type_set(fault, eType);
+
+ evel_start_epoch_set(&fault->header, epoch_now);
+ evel_last_epoch_set(&fault->header, epoch_now);
+ if(nfcCode != NULL)
+ evel_nfcnamingcode_set(&fault->header, nfcCode);
+ if(nfCode != NULL)
+ evel_nfnamingcode_set(&fault->header, nfCode);
+ evel_reporting_entity_name_set(&fault->header, reportEName);
+ if(reportEId != NULL)
+ evel_reporting_entity_id_set(&fault->header, reportEId);
+ if(timeZOff != NULL)
+ evel_time_zone_offset_set(&fault->header, timeZOff);
+ if(nfVendor != NULL)
+ evel_nf_vendor_name_set(&fault->header, nfVendor);
+ if(srcId != NULL )
+ evel_source_id_set(&fault->header, srcId);
+ if(srcName!= NULL )
+ evel_source_name_set(&fault->header, srcName);
+
+ evel_rc = evel_post_event(fault_header);
+
+ if(evel_rc == EVEL_SUCCESS) {
+ printf("FAULT02::Fault event is correctly sent to the collector!\n");
+ }
+ else {
+ printf("FAULT02::Post failed %d (%s)\n", evel_rc, evel_error_string());
+ }
+ }
+ else {
+ printf("FAULT02::New new fault failed (%s)\n", evel_error_string());
+ }
+ }
+ /********************************************************************************
+ * Put the condition to clear the fault here
+ *******************************************************************************/
+ else if ((atoi(commandArray[0].resultStr) == 0) && (fault_raised == 1))
+ {
+ printf("\nFAULT02:: Clearing fault\n");
+ memset(event_id, 0, BUFSIZE);
+ sprintf(event_id2, "%09d", (i+1));
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ ret = getIntToken(js, tokens, numToken, "tmp_faultCheckInterval", "tmp_faultInstance02", &flt_interval);
+ if (ret != 0)
+ {
+ printf("FAULT02::The parameter tmp_faultCheckInterval is not defined, defaulted to 60 seconds\n");
+ flt_interval = 60;
+ }
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", reportEName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("FAULT02::Defaulting reportingEntityName to hostname\n");
+ strcpy(reportEName, hostname);
+ }
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", srcName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("FAULT02::Defaulting sourceName to hostname\n");
+ strcpy(srcName, hostname);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "priority", "tmp_directParameters", prio, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - priority is not there in tmp_directParameters\nDefaulting priority to Low\n");
+ strcpy(prio, "Medium");
+ }
+ priority = get_priority(prio);
+ if(priority == -1)
+ {
+ printf("FAULT02::Fault priority value is not matching, prioirty-%s \n", prio);
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "specificProblem", "tmp_alarmClearParameters", "tmp_faultInstance02", specProb, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - specificProblem is not there in tmp_alarmClearParameters, exiting ...\n");
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "alarmCondition", "tmp_alarmClearParameters", "tmp_faultInstance02", alarmCondn, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - alarmCondition is not there in tmp_alarmClearParameters, exiting ...\n");
+ exit(1);
+ }
+
+ ret = getStringTokenV2(js, tokens, numToken, "eventSeverity", "tmp_alarmClearParameters", "tmp_faultInstance02", eventSev, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("FAULT02::Missing mandatory parameters - eventSeverity is not there in tmp_alarmClearParameters\n");
+ printf("FAULT02::Defaulting eventSeverity to MAJOR\n");
+ strcpy(eventSev, "NORMAL");
+ }
+ eSev = get_severity(eventSev);
+ if(eSev == -1)
+ {
+ printf("FAULT02::Fault eventSeverity value is not matching, eventSeverity-%s \n", eventSev);
+ exit(1);
+ }
+
+ fault = evel_new_fault(eName, event_id, alarmCondn,
+ specProb, priority, eSev, srcTyp,vfStat);
+ if (fault != NULL)
+ {
+ fault_raised = 0;
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+
+ fault_header = (EVENT_HEADER *)fault;
+ evel_fault_category_set(fault, eCategory);
+ if (aInterface != NULL)
+ evel_fault_interface_set(fault, aInterface);
+
+ if (eType != NULL)
+ evel_fault_type_set(fault, eType);
+
+ evel_start_epoch_set(&fault->header, last_epoch);
+ evel_last_epoch_set(&fault->header, epoch_now);
+ last_epoch = 0;
+
+ if(nfcCode != NULL)
+ evel_nfcnamingcode_set(&fault->header, nfcCode);
+ if(nfCode != NULL)
+ evel_nfnamingcode_set(&fault->header, nfCode);
+ evel_reporting_entity_name_set(&fault->header, reportEName);
+ if(reportEId != NULL)
+ evel_reporting_entity_id_set(&fault->header, reportEId);
+ if(timeZOff != NULL)
+ evel_time_zone_offset_set(&fault->header, timeZOff);
+ if(nfVendor != NULL)
+ evel_nf_vendor_name_set(&fault->header, nfVendor);
+ if(srcId != NULL )
+ evel_source_id_set(&fault->header, srcId);
+ if(srcName!= NULL )
+ evel_source_name_set(&fault->header, srcName);
+
+ evel_rc = evel_post_event(fault_header);
+
+ if(evel_rc == EVEL_SUCCESS) {
+ printf("FAULT02::Fault event is correctly sent to the collector!\n");
+ }
+ else {
+ printf("FAULT02::Post failed %d (%s)\n", evel_rc, evel_error_string());
+ }
+ }
+ else {
+ printf("FAULT02::New fault failed (%s)\n", evel_error_string());
+ }
+
+ }
+
+ sleep(flt_interval);
+ }
+
+ /***************************************************************************/
+ /* Terminate */
+ /***************************************************************************/
+ sleep(1);
+}
+
+void *FaultThread03(void *faultInstanceTag)
+{
+ sleep(4);
+ printf("FAULT03::thread created\n");
+ fflush(stdout);
+ while (1)
+ { sleep (100); }
+}
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/LICENSE.TXT
new file mode 100644
index 0000000..16285cd
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/LICENSE.TXT
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is trademark and service mark of AT&T Intellectual Property.
+ *
+ */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/Makefile b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/Makefile
new file mode 100644
index 0000000..4b0fd85
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/Makefile
@@ -0,0 +1,52 @@
+#############################################################################
+#
+# Copyright © 2019 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)/../..
+#CODE_ROOT=../code/evel-library
+LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH)
+#LIBS_DIR=/usr/lib
+INCLUDE_DIR= -I $(CODE_ROOT)/code/evel_library -I .
+
+#******************************************************************************
+# Standard compiler flags. *
+#******************************************************************************
+CPPFLAGS=
+CFLAGS=-Wall -g -fPIC
+FILEOBJLIST= jsmn.o ves_syslog_reporter.o
+
+all: ves_syslog_reporter
+
+clean:
+ rm -f *.o ves_syslog_reporter
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
+
+jsmn.o: jsmn.c jsmn.h
+ves_syslog_reporter.o: ves_syslog_reporter.c
+
+ves_syslog_reporter: $(FILEOBJLIST)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o ves_syslog_reporter \
+ -L $(LIBS_DIR) \
+ $(FILEOBJLIST) \
+ -lpthread \
+ -level \
+ -lcurl
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/README.md b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/README.md
new file mode 100644
index 0000000..9aecc2a
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/README.md
@@ -0,0 +1,37 @@
+
+PROJECT DESCRIPTION
+
+---
+This project contains the source code and scripts for the generation of syslog events. The folder contains:
+
+ - README.md: this file.
+
+ - LICENSE.TXT: the license text.
+
+ - ves_syslog_reporter.c and other .c files: source code that uses the ECOMP Vendor Event Listener Library (VES) to generate the syslog events. Syslog events are generated based on /var/log/syslog entries. If a specific pattern is observed in the syslog file, then it generates the syslog event. The application reads syslog_config.json file for parameter values and poppulate the syslog event. If eventName, eventSourceType, syslogTag and tmp_syslogFile parameter value is not given, the application terminates. If reportingEntityName and/or sourceName parameter values are not given, then it gets the hostname and poppulates it.
+
+ - Makefile: makefile that compiles ves_syslog_reporter.c and generates ves_syslog_reporter binary.
+
+ - go-client.sh/go-client_2_collectors.sh: bash script that starts up the ves_syslog_reporter. It reads input parameters like DCAE IP address and port from configuration files contained in /opt/config. Based on the collector configuration, use go-client.sh for single collector configuration, or use go-client_2_collectors.sh for 2 collectors configuration.
+
+
+USAGE
+-----
+
+Update the configuration files with proper parameters values so that events generated would contain those values
+
+To run the ves_syslog_reporter in single collector configuration, please execute the following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client.sh
+
+ - Run the go-client.sh script
+ ./go-client.sh
+
+For 2 collectors configuration, please execute following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client_2_collectors.sh
+
+ - Run the go-client_2_collectors.sh script
+ ./go-client_2_collectors.sh
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/dep.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/dep.xml
new file mode 100644
index 0000000..fc18229
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/dep.xml
@@ -0,0 +1,25 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>demo</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.sh</include>
+ <include>*.md</include>
+ <include>*.TXT</include>
+ <include>*.c</include>
+ <include>Makefile</include>
+ </includes>
+ </fileSet>
+
+ </fileSets>
+</assembly>
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client.sh
new file mode 100755
index 0000000..0701456
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+./ves_syslog_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client_2_collectors.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client_2_collectors.sh
new file mode 100755
index 0000000..492d76d
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/go-client_2_collectors.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+
+#Usage for 2 collectors:
+#./ves_syslog_reporter <FQDN>|<IP address> <port> <FQDN>|<IP address> <port>
+
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+DCAE_COLLECTOR_IP2=$(cat /opt/config/dcae_collector_ip2.txt)
+DCAE_COLLECTOR_PORT2=$(cat /opt/config/dcae_collector_port2.txt)
+./ves_syslog_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT $DCAE_COLLECTOR_IP2 $DCAE_COLLECTOR_PORT2
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.c
new file mode 100644
index 0000000..1d72ba4
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.c
@@ -0,0 +1,672 @@
+/*************************************************************************//**
+ *
+ * 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.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ****************************************************************************/
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include "jsmn.h"
+
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+ jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *tok;
+ if (parser->toknext >= num_tokens) {
+ return NULL;
+ }
+ tok = &tokens[parser->toknext++];
+ tok->start = tok->end = -1;
+ tok->size = 0;
+//#ifdef JSMN_PARENT_LINKS
+ tok->parent = -1;
+//#endif
+ return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+ int start, int end) {
+//printf("jsmn_fill_token:: start-%d, end-%d\n", start, end);
+ token->type = type;
+ token->start = start;
+ token->end = end;
+ token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+ int start;
+
+ start = parser->pos;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+//printf("jsmn_parse_primitive:: the char is - %c\n", js[parser->pos]);
+ switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+ /* In strict mode primitive must be followed by "," or "}" or "]" */
+ case ':':
+#endif
+ case '\t' : case '\r' : case '\n' : case ' ' :
+ case ',' : case ']' : case '}' :
+ goto found;
+ }
+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#ifdef JSMN_STRICT
+ /* In strict mode primitive must be followed by a comma/object/array */
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+#endif
+
+found:
+ if (tokens == NULL) {
+ parser->pos--;
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ parser->pos--;
+ return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+
+ int start = parser->pos;
+
+ parser->pos++;
+
+ /* Skip starting quote */
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c = js[parser->pos];
+ char d = js[parser->pos + 1];
+// char e = js[parser->pos + 2];
+//printf("jsmn_parse_string: value-%c, pos-%d\n", c,parser->pos);
+
+ /* Quote: end of string */
+// if (c == '\"') {
+ if (d == '\"') {
+// if ((d == '\"')&&((e == ' ')||(e == ','))) {
+parser->pos++;
+//printf("jsmn_parse_string: end of string\n");
+ if (tokens == NULL) {
+//printf("jsmn_parse_string: end tokens is NULL\n");
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+//printf("jsmn_parse_string: Allocated tokens \n");
+ if (token == NULL) {
+//printf("jsmn_parse_string: Allocated tokens is NULL\n");
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+//printf("jsmn_parse_string: Allocated tokens is filled\n");
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ return 0;
+ }
+
+ /* Backslash: Quoted symbol expected */
+ if (c == '\\' && parser->pos + 1 < len) {
+ int i;
+ parser->pos++;
+//printf("jsmn_parse_string: value - %c, POS-%3d \n",c, js[parser->pos]);
+ switch (js[parser->pos]) {
+ /* Allowed escaped symbols */
+ case '\"': case '/' : case '\\' : case 'b' :
+ case 'f' : case 'r' : case 'n' : case 't' :
+ break;
+ /* Allows escaped symbol \uXXXX */
+ case 'u':
+ parser->pos++;
+ for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+ /* If it isn't a hex character we have an error */
+ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ parser->pos++;
+ }
+ parser->pos--;
+ break;
+ /* Unexpected symbol */
+ default:
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+ }
+ parser->pos = start;
+printf("jsmn_parse_string: exiting with ERROR_PART, pos-%d", parser->pos);
+ return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens) {
+ int r;
+ int i;
+ jsmntok_t *token;
+ int count = parser->toknext;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c;
+ jsmntype_t type;
+
+ c = js[parser->pos];
+//printf("jsmn_parse: value of c - %c\n",c);
+ switch (c) {
+ case '{': case '[':
+ count++;
+ if (tokens == NULL) {
+ break;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL)
+ return JSMN_ERROR_NOMEM;
+ if (parser->toksuper != -1) {
+ tokens[parser->toksuper].size++;
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ }
+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+ token->start = parser->pos;
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case '}': case ']':
+ if (tokens == NULL)
+ break;
+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+//#ifdef JSMN_PARENT_LINKS
+ if (parser->toknext < 1) {
+ return JSMN_ERROR_INVAL;
+ }
+ token = &tokens[parser->toknext - 1];
+ for (;;) {
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ token->end = parser->pos + 1;
+ parser->toksuper = token->parent;
+ break;
+ }
+ if (token->parent == -1) {
+ break;
+ }
+ token = &tokens[token->parent];
+ }
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// if (token->type != type) {
+// return JSMN_ERROR_INVAL;
+// }
+// parser->toksuper = -1;
+// token->end = parser->pos + 1;
+// break;
+// }
+// }
+// /* Error if unmatched closing bracket */
+// if (i == -1) return JSMN_ERROR_INVAL;
+// for (; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+//#endif
+ break;
+ case '\"':
+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+ case '\t' : case '\r' : case '\n' : case ' ':
+ break;
+ case ':':
+ parser->toksuper = parser->toknext - 1;
+//printf("jsmn_parse: value of c is :: - %c\n",c);
+ break;
+ case ',':
+ if (tokens != NULL && parser->toksuper != -1 &&
+ tokens[parser->toksuper].type != JSMN_ARRAY &&
+ tokens[parser->toksuper].type != JSMN_OBJECT) {
+//#ifdef JSMN_PARENT_LINKS
+ parser->toksuper = tokens[parser->toksuper].parent;
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+// if (tokens[i].start != -1 && tokens[i].end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+// }
+//#endif
+ }
+ break;
+#ifdef JSMN_STRICT
+ /* In strict mode primitives are: numbers and booleans */
+ case '-': case '0': case '1' : case '2': case '3' : case '4':
+ case '5': case '6': case '7' : case '8': case '9':
+ case 't': case 'f': case 'n' :
+ /* And they must not be keys of the object */
+ if (tokens != NULL && parser->toksuper != -1) {
+ jsmntok_t *t = &tokens[parser->toksuper];
+ if (t->type == JSMN_OBJECT ||
+ (t->type == JSMN_STRING && t->size != 0)) {
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#else
+ /* In non-strict mode every unquoted value is a primitive */
+ default:
+#endif
+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+
+#ifdef JSMN_STRICT
+ /* Unexpected char in strict mode */
+ default:
+ return JSMN_ERROR_INVAL;
+#endif
+ }
+ }
+
+ if (tokens != NULL) {
+ for (i = parser->toknext - 1; i >= 0; i--) {
+//printf("index -%2d, start is %3d, end is %3d\n", i, tokens[i].start, tokens[i].end);
+ /* Unmatched opened object or array */
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ return JSMN_ERROR_PART;
+ }
+ }
+ }
+
+ return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+void jsmn_init(jsmn_parser *parser) {
+ parser->pos = 0;
+ parser->toknext = 0;
+ parser->toksuper = -1;
+}
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+ if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
+ strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+ return 0;
+ }
+ return -1;
+}
+
+void printToken(char * js, jsmntok_t * tokens, int numToken)
+{
+ for (int i = 1; i < numToken; i++)
+ {
+ printf("Token number-%2d, parent-%2d, type-%d size-%2d, parameter -", i, tokens[i].parent, tokens[i].type, tokens[i].size);
+ if (tokens[i].type == JSMN_STRING || tokens[i].type == JSMN_PRIMITIVE) {
+ printf("%.*s\n", tokens[i].end - tokens[i].start, js + tokens[i].start);
+ } else if (tokens[i].type == JSMN_ARRAY) {
+ printf("[%d elems]\n", tokens[i].size);
+ } else if (tokens[i].type == JSMN_OBJECT) {
+ printf("{%d elems}\n", tokens[i].size);
+ } else {
+ printf("value?? - ");
+ TOKEN_PRINT(tokens[i]);
+ }
+ }
+}
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * gParam,char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], gParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Grand Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 2; //Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ {
+ continue;
+ }
+
+ if(tokens[i+1].type != JSMN_PRIMITIVE)
+ return 3; //Wrong parameter type
+
+// printf("INT parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], val);
+ *value = atoi(val);
+// printf(" - %d\n", *value);
+
+ return 0; //success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+void parseDirectParameters(char * js, jsmntok_t * tokens, int numToken)
+{
+ int i = 0;
+ int dpToken = 0;
+ char param[128];
+ char value[128];
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], "directParameters") == 0)
+ break;
+ }
+
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+
+ for (int i = 1; i < numToken; i++)
+ {
+ memset(param, 0, 128);
+ memset(value, 0, 128);
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ TOKEN_COPY(js, tokens[i], param);
+// printf("parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], value);
+// printf(" - %s\n", value);
+ }
+ }
+}
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_ARRAY)
+ {
+ *numElements = tokens[i+1].size;
+// printf("[%d elems]\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k], arrayValue[k].arrayString);
+// printf(" - %s\n", arrayValue[k].arrayString);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING)
+ {
+ if(jsoneq(js, &tokens[i], param) == 0)
+ {
+ return 0; //Token present
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //Token Not present
+}
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_OBJECT)
+ {
+ *numElements = tokens[i+1].size;
+// printf("{%d elems}\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k*2], keyValueResultList[k].keyStr);
+// printf("Key - %s", keyValueResultList[k].keyStr);
+ TOKEN_COPY(js, tokens[i+3+k*2], keyValueResultList[k].valStr);
+// printf("Value - %s\n", keyValueResultList[k].valStr);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.h b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.h
new file mode 100644
index 0000000..f9d838b
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/jsmn.h
@@ -0,0 +1,136 @@
+/*************************************************************************//**
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __JSMN_H_
+#define __JSMN_H_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * o Object
+ * o Array
+ * o String
+ * o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+ JSMN_UNDEFINED = 0,
+ JSMN_OBJECT = 1,
+ JSMN_ARRAY = 2,
+ JSMN_STRING = 3,
+ JSMN_PRIMITIVE = 4
+} jsmntype_t;
+
+enum jsmnerr {
+ /* Not enough tokens were provided */
+ JSMN_ERROR_NOMEM = -1,
+ /* Invalid character inside JSON string */
+ JSMN_ERROR_INVAL = -2,
+ /* The string is not a full JSON packet, more bytes expected */
+ JSMN_ERROR_PART = -3
+};
+
+typedef struct arrayValues {
+ char arrayString[32];
+} ARRAYVAL;
+
+typedef struct keyValResult {
+ char keyStr[80];
+ char valStr[250];
+ char resultStr[80];
+} KEYVALRESULT;
+
+/**
+ * JSON token description.
+ * @param type type (object, array, string etc.)
+ * @param start start position in JSON data string
+ * @param end end position in JSON data string
+ */
+typedef struct {
+ jsmntype_t type;
+ int start;
+ int end;
+ int size;
+//#ifdef JSMN_PARENT_LINKS
+ int parent;
+//#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string
+ */
+typedef struct {
+ unsigned int pos; /* offset in the JSON string */
+ unsigned int toknext; /* next token to allocate */
+ int toksuper; /* superior token node, e.g parent object or array */
+} jsmn_parser;
+
+#define TOKEN_EQ(t, tok_start, tok_end, tok_type) \
+ ((t).start == tok_start \
+ && (t).end == tok_end \
+ && (t).type == (tok_type))
+
+#define TOKEN_STRING(js, t, s) \
+ (strncmp(js+(t).start, s, (t).end - (t).start) == 0 \
+ && strlen(s) == (t).end - (t).start)
+
+#define TOKEN_COPY(js, t, s) \
+ strncpy(s, js+(t).start, (t).end - (t).start)
+
+#define TOKEN_PRINT(t) \
+ printf("start: %d, end: %d, type: %d, size: %d\n", \
+ (t).start, (t).end, (t).type, (t).size)
+
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
+ * a single JSON object.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens);
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
+
+void printToken(char * js, jsmntok_t * tokens, int numToken);
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize);
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value);
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements);
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam);
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements);
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char *gParam, char * value, int maxValueSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __JSMN_H_ */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/pom.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/pom.xml
new file mode 100644
index 0000000..f9f42eb
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START==========================================
+ ===================================================================
+ 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.
+ ============LICENSE_END============================================
+
+ ECOMP and OpenECOMP are trademarks
+ and service marks of AT&T Intellectual Property.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+<parent>
+ <groupId>org.onap.demo.vnf</groupId>
+ <artifactId>demo-aggregator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.demo.vnf.ves5</groupId>
+ <artifactId>ves_vfw_reporting</artifactId>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>never</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <descriptor>dep.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-archive</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/sample_syslog_event.txt b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/sample_syslog_event.txt
new file mode 100644
index 0000000..8f61385
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/sample_syslog_event.txt
@@ -0,0 +1,33 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "syslog",
+ "eventId": "syslog000000000",
+ "eventName": "syslog_vFirewall-AT&T_connectionReset",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1548241988387486,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Normal",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 0,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 0,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.1",
+ "vesEventListenerVersion": "7.1"
+ },
+ "syslogFields": {
+ "eventSourceType": "virtualMachine",
+ "syslogFacility": 16,
+ "syslogFieldsVersion": "4.0",
+ "syslogMsg": "Jan 23 16:43:06 prakash-VirtualBox prakash: peer reset1234567891234567812345",
+ "syslogProc": "vSyslog",
+ "syslogTag": "peer reset"
+ }
+ }
+}
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/syslog_config.json b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/syslog_config.json
new file mode 100644
index 0000000..6a434e4
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/syslog_config.json
@@ -0,0 +1,20 @@
+{
+ "tmp_directParameters": {
+ "eventName": "syslog_vFirewall-AT&T_connectionReset",
+ "eventType": "applicationVnf",
+ "nfcNamingCode": "AFX",
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "timeZoneOffset": "UTC-05:30",
+ "eventSourceType": "virtualMachine",
+ "syslogProc": "vSyslog",
+ "syslogTag": "peer reset"
+ },
+ "tmp_indirectParameters": {
+ "tmp_syslogFile": "/var/log/syslog"
+ }
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/ves_syslog_reporter.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/ves_syslog_reporter.c
new file mode 100644
index 0000000..e322f60
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog/ves_syslog_reporter.c
@@ -0,0 +1,381 @@
+/*************************************************************************//**
+ *
+ * Copyright © 2018 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.
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include "jsmn.h"
+#include "evel.h"
+
+#define BUFSIZE 128
+#define MAX_BUFFER_SIZE 4096
+#define MAX_TOKENS 1000
+
+void *SyslogThread(void *threadarg);
+
+unsigned long long epoch_start = 0;
+
+int main(int argc, char** argv)
+{
+ char* fqdn = argv[1];
+ int port = atoi(argv[2]);
+ int i=0;
+ int rc;
+ pthread_attr_t attr;
+ pthread_t syslog_thread;
+ char* fqdn2 = NULL;
+ int port2 = 0;
+
+ if(argc == 5)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ }
+
+ if (!((argc == 3) || (argc == 5)))
+ {
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> \n", argv[0]);
+ fprintf(stderr, "OR\n");
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> \n", argv[0]);
+ exit(-1);
+ }
+
+ /**************************************************************************/
+ /* Initialize */
+ /**************************************************************************/
+ if(evel_initialize(fqdn, /* FQDN */
+ port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 0, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ NULL, /* ca info */
+ NULL, /* ca file */
+ 0, /* verify peer */
+ 0, /* verify host */
+ "sample1", /* Username */
+ "sample1", /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
+ NULL, /* Source ip */
+ NULL, /* Source ip2 */
+ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
+ "vSyslog", /* Role */
+ 1)) /* Verbosity */
+ {
+ fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
+ exit(-1);
+ }
+ else
+ {
+ printf("\nInitialization completed\n");
+ }
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ printf("Main:Creating thread \n");
+ rc = pthread_create(&syslog_thread, NULL, SyslogThread, &i);
+ if (rc)
+ {
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ printf("Main:Created Syslog thread \n");
+
+ pthread_join(syslog_thread, NULL);
+
+ evel_terminate();
+ printf("Terminated\n");
+ return 0;
+}
+
+void *SyslogThread(void *threadarg)
+{
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+ FILE * fp;
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+ char eName[BUFSIZE];
+ char eventSrcTyp[BUFSIZE];
+ char syslog_tag[BUFSIZE];
+ char syslog_msg[8*BUFSIZE];
+ char str[8*BUFSIZE];
+ char syslog_file[BUFSIZE];
+ int srcTyp = 0;
+ int count = 0;
+ unsigned long long pos;
+ unsigned long long prevpos = 0;
+
+ sleep(1);
+ printf("Running Syslog thread \n");
+ fflush(stdout);
+
+ while(1)
+ {
+
+ FILE * file = fopen("syslog_config.json", "r");
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+// printf("the file content is \n %s \n", js);
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+// printf("Token count-%d\n", numToken);
+
+// printToken(js,tokens, numToken);
+
+ ret = getStringToken(js, tokens, numToken, "tmp_syslogFile", "tmp_indirectParameters", syslog_file, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("Missing mandatory parameters - tmp_syslogFile is not there in tmp_indirectParameters. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "syslogTag", "tmp_directParameters", syslog_tag, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("Missing mandatory parameters - syslogTag is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventName", "tmp_directParameters", eName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("Missing mandatory parameters - eventName is not there in tmp_directParameters. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventSourceType", "tmp_directParameters", eventSrcTyp, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("Missing mandatory parameters - eventSourceType is not there in tmp_directParameters, exiting..\n");
+ exit(1);
+ }
+ srcTyp = get_source(eventSrcTyp);
+ if(srcTyp == -1)
+ {
+ printf("Fault eventSourceType value is not matching, eventSourceType-%s \n", eventSrcTyp);
+ exit(1);
+ }
+
+ // Open file in read mode
+ fp = fopen(syslog_file, "r");
+ if (fp == NULL)
+ {
+ printf("Error while opening file");
+ exit(EXIT_FAILURE);
+ }
+
+ memset(str, 0, 8*BUFSIZE);
+ if (fseek(fp, 0, SEEK_END))
+ perror("fseek() failed");
+ else
+ {
+ // pos will contain no. of chars in input file.
+ int n = 8;
+ pos = ftell(fp);
+
+ // search for '\n' characters
+ while (pos>prevpos)
+ {
+ // Move 'pos' away from end of file.
+ if (!fseek(fp, --pos, SEEK_SET))
+ {
+ if (fgetc(fp) == '\n')
+
+ // stop reading when n newlines is found
+ if (count++ == n)
+ break;
+ }
+ else
+ perror("fseek() failed");
+ }
+ //printf("pos %d prevpos %d\n",pos,prevpos);
+
+ // print last n lines
+ prevpos = pos;
+
+ while (fgets(str, sizeof(str), fp))
+ {
+ char * position;
+ // printf("str is - %s\n", str);
+ if ((position=strchr(str, '\n')) != NULL)
+ *position = '\0';
+ if(strstr(str, syslog_tag) && !strstr(str,"EVEL") && !strstr(str,"commonEventHeader") && !strstr(str,"syslogMsg") && !strstr(str,"syslogTag"))
+ {
+ memset(syslog_msg, 0, 8*BUFSIZE);
+ memcpy(syslog_msg, str, 8*BUFSIZE);
+ report_syslog(js, tokens, numToken, syslog_tag, eName, srcTyp, syslog_msg);
+ }
+
+ prevpos += strlen(str);
+ //printf("new prevpos is %d, size of str is %d\n", prevpos, strlen(str));
+ }
+ }
+ sleep(3);
+ }
+}
+
+void report_syslog(char * js, jsmntok_t * tokens, int numToken, char * syslog_tag, char * eName, int srcTyp, char * syslog_msg)
+{
+ EVENT_HEARTBEAT_FIELD * event = NULL;
+ EVENT_HEADER* syslog_header = NULL;
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ char stringVal[BUFSIZE];
+
+ char event_id1[10] = "syslog";
+ char event_id2[15] = {0};
+ int event_id3 = 0;
+ char event_id[BUFSIZE] = {0};
+
+ int ret = 0;
+ /***************************************************************************/
+ /* Syslog */
+ /***************************************************************************/
+ memset(event_id, 0, BUFSIZE);
+ memset(event_id2, 0, 15);
+ sprintf(event_id2, "%09d", event_id3++);
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+
+ event = evel_new_syslog(eName, event_id, srcTyp, syslog_msg, syslog_tag);
+
+ if (event != NULL)
+ {
+ syslog_header = (EVENT_HEADER *)event;
+
+ ret = getStringToken(js, tokens, numToken, "syslogProc", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_syslog_proc_set(event, stringVal);
+ evel_syslog_facility_set(event, EVEL_SYSLOG_FACILITY_LOCAL0);
+ ret = getStringToken(js, tokens, numToken, "eventType", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_header_type_set(&event->header, stringVal);
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+
+ evel_start_epoch_set(&event->header, epoch_start);
+ evel_last_epoch_set(&event->header, epoch_now);
+ epoch_start = epoch_now;
+
+ ret = getStringToken(js, tokens, numToken, "nfcNamingCode", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nfcnamingcode_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "nfNamingCode", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nfnamingcode_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_reporting_entity_name_set(&event->header, stringVal);
+ else
+ {
+ printf("Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("Defaulting reportingEntityName to hostname\n");
+ }
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityId", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_reporting_entity_id_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "timeZoneOffset", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_time_zone_offset_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "nfVendorName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_nf_vendor_name_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "sourceId", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_source_id_set(&event->header, stringVal);
+
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", stringVal, BUFSIZE);
+ if (ret == 0)
+ evel_source_name_set(&event->header, stringVal);
+ else
+ {
+ printf("Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("Defaulting sourceName to hostname\n");
+ }
+
+ evel_rc = evel_post_event(syslog_header);
+ if (evel_rc != EVEL_SUCCESS)
+ {
+ EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string());
+ }
+ }
+ else
+ {
+ EVEL_ERROR("New Syslog failed");
+ }
+ printf(" Processed Syslog\n");
+}
+
+int get_source(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "other") == 0)
+ result = EVEL_SOURCE_OTHER;
+ else if(strcmp(inStr, "router") == 0)
+ result = EVEL_SOURCE_ROUTER;
+ else if(strcmp(inStr, "switch") == 0)
+ result = EVEL_SOURCE_SWITCH;
+ else if(strcmp(inStr, "host") == 0)
+ result = EVEL_SOURCE_HOST;
+ else if(strcmp(inStr, "card") == 0)
+ result = EVEL_SOURCE_CARD;
+ else if(strcmp(inStr, "port") == 0)
+ result = EVEL_SOURCE_PORT;
+ else if(strcmp(inStr, "slotThreshold") == 0)
+ result = EVEL_SOURCE_SLOT_THRESHOLD;
+ else if(strcmp(inStr, "portThreshold") == 0)
+ result = EVEL_SOURCE_PORT_THRESHOLD;
+ else if(strcmp(inStr, "virtualMachine") == 0)
+ result = EVEL_SOURCE_VIRTUAL_MACHINE;
+ else if(strcmp(inStr, "virtualNetworkFunction") == 0)
+ result = EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION;
+
+ return result;
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/.meas_config.json.swp b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/.meas_config.json.swp
new file mode 100644
index 0000000..c918d8e
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/.meas_config.json.swp
Binary files differ
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/LICENSE.TXT
new file mode 100644
index 0000000..16285cd
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/LICENSE.TXT
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is trademark and service mark of AT&T Intellectual Property.
+ *
+ */
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/Makefile b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/Makefile
index dbc6b1b..9d1812f 100644
--- a/veslibrary/ves_clibrary/VESreporting_vLB/Makefile
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/Makefile
@@ -1,7 +1,6 @@
-
#############################################################################
#
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2019 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.
@@ -18,23 +17,36 @@
CC=gcc
ARCH=$(shell getconf LONG_BIT)
-CODE_ROOT=$(CURDIR)/../evel/evel-library
+CODE_ROOT=$(CURDIR)/../..
+#CODE_ROOT=../code/evel-library
LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH)
-INCLUDE_DIR=$(CODE_ROOT)/code/evel_library
+#LIBS_DIR=/usr/lib
+INCLUDE_DIR= -I $(CODE_ROOT)/code/evel_library -I .
#******************************************************************************
# Standard compiler flags. *
#******************************************************************************
CPPFLAGS=
CFLAGS=-Wall -g -fPIC
+FILEOBJLIST= jsmn.o vpp_measurement_reporter.o
all: vpp_measurement_reporter
clean:
- rm -f vpp_measurement_reporter
+ rm -f *.o vpp_measurement_reporter
+
+%.o: %.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
+
+jsmn.o: jsmn.c jsmn.h
+vpp_measurement_reporter.o: vpp_measurement_reporter.c
-vpp_measurement_reporter: vpp_measurement_reporter.c
+vpp_measurement_reporter: $(FILEOBJLIST)
$(CC) $(CPPFLAGS) $(CFLAGS) -o vpp_measurement_reporter \
-L $(LIBS_DIR) \
- -I $(INCLUDE_DIR) \
- vpp_measurement_reporter.c -lm -lpthread -level -lcurl
+ $(FILEOBJLIST) \
+ -lpthread \
+ -level \
+ -lcurl
+
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/README.md b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/README.md
new file mode 100644
index 0000000..6921cdc
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/README.md
@@ -0,0 +1,37 @@
+
+PROJECT DESCRIPTION
+
+---
+This project contains the source code and scripts for the periodic generation of measurement events. The folder contains:
+
+ - README.md: this file.
+
+ - LICENSE.TXT: the license text.
+
+ - vpp_measurement_reporter.c and other .c files: source code that uses the ECOMP Vendor Event Listener Library (VES) to generate the measurement events. Measurement event is generated periodically on each of the interfaces. It gives the number of bytes/packets that transmitted/received. The application reads meas_config.json file for parameter values and poppulate the measurement event. If eventName parameter value is not given, the application terminates. If reportingEntityName and sourceName parameter values are not given, then it gets the hostname and poppulates it. If measurementInterval is not given, it defaults to 60 seconds.
+
+ - Makefile: makefile that compiles vpp_measurement_reporter.c and generates vpp_measurement_reporter binary.
+
+ - go-client.sh/go-client_2_collectors.sh: bash script that starts up the vpp_measurement_reporter. It reads input parameters like DCAE IP address and port from configuration files contained in /opt/config. Based on the collector configuration, use go-client.sh for single collector configuration, or use go-client_2_collectors.sh for 2 collectors configuration.
+
+
+USAGE
+-----
+
+Update the configuration files with proper parameters values so that events generated would contain those values
+
+To run the vpp_measurement_reporter in single collector configuration, please execute the following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client.sh
+
+ - Run the go-client.sh script
+ ./go-client.sh
+
+For 2 collectors configuration, please execute following steps:
+
+ - Make the go-client.sh script executable
+ chmod +x go-client_2_collectors.sh
+
+ - Run the go-client_2_collectors.sh script
+ ./go-client_2_collectors.sh
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/dep.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/dep.xml
new file mode 100644
index 0000000..fc18229
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/dep.xml
@@ -0,0 +1,25 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>demo</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.sh</include>
+ <include>*.md</include>
+ <include>*.TXT</include>
+ <include>*.c</include>
+ <include>Makefile</include>
+ </includes>
+ </fileSet>
+
+ </fileSets>
+</assembly>
+
+
diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client.sh
index 116f890..b2b3a08 100755
--- a/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client.sh
@@ -3,4 +3,4 @@
export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
-./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT eth1
+./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client_2_collectors.sh b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client_2_collectors.sh
new file mode 100755
index 0000000..65f7126
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/go-client_2_collectors.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/"
+
+#Usage for 2 collectors:
+#./vpp_measurement_reporter <FQDN>|<IP address> <port> <FQDN>|<IP address> <port>
+
+DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt)
+DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt)
+DCAE_COLLECTOR_IP2=$(cat /opt/config/dcae_collector_ip2.txt)
+DCAE_COLLECTOR_PORT2=$(cat /opt/config/dcae_collector_port2.txt)
+./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT $DCAE_COLLECTOR_IP2 $DCAE_COLLECTOR_PORT2
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.c
new file mode 100644
index 0000000..1d72ba4
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.c
@@ -0,0 +1,672 @@
+/*************************************************************************//**
+ *
+ * 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.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ****************************************************************************/
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include "jsmn.h"
+
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+ jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *tok;
+ if (parser->toknext >= num_tokens) {
+ return NULL;
+ }
+ tok = &tokens[parser->toknext++];
+ tok->start = tok->end = -1;
+ tok->size = 0;
+//#ifdef JSMN_PARENT_LINKS
+ tok->parent = -1;
+//#endif
+ return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+ int start, int end) {
+//printf("jsmn_fill_token:: start-%d, end-%d\n", start, end);
+ token->type = type;
+ token->start = start;
+ token->end = end;
+ token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+ int start;
+
+ start = parser->pos;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+//printf("jsmn_parse_primitive:: the char is - %c\n", js[parser->pos]);
+ switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+ /* In strict mode primitive must be followed by "," or "}" or "]" */
+ case ':':
+#endif
+ case '\t' : case '\r' : case '\n' : case ' ' :
+ case ',' : case ']' : case '}' :
+ goto found;
+ }
+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#ifdef JSMN_STRICT
+ /* In strict mode primitive must be followed by a comma/object/array */
+ parser->pos = start;
+ return JSMN_ERROR_PART;
+#endif
+
+found:
+ if (tokens == NULL) {
+ parser->pos--;
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL) {
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ parser->pos--;
+ return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+ size_t len, jsmntok_t *tokens, size_t num_tokens) {
+ jsmntok_t *token;
+
+ int start = parser->pos;
+
+ parser->pos++;
+
+ /* Skip starting quote */
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c = js[parser->pos];
+ char d = js[parser->pos + 1];
+// char e = js[parser->pos + 2];
+//printf("jsmn_parse_string: value-%c, pos-%d\n", c,parser->pos);
+
+ /* Quote: end of string */
+// if (c == '\"') {
+ if (d == '\"') {
+// if ((d == '\"')&&((e == ' ')||(e == ','))) {
+parser->pos++;
+//printf("jsmn_parse_string: end of string\n");
+ if (tokens == NULL) {
+//printf("jsmn_parse_string: end tokens is NULL\n");
+ return 0;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+//printf("jsmn_parse_string: Allocated tokens \n");
+ if (token == NULL) {
+//printf("jsmn_parse_string: Allocated tokens is NULL\n");
+ parser->pos = start;
+ return JSMN_ERROR_NOMEM;
+ }
+ jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+//printf("jsmn_parse_string: Allocated tokens is filled\n");
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ return 0;
+ }
+
+ /* Backslash: Quoted symbol expected */
+ if (c == '\\' && parser->pos + 1 < len) {
+ int i;
+ parser->pos++;
+//printf("jsmn_parse_string: value - %c, POS-%3d \n",c, js[parser->pos]);
+ switch (js[parser->pos]) {
+ /* Allowed escaped symbols */
+ case '\"': case '/' : case '\\' : case 'b' :
+ case 'f' : case 'r' : case 'n' : case 't' :
+ break;
+ /* Allows escaped symbol \uXXXX */
+ case 'u':
+ parser->pos++;
+ for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+ /* If it isn't a hex character we have an error */
+ if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ parser->pos++;
+ }
+ parser->pos--;
+ break;
+ /* Unexpected symbol */
+ default:
+ parser->pos = start;
+ return JSMN_ERROR_INVAL;
+ }
+ }
+ }
+ parser->pos = start;
+printf("jsmn_parse_string: exiting with ERROR_PART, pos-%d", parser->pos);
+ return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens) {
+ int r;
+ int i;
+ jsmntok_t *token;
+ int count = parser->toknext;
+
+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+ char c;
+ jsmntype_t type;
+
+ c = js[parser->pos];
+//printf("jsmn_parse: value of c - %c\n",c);
+ switch (c) {
+ case '{': case '[':
+ count++;
+ if (tokens == NULL) {
+ break;
+ }
+ token = jsmn_alloc_token(parser, tokens, num_tokens);
+ if (token == NULL)
+ return JSMN_ERROR_NOMEM;
+ if (parser->toksuper != -1) {
+ tokens[parser->toksuper].size++;
+//#ifdef JSMN_PARENT_LINKS
+ token->parent = parser->toksuper;
+//#endif
+ }
+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+ token->start = parser->pos;
+ parser->toksuper = parser->toknext - 1;
+ break;
+ case '}': case ']':
+ if (tokens == NULL)
+ break;
+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+//#ifdef JSMN_PARENT_LINKS
+ if (parser->toknext < 1) {
+ return JSMN_ERROR_INVAL;
+ }
+ token = &tokens[parser->toknext - 1];
+ for (;;) {
+ if (token->start != -1 && token->end == -1) {
+ if (token->type != type) {
+ return JSMN_ERROR_INVAL;
+ }
+ token->end = parser->pos + 1;
+ parser->toksuper = token->parent;
+ break;
+ }
+ if (token->parent == -1) {
+ break;
+ }
+ token = &tokens[token->parent];
+ }
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// if (token->type != type) {
+// return JSMN_ERROR_INVAL;
+// }
+// parser->toksuper = -1;
+// token->end = parser->pos + 1;
+// break;
+// }
+// }
+// /* Error if unmatched closing bracket */
+// if (i == -1) return JSMN_ERROR_INVAL;
+// for (; i >= 0; i--) {
+// token = &tokens[i];
+// if (token->start != -1 && token->end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+//#endif
+ break;
+ case '\"':
+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+ case '\t' : case '\r' : case '\n' : case ' ':
+ break;
+ case ':':
+ parser->toksuper = parser->toknext - 1;
+//printf("jsmn_parse: value of c is :: - %c\n",c);
+ break;
+ case ',':
+ if (tokens != NULL && parser->toksuper != -1 &&
+ tokens[parser->toksuper].type != JSMN_ARRAY &&
+ tokens[parser->toksuper].type != JSMN_OBJECT) {
+//#ifdef JSMN_PARENT_LINKS
+ parser->toksuper = tokens[parser->toksuper].parent;
+//#else
+// for (i = parser->toknext - 1; i >= 0; i--) {
+// if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+// if (tokens[i].start != -1 && tokens[i].end == -1) {
+// parser->toksuper = i;
+// break;
+// }
+// }
+// }
+//#endif
+ }
+ break;
+#ifdef JSMN_STRICT
+ /* In strict mode primitives are: numbers and booleans */
+ case '-': case '0': case '1' : case '2': case '3' : case '4':
+ case '5': case '6': case '7' : case '8': case '9':
+ case 't': case 'f': case 'n' :
+ /* And they must not be keys of the object */
+ if (tokens != NULL && parser->toksuper != -1) {
+ jsmntok_t *t = &tokens[parser->toksuper];
+ if (t->type == JSMN_OBJECT ||
+ (t->type == JSMN_STRING && t->size != 0)) {
+ return JSMN_ERROR_INVAL;
+ }
+ }
+#else
+ /* In non-strict mode every unquoted value is a primitive */
+ default:
+#endif
+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+ if (r < 0) return r;
+ count++;
+ if (parser->toksuper != -1 && tokens != NULL)
+ tokens[parser->toksuper].size++;
+ break;
+
+#ifdef JSMN_STRICT
+ /* Unexpected char in strict mode */
+ default:
+ return JSMN_ERROR_INVAL;
+#endif
+ }
+ }
+
+ if (tokens != NULL) {
+ for (i = parser->toknext - 1; i >= 0; i--) {
+//printf("index -%2d, start is %3d, end is %3d\n", i, tokens[i].start, tokens[i].end);
+ /* Unmatched opened object or array */
+ if (tokens[i].start != -1 && tokens[i].end == -1) {
+ return JSMN_ERROR_PART;
+ }
+ }
+ }
+
+ return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+void jsmn_init(jsmn_parser *parser) {
+ parser->pos = 0;
+ parser->toknext = 0;
+ parser->toksuper = -1;
+}
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+ if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
+ strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+ return 0;
+ }
+ return -1;
+}
+
+void printToken(char * js, jsmntok_t * tokens, int numToken)
+{
+ for (int i = 1; i < numToken; i++)
+ {
+ printf("Token number-%2d, parent-%2d, type-%d size-%2d, parameter -", i, tokens[i].parent, tokens[i].type, tokens[i].size);
+ if (tokens[i].type == JSMN_STRING || tokens[i].type == JSMN_PRIMITIVE) {
+ printf("%.*s\n", tokens[i].end - tokens[i].start, js + tokens[i].start);
+ } else if (tokens[i].type == JSMN_ARRAY) {
+ printf("[%d elems]\n", tokens[i].size);
+ } else if (tokens[i].type == JSMN_OBJECT) {
+ printf("{%d elems}\n", tokens[i].size);
+ } else {
+ printf("value?? - ");
+ TOKEN_PRINT(tokens[i]);
+ }
+ }
+}
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * gParam,char * value, int maxValueSize)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ memset(value, 0, maxValueSize);
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], gParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Grand Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 2; //Parent token not seen
+ }
+
+ for (i=dpToken; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+ TOKEN_COPY(js, tokens[i+1], value);
+
+ return 0; //Success
+ }
+ }
+
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ if(jsoneq(js, &tokens[i], param) != 0)
+ {
+ continue;
+ }
+
+ if(tokens[i+1].type != JSMN_PRIMITIVE)
+ return 3; //Wrong parameter type
+
+// printf("INT parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], val);
+ *value = atoi(val);
+// printf(" - %d\n", *value);
+
+ return 0; //success
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+void parseDirectParameters(char * js, jsmntok_t * tokens, int numToken)
+{
+ int i = 0;
+ int dpToken = 0;
+ char param[128];
+ char value[128];
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], "directParameters") == 0)
+ break;
+ }
+
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+
+ for (int i = 1; i < numToken; i++)
+ {
+ memset(param, 0, 128);
+ memset(value, 0, 128);
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+ TOKEN_COPY(js, tokens[i], param);
+// printf("parameter / Value - %s", param);
+ TOKEN_COPY(js, tokens[i+1], value);
+// printf(" - %s\n", value);
+ }
+ }
+}
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_ARRAY)
+ {
+ *numElements = tokens[i+1].size;
+// printf("[%d elems]\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k], arrayValue[k].arrayString);
+// printf(" - %s\n", arrayValue[k].arrayString);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam)
+{
+ int i = 0;
+ int dpToken = 0;
+ char val[128];
+
+ memset(val, 0, 128);
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING)
+ {
+ if(jsoneq(js, &tokens[i], param) == 0)
+ {
+ return 0; //Token present
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //Token Not present
+}
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements)
+{
+ int i = 0;
+ int dpToken = 0;
+
+ for (i = 1; i < numToken; i++)
+ {
+ if(jsoneq(js, &tokens[i], pParam) == 0)
+ break;
+ }
+ if (i < numToken)
+ {
+ dpToken = ++i;
+ }
+ else
+ {
+ printf("The parameter %s is not present in JSON file\n", pParam);
+ return 1; //Parent token not seen
+ }
+ for (i=1; i < numToken; i++)
+ {
+ if (tokens[i].parent == dpToken && tokens[i].type == JSMN_STRING && tokens[i].size == 1)
+ {
+// printf("value of token %d\n", i);
+ if(jsoneq(js, &tokens[i], param) != 0)
+ continue;
+
+ if (tokens[i+1].type == JSMN_OBJECT)
+ {
+ *numElements = tokens[i+1].size;
+// printf("{%d elems}\n", *numElements);
+
+ for (int k = 0; k < *numElements; k++)
+ {
+ TOKEN_COPY(js, tokens[i+2+k*2], keyValueResultList[k].keyStr);
+// printf("Key - %s", keyValueResultList[k].keyStr);
+ TOKEN_COPY(js, tokens[i+3+k*2], keyValueResultList[k].valStr);
+// printf("Value - %s\n", keyValueResultList[k].valStr);
+ }
+ return 0; //Success
+ }
+ }
+ }
+ printf("The parameter %s is not present in JSON file\n", param);
+ return 2; //parameter not found
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.h b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.h
new file mode 100644
index 0000000..f9d838b
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/jsmn.h
@@ -0,0 +1,136 @@
+/*************************************************************************//**
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __JSMN_H_
+#define __JSMN_H_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * o Object
+ * o Array
+ * o String
+ * o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+ JSMN_UNDEFINED = 0,
+ JSMN_OBJECT = 1,
+ JSMN_ARRAY = 2,
+ JSMN_STRING = 3,
+ JSMN_PRIMITIVE = 4
+} jsmntype_t;
+
+enum jsmnerr {
+ /* Not enough tokens were provided */
+ JSMN_ERROR_NOMEM = -1,
+ /* Invalid character inside JSON string */
+ JSMN_ERROR_INVAL = -2,
+ /* The string is not a full JSON packet, more bytes expected */
+ JSMN_ERROR_PART = -3
+};
+
+typedef struct arrayValues {
+ char arrayString[32];
+} ARRAYVAL;
+
+typedef struct keyValResult {
+ char keyStr[80];
+ char valStr[250];
+ char resultStr[80];
+} KEYVALRESULT;
+
+/**
+ * JSON token description.
+ * @param type type (object, array, string etc.)
+ * @param start start position in JSON data string
+ * @param end end position in JSON data string
+ */
+typedef struct {
+ jsmntype_t type;
+ int start;
+ int end;
+ int size;
+//#ifdef JSMN_PARENT_LINKS
+ int parent;
+//#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string
+ */
+typedef struct {
+ unsigned int pos; /* offset in the JSON string */
+ unsigned int toknext; /* next token to allocate */
+ int toksuper; /* superior token node, e.g parent object or array */
+} jsmn_parser;
+
+#define TOKEN_EQ(t, tok_start, tok_end, tok_type) \
+ ((t).start == tok_start \
+ && (t).end == tok_end \
+ && (t).type == (tok_type))
+
+#define TOKEN_STRING(js, t, s) \
+ (strncmp(js+(t).start, s, (t).end - (t).start) == 0 \
+ && strlen(s) == (t).end - (t).start)
+
+#define TOKEN_COPY(js, t, s) \
+ strncpy(s, js+(t).start, (t).end - (t).start)
+
+#define TOKEN_PRINT(t) \
+ printf("start: %d, end: %d, type: %d, size: %d\n", \
+ (t).start, (t).end, (t).type, (t).size)
+
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each describing
+ * a single JSON object.
+ */
+int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+ jsmntok_t *tokens, unsigned int num_tokens);
+
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
+
+void printToken(char * js, jsmntok_t * tokens, int numToken);
+
+int getStringToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char * value, int maxValueSize);
+
+int getIntToken(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, int * value);
+
+int getArrayTokens(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, ARRAYVAL * arrayValue, int * numElements);
+
+int isTokenPresent(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam);
+
+int read_keyVal_params(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, KEYVALRESULT * keyValueResultList, int * numElements);
+
+int getStringTokenV2(char * js, jsmntok_t * tokens, int numToken, char * param, char * pParam, char *gParam, char * value, int maxValueSize);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __JSMN_H_ */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/meas_config.json b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/meas_config.json
new file mode 100644
index 0000000..c06172d
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/meas_config.json
@@ -0,0 +1,52 @@
+{
+ "tmp_directParameters": {
+ "eventName": "Measurement_vFirewall-AT&T_nicPerformance",
+ "eventType": "applicationVnf",
+ "nfcNamingCode": "AFX",
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "priority": "Low",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "timeZoneOffset": "UTC-05:30",
+ "measurementInterval": 20,
+ "tmp_device": ["lo", "enp0s3", "docker0"]
+
+ },
+ "tmp_indirectParameters": {
+ "tmp_init":{
+ "tmp_t0BytesIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f2",
+ "tmp_t0BytesOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f10",
+ "tmp_t0PacketsIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f3",
+ "tmp_t0PacketsOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f11"
+ },
+ "vNicPerformance": {
+ "tmp_vnic_command": {
+ "tmp_t1BytesIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f2",
+ "tmp_t1BytesOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f10",
+ "tmp_t1PacketsIn": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f3",
+ "tmp_t1PacketsOut": "sudo cat /proc/net/dev | grep $tmp_device | tr -s ' ' | cut -d ':' -f2 | cut -d ' ' -f11"
+ },
+ "receivedOctetsDelta": "$(tmp_t1BytesIn - tmp_t0BytesIn)",
+ "receivedTotalPacketsDelta": "$(tmp_t1PacketsIn - tmp_t0PacketsIn)",
+ "transmittedOctetsDelta": "$(tmp_t1BytesOut - tmp_t0BytesOut)",
+ "transmittedTotalPacketsDelta": "$(tmp_t1PacketsOut - tmp_t0PacketsOut)",
+ "valuesAreSuspect": "true",
+ "vNicIdentifier": "$tmp_device"
+ }
+ "cpuUsage": {
+ "tmp_cpuuse_command": {
+ "tmp_cpuUseCmd": "/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 | cut -d ':' -f2",
+ "tmp_cpuIdle": "/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 |cut -d ':' -f2 | cut -d ',' -f4 | cut -b 1-5",
+ "tmp_cpuUsageSystem": "/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 |cut -d ':' -f2 | cut -d ',' -f2 | cut -b 1-5",
+ "tmp_cpuUsageUser": "/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 |cut -d ':' -f2 | cut -d ',' -f1 | cut -b 1-5"
+ },
+ "cpuIdentifier": "Cpu1",
+ "cpuIdle": "$tmp_cpuIdle",
+ "cpuUsageSystem": "$tmp_cpuUsageSystem",
+ "cpuUsageUser": "$tmp_cpuUsageUser"
+ }
+ }
+}
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/pom.xml b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/pom.xml
new file mode 100644
index 0000000..f9f42eb
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START==========================================
+ ===================================================================
+ 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.
+ ============LICENSE_END============================================
+
+ ECOMP and OpenECOMP are trademarks
+ and service marks of AT&T Intellectual Property.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+<parent>
+ <groupId>org.onap.demo.vnf</groupId>
+ <artifactId>demo-aggregator</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.demo.vnf.ves5</groupId>
+ <artifactId>ves_vfw_reporting</artifactId>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>never</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <descriptor>dep.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-archive</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/sample_measurement_event.txt b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/sample_measurement_event.txt
new file mode 100644
index 0000000..b76b382
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/sample_measurement_event.txt
@@ -0,0 +1,65 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "domain": "measurement",
+ "eventId": "mvfs000000005",
+ "eventName": "Measurement_vFirewall-AT&T_nicPerformance",
+ "eventType": "applicationVnf",
+ "lastEpochMicrosec": 1547139835280053,
+ "nfNamingCode": "AFX",
+ "nfVendorName": "AT&T",
+ "nfcNamingCode": "AFX",
+ "priority": "Normal",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "reportingEntityName": "ibcx0001vm002oam001",
+ "sequence": 0,
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "sourceName": "scfx0001vm002cap001",
+ "startEpochMicrosec": 1547139813738836,
+ "timeZoneOffset": "UTC-05:30",
+ "version": "4.1",
+ "vesEventListenerVersion": "7.1"
+ },
+ "measurementFields": {
+ "cpuUsageArray": [
+ {
+ "cpuIdentifier": "Cpu1",
+ "cpuIdle": 25.0,
+ "cpuUsageSystem": 25.0,
+ "cpuUsageUser": 33.3,
+ "percentUsage": 0.0
+ }
+ ],
+ "measurementFieldsVersion": "4.0",
+ "measurementInterval": 60,
+ "nicPerformanceArray": [
+ {
+ "nicIdentifier": "lo",
+ "receivedOctetsDelta": 2811.0,
+ "receivedTotalPacketsDelta": 18.0,
+ "transmittedOctetsDelta": 2811.0,
+ "transmittedTotalPacketsDelta": 18.0,
+ "valuesAreSuspect": "true"
+ },
+ {
+ "nicIdentifier": "enp0s3",
+ "receivedOctetsDelta": 354.0,
+ "receivedTotalPacketsDelta": 4.0,
+ "transmittedOctetsDelta": 350.0,
+ "transmittedTotalPacketsDelta": 4.0,
+ "valuesAreSuspect": "true"
+ },
+ {
+ "nicIdentifier": "docker0",
+ "receivedOctetsDelta": 0.0,
+ "receivedTotalPacketsDelta": 0.0,
+ "transmittedOctetsDelta": 0.0,
+ "transmittedTotalPacketsDelta": 0.0,
+ "valuesAreSuspect": "true"
+ }
+ ],
+ "requestRate": 0.0
+ }
+ }
+}
+
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/vpp_measurement_reporter.c b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/vpp_measurement_reporter.c
new file mode 100644
index 0000000..40bd3aa
--- /dev/null
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW/vpp_measurement_reporter.c
@@ -0,0 +1,694 @@
+/*************************************************************************//**
+ *
+ * Copyright © 2019 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.
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include "jsmn.h"
+#include "evel.h"
+
+#define BUFSIZE 128
+#define MAX_BUFFER_SIZE 4096
+#define MAX_TOKENS 1000
+#define MAX_INTERFACES 40
+
+void *MeasThread(void *threadarg);
+
+typedef struct dummy_vpp_metrics_struct {
+ int curr_bytes_in;
+ int curr_bytes_out;
+ int curr_packets_in;
+ int curr_packets_out;
+ int last_bytes_in;
+ int last_bytes_out;
+ int last_packets_in;
+ int last_packets_out;
+} vpp_metrics_struct;
+
+typedef struct linkstat {
+
+ char linkname[32];
+ char linkdescr[64];
+ char linkmode[64];
+ int speedmbps;
+
+}LINKSTAT;
+
+vpp_metrics_struct meas_intfstat[MAX_INTERFACES];
+LINKSTAT meas_linkstat[MAX_INTERFACES];
+
+unsigned long long epoch_start = 0;
+
+int format_val_params(KEYVALRESULT * keyValArray, int numElements, const char *replace, const char *search)
+{
+ char *sp;
+ int i =0;
+ int search_len;
+ int replace_len;
+ int tail_len;
+
+ for (i=0; i<numElements; i++)
+ {
+ if ((sp = strstr(keyValArray[i].valStr, search)) == NULL) {
+ printf("\n String not found\n");
+ return 1; //Error search string not found
+ }
+
+ search_len = strlen(search);
+ replace_len = strlen(replace);
+ tail_len = strlen(sp+search_len);
+ memmove(sp+replace_len,sp+search_len,tail_len+1);
+ memcpy(sp, replace, replace_len);
+// printf("\n Changed value for i=%d is %s", i, keyValArray[i].valStr);
+ }
+ return 0; //search and replace is successful
+}
+
+void runCommands(KEYVALRESULT * commandArray, int numCommands)
+{
+
+ char buf[BUFSIZE]; /* buffer used to store VPP metrics */
+ FILE *fp; /* file descriptor to pipe cmd to shell */
+ int i;
+
+ for(i = 0; i < numCommands; i++)
+ {
+ memset(buf, 0, BUFSIZE);
+
+ // Open a pipe and read VPP values
+ if ((fp = popen(commandArray[i].valStr, "r")) == NULL) {
+ printf("Error opening pipe!\n");
+ return;
+ }
+
+ while (fgets(buf, BUFSIZE, fp) != NULL);
+ strcpy(commandArray[i].resultStr, buf);
+
+ if(pclose(fp)) {
+ printf("Command not found or exited with error status\n");
+ return;
+ }
+ }
+ //for(i = 0; i < numCommands; i++)
+ // printf("-%d-valstr and resultStr is- %s - %s\n", i, commandArray[i].valStr, commandArray[i].resultStr);
+ printf("%d - %d - %d - %d\n", atoi(commandArray[0].resultStr), atoi(commandArray[1].resultStr), atoi(commandArray[2].resultStr), atoi(commandArray[3].resultStr));
+}
+
+
+void copy_vpp_metic_data(vpp_metrics_struct *intfstats, KEYVALRESULT * cmdArray, int numCmds, int linkNum)
+{
+ int i;
+
+ // Store the current metric in the last metric
+ intfstats[linkNum].last_bytes_in = intfstats[linkNum].curr_bytes_in;
+ intfstats[linkNum].last_bytes_out = intfstats[linkNum].curr_bytes_out;
+ intfstats[linkNum].last_packets_in = intfstats[linkNum].curr_packets_in;
+ intfstats[linkNum].last_packets_out = intfstats[linkNum].curr_packets_out;
+
+ // Store metrics read from the vNIC in the current
+ for(i=0; i<numCmds; i++)
+ {
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0BytesIn") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1BytesIn") == 0))
+ intfstats[linkNum].curr_bytes_in = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0BytesOut") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1BytesOut") == 0))
+ intfstats[linkNum].curr_bytes_out = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0PacketsIn") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1PacketsIn") == 0))
+ intfstats[linkNum].curr_packets_in = atoi(cmdArray[i].resultStr);
+
+ if((strcmp(cmdArray[i].keyStr, "tmp_t0PacketsOut") == 0) ||
+ (strcmp(cmdArray[i].keyStr, "tmp_t1PacketsOut") == 0))
+ intfstats[linkNum].curr_packets_out = atoi(cmdArray[i].resultStr);
+ }
+ // printf("intfstats[%d].curr_bytes_in = %d\n", linkNum, intfstats[linkNum].curr_bytes_in);
+ // printf("intfstats[%d].curr_bytes_out = %d\n", linkNum, intfstats[linkNum].curr_bytes_out);
+ // printf("intfstats[%d].curr_packets_in = %d\n", linkNum, intfstats[linkNum].curr_packets_in);
+ // printf("intfstats[%d].curr_packets_out = %d\n", linkNum, intfstats[linkNum].curr_packets_out);
+}
+
+int get_priority(char * inStr)
+{
+ int result = -1;
+
+ if(strcmp(inStr, "High") == 0)
+ result = EVEL_PRIORITY_HIGH;
+ else if(strcmp(inStr, "Medium") == 0)
+ result = EVEL_PRIORITY_MEDIUM;
+ else if(strcmp(inStr, "Normal") == 0)
+ result = EVEL_PRIORITY_NORMAL;
+ else if(strcmp(inStr, "Low") == 0)
+ result = EVEL_PRIORITY_LOW;
+
+ return result;
+}
+
+/**************************************************************************//**
+ * tap live cpu stats
+ *****************************************************************************/
+void evel_get_cpu_stats(EVENT_MEASUREMENT * measurement)
+{
+ FILE *fp;
+ char path[1024];
+ double usage=0.0;
+ double idle;
+ double intrpt;
+ double nice;
+ double softirq;
+ double steal;
+ double sys;
+ double user;
+ double wait;
+ MEASUREMENT_CPU_USE *cpu_use = NULL;
+
+ /* Open the command for reading. */
+ //fp = popen("/bin/ls /etc/", "r");
+ fp = popen("/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 ", "r");
+ if (fp == NULL) {
+ printf("Failed to run command\n" );
+ exit(1);
+ }
+
+ /* Read the output a line at a time - output it. */
+ while (fgets(path, sizeof(path)-1, fp) != NULL) {
+ printf("%s", path+10);
+ sscanf(path+10," %lf us, %lf sy, %lf ni, %lf id, %lf wa, %lf hi, %lf si, %lf st",
+ &user,&sys,&nice,&idle,&wait,&intrpt,&softirq,&steal);
+ }
+
+ /* close */
+ pclose(fp);
+
+ cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", usage);
+ if( cpu_use != NULL ){
+
+ evel_measurement_cpu_use_idle_set(cpu_use,idle);
+ //evel_measurement_cpu_use_interrupt_set(cpu_use,intrpt);
+ //evel_measurement_cpu_use_nice_set(cpu_use,nice);
+ //evel_measurement_cpu_use_softirq_set(cpu_use,softirq);
+ //evel_measurement_cpu_use_steal_set(cpu_use,steal);
+ evel_measurement_cpu_use_system_set(cpu_use,sys);
+ evel_measurement_cpu_use_usageuser_set(cpu_use,user);
+ //evel_measurement_cpu_use_wait_set(cpu_use,wait);
+ //evel_measurement_cpu_use_add(measurement, "cpu2", usage,idle,intrpt,nice,softirq,steal,sys,user,wait);
+ }
+}
+
+int measure_traffic()
+{
+
+ FILE *fp;
+ int status;
+ char count[10];
+ time_t rawtime;
+ struct tm * timeinfo;
+ char period [21];
+ char cmd [100];
+ char secs [3];
+ int sec;
+ int request_rate=0;
+
+ printf("Checking app traffic\n");
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo);
+ strftime(secs,3,"%S",timeinfo);
+ sec = atoi(secs);
+ if (sec == 0) sec = 59;
+ sprintf(secs, "%02d", sec);
+ strncat(period, secs, 21);
+ // ....x....1....x....2.
+ // 15/Oct/2016:17:51:19
+ strcpy(cmd, "sudo docker logs vHello | grep -c ");
+ strncat(cmd, period, 100);
+ fp = popen(cmd, "r");
+ if (fp == NULL) {
+ EVEL_ERROR("popen failed to execute command");
+ }
+
+ if (fgets(count, 10, fp) != NULL) {
+ request_rate = atoi(count);
+ printf("Reporting request rate for second: %s as %d\n", period, request_rate);
+
+ }
+ else {
+ EVEL_ERROR("New Measurement failed");
+ }
+ printf("Processed measurement\n");
+
+ status = pclose(fp);
+ if (status == -1) {
+ EVEL_ERROR("pclose returned an error");
+ }
+ return request_rate;
+}
+
+
+
+int main(int argc, char** argv)
+{
+ char* fqdn = argv[1];
+ int port = atoi(argv[2]);
+ int i=0;
+ int rc;
+ pthread_attr_t attr;
+ pthread_t meas_thread;
+ char* fqdn2 = NULL;
+ int port2 = 0;
+
+ if(argc == 5)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ }
+
+ if (!((argc == 3) || (argc == 5)))
+ {
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> \n", argv[0]);
+ fprintf(stderr, "OR\n");
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> \n", argv[0]);
+ exit(-1);
+ }
+
+ /**************************************************************************/
+ /* Initialize */
+ /**************************************************************************/
+ if(evel_initialize(fqdn, /* FQDN */
+ port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 0, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ NULL, /* ca info */
+ NULL, /* ca file */
+ 0, /* verify peer */
+ 0, /* verify host */
+ "sample1", /* Username */
+ "sample1", /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
+ NULL, /* Source ip */
+ NULL, /* Source ip2 */
+ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
+ "vFirewall", /* Role */
+ 1)) /* Verbosity */
+ {
+ fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
+ exit(-1);
+ }
+ else
+ {
+ printf("\nInitialization completed\n");
+ }
+
+ /* Initialize and set thread detached attribute */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ printf("Main:Creating thread \n");
+ rc = pthread_create(&meas_thread, NULL, MeasThread, &i);
+ if (rc)
+ {
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ exit(-1);
+ }
+ printf("Main:Created Meas thread \n");
+
+ pthread_join(meas_thread, NULL);
+
+ evel_terminate();
+ printf("Terminated\n");
+ return 0;
+}
+
+void *MeasThread(void *mainMeas)
+{
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ EVENT_MEASUREMENT * vpp_m = NULL;
+ MEASUREMENT_CPU_USE *cpu_use = NULL;
+ EVENT_HEADER* vpp_m_header = NULL;
+ int bytes_in;
+ int bytes_out;
+ int packets_in;
+ int packets_out;
+ unsigned long long epoch_now;
+ int request_rate = 0;
+
+ struct timeval time_val;
+ MEASUREMENT_NIC_PERFORMANCE * vnic_performance = NULL;
+ char event_id1[10] = "mvfs";
+ char event_id2[15] = {0};
+ char event_id[BUFSIZE] = {0};
+ int meas_event_id = 0;
+
+ int numToken;
+ jsmntok_t tokens[MAX_TOKENS];
+ char js[MAX_BUFFER_SIZE];
+
+ jsmn_parser p;
+ char ch[BUFSIZE];
+ int ret = 0;
+ char eName[BUFSIZE];
+ char eType[BUFSIZE];
+ char nfcCode[BUFSIZE];
+ char nfCode[BUFSIZE];
+ char nfVendor[BUFSIZE];
+ char prio[BUFSIZE];
+ char reportEId[BUFSIZE];
+ char reportEName[BUFSIZE];
+ char srcId[BUFSIZE];
+ char srcName[BUFSIZE];
+ char timeZOff[BUFSIZE];
+ char cpuId[BUFSIZE];
+
+ int priority;
+
+ char hostname[BUFSIZE];
+
+ int meas_interval;
+ ARRAYVAL intfArray[MAX_INTERFACES];
+ KEYVALRESULT keyValResultArray[32];
+ KEYVALRESULT keyValResultArray2[32];
+ KEYVALRESULT vnicCommandArray[32];
+ KEYVALRESULT cpuUsageCommandArray[32];
+ int numInitCommands = 0;
+ int numVnicCommands = 0;
+ int numCpuUsageCommands = 0;
+ int linkCount = 0;
+ double usage=0.0;
+ double cpuIdle=0.0;
+ double cpuSystem=0.0;
+ double cpuUser=0.0;
+ double intrpt;
+ double nice;
+ double softirq;
+ double steal;
+ double wait;
+
+ int i = 0;
+
+ memset(hostname, 0, BUFSIZE);
+ gethostname(hostname, BUFSIZE);
+ printf("MeasThread::The hostname is %s\n", hostname);
+
+ sleep(1);
+ printf("MeasThread::Running Meas thread \n");
+ fflush(stdout);
+
+ memset(&intfArray[0],0,(sizeof(ARRAYVAL) * MAX_INTERFACES));
+ memset(&keyValResultArray[0],0,(sizeof(KEYVALRESULT) * 32));
+
+ memset(js, 0, MAX_BUFFER_SIZE);
+ memset(ch, 0, BUFSIZE);
+ memset(&meas_intfstat[0],0,(sizeof(vpp_metrics_struct)* MAX_INTERFACES));
+ memset(&meas_linkstat[0],0,(sizeof(LINKSTAT) * MAX_INTERFACES));
+
+ FILE * file = fopen("meas_config.json", "r");
+
+ while((fgets(ch, (BUFSIZE-1), file)) !=NULL)
+ {
+ strcat(js, ch);
+ memset(ch, 0, BUFSIZE);
+ }
+// printf("MeasThread::the file content is \n %s \n", js);
+
+ jsmn_init(&p);
+ numToken = jsmn_parse(&p, js, strlen(js), tokens, MAX_TOKENS);
+ printf("MeasThread::count-%d\n", numToken);
+
+// printToken(js,tokens, numToken);
+
+
+ ret = getIntToken(js, tokens, numToken, "measurementInterval", "tmp_directParameters", &meas_interval);
+ if (ret != 0)
+ {
+ printf("MeasThread::The parameter measurementInterval is not defined, defaulted to 60 seconds\n");
+ meas_interval = 60;
+ }
+
+ ret = getArrayTokens(js, tokens, numToken, "tmp_device", "tmp_directParameters", intfArray, &linkCount);
+
+ printf("MeasThread::Array link count is %d\n", linkCount);
+
+ /* Copy the link information */
+ for(i=0;i<linkCount;i++)
+ {
+ strcpy(meas_linkstat[i].linkname, &intfArray[i]);
+// printf("MeasThread::Link name %s\n", meas_linkstat[i].linkname);
+ }
+
+
+ read_keyVal_params(js, tokens, numToken, "tmp_init", "tmp_indirectParameters", keyValResultArray, &numInitCommands);
+
+ for(i=0;i<linkCount;i++)
+ {
+ memset(&vnicCommandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(vnicCommandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ format_val_params(vnicCommandArray, numInitCommands, meas_linkstat[i].linkname, "$tmp_device");
+ runCommands(vnicCommandArray, numInitCommands);
+ copy_vpp_metic_data(meas_intfstat, vnicCommandArray, numInitCommands, i);
+ }
+
+ gettimeofday(&time_val, NULL);
+
+ sleep(meas_interval);
+
+ /***************************************************************************/
+ /* Collect metrics from the VNIC */
+ /***************************************************************************/
+ while(1)
+ {
+
+ ret = getIntToken(js, tokens, numToken, "measurementInterval", "tmp_directParameters", &meas_interval);
+ if (ret != 0)
+ {
+ meas_interval = 60;
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventName", "tmp_directParameters", eName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("MeasThread::Missing mandatory parameters - eventName is not there in tmp_directParameters. Exiting...\n");
+ exit(1);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "eventType", "tmp_directParameters", eType, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfcNamingCode", "tmp_directParameters", nfcCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfNamingCode", "tmp_directParameters", nfCode, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "nfVendorName", "tmp_directParameters", nfVendor, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "reportingEntityId", "tmp_directParameters", reportEId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "sourceId", "tmp_directParameters", srcId, BUFSIZE);
+ ret = getStringToken(js, tokens, numToken, "timeZoneOffset", "tmp_directParameters", timeZOff, BUFSIZE);
+
+ ret = getStringToken(js, tokens, numToken, "reportingEntityName", "tmp_directParameters", reportEName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("MeasThread::Missing mandatory parameters - reportingEntityName is not there in tmp_directParameters\n");
+ printf("MeasThread::Defaulting reportingEntityName to hostname\n");
+ strcpy(reportEName, hostname);
+ }
+ ret = getStringToken(js, tokens, numToken, "sourceName", "tmp_directParameters", srcName, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("MeasThread::Missing mandatory parameters - sourceName is not there in tmp_directParameters\n");
+ printf("MeasThread::Defaulting sourceName to hostname\n");
+ strcpy(srcName, hostname);
+ }
+
+ ret = getStringToken(js, tokens, numToken, "priority", "tmp_directParameters", prio, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("MeasThread::Missing mandatory parameters - priority is not there in tmp_directParameters\nDefaulting priority to Low\n");
+ strcpy(prio, "Medium");
+ }
+ priority = get_priority(prio);
+ if(priority == -1)
+ {
+ printf("MeasThread::Meas priority value is not matching, prioirty-%s \n", prio);
+ exit(1);
+ }
+
+ read_keyVal_params(js, tokens, numToken, "tmp_vnic_command", "vNicPerformance", keyValResultArray, &numVnicCommands);
+
+ for(i=0;i<linkCount;i++)
+ {
+ memset(&vnicCommandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+ memcpy(vnicCommandArray, keyValResultArray, (sizeof(KEYVALRESULT) * 32));
+ format_val_params(vnicCommandArray, numVnicCommands, meas_linkstat[i].linkname, "$tmp_device");
+ runCommands(vnicCommandArray, numVnicCommands);
+ copy_vpp_metic_data(meas_intfstat, vnicCommandArray, numVnicCommands, i);
+ }
+
+ memset(event_id, 0, BUFSIZE);
+ meas_event_id = meas_event_id+1;
+ sprintf(event_id2, "%09d", meas_event_id);
+ strcat(event_id, event_id1);
+ strcat(event_id, event_id2);
+
+ vpp_m = evel_new_measurement(meas_interval, eName,event_id);
+
+ if(vpp_m != NULL)
+ {
+ printf("New measurement report created...\n");
+
+ for (int i = 0; i < linkCount; i++)
+ {
+ if(meas_intfstat[i].curr_bytes_in - meas_intfstat[i].last_bytes_in > 0) {
+ bytes_in = meas_intfstat[i].curr_bytes_in - meas_intfstat[i].last_bytes_in;
+ }
+ else {
+ bytes_in = 0;
+ }
+ if(meas_intfstat[i].curr_bytes_out - meas_intfstat[i].last_bytes_out > 0) {
+ bytes_out = meas_intfstat[i].curr_bytes_out - meas_intfstat[i].last_bytes_out;
+ }
+ else {
+ bytes_out = 0;
+ }
+ if(meas_intfstat[i].curr_packets_in - meas_intfstat[i].last_packets_in > 0) {
+ packets_in = meas_intfstat[i].curr_packets_in - meas_intfstat[i].last_packets_in;
+ }
+ else {
+ packets_in = 0;
+ }
+ if(meas_intfstat[i].curr_packets_out - meas_intfstat[i].last_packets_out > 0) {
+ packets_out = meas_intfstat[i].curr_packets_out - meas_intfstat[i].last_packets_out;
+ }
+ else {
+ packets_out = 0;
+ }
+ vnic_performance = (MEASUREMENT_NIC_PERFORMANCE *)evel_measurement_new_nic_performance(meas_linkstat[i].linkname, "true");
+ evel_meas_nic_performance_add(vpp_m, vnic_performance);
+ evel_nic_performance_rx_total_pkt_delta_set(vnic_performance, packets_in);
+ evel_nic_performance_tx_total_pkt_delta_set(vnic_performance, packets_out);
+
+ evel_nic_performance_rx_octets_delta_set(vnic_performance, bytes_in);
+ evel_nic_performance_tx_octets_delta_set(vnic_performance, bytes_out);
+
+ if (strcmp(meas_linkstat[i].linkname, "docker") == 0)
+ {
+ request_rate = measure_traffic();
+ }
+ }
+
+ evel_measurement_request_rate_set(vpp_m, request_rate);
+
+ //evel_get_cpu_stats(vpp_m);
+ memset(&keyValResultArray2[0],0,(sizeof(KEYVALRESULT) * 32));
+ memset(&cpuUsageCommandArray[0],0,(sizeof(KEYVALRESULT) * 32));
+
+ ret = getStringToken(js, tokens, numToken, "cpuIdentifier", "cpuUsage", cpuId, BUFSIZE);
+ if (ret != 0)
+ {
+ printf("MeasThread::Missing parameters - cpuIdentifier is not there in cpuUsage, default to Cpu1\n");
+ strcpy(cpuId, "Cpu1");
+ }
+ read_keyVal_params(js, tokens, numToken, "tmp_cpuuse_command", "cpuUsage", keyValResultArray2, &numCpuUsageCommands);
+ memcpy(cpuUsageCommandArray, keyValResultArray2, (sizeof(KEYVALRESULT) * 32));
+ runCommands(cpuUsageCommandArray, numCpuUsageCommands);
+
+ cpu_use = evel_measurement_new_cpu_use_add(vpp_m, cpuId, usage);
+ if( cpu_use != NULL )
+ {
+/****************************
+ for(i=0; i<numCpuUsageCommands; i++)
+ {
+ if(strcmp(cpuUsageCommandArray[i].keyStr, "tmp_cpuIdle") == 0)
+ {
+ cpuIdle = atof(cpuUsageCommandArray[i].resultStr);
+ }
+ if(strcmp(cpuUsageCommandArray[i].keyStr, "tmp_cpuUsageSystem") == 0)
+ {
+ cpuSystem = atof(cpuUsageCommandArray[i].resultStr);
+ }
+ if(strcmp(cpuUsageCommandArray[i].keyStr, "tmp_cpuUsageUser") == 0)
+ {
+ cpuUser = atof(cpuUsageCommandArray[i].resultStr);
+ }
+ } **********************/
+ printf("%s", cpuUsageCommandArray[0].resultStr);
+ sscanf(cpuUsageCommandArray[0].resultStr, " %lf us, %lf sy, %lf ni, %lf id, %lf wa, %lf hi, %lf si, %lf st", &cpuUser,&cpuSystem,&nice,&cpuIdle,&wait,&intrpt,&softirq,&steal);
+printf("user - %f, system - %f, idle - %f\n", cpuUser, cpuSystem, cpuIdle);
+
+ evel_measurement_cpu_use_idle_set(cpu_use, cpuIdle);
+ evel_measurement_cpu_use_system_set(cpu_use, cpuSystem);
+ evel_measurement_cpu_use_usageuser_set(cpu_use, cpuUser);
+ }
+
+ struct timeval tv_now;
+ gettimeofday(&tv_now, NULL);
+ epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec;
+
+ vpp_m_header = (EVENT_HEADER *)vpp_m;
+
+
+ if (eType != NULL)
+ evel_measurement_type_set(vpp_m, eType);
+
+ evel_start_epoch_set(&vpp_m->header, epoch_start);
+ evel_last_epoch_set(&vpp_m->header, epoch_now);
+ epoch_start= epoch_now;
+
+ if(nfcCode != NULL)
+ evel_nfcnamingcode_set(&vpp_m->header, nfcCode);
+ if(nfCode != NULL)
+ evel_nfnamingcode_set(&vpp_m->header, nfCode);
+ evel_reporting_entity_name_set(&vpp_m->header, reportEName);
+ if(reportEId != NULL)
+ evel_reporting_entity_id_set(&vpp_m->header, reportEId);
+ if(timeZOff != NULL)
+ evel_time_zone_offset_set(&vpp_m->header, timeZOff);
+ if(nfVendor != NULL)
+ evel_nf_vendor_name_set(&vpp_m->header, nfVendor);
+ if(srcId != NULL )
+ evel_source_id_set(&vpp_m->header, srcId);
+ if(srcName!= NULL )
+ evel_source_name_set(&vpp_m->header, srcName);
+
+ evel_rc = evel_post_event(vpp_m_header);
+
+ if(evel_rc == EVEL_SUCCESS)
+ printf("MeasThread::Meas event is correctly sent to the collector!\n");
+ else
+ printf("MeasThread::Post failed %d (%s)\n", evel_rc, evel_error_string());
+ }
+ else
+ {
+ printf("MeasThread::Measurement event creation failed (%s)\n", evel_error_string());
+ }
+
+ sleep(meas_interval);
+ }
+
+ /***************************************************************************/
+ /* Terminate */
+ /***************************************************************************/
+ sleep(1);
+}
+
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 f0e4dea..8bb8a8e 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
@@ -70,7 +70,6 @@ char *functional_role = 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
@@ -100,7 +99,6 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn,
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,
@@ -228,10 +226,12 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn,
/***************************************************************************/
offset = sprintf(version_string, "%d", EVEL_API_MAJOR_VERSION);
+/******************
if (EVEL_API_MINOR_VERSION != 0)
{
sprintf(version_string + offset, ".%d", EVEL_API_MINOR_VERSION);
}
+**************/
/***************************************************************************/
/* Build a common base of the API URLs. */
@@ -308,7 +308,6 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn,
bakup_source_ip,
ring_buf_size,
secure,
- activmode,
cert_file_path,
key_file_path,
ca_info,
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 c149749..9de3868 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
@@ -47,8 +47,8 @@ extern "C" {
/* Supported API version. */
/*****************************************************************************/
#define EVEL_API_MAJOR_VERSION 7
-#define EVEL_API_MINOR_VERSION 0
-#define EVEL_API_PATCH_VERSION 2
+#define EVEL_API_MINOR_VERSION 1
+#define EVEL_API_PATCH_VERSION 0
/**************************************************************************//**
* Error codes
@@ -2975,7 +2975,6 @@ typedef struct copyright {
* @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
@@ -3005,7 +3004,6 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn,
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,
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c
index a33e5e1..ca8206b 100644
--- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c
@@ -145,6 +145,7 @@ void evel_free_batch(EVENT_HEADER * event)
evel_free_event(batch_field);
batch_field = dlist_pop_last(&event->batch_events);
}
+ evel_free_header(event);
EVEL_EXIT();
}
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 88ef12f..7200e06 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
@@ -604,7 +604,7 @@ 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);
- char * version = "4.0.2";
+ char * version = "4.1";
evel_enc_kv_string(jbuf, "version", version);
// evel_enc_version(
// jbuf, "version", event->major_version, event->minor_version);
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 4127f25..12ba7cd 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,12 @@
* How long we're prepared to wait for the API service to respond in
* seconds.
*****************************************************************************/
-static const int EVEL_API_TIMEOUT = 10;
+static const int EVEL_API_TIMEOUT = 5;
+
+/**************************************************************************//**
+ * Wait time if both the collectors are not responding
+ *****************************************************************************/
+static const int EVEL_COLLECTOR_RECONNECTION_WAIT_TIME = 120;
/*****************************************************************************/
/* Prototypes of locally scoped functions. */
@@ -58,29 +63,24 @@ 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();
+static EVEL_ERR_CODES evel_setup_curl();
+static EVEL_ERR_CODES evel_send_to_another_collector(const EVEL_EVENT_DOMAINS evel_domain, char * json_body, size_t json_size);
/**************************************************************************//**
* Buffers for error strings from libcurl.
*****************************************************************************/
static char curl_err_string[CURL_ERROR_SIZE] = "<NULL>";
-static char curl_err_string2[CURL_ERROR_SIZE] = "<NULL>";
/**************************************************************************//**
* 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.
@@ -136,6 +136,8 @@ static char * evel_password = NULL;
static char * evel_username2 = NULL;
static char * evel_password2 = NULL;
+static long http_response_code = 0;
+static int evel_collector_id = 1;
/**************************************************************************//**
* Initialize the event handler.
*
@@ -167,7 +169,6 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
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,
@@ -181,9 +182,7 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
int verbosity)
{
int rc = EVEL_SUCCESS;
- CURLcode curl_rc = CURLE_OK;
char batch_api_url[EVEL_MAX_URL_LEN + 1] = {0};
- char local_address[64];
EVEL_ENTER();
@@ -200,7 +199,6 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
assert(password2 != NULL);
}
-
/***************************************************************************/
/* Store the API URLs. */
/***************************************************************************/
@@ -211,13 +209,14 @@ 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);
+ sprintf(batch_api_url,"%s/eventBatch",bakup_api_url);
evel_bbatch_api_url = strdup(batch_api_url);
assert(evel_bbatch_api_url != NULL);
evel_bthrot_api_url = strdup(throt_api_url);
@@ -225,9 +224,9 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
curr_global_handles = 2;
}
- /***********************************************************************//**
- * Store other parameters
- ***************************************************************************/
+ /***************************************************************************/
+ /* Store other parameters */
+ /***************************************************************************/
evel_secure = secure;
evel_verbosity = verbosity;
@@ -313,6 +312,83 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
else {
EVEL_INFO("Old Curl version.");
}
+
+ /***************************************************************************/
+ /* Initialize a message ring-buffer to be used between the foreground and */
+ /* the thread which sends the messages. This can't fail. */
+ /***************************************************************************/
+ if( ring_buf_size < EVEL_EVENT_BUFFER_DEPTH )
+ {
+ log_error_state("Warning: Failed to initialize Ring buffer size to %d. ",
+ ring_buf_size);
+ goto exit_label;
+ }
+ ring_buffer_initialize(&event_buffer, EVEL_EVENT_BUFFER_DEPTH);
+
+exit_label:
+
+ EVEL_EXIT();
+
+ return rc;
+
+}
+/**************************************************************************//**
+ * Setup the curl connection to collector
+ *
+ * Primarily responsible for getting CURL ready to send message. Also it would
+ * be used to swithch over to other collector
+ *****************************************************************************/
+static EVEL_ERR_CODES evel_setup_curl()
+{
+ int rc = EVEL_SUCCESS;
+ CURLcode curl_rc = CURLE_OK;
+ char local_address[64];
+ char * api_url = NULL;
+ char * username = NULL;
+ char * password = NULL;
+ char * source_ip = NULL;
+
+ EVEL_ENTER();
+
+ if (evel_collector_id > 2)
+ {
+ rc = EVEL_CURL_LIBRARY_FAIL;
+ log_error_state("Wrong evel_collector- value > 2");
+ goto exit_label;
+ }
+
+ /***************************************************************************/
+ /* Initialize the local variable with proper global variables that are */
+ /* required to setup the connection */
+ /***************************************************************************/
+ if (evel_collector_id == 1)
+ {
+ api_url = evel_event_api_url;
+ source_ip = evel_source_ip;
+ username = evel_username;
+ password = evel_password;
+ }
+ else if (evel_collector_id == 2)
+ {
+ api_url = evel_bevent_api_url;
+ source_ip = evel_source_ip_bakup;
+ username = evel_username2;
+ password = evel_password2;
+ }
+ /***************************************************************************/
+ /* Clean-up the cURL library. */
+ /***************************************************************************/
+ if (curl_handle != NULL)
+ {
+ curl_easy_cleanup(curl_handle);
+ curl_handle = NULL;
+ }
+ if (hdr_chunk != NULL)
+ {
+ curl_slist_free_all(hdr_chunk);
+ hdr_chunk = NULL;
+ }
+
/***************************************************************************/
/* Start the CURL library. Note that this initialization is not threadsafe */
/* which imposes a constraint that the EVEL library is initialized before */
@@ -337,16 +413,6 @@ 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. */
/***************************************************************************/
@@ -361,25 +427,10 @@ 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. */
/***************************************************************************/
- if (verbosity > 0)
+ if (evel_verbosity > 0)
{
curl_rc = curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
if (curl_rc != CURLE_OK)
@@ -389,26 +440,12 @@ 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. */
/***************************************************************************/
- curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, event_api_url);
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, api_url);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -416,22 +453,7 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
"Error code=%d (%s)", curl_rc, curl_err_string);
goto exit_label;
}
- 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;
- }
- }
-
+ EVEL_INFO("Initializing CURL to send events to: %s", api_url);
/***************************************************************************/
/* send all data to this function. */
@@ -446,21 +468,6 @@ 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 */
@@ -483,46 +490,17 @@ 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 */
/***************************************************************************/
- if( secure )
+ if( evel_secure )
{
- if( cert_file_path != NULL )
+ if( evel_cert_file_path != NULL )
{
curl_rc = curl_easy_setopt(curl_handle,
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( bakup_api_url != NULL )
- {
- curl_rc = curl_easy_setopt(curl_handle2,
- CURLOPT_SSLCERT,
- cert_file_path);
+ evel_cert_file_path);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -530,26 +508,13 @@ 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( key_file_path != NULL )
+ if( evel_key_file_path != NULL )
{
curl_rc = curl_easy_setopt(curl_handle,
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( bakup_api_url != NULL )
- {
- curl_rc = curl_easy_setopt(curl_handle2,
- CURLOPT_SSLKEY,
- key_file_path);
+ evel_key_file_path);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -557,26 +522,13 @@ 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( ca_info != NULL )
+ if( evel_ca_info != NULL )
{
curl_rc = curl_easy_setopt(curl_handle,
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( bakup_api_url != NULL )
- {
- curl_rc = curl_easy_setopt(curl_handle2,
- CURLOPT_CAINFO,
- ca_info);
+ evel_ca_info);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -584,26 +536,13 @@ 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( ca_file_path != NULL )
+ if( evel_ca_file_path != NULL )
{
curl_rc = curl_easy_setopt(curl_handle,
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;
- }
- if( bakup_api_url != NULL )
- {
- curl_rc = curl_easy_setopt(curl_handle2,
- CURLOPT_CAPATH,
- ca_file_path);
+ evel_ca_file_path);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -611,12 +550,11 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
"Error code=%d (%s)", curl_rc, curl_err_string);
goto exit_label;
}
- }
}
curl_rc = curl_easy_setopt(curl_handle,
CURLOPT_SSL_VERIFYPEER,
- verify_peer);
+ evel_verify_peer);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -626,7 +564,7 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
}
curl_rc = curl_easy_setopt(curl_handle,
CURLOPT_SSL_VERIFYHOST,
- verify_host);
+ evel_verify_host);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -635,29 +573,6 @@ 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;
- }
- }
}
@@ -676,20 +591,6 @@ 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. */
@@ -702,18 +603,6 @@ 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. */
@@ -726,18 +615,6 @@ 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 */
@@ -760,21 +637,6 @@ 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. */
@@ -789,18 +651,6 @@ 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 */
@@ -831,57 +681,6 @@ 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. */
- /***************************************************************************/
- if( ring_buf_size < EVEL_EVENT_BUFFER_DEPTH )
- {
- log_error_state("Warning: Failed to initialize Ring buffer size to %d. ",
- ring_buf_size);
- goto exit_label;
- }
- ring_buffer_initialize(&event_buffer, EVEL_EVENT_BUFFER_DEPTH);
-
/***************************************************************************/
/* Initialize the priority post buffer to empty. */
/***************************************************************************/
@@ -914,11 +713,7 @@ EVEL_ERR_CODES event_handler_run()
/* Start the event handler thread. */
/***************************************************************************/
evt_handler_state = EVT_HANDLER_INACTIVE;
- 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);
-
+ pthread_rc = pthread_create(&evt_handler_thread, NULL, event_handler, NULL);
if (pthread_rc != 0)
{
rc = EVEL_PTHREAD_LIBRARY_FAIL;
@@ -991,31 +786,16 @@ 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. */
@@ -1107,7 +887,6 @@ static EVEL_ERR_CODES evel_post_api(char * msg, size_t size)
CURLcode curl_rc = CURLE_OK;
MEMORY_CHUNK rx_chunk;
MEMORY_CHUNK tx_chunk;
- int http_response_code = 0;
EVEL_ENTER();
@@ -1170,6 +949,8 @@ static EVEL_ERR_CODES evel_post_api(char * msg, size_t size)
/***************************************************************************/
/* Now run off and do what you've been told! */
/***************************************************************************/
+ http_response_code = 0;
+
curl_rc = curl_easy_perform(curl_handle);
if (curl_rc != CURLE_OK)
{
@@ -1226,6 +1007,57 @@ exit_label:
}
/**************************************************************************//**
+ * Send event to another collector
+ *
+ * Identify the next collector and try sending the event to that collector
+ ****************************************************************************/
+static EVEL_ERR_CODES evel_send_to_another_collector(
+ const EVEL_EVENT_DOMAINS evel_domain,
+ char * json_body,
+ size_t json_size)
+{
+ int rc = EVEL_SUCCESS;
+ CURLcode curl_rc;
+
+ EVEL_ENTER();
+
+ if ((evel_collector_id == 1) && (curr_global_handles == 2))
+ {
+ evel_collector_id =2;
+ }
+ else if (evel_collector_id == 2)
+ {
+ evel_collector_id =1;
+ }
+
+ rc = evel_setup_curl();
+
+ if ( rc == EVEL_SUCCESS)
+ {
+ if (evel_collector_id == 1)
+ {
+ if (evel_domain == EVEL_DOMAIN_BATCH)
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url);
+ else
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url);
+ }
+ else if (evel_collector_id == 2)
+ {
+ if (evel_domain == EVEL_DOMAIN_BATCH)
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_bbatch_api_url);
+ else
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_bevent_api_url);
+ }
+
+ rc = evel_post_api(json_body, json_size);
+ }
+
+ EVEL_EXIT();
+
+ return rc;
+}
+
+/**************************************************************************//**
* Callback function to provide data to send.
*
* Copy data into the supplied buffer, read_callback::ptr, checking size
@@ -1299,309 +1131,6 @@ size_t evel_write_callback(void *contents,
return realsize;
}
-
-/**************************************************************************//**
- * Post an event to the Vendor Event Listener API.
- *
- * @returns Status code
- * @retval EVEL_SUCCESS On success
- * @retval "One of ::EVEL_ERR_CODES" On failure.
- *****************************************************************************/
-static EVEL_ERR_CODES evel_postmulti_message(char *msg, size_t size, int *still,
- CURL *handle, CURL *bhandle, int numhandles )
-{
- int rc = EVEL_SUCCESS;
- CURLcode curl_rc = CURLE_OK;
- MEMORY_CHUNK rx_chunk[2];
- MEMORY_CHUNK tx_chunk[2];
- int i;
-
- 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<numhandles;i++)
-{
- rx_chunk[i].memory = malloc(1);
- assert(rx_chunk[i].memory != NULL);
- rx_chunk[i].size = 0;
-
- /***************************************************************************/
- /* Create the memory chunk to be sent as the body of the post. */
- /***************************************************************************/
- tx_chunk[i].memory = msg;
- tx_chunk[i].size = size;
- EVEL_DEBUG("Sending chunk of size %d", tx_chunk[i].size);
-}
-
- /***************************************************************************/
- /* Point to the data to be received. */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(handle, CURLOPT_WRITEDATA, &rx_chunk[0]);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to initialize libCURL rx to upload. "
- "Error code=%d (%s)", curl_rc, curl_err_string);
- goto exit_label;
- }
-
- /***************************************************************************/
- /* Pointer to pass to our read function */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(handle, CURLOPT_READDATA, &tx_chunk[0]);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to set upload data for libCURL tx to upload. "
- "Error code=%d (%s)", curl_rc, curl_err_string);
- goto exit_label;
- }
- /***************************************************************************/
- /* Size of the data to transmit. */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(handle,
- CURLOPT_POSTFIELDSIZE,
- tx_chunk[0].size);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to set length of upload data for libCURL to "
- "upload. Error code=%d (%s)", curl_rc, curl_err_string);
- goto exit_label;
- }
-
-if(numhandles == 2)
-{
-
- /***************************************************************************/
- /* Point to the data to be received. */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(bhandle, CURLOPT_WRITEDATA, &rx_chunk[1]);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to initialize libCURL2 rx to upload. "
- "Error code=%d (%s)", curl_rc, curl_err_string2);
- goto exit_label;
- }
-
- /***************************************************************************/
- /* Pointer to pass to our read function */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(bhandle, CURLOPT_READDATA, &tx_chunk[1]);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to set upload data for libCURL2 tx to upload. "
- "Error code=%d (%s)", curl_rc, curl_err_string2);
- goto exit_label;
- }
- /***************************************************************************/
- /* Size of the data to transmit. */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(bhandle,
- CURLOPT_POSTFIELDSIZE,
- tx_chunk[1].size);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to set length of upload data for libCURL2 to "
- "upload. Error code=%d (%s)", curl_rc, curl_err_string);
- goto exit_label;
- }
-
-}
-
- /***************************************************************************/
- /* Now run off and do what you've been told! */
- /***************************************************************************/
- curl_rc = curl_multi_perform(multi_handle, still);
- if (curl_rc != CURLE_OK)
- {
- rc = EVEL_CURL_LIBRARY_FAIL;
- log_error_state("Failed to transfer an multi event to Vendor Event Listener! "
- "Error code=%d (%s)", curl_rc, curl_multi_strerror(curl_rc
-));
- EVEL_ERROR("Dropped event: %s", msg);
- goto exit_label;
- }
-
- /***************************************************************************/
- /* See what response we got - any 2XX response is good. */
- /***************************************************************************/
-
-exit_label:
- for (i=0;i<numhandles;i++)
- free(rx_chunk[i].memory);
- EVEL_EXIT();
-
- return(rc);
-}
-
-
-/**************************************************************************//**
- * Event Multi Post Handler.
- *
- * Watch for messages coming on the internal queue and send them to the
- * listener.
- *
- * param[in] jsonmsg json message to be sent.
- * param[in] size size of json message
- * param[in] currhandle Primary handle
- * param[in] url1 pimary url
- * param[in] bakkhandle Backup handle
- * param[in] url2 secondary url
- *****************************************************************************/
-static int evel_post_multiapi(char *jsonmsg, size_t size,CURL *currhandle, char *url1,
- CURL *bakkhandle, char *url2)
-{
- CURLcode curl_rc = 0;
- int nhandles = 1;
- int still_running;
- CURLMsg *msg; /* for picking up messages with the transfer status */
- int msgs_left; /* how many messages are left */
-
- /***************************************************************************/
- /* Set the URL for the API. */
- /***************************************************************************/
- curl_rc = curl_easy_setopt(currhandle, CURLOPT_URL, url1);
- if (curl_rc != CURLE_OK )
- {
- log_error_state("Failed to initialize libCURL with the multi API URL. "
- "%s Error code=%d (%s)", url1, curl_rc, curl_err_string);
- }
-
- if( url2 != NULL && activmode == 1 )
- {
- curl_rc = curl_easy_setopt(bakkhandle, CURLOPT_URL, url2);
- if (curl_rc != CURLE_OK)
- {
- log_error_state("Failed to initialize libCURL with the API URL. "
- "%s Error code=%d (%s)", url2, curl_rc, curl_err_string2);
- }
- nhandles = 2;
- }
-
- /* we start some action by calling perform right away */
- curl_multi_add_handle(multi_handle, currhandle);
- if(nhandles==2){
- curl_multi_add_handle(multi_handle, bakkhandle);
- }
-
- /* we start some action by calling perform right away */
- curl_multi_perform(multi_handle, &still_running);
-
- do {
- struct timeval timeout;
- int rc; /* select() return code */
- CURLMcode mc; /* curl_multi_fdset() return code */
-
- fd_set fdread;
- fd_set fdwrite;
- fd_set fdexcep;
- int maxfd = -1;
-
- long curl_timeo = -1;
-
- FD_ZERO(&fdread);
- FD_ZERO(&fdwrite);
- FD_ZERO(&fdexcep);
-
- /* set a suitable timeout to play around with */
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
-
- curl_multi_timeout(multi_handle, &curl_timeo);
- if(curl_timeo >= 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; idx<nhandles; idx++) {
- if (msg->easy_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.
*
@@ -1610,7 +1139,7 @@ static int evel_post_multiapi(char *jsonmsg, size_t size,CURL *currhandle, char
*
* param[in] arg Argument - unused.
*****************************************************************************/
-static void * event_multi_handler(void * arg __attribute__ ((unused)))
+static void * event_handler(void * arg __attribute__ ((unused)))
{
int old_type = 0;
EVENT_HEADER * msg = NULL;
@@ -1619,12 +1148,10 @@ static void * event_multi_handler(void * arg __attribute__ ((unused)))
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;
+ int collector_down_count = 0;
+ int switch_coll = 0;
- EVEL_INFO("Event multi handler thread started");
+ EVEL_INFO("Event handler thread started");
/***************************************************************************/
/* Set this thread to be cancellable immediately. */
@@ -1645,227 +1172,49 @@ static void * event_multi_handler(void * arg __attribute__ ((unused)))
EVEL_ERROR("Event Handler State was not INACTIVE at start-up - "
"Handler will exit immediately!");
}
-
- currhandler = curl_handle;
- while (evt_handler_state == EVT_HANDLER_ACTIVE)
- {
- /*************************************************************************/
- /* Wait for a message to be received. */
- /*************************************************************************/
- 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_DEBUG("Batch event received");
-
- /***********************************************************************/
- /* Encode the event in JSON. */
- /***********************************************************************/
- json_size = evel_json_encode_batch_event(json_body, EVEL_MAX_JSON_BODY, msg);
-
- /***************************************************************************/
- /* Set the URL for the API. */
- /***************************************************************************/
- 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_multiapi(json_body, json_size, currhandler, send_url, bakhandler, send_url2);
- if (rc != EVEL_SUCCESS)
- {
- 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 )
- {
- 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. */
- /***************************************************************************/
- 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 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 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
- {
- EVEL_DEBUG("Internal event received");
- internal_msg = (EVENT_INTERNAL *) msg;
- assert(internal_msg->command == EVT_CMD_TERMINATE);
- evt_handler_state = EVT_HANDLER_TERMINATING;
- }
-
- /*************************************************************************/
- /* 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! */
+ /* Set the connection to collector */
/***************************************************************************/
- evt_handler_state = EVT_HANDLER_TERMINATING;
- while (!ring_buffer_is_empty(&event_buffer))
+ while (true)
{
- 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);
-}
+ evel_collector_id = 1;
+ rc = evel_setup_curl();
-
-/**************************************************************************//**
- * Event Handler.
- *
- * Watch for messages coming on the internal queue and send them to the
- * listener.
- *
- * param[in] arg Argument - unused.
- *****************************************************************************/
-static void * event_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;
-
- EVEL_INFO("Event handler thread started");
-
- /***************************************************************************/
- /* Set this thread to be cancellable immediately. */
- /***************************************************************************/
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_type);
-
- /***************************************************************************/
- /* 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. */
- /***************************************************************************/
- if (evt_handler_state == EVT_HANDLER_INACTIVE)
- {
- evt_handler_state = EVT_HANDLER_ACTIVE;
- }
- else
- {
- EVEL_ERROR("Event Handler State was not INACTIVE at start-up - "
- "Handler will exit immediately!");
+ if ( rc != EVEL_SUCCESS)
+ {
+ EVEL_ERROR("Failed to setup the first collector. Error code=%d", rc);
+ if (curr_global_handles == 2)
+ {
+ EVEL_DEBUG("Switching to other collector");
+
+ evel_collector_id = 2;
+
+ rc = evel_setup_curl();
+ if ( rc != EVEL_SUCCESS)
+ {
+ EVEL_ERROR("Failed to setup the connection to second collector also, Error code%d", rc);
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collectors setup issue- retry count=%d", collector_down_count);
+ }
+ else
+ {
+ collector_down_count = 0;
+ break;
+ }
+ }
+ else
+ {
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+ }
+ else
+ {
+ collector_down_count = 0;
+ break;
+ }
}
while (evt_handler_state == EVT_HANDLER_ACTIVE)
@@ -1892,7 +1241,15 @@ 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 (evel_collector_id == 1)
+ {
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url);
+ }
+ else
+ {
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_bbatch_api_url);
+ }
+
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -1905,9 +1262,70 @@ static void * event_handler(void * arg __attribute__ ((unused)))
/***********************************************************************/
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)
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
{
- EVEL_ERROR("Failed to transfer the data %s. Error code=%d", evel_batch_api_url, rc);
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ EVEL_ERROR("Failed to transfer the data. Error code=%d", rc);
+ EVEL_DEBUG("Switching to other collector if any");
+
+ while (true)
+ {
+ if (curr_global_handles == 2)
+ {
+ rc = evel_send_to_another_collector(msg->event_domain, json_body, json_size);
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
+ {
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+
+ rc = evel_send_to_another_collector(msg->event_domain, json_body, json_size);
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
+ {
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+ else
+ {
+ break;
+ }
+ }
}
}
else if (msg->event_domain != EVEL_DOMAIN_INTERNAL )
@@ -1922,7 +1340,10 @@ 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 (evel_collector_id == 1)
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url);
+ else
+ curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_bevent_api_url);
if (curl_rc != CURLE_OK)
{
rc = EVEL_CURL_LIBRARY_FAIL;
@@ -1935,45 +1356,69 @@ static void * event_handler(void * arg __attribute__ ((unused)))
/***********************************************************************/
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)
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
{
- 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)
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ EVEL_ERROR("Failed to transfer the data. Error code=%d", rc);
+ EVEL_DEBUG("Switching to other collector if any");
+
+ while (true)
{
- 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);
- }
- }
+ if (curr_global_handles == 2)
+ {
+ rc = evel_send_to_another_collector(msg->event_domain, json_body, json_size);
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
+ {
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ sleep(EVEL_COLLECTOR_RECONNECTION_WAIT_TIME);
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+
+ rc = evel_send_to_another_collector(msg->event_domain, json_body, json_size);
+
+ switch_coll = 0;
+ if ((rc == EVEL_SUCCESS) && ((http_response_code / 100) != 2))
+ {
+ switch_coll = 1;
+ if (http_response_code == 400) // 400 - Bad JSON related return code
+ switch_coll = 0;
+ }
+ if ((rc != EVEL_SUCCESS) || (switch_coll == 1))
+ {
+ collector_down_count = collector_down_count + 1;
+ EVEL_ERROR("Collector setup issue-retry count=%d", collector_down_count);
+ }
+ else
+ {
+ break;
+ }
}
}
}
@@ -1985,8 +1430,6 @@ static void * event_handler(void * arg __attribute__ ((unused)))
evt_handler_state = EVT_HANDLER_TERMINATING;
}
-next:
-
/*************************************************************************/
/* We are responsible for freeing the memory. */
/*************************************************************************/
@@ -2108,11 +1551,11 @@ void evel_handle_event_response(const MEMORY_CHUNK * const chunk,
}
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_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();
@@ -2132,7 +1575,7 @@ bool evel_handle_response_tokens(const MEMORY_CHUNK * const chunk,
const int num_tokens,
MEMORY_CHUNK * const post)
{
- bool json_ok = false;
+ bool json_ok = true;
EVEL_ENTER();
@@ -2219,566 +1662,3 @@ 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_internal.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h
index 02a4697..29ba6cd 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
@@ -201,7 +201,6 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url,
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,
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 f57860d..d0d31dd 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
@@ -4658,7 +4658,7 @@ void evel_json_encode_ipmi(EVEL_JSON_BUFFER * jbuf, MEASUREMENT_IPMI * ipmi_entr
/* IPMI Global Aggregate Temperature margin */
/***************************************************************************/
evel_json_checkpoint(jbuf);
- if (evel_json_open_opt_named_list(jbuf, "globalAggregateTemperatureMarginArray"))
+ if (evel_json_open_opt_named_list(jbuf, "ipmiGlobalAggregateTemperatureMarginArray"))
{
bool item_added = false;
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 bb9f8bc..1a77e76 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
@@ -199,7 +199,7 @@ void evel_voice_quality_caller_codec_set(EVENT_VOICE_QUALITY * voiceQuality,
assert(voiceQuality->header.event_domain == EVEL_DOMAIN_VOICE_QUALITY);
assert(callerCodecForCall != NULL);
- voiceQuality->calleeSideCodec = strdup(callerCodecForCall);
+ voiceQuality->callerSideCodec = strdup(callerCodecForCall);
EVEL_EXIT();
}
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 c812636..4390c6d 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
@@ -255,13 +255,12 @@ point the `evel_initialize()` function is called:
...
if(evel_initialize(fqdn, /* FQDN */
port, /* Port */
- NULL, /* Backup FQDN */
- 0, /* Backup port */
+ fqdn2, /* Backup FQDN */
+ port2, /* 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 */
diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/readme.md b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/readme.md
index 3cf5708..93bbdd1 100644
--- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/readme.md
+++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/readme.md
@@ -47,11 +47,15 @@ Once initialized, and now MT-safe, there are factory functions to produce
new events:
- Faults - ::evel_new_fault
- Measurements - ::evel_new_measurement
-- Report - ::evel_new_report
- State Change - ::evel_new_state_change
- Syslog - ::evel_new_syslog
- Other - ::evel_new_other
- Mobile Flow - ::evel_new_mobile_flow
+- Notification - ::evel_new_notification
+- PNF Registration - ::evel_new_pnf_registration
+- SIP Signaling - ::evel_new_signaling
+- Threshold Crossing Alert - ::evel_new_threshold_cross
+- Voice Quality - ::evel_new_voice_quality
There is also a factory function ::evel_new_mobile_gtp_flow_metrics to create
the parameter gtp_per_flow_metrics, which is then configured and passed to the
@@ -76,16 +80,29 @@ The following fragment illustrates the above usage:
```C
- 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 */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 0, /* HTTPS? */
+ 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);
@@ -93,10 +110,14 @@ The following fragment illustrates the above usage:
...
- 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)
{
evel_fault_type_set(fault, "Bad things happen...");
@@ -117,79 +138,6 @@ within library are defined in separate headers (<em>e.g.</em>
evel_internal.h), but these should not need to be included by the code
using the library.
-# Example Application
-
-A simple command-line application to generate events is provided as part of
-the source package (the above code fragment is taken from that application).
-
-The following illustrates its operation to a co-located "test-collector":
-```
-$ ./evel_demo --fqdn 127.0.0.1 --port 30000 --path vendor_event_listener --topic example_vnf --verbose
-./evel_demo built Feb 26 2016 18:14:48
-* About to connect() to 169.254.169.254 port 80 (#0)
-* Trying 169.254.169.254... * Timeout
-* connect() timed out!
-* Closing connection #0
-* About to connect() to 127.0.0.1 port 30000 (#0)
-* Trying 127.0.0.1... * connected
-* Connected to 127.0.0.1 (127.0.0.1) port 30000 (#0)
-* Server auth using Basic with user 'Alice'
-> POST /vendor_event_listener/eventListener/v1/example_vnf HTTP/1.1
-Authorization: Basic QWxpY2U6VGhpcyBpc24ndCB2ZXJ5IHNlY3VyZSE=
-User-Agent: libcurl-agent/1.0
-Host: 127.0.0.1:30000
-Accept: */*
-Content-type: application/json
-Content-Length: 510
-
-* HTTP 1.0, assume close after body
-< HTTP/1.0 204 No Content
-< Date: Fri, 04 Mar 2016 15:37:22 GMT
-< Server: WSGIServer/0.1 Python/2.6.6
-<
-* Closing connection #0
-* About to connect() to 127.0.0.1 port 30000 (#0)
-* Trying 127.0.0.1... * connected
-* Connected to 127.0.0.1 (127.0.0.1) port 30000 (#0)
-* Server auth using Basic with user 'Alice'
-> POST /vendor_event_listener/eventListener/v1/example_vnf HTTP/1.1
-Authorization: Basic QWxpY2U6VGhpcyBpc24ndCB2ZXJ5IHNlY3VyZSE=
-User-Agent: libcurl-agent/1.0
-Host: 127.0.0.1:30000
-Accept: */*
-Content-type: application/json
-Content-Length: 865
-
-* HTTP 1.0, assume close after body
-< HTTP/1.0 204 No Content
-< Date: Fri, 04 Mar 2016 15:37:22 GMT
-< Server: WSGIServer/0.1 Python/2.6.6
-<
-* Closing connection #0
-* About to connect() to 127.0.0.1 port 30000 (#0)
-* Trying 127.0.0.1... * connected
-* Connected to 127.0.0.1 (127.0.0.1) port 30000 (#0)
-* Server auth using Basic with user 'Alice'
-> POST /vendor_event_listener/eventListener/v1/example_vnf HTTP/1.1
-Authorization: Basic QWxpY2U6VGhpcyBpc24ndCB2ZXJ5IHNlY3VyZSE=
-User-Agent: libcurl-agent/1.0
-Host: 127.0.0.1:30000
-Accept: */*
-Content-type: application/json
-Content-Length: 2325
-
-* HTTP 1.0, assume close after body
-< HTTP/1.0 204 No Content
-< Date: Fri, 04 Mar 2016 15:37:22 GMT
-< Server: WSGIServer/0.1 Python/2.6.6
-<
-* Closing connection #0
-^C
-
-Interrupted - quitting!
-$
-```
-
# Restrictions and Limitations
## Constraint Validation
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 affb88a..60eb4be 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
@@ -50,39 +50,19 @@ typedef enum {
/* Local prototypes. */
/*****************************************************************************/
static void test_encode_heartbeat();
-//static void test_encode_header_overrides();
static void test_encode_fault();
-//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_mand();
+static void test_encode_mobile_opts();
static void test_encode_other();
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_encode_header_overrides();
static void compare_strings(char * expected,
char * actual,
int max_size,
@@ -130,15 +110,14 @@ int main(int argc, char ** argv)
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 */
+ "sample1", /* Username */
+ "sample1", /* Password */
"", /* Username2 */
"", /* Password2 */
NULL, /* Source ip */
@@ -158,53 +137,21 @@ int main(int argc, char ** argv)
/***************************************************************************/
/* Test each encoder. */
/***************************************************************************/
- 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();
- test_json_throttle_spec_field();
- 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(); // 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");
+ test_encode_heartbeat();
+ test_encode_header_overrides();
+ test_encode_fault();
+ test_encode_measurement();
+// test_encode_mobile_mand();
+ test_encode_mobile_opts();
+ test_encode_notif();
+ test_encode_other();
+ test_encode_pnfreg();
+ test_encode_signaling();
+ test_encode_state_change();
+ test_encode_syslog();
+ test_encode_tca();
+ test_encode_voiceQ();
+ printf ("\n************ All Tests Passed ************\n\n");
evel_terminate();
return 0;
}
@@ -222,28 +169,11 @@ int gettimeofday(struct timeval *tv,
void test_encode_heartbeat()
{
- char * expected =
- "{\"event\": {"
- "\"commonEventHeader\": {"
- "\"domain\": \"heartbeat\", "
- "\"eventId\": \"heartbeat000000001\", "
- "\"eventName\": \"heartbeat_VM\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 121, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 3.0, "
- "\"eventType\": \"Autonomous heartbeat\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}}}";
+ char * expected =
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"heartbeat\", \"eventId\": \"1\", \"eventName\": \"Heartbeat\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Autonomous heartbeat\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
-
/***************************************************************************/
/* Test the VM name/uuid once. */
/***************************************************************************/
@@ -251,6 +181,8 @@ void test_encode_heartbeat()
EVENT_HEADER * heartbeat = evel_new_heartbeat();
assert(heartbeat != NULL);
+ evel_source_name_set(heartbeat, "VM-VirtualBox");
+ evel_reporting_entity_name_set(heartbeat, "VM-VirtualBox");
json_size = evel_json_encode_event(
json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat);
@@ -259,7 +191,7 @@ void test_encode_heartbeat()
if(evel_post_event(heartbeat) == EVEL_SUCCESS)
{
- printf("Message sent to Collector successfully\n");
+ printf("HB Message sent to Collector successfully\n");
}
else
{
@@ -272,20 +204,7 @@ void test_encode_heartbeat()
void test_encode_header_overrides()
{
char * expected =
- "{\"event\": {"
- "\"commonEventHeader\": {"
- "\"domain\": \"heartbeat\", "
- "\"eventId\": \"121\", "
- "\"lastEpochMicrosec\": 1000, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"entity_name_override\", "
- "\"sequence\": 121, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1001, "
- "\"version\": 1.2, "
- "\"eventType\": \"Autonomous heartbeat\", "
- "\"reportingEntityId\": \"entity_id_override\" "
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"heartbeat\", \"eventId\": \"2\", \"eventName\": \"Heartbeat\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000, \"priority\": \"Normal\", \"reportingEntityName\": \"entity_name_override\", \"sequence\": 121, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1001, \"version\": \"4.1\", \"eventType\": \"Autonomous heartbeat\", \"reportingEntityId\": \"entity_id_override\", \"sourceId\": \"Source_ID\", \"nfcNamingCode\": \"NFC_Name\", \"nfNamingCode\": \"NF_Name\", \"timeZoneOffset\": \"UTC+5:30\", \"nfVendorName\": \"Vendor_Name\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -303,50 +222,34 @@ void test_encode_header_overrides()
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_source_name_set(heartbeat, "VM-VirtualBox");
evel_time_zone_offset_set(heartbeat, "UTC+5:30");
+ evel_nfcnamingcode_set(heartbeat, "NFC_Name");
+ evel_nfnamingcode_set(heartbeat, "NF_Name");
+ evel_source_id_set(heartbeat, "Source_ID");
+ evel_nf_vendor_name_set(heartbeat, "Vendor_Name");
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);
+ if(evel_post_event(heartbeat) == EVEL_SUCCESS)
+ {
+ printf("HB Message sent to Collector successfully\n");
+ }
+ else
+ {
+ printf("Message sending Error\n");
+ }
+
+// evel_free_event(heartbeat);
}
void test_encode_fault()
{
char * expected =
- "{\"event\": {"
- "\"commonEventHeader\": {"
- "\"domain\": \"fault\", "
- "\"eventId\": \"fault000000001\", "
- "\"eventName\": \"fault_eNodeB_alarm\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 122, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Bad things happen...\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"faultFields\": {"
- "\"alarmCondition\": \"My alarm condition\", "
- "\"eventSeverity\": \"MAJOR\", "
- "\"eventSourceType\": \"other\", "
- "\"specificProblem\": \"It broke very badly\", "
- "\"eventCategory\": \"link\", "
- "\"vfStatus\": \"Active\", "
- "\"faultFieldsVersion\": 1.1, "
- "\"alarmAdditionalInformation\": ["
- "{\"name\": \"name1\", "
- "\"value\": \"value1\"}, "
- "{\"name\": \"name2\", "
- "\"value\": \"value2\"}], "
- "\"alarmInterfaceA\": \"My Interface Card\""
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"fault\", \"eventId\": \"fault000000001\", \"eventName\": \"fault_eNodeB_alarm\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 1, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Bad things happen...\"}, \"faultFields\": {\"alarmCondition\": \"My alarm condition\", \"eventCategory\": \"link\", \"eventSeverity\": \"MAJOR\", \"eventSourceType\": \"host\", \"specificProblem\": \"It broke very badly\", \"vfStatus\": \"Ready to terminate\", \"faultFieldsVersion\": \"4.0\", \"alarmAdditionalInformation\": {\"name1\": \"value1\", \"name2\": \"value2\"}, \"alarmInterfaceA\": \"My Interface Card\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -364,7 +267,9 @@ void test_encode_fault()
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");
+ evel_source_name_set(&fault->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&fault->header, "VM-VirtualBox");
+ evel_fault_category_set(fault, "link");
json_size = evel_json_encode_event(
json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
@@ -385,109 +290,8 @@ evel_fault_category_set(fault, "link");
void test_encode_measurement()
{
char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"measurementsForVfScaling\", "
- "\"eventId\": \"mvfs000000001\", "
- "\"eventName\": \"mvfs_perfUnit_issue\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 3000, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"entity_name\", "
- "\"sequence\": 123, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 2000, "
- "\"version\": 1.2, "
- "\"eventType\": \"Perf management...\", "
- "\"reportingEntityId\": \"entity_id\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"measurementsForVfScalingFields\": "
- "{"
- "\"measurementInterval\": 5.500000, "
- "\"concurrentSessions\": 1, "
- "\"configuredEntities\": 2, "
- "\"cpuUsageArray\": ["
- "{\"cpuIdentifier\": \"cpu1\", "
- "\"percentUsage\": 11.110000}, "
- "{\"cpuIdentifier\": \"cpu2\", "
- "\"percentUsage\": 22.220000}], "
- "\"filesystemUsageArray\": ["
- "{\"blockConfigured\": 100.110000, "
- "\"blockIops\": 33, "
- "\"blockUsed\": 100.220000, "
- "\"ephemeralConfigured\": 100.110000, "
- "\"ephemeralIops\": 44, "
- "\"ephemeralUsed\": 200.220000, "
- "\"filesystemName\": \"00-11-22\"}, "
- "{\"blockConfigured\": 300.110000, "
- "\"blockIops\": 55, "
- "\"blockUsed\": 300.220000, "
- "\"ephemeralConfigured\": 300.110000, "
- "\"ephemeralIops\": 66, "
- "\"ephemeralUsed\": 400.220000, "
- "\"filesystemName\": \"33-44-55\"}], "
- "\"latencyDistribution\": ["
- "{\"countsInTheBucket\": 20}, "
- "{\"lowEndOfLatencyBucket\": 10.000000, "
- "\"highEndOfLatencyBucket\": 20.000000, "
- "\"countsInTheBucket\": 30}], "
- "\"meanRequestLatency\": 4.400000, "
- "\"memoryConfigured\": 6.600000, "
- "\"memoryUsed\": 3.300000, "
- "\"requestRate\": 7, "
- "\"vNicUsageArray\": ["
- "{"
- "\"bytesIn\": 3, "
- "\"bytesOut\": 4, "
- "\"packetsIn\": 100, "
- "\"packetsOut\": 200, "
- "\"vNicIdentifier\": \"eth0\""
- "}, "
- "{"
- "\"bytesIn\": 13, "
- "\"bytesOut\": 14, "
- "\"packetsIn\": 110, "
- "\"packetsOut\": 240, "
- "\"vNicIdentifier\": \"eth1\", "
- "\"broadcastPacketsIn\": 11, "
- "\"broadcastPacketsOut\": 12, "
- "\"multicastPacketsIn\": 15, "
- "\"multicastPacketsOut\": 16, "
- "\"unicastPacketsIn\": 17, "
- "\"unicastPacketsOut\": 18"
- "}"
- "], "
- "\"aggregateCpuUsage\": 8.800000, "
- "\"numberOfMediaPortsInUse\": 1234, "
- "\"vnfcScalingMetric\": 1234.567800, "
- "\"errors\": {"
- "\"receiveDiscards\": 1, "
- "\"receiveErrors\": 0, "
- "\"transmitDiscards\": 2, "
- "\"transmitErrors\": 1}, "
- "\"featureUsageArray\": ["
- "{\"featureIdentifier\": \"FeatureA\", "
- "\"featureUtilization\": 123}, "
- "{\"featureIdentifier\": \"FeatureB\", "
- "\"featureUtilization\": 567}], "
- "\"codecUsageArray\": ["
- "{\"codecIdentifier\": \"G711a\", "
- "\"numberInUse\": 91}, "
- "{\"codecIdentifier\": \"G729ab\", "
- "\"numberInUse\": 92}], "
- "\"additionalMeasurements\": ["
- "{\"name\": \"Group1\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}]}, "
- "{\"name\": \"Group2\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}, "
- "{\"name\": \"Name2\", "
- "\"value\": \"Value2\"}]}], "
- "\"measurementsForVfScalingVersion\": 1.1}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"measurement\", \"eventId\": \"mvfs000000001\", \"eventName\": \"mvfs_perfUnit_issue\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 3000, \"priority\": \"Normal\", \"reportingEntityName\": \"entity_name\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 2000, \"version\": \"4.1\", \"eventType\": \"Perf management...\", \"reportingEntityId\": \"entity_id\"}, \"measurementFields\": {\"measurementInterval\": 5, \"ipmi\": {\"exitAirTemperature\": 98.400000, \"frontPanelTemperature\": 98.400000, \"ioModuleTemperature\": 98.400000, \"systemAirflow\": 98.400000, \"ipmiBaseboardTemperatureArray\": [{\"baseboardTemperatureIdentifier\": \"BBTEMP1\", \"baseboardTemperature\": 99.800000}, {\"baseboardTemperatureIdentifier\": \"BBTEMP2\", \"baseboardTemperature\": 79.800000}], \"ipmiBaseboardVoltageRegulatorArray\": [{\"baseboardVoltageRegulatorIdentifier\": \"BBVOLT1\", \"voltageRegulatorTemperature\": 88.900000}, {\"baseboardVoltageRegulatorIdentifier\": \"BBVOLT2\", \"voltageRegulatorTemperature\": 68.900000}], \"ipmiBatteryArray\": [{\"batteryIdentifier\": \"BBBATTERY1\", \"batteryVoltageLevel\": 230.000000, \"batteryType\": \"BattType\"}, {\"batteryIdentifier\": \"BBBATTERY2\", \"batteryVoltageLevel\": 110.000000, \"batteryType\": \"BattType2\"}], \"ipmiFanArray\": [{\"fanIdentifier\": \"FAN1\", \"fanSpeed\": 300.000000}, {\"fanIdentifier\": \"FAN2\", \"fanSpeed\": 200.000000}], \"ipmiHsbpArray\": [{\"hsbpIdentifier\": \"BBHSBP1\", \"hsbpTemperature\": 100.000000}, {\"hsbpIdentifier\": \"BBHSBP2\", \"hsbpTemperature\": 200.000000}], \"ipmiGlobalAggregateTemperatureMarginArray\": [{\"globalAggregateTemperatureMarginIdentifier\": \"BBGLOBAL\", \"globalAggregateTemperatureMargin\": 22.500000}, {\"globalAggregateTemperatureMarginIdentifier\": \"BBGLOBAL2\", \"globalAggregateTemperatureMargin\": 32.500000}], \"ipmiNicArray\": [{\"nicIdentifier\": \"NIC_1\", \"nicTemperature\": 33.500000}, {\"nicIdentifier\": \"NIC_2\", \"nicTemperature\": 43.500000}], \"ipmiPowerSupplyArray\": [{\"powerSupplyIdentifier\": \"POWERSupply1\", \"powerSupplyCurrentOutputPercent\": 50.400000, \"powerSupplyInputPower\": 200.500000, \"powerSupplyTemperature\": 100.500000}, {\"powerSupplyIdentifier\": \"POWERSupply2\", \"powerSupplyCurrentOutputPercent\": 60.400000, \"powerSupplyInputPower\": 300.500000, \"powerSupplyTemperature\": 200.500000}], \"ipmiProcessorArray\": [{\"processorIdentifier\": \"PROCESSOR1\", \"processorDtsThermalMargin\": 29.800000, \"processorThermalControlPercent\": 10.900000, \"processorDimmAggregateThermalMarginArray\": [{\"processorDimmAggregateThermalMarginIdentifier\": \"DIMM1\", \"thermalMargin\": 15.800000}, {\"processorDimmAggregateThermalMarginIdentifier\": \"DIMM2\", \"thermalMargin\": 25.800000}]}, {\"processorIdentifier\": \"PROCESSOR2\", \"processorDtsThermalMargin\": 39.800000, \"processorThermalControlPercent\": 30.900000, \"processorDimmAggregateThermalMarginArray\": [{\"processorDimmAggregateThermalMarginIdentifier\": \"DIMM1\", \"thermalMargin\": 35.800000}, {\"processorDimmAggregateThermalMarginIdentifier\": \"DIMM2\", \"thermalMargin\": 55.800000}]}]}, \"hugePagesArray\": [{\"hugePagesIdentifier\": \"HUGEPage1\", \"bytesUsed\": 100.000000, \"bytesFree\": 200.000000, \"vmPageNumberUsed\": 300.000000, \"vmPageNumberFree\": 400.000000, \"percentUsed\": 100.000000, \"percentFree\": 100.000000}, {\"hugePagesIdentifier\": \"HUGEPage2\", \"bytesUsed\": 180.000000, \"bytesFree\": 280.000000, \"vmPageNumberUsed\": 380.000000, \"vmPageNumberFree\": 480.000000, \"percentUsed\": 180.000000, \"percentFree\": 180.000000}], \"machineCheckExceptionArray\": [{\"vmIdentifier\": \"ProcessID1\", \"correctedMemoryErrors\": 110.100000, \"correctedMemoryErrorsIn1Hr\": 210.100000, \"uncorrectedMemoryErrors\": 310.100000, \"uncorrectedMemoryErrorsIn1Hr\": 410.100000}, {\"vmIdentifier\": \"ProcessID2\", \"correctedMemoryErrors\": 410.100000, \"correctedMemoryErrorsIn1Hr\": 510.100000, \"uncorrectedMemoryErrors\": 610.100000, \"uncorrectedMemoryErrorsIn1Hr\": 710.100000}], \"loadArray\": [{\"shortTerm\": 22.500000, \"midTerm\": 33.600000, \"longTerm\": 44.800000}], \"processStatsArray\": [{\"processIdentifier\": \"Process1\", \"forkRate\": 10.100000, \"psStateBlocked\": 20.100000, \"psStatePaging\": 30.100000, \"psStateRunning\": 40.100000, \"psStateSleeping\": 50.100000, \"psStateStopped\": 60.100000, \"psStateZombie\": 70.100000}, {\"processIdentifier\": \"Process2\", \"forkRate\": 110.100000, \"psStateBlocked\": 120.100000, \"psStatePaging\": 230.100000, \"psStateRunning\": 340.100000, \"psStateSleeping\": 450.100000, \"psStateStopped\": 560.100000, \"psStateZombie\": 670.100000}], \"additionalFields\": {\"name2\": \"value2\", \"name3\": \"value3\", \"name1\": \"value1\", \"name4\": \"value4\"}, \"concurrentSessions\": 1, \"configuredEntities\": 2, \"cpuUsageArray\": [{\"cpuIdentifier\": \"cpu1\", \"cpuIdle\": 22.220000, \"cpuUsageInterrupt\": 33.330000, \"cpuUsageNice\": 44.440000, \"cpuUsageSoftIrq\": 55.550000, \"cpuUsageSteal\": 66.660000, \"cpuUsageSystem\": 77.770000, \"cpuUsageUser\": 88.880000, \"cpuWait\": 99.990000, \"percentUsage\": 11.110000, \"cpuCapacityContention\": 12.200000, \"cpuDemandAvg\": 14.400000, \"cpuDemandMhz\": 15.400000, \"cpuDemandPct\": 16.400000, \"cpuLatencyAvg\": 17.400000, \"cpuOverheadAvg\": 18.400000, \"cpuSwapWaitTime\": 19.400000}, {\"cpuIdentifier\": \"cpu2\", \"cpuIdle\": 12.220000, \"cpuUsageInterrupt\": 33.330000, \"cpuUsageNice\": 44.440000, \"cpuUsageSoftIrq\": 55.550000, \"cpuUsageSteal\": 66.660000, \"cpuUsageSystem\": 77.770000, \"cpuUsageUser\": 88.880000, \"cpuWait\": 19.990000, \"percentUsage\": 22.220000, \"cpuCapacityContention\": 22.200000, \"cpuDemandAvg\": 24.400000, \"cpuDemandMhz\": 25.400000, \"cpuDemandPct\": 26.400000, \"cpuLatencyAvg\": 27.400000, \"cpuOverheadAvg\": 28.400000, \"cpuSwapWaitTime\": 29.400000}], \"diskUsageArray\": [{\"diskIdentifier\": \"Disk1\", \"diskIoTimeAvg\": 11.100000, \"diskIoTimeLast\": 12.100000, \"diskIoTimeMax\": 13.100000, \"diskIoTimeMin\": 14.100000, \"diskMergedReadAvg\": 15.100000, \"diskMergedReadLast\": 16.100000, \"diskMergedReadMax\": 17.100000, \"diskMergedReadMin\": 18.100000, \"diskMergedWriteAvg\": 30.100000, \"diskMergedWriteLast\": 19.100000, \"diskMergedWriteMax\": 20.100000, \"diskMergedWriteMin\": 40.100000, \"diskOctetsReadAvg\": 50.100000, \"diskOctetsReadLast\": 60.100000, \"diskOctetsReadMax\": 70.100000, \"diskOctetsReadMin\": 80.100000, \"diskOctetsWriteAvg\": 90.100000, \"diskOctetsWriteLast\": 110.100000, \"diskOctetsWriteMax\": 120.100000, \"diskOctetsWriteMin\": 130.100000, \"diskOpsReadAvg\": 140.100000, \"diskOpsReadLast\": 150.100000, \"diskOpsReadMax\": 160.100000, \"diskOpsReadMin\": 170.100000, \"diskOpsWriteAvg\": 180.100000, \"diskOpsWriteLast\": 190.100000, \"diskOpsWriteMax\": 210.100000, \"diskOpsWriteMin\": 310.100000, \"diskPendingOperationsAvg\": 410.100000, \"diskPendingOperationsLast\": 610.100000, \"diskPendingOperationsMax\": 710.100000, \"diskPendingOperationsMin\": 810.100000, \"diskTimeReadAvg\": 910.100000, \"diskTimeReadLast\": 10.200000, \"diskTimeReadMax\": 10.330000, \"diskTimeReadMin\": 10.400000, \"diskTimeWriteAvg\": 10.500000, \"diskTimeWriteLast\": 10.600000, \"diskTimeWriteMax\": 10.700000, \"diskTimeWriteMin\": 10.800000, \"diskBusResets\": 10.900000, \"diskCommandsAborted\": 10.100000, \"diskTime\": 10.100000, \"diskFlushRequests\": 10.100000, \"diskFlushTime\": 10.100000, \"diskCommandsAvg\": 10.100000, \"diskReadCommandsAvg\": 10.100000, \"diskWriteCommandsAvg\": 10.100000, \"diskTotalReadLatencyAvg\": 10.100000, \"diskTotalWriteLatencyAvg\": 10.100000, \"diskWeightedIoTimeAvg\": 10.100000, \"diskWeightedIoTimeLast\": 10.100000, \"diskWeightedIoTimeMax\": 10.100000, \"diskWeightedIoTimeMin\": 10.100000}, {\"diskIdentifier\": \"Disk2\", \"diskIoTimeAvg\": 71.100000, \"diskIoTimeLast\": 72.100000, \"diskIoTimeMax\": 73.100000, \"diskIoTimeMin\": 74.100000}], \"filesystemUsageArray\": [{\"filesystemName\": \"00-11-22\", \"blockConfigured\": 100.110000, \"blockIops\": 33.000000, \"blockUsed\": 100.220000, \"ephemeralConfigured\": 200.110000, \"ephemeralIops\": 44.000000, \"ephemeralUsed\": 200.220000}, {\"filesystemName\": \"33-44-55\", \"blockConfigured\": 300.110000, \"blockIops\": 55.000000, \"blockUsed\": 300.220000, \"ephemeralConfigured\": 400.110000, \"ephemeralIops\": 66.000000, \"ephemeralUsed\": 400.220000}], \"latencyDistribution\": [{\"lowEndOfLatencyBucket\": 50.000000, \"highEndOfLatencyBucket\": 60.000000, \"countsInTheBucket\": 20}, {\"lowEndOfLatencyBucket\": 10.000000, \"highEndOfLatencyBucket\": 20.000000, \"countsInTheBucket\": 30}, {\"lowEndOfLatencyBucket\": 70.000000, \"highEndOfLatencyBucket\": 90.000000, \"countsInTheBucket\": 40}], \"meanRequestLatency\": 4.400000, \"requestRate\": 7.000000, \"nicPerformanceArray\": [{\"administrativeState\": \"outOfService\", \"operationalState\": \"inService\", \"receivedPercentDiscard\": 222.330000, \"receivedPercentError\": 222.330000, \"receivedUtilization\": 222.330000, \"speed\": 222.330000, \"transmittedPercentDiscard\": 222.330000, \"transmittedPercentError\": 222.330000, \"transmittedUtilization\": 222.330000, \"receivedBroadcastPacketsAccumulated\": 222.330000, \"receivedBroadcastPacketsDelta\": 222.330000, \"receivedDiscardedPacketsAccumulated\": 222.330000, \"receivedDiscardedPacketsDelta\": 222.330000, \"receivedErrorPacketsAccumulated\": 222.330000, \"receivedErrorPacketsDelta\": 222.330000, \"receivedMulticastPacketsAccumulated\": 222.330000, \"receivedMulticastPacketsDelta\": 222.330000, \"receivedOctetsAccumulated\": 222.330000, \"receivedOctetsDelta\": 222.330000, \"receivedTotalPacketsAccumulated\": 222.330000, \"receivedTotalPacketsDelta\": 222.330000, \"receivedUnicastPacketsAccumulated\": 222.330000, \"receivedUnicastPacketsDelta\": 222.330000, \"transmittedBroadcastPacketsAccumulated\": 222.330000, \"transmittedBroadcastPacketsDelta\": 222.330000, \"transmittedDiscardedPacketsAccumulated\": 222.330000, \"transmittedDiscardedPacketsDelta\": 222.330000, \"transmittedErrorPacketsAccumulated\": 222.330000, \"transmittedErrorPacketsDelta\": 222.330000, \"transmittedMulticastPacketsAccumulated\": 222.330000, \"transmittedMulticastPacketsDelta\": 222.330000, \"transmittedOctetsAccumulated\": 222.330000, \"transmittedOctetsDelta\": 222.330000, \"transmittedTotalPacketsAccumulated\": 222.330000, \"transmittedTotalPacketsDelta\": 222.330000, \"transmittedUnicastPacketsAccumulated\": 222.330000, \"transmittedUnicastPacketsDelta\": 222.330000, \"valuesAreSuspect\": \"true\", \"nicIdentifier\": \"eth0\"}, {\"administrativeState\": \"inService\", \"operationalState\": \"outOfService\", \"receivedPercentDiscard\": 11.660000, \"receivedPercentError\": 11.660000, \"receivedUtilization\": 11.660000, \"speed\": 11.660000, \"transmittedPercentDiscard\": 11.660000, \"transmittedPercentError\": 11.660000, \"transmittedUtilization\": 11.660000, \"receivedBroadcastPacketsAccumulated\": 11.660000, \"receivedBroadcastPacketsDelta\": 11.660000, \"receivedDiscardedPacketsAccumulated\": 11.660000, \"receivedDiscardedPacketsDelta\": 11.660000, \"receivedErrorPacketsAccumulated\": 11.660000, \"receivedErrorPacketsDelta\": 11.660000, \"receivedMulticastPacketsAccumulated\": 11.660000, \"receivedMulticastPacketsDelta\": 11.660000, \"receivedOctetsAccumulated\": 11.660000, \"receivedOctetsDelta\": 11.660000, \"receivedTotalPacketsAccumulated\": 11.660000, \"receivedTotalPacketsDelta\": 11.660000, \"receivedUnicastPacketsAccumulated\": 11.660000, \"receivedUnicastPacketsDelta\": 11.660000, \"transmittedBroadcastPacketsAccumulated\": 11.660000, \"transmittedBroadcastPacketsDelta\": 11.660000, \"transmittedDiscardedPacketsAccumulated\": 11.660000, \"transmittedDiscardedPacketsDelta\": 11.660000, \"transmittedErrorPacketsAccumulated\": 11.660000, \"transmittedErrorPacketsDelta\": 11.660000, \"transmittedMulticastPacketsAccumulated\": 11.660000, \"transmittedMulticastPacketsDelta\": 11.660000, \"transmittedOctetsAccumulated\": 11.660000, \"transmittedOctetsDelta\": 11.660000, \"transmittedTotalPacketsAccumulated\": 11.660000, \"transmittedTotalPacketsDelta\": 11.660000, \"transmittedUnicastPacketsAccumulated\": 11.660000, \"transmittedUnicastPacketsDelta\": 11.660000, \"valuesAreSuspect\": \"false\", \"nicIdentifier\": \"ens03\"}], \"memoryUsageArray\": [{\"memoryCached\": 121.700000, \"memoryConfigured\": 122.700000, \"memoryFree\": 120.000000, \"memorySlabRecl\": 123.700000, \"memorySlabUnrecl\": 124.700000, \"memoryUsed\": 150.000000, \"vmIdentifier\": \"VMID\", \"memoryDemand\": 125.700000, \"memoryLatencyAvg\": 126.700000, \"memorySharedAvg\": 127.700000, \"memorySwapInAvg\": 128.700000, \"memorySwapInRateAvg\": 129.700000, \"memorySwapOutAvg\": 130.700000, \"memorySwapOutRateAvg\": 131.700000, \"memorySwapUsedAvg\": 132.700000, \"percentMemoryUsage\": 133.700000}, {\"memoryBuffered\": 100.400000, \"memoryCached\": 221.700000, \"memoryConfigured\": 222.700000, \"memoryFree\": 220.000000, \"memorySlabRecl\": 223.700000, \"memorySlabUnrecl\": 224.700000, \"memoryUsed\": 250.000000, \"vmIdentifier\": \"VMID2\", \"memoryDemand\": 225.700000, \"memoryLatencyAvg\": 226.700000, \"memorySharedAvg\": 227.700000, \"memorySwapInAvg\": 228.700000, \"memorySwapInRateAvg\": 229.700000, \"memorySwapOutAvg\": 230.700000, \"memorySwapOutRateAvg\": 231.700000, \"memorySwapUsedAvg\": 232.700000, \"percentMemoryUsage\": 233.700000}], \"numberOfMediaPortsInUse\": 55, \"nfcScalingMetric\": 66, \"featureUsageArray\": {\"FeatureA\": \"123\", \"FeatureB\": \"567\"}, \"codecUsageArray\": [{\"codecIdentifier\": \"G711a\", \"numberInUse\": 91}, {\"codecIdentifier\": \"G729ab\", \"numberInUse\": 92}], \"additionalMeasurements\": [{\"name\": \"hmNam1\", \"hashMap\": {\"hmkey1\": \"hmVal1\", \"hmkey4\": \"hmVal4\", \"hmkey2\": \"hmVal2\", \"hmkey3\": \"hmVal3\"}}, {\"name\": \"hmNam2\", \"hashMap\": {\"hmkey24\": \"hmVal24\", \"hmkey22\": \"hmVal22\", \"hmkey23\": \"hmVal23\", \"hmkey21\": \"hmVal21\"}}], \"measurementFieldsVersion\": \"4.0\"}}}";
+
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -501,9 +305,10 @@ void test_encode_measurement()
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_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);
@@ -527,7 +332,8 @@ void test_encode_measurement()
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);
@@ -544,7 +350,7 @@ void test_encode_measurement()
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);
@@ -560,6 +366,7 @@ void test_encode_measurement()
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);
@@ -631,19 +438,28 @@ void test_encode_measurement()
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);
-
+
+ disk_use = evel_measurement_new_disk_use_add(measurement, "Disk2");
+ evel_measurement_disk_use_iotimeavg_set(disk_use, 71.1);
+ evel_measurement_disk_use_iotimelast_set(disk_use, 72.1);
+ evel_measurement_disk_use_iotimemax_set(disk_use, 73.1);
+ evel_measurement_disk_use_iotimemin_set(disk_use, 74.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_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, "hmkey2", "hmVal2");
evel_measurement_addl_measurement_set(ht1, "hmkey3", "hmVal3");
evel_measurement_addl_measurement_set(ht1, "hmkey4", "hmVal4");
@@ -712,14 +528,15 @@ void test_encode_measurement()
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);
@@ -730,37 +547,56 @@ void test_encode_measurement()
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);
+ temp = evel_measurement_new_base_board_temp_add(ipmi, "BBTEMP2");
+ evel_measurement_ipmi_bb_temp_set(ipmi, temp, 79.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);
+ volt = evel_measurement_new_base_board_volt_add(ipmi, "BBVOLT2");
+ evel_measurement_ipmi_bb_volt_set(ipmi, volt, 68.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);
+ batt = evel_measurement_new_ipmi_battery_add(ipmi, "BBBATTERY2");
+ evel_measurement_ipmi_battery_type_set(ipmi, batt, "BattType2");
+ evel_measurement_ipmi_battery_voltage_set(ipmi, batt, 110);
MEASUREMENT_IPMI_FAN * fan;
fan = evel_measurement_new_ipmi_fan_add(ipmi, "FAN1");
evel_measurement_ipmi_fan_speed_set(ipmi, fan, 300);
+ fan = evel_measurement_new_ipmi_fan_add(ipmi, "FAN2");
+ evel_measurement_ipmi_fan_speed_set(ipmi, fan, 200);
MEASUREMENT_IPMI_HSBP * hsbp;
hsbp = evel_measurement_new_ipmi_hsbp_add(ipmi, "BBHSBP1");
evel_measurement_ipmi_hsbp_temp_set(ipmi, hsbp, 100);
+ hsbp = evel_measurement_new_ipmi_hsbp_add(ipmi, "BBHSBP2");
+ evel_measurement_ipmi_hsbp_temp_set(ipmi, hsbp, 200);
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);
+ glob = evel_measurement_new_ipmi_global_temp_add(ipmi, "BBGLOBAL2");
+ evel_measurement_ipmi_global_temp_margin_set(ipmi, glob, 32.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);
+ nic = evel_measurement_new_ipmi_nic_add(ipmi, "NIC_2");
+ evel_measurement_ipmi_nic_temp_set(ipmi, nic, 43.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);
+ pwr = evel_measurement_new_ipmi_power_add(ipmi, "POWERSupply2");
+ evel_measurement_ipmi_power_inputpwr_set(ipmi, pwr, 300.5);
+ evel_measurement_ipmi_power_current_op_set(ipmi, pwr, 60.4);
+ evel_measurement_ipmi_power_temp_set(ipmi, pwr, 200.5);
MEASUREMENT_IPMI_PROCESSOR * proc;
proc = evel_measurement_new_ipmi_processor_add(ipmi, "PROCESSOR1");
@@ -769,9 +605,19 @@ void test_encode_measurement()
MEASUREMENT_IPMI_PROCESSOR_DIMMAGG_THERM * dimm;
dimm = evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add(ipmi, proc, "DIMM1", 15.8);
+ assert(dimm != NULL);
+ dimm = evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add(ipmi, proc, "DIMM2", 25.8);
+ assert(dimm != NULL);
+ proc = evel_measurement_new_ipmi_processor_add(ipmi, "PROCESSOR2");
+ evel_measurement_ipmi_processor_theralCtrl_set(ipmi, proc, 30.9);
+ evel_measurement_ipmi_processor_theralMargin_set(ipmi, proc, 39.8);
+
+ dimm = evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add(ipmi, proc, "DIMM1", 35.8);
assert(dimm != NULL);
-
+ dimm = evel_measurement_ipmi_processor_new_dimmAggThermalMargin_add(ipmi, proc, "DIMM2", 55.8);
+ assert(dimm != NULL);
+
MEASUREMENT_LOAD * load;
load = evel_measurement_new_loads_add(measurement);
evel_measurement_load_shortTerm_set(load, 22.5);
@@ -788,7 +634,17 @@ void test_encode_measurement()
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);
-
+
+ pstat = evel_measurement_new_process_stats_add(measurement, "Process2");
+ evel_measurement_process_stat_forkRate_set(pstat, 110.1);
+ evel_measurement_process_stat_psStateBlocked_set(pstat, 120.1);
+ evel_measurement_process_stat_psStatePaging_set(pstat, 230.1);
+ evel_measurement_process_stat_psStateRunning_set(pstat, 340.1);
+ evel_measurement_process_stat_psStateSleeping_set(pstat, 450.1);
+ evel_measurement_process_stat_psStateStopped_set(pstat, 560.1);
+ evel_measurement_process_stat_psStateZombie_set(pstat, 670.1);
+ evel_measurement_process_stat_psStateZombie_set(pstat, 780.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);
@@ -796,6 +652,12 @@ void test_encode_measurement()
evel_measurement_machine_check_uncor_mem_err_set(mcheck, 310.1);
evel_measurement_machine_check_uncor_mem_err_1hr_set(mcheck, 410.1);
+ mcheck = evel_measurement_new_machine_check_exception_add(measurement, "ProcessID2");
+ evel_measurement_machine_check_cor_mem_err_set(mcheck, 410.1);
+ evel_measurement_machine_check_cor_mem_err_1hr_set(mcheck, 510.1);
+ evel_measurement_machine_check_uncor_mem_err_set(mcheck, 610.1);
+ evel_measurement_machine_check_uncor_mem_err_1hr_set(mcheck, 710.1);
+
MEASUREMENT_HUGE_PAGE * hugep;
hugep = evel_measurement_new_huge_page_add(measurement, "HUGEPage1");
evel_measurement_huge_page_bytesUsed_set(hugep, 100);
@@ -805,6 +667,15 @@ void test_encode_measurement()
evel_measurement_huge_page_percentUsed_set(hugep, 500);
evel_measurement_huge_page_percentFree_set(hugep, 600);
+ hugep = evel_measurement_new_huge_page_add(measurement, "HUGEPage2");
+ evel_measurement_huge_page_bytesUsed_set(hugep, 180);
+ evel_measurement_huge_page_bytesFree_set(hugep, 280);
+ evel_measurement_huge_page_vmPageNumberUsed_set(hugep, 380);
+ evel_measurement_huge_page_vmPageNumberFree_set(hugep, 480);
+ evel_measurement_huge_page_percentUsed_set(hugep, 580);
+ evel_measurement_huge_page_percentFree_set(hugep, 680);
+
+ evel_source_name_set(&measurement->header, "VM-VirtualBox");
evel_start_epoch_set(&measurement->header, 2000);
evel_last_epoch_set(&measurement->header, 3000);
evel_reporting_entity_name_set(&measurement->header, "entity_name");
@@ -827,6 +698,7 @@ void test_encode_measurement()
// evel_free_event(measurement);
}
+/**********
void test_encode_mobile_mand()
{
char * expected =
@@ -838,9 +710,9 @@ void test_encode_mobile_mand()
"\"functionalRole\": \"UNIT TEST\", "
"\"lastEpochMicrosec\": 1000002, "
"\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
+ "\"reportingEntityName\": \"VM-VirtualBox\", "
"\"sequence\": 1241, "
- "\"sourceName\": \"prakash-VirtualBox\", "
+ "\"sourceName\": \"VM-VirtualBox\", "
"\"startEpochMicrosec\": 1000002, "
"\"version\": 1.2, "
"\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
@@ -893,9 +765,6 @@ void test_encode_mobile_mand()
MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
EVENT_MOBILE_FLOW * mobile_flow = NULL;
- /***************************************************************************/
- /* Mobile. */
- /***************************************************************************/
// evel_set_next_event_sequence(1241);
metrics = evel_new_mobile_gtp_flow_metrics(12.3,
@@ -940,6 +809,8 @@ void test_encode_mobile_mand()
"4.2.3.1",
4321);
assert(mobile_flow != NULL);
+ evel_source_name_set(&mobile_flow->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&mobile_flow->header, "VM-VirtualBox");
json_size = evel_json_encode_event(
json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
@@ -957,114 +828,12 @@ void test_encode_mobile_mand()
//evel_free_event(mobile_flow);
}
+*******************/
void test_encode_mobile_opts()
{
char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"mobileFlow\", "
- "\"eventId\": \"mobileFlow000000001\", "
- "\"eventName\": \"mobileFlow_error\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 1242, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Mobile flow...\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"mobileFlowFields\": {"
- "\"flowDirection\": \"Inbound\", "
- "\"gtpPerFlowMetrics\": {"
- "\"avgBitErrorRate\": 132.000100, "
- "\"avgPacketDelayVariation\": 31.200000, "
- "\"avgPacketLatency\": 101, "
- "\"avgReceiveThroughput\": 2101, "
- "\"avgTransmitThroughput\": 501, "
- "\"flowActivationEpoch\": 1470409422, "
- "\"flowActivationMicrosec\": 988, "
- "\"flowDeactivationEpoch\": 1470409432, "
- "\"flowDeactivationMicrosec\": 12, "
- "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
- "\"flowStatus\": \"Inactive\", "
- "\"maxPacketDelayVariation\": 88, "
- "\"numActivationFailures\": 4, "
- "\"numBitErrors\": 18, "
- "\"numBytesReceived\": 123655, "
- "\"numBytesTransmitted\": 4562, "
- "\"numDroppedPackets\": 1, "
- "\"numL7BytesReceived\": 13, "
- "\"numL7BytesTransmitted\": 11, "
- "\"numLostPackets\": 2, "
- "\"numOutOfOrderPackets\": 4, "
- "\"numPacketErrors\": 8, "
- "\"numPacketsReceivedExclRetrans\": 900, "
- "\"numPacketsReceivedInclRetrans\": 902, "
- "\"numPacketsTransmittedInclRetrans\": 303, "
- "\"numRetries\": 7, "
- "\"numTimeouts\": 3, "
- "\"numTunneledL7BytesReceived\": 1, "
- "\"roundTripTime\": 111, "
- "\"timeToFirstByte\": 226, "
- "\"ipTosCountList\": ["
- "[\"1\", 13], "
- "[\"4\", 99], "
- "[\"17\", 1]], "
- "\"ipTosList\": [\"1\", \"4\", \"17\"], "
- "\"tcpFlagList\": [\"CWR\", \"URG\"], "
- "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
- "\"mobileQciCosList\": [\"conversational\", \"65\"], "
- "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
- "\"durConnectionFailedStatus\": 12, "
- "\"durTunnelFailedStatus\": 13, "
- "\"flowActivatedBy\": \"Remote\", "
- "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
- "\"flowDeactivatedBy\": \"Remote\", "
- "\"gtpConnectionStatus\": \"Connected\", "
- "\"gtpTunnelStatus\": \"Not tunneling\", "
- "\"largePacketRtt\": 80, "
- "\"largePacketThreshold\": 600.000000, "
- "\"maxReceiveBitRate\": 1357924680, "
- "\"maxTransmitBitRate\": 235711, "
- "\"numGtpEchoFailures\": 1, "
- "\"numGtpTunnelErrors\": 4, "
- "\"numHttpErrors\": 2"
- "}, "
- "\"ipProtocolType\": \"UDP\", "
- "\"ipVersion\": \"IPv6\", "
- "\"otherEndpointIpAddress\": \"2.3.4.2\", "
- "\"otherEndpointPort\": 2342, "
- "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
- "\"reportingEndpointPort\": 4322, "
- "\"applicationType\": \"Demo application\", "
- "\"appProtocolType\": \"GSM\", "
- "\"appProtocolVersion\": \"1\", "
- "\"cid\": \"65535\", "
- "\"connectionType\": \"S1-U\", "
- "\"ecgi\": \"e65535\", "
- "\"gtpProtocolType\": \"GTP-U\", "
- "\"gtpVersion\": \"1\", "
- "\"httpHeader\": \"http://www.something.com\", "
- "\"imei\": \"209917614823\", "
- "\"imsi\": \"355251/05/850925/8\", "
- "\"lac\": \"1\", "
- "\"mcc\": \"410\", "
- "\"mnc\": \"04\", "
- "\"msisdn\": \"6017123456789\", "
- "\"otherFunctionalRole\": \"MME\", "
- "\"rac\": \"514\", "
- "\"radioAccessTechnology\": \"LTE\", "
- "\"sac\": \"1\", "
- "\"samplingAlgorithm\": 1, "
- "\"tac\": \"2099\", "
- "\"tunnelId\": \"Tunnel 1\", "
- "\"vlanId\": \"15\""
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"mobileFlow\", \"eventId\": \"mobileFlow000000001\", \"eventName\": \"mobileFlow_error\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Mobile flow...\"}, \"mobileFlowFields\": {\"additionalFields\": {\"Mkey1\": \"MValue1\", \"Mkey2\": \"MValue2\"}, \"flowDirection\": \"Inbound\", \"gtpPerFlowMetrics\": {\"avgBitErrorRate\": 132.000100, \"avgPacketDelayVariation\": 31.200000, \"avgPacketLatency\": 101, \"avgReceiveThroughput\": 2101, \"avgTransmitThroughput\": 501, \"flowActivationEpoch\": 1470409422, \"flowActivationMicrosec\": 988, \"flowDeactivationEpoch\": 1470409432, \"flowDeactivationMicrosec\": 12, \"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", \"flowStatus\": \"Inactive\", \"maxPacketDelayVariation\": 88, \"numActivationFailures\": 4, \"numBitErrors\": 18, \"numBytesReceived\": 123655, \"numBytesTransmitted\": 4562, \"numDroppedPackets\": 1, \"numL7BytesReceived\": 13, \"numL7BytesTransmitted\": 11, \"numLostPackets\": 2, \"numOutOfOrderPackets\": 4, \"numPacketErrors\": 8, \"numPacketsReceivedExclRetrans\": 900, \"numPacketsReceivedInclRetrans\": 902, \"numPacketsTransmittedInclRetrans\": 303, \"numRetries\": 7, \"numTimeouts\": 3, \"numTunneledL7BytesReceived\": 1, \"roundTripTime\": 111, \"timeToFirstByte\": 226, \"durConnectionFailedStatus\": 12, \"durTunnelFailedStatus\": 13, \"flowActivatedBy\": \"Remote\", \"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", \"flowDeactivatedBy\": \"Remote\", \"gtpConnectionStatus\": \"Connected\", \"gtpTunnelStatus\": \"Not tunneling\", \"largePacketRtt\": 80, \"largePacketThreshold\": 600.000000, \"maxReceiveBitRate\": 1357924680, \"maxTransmitBitRate\": 235711, \"numGtpEchoFailures\": 1, \"numGtpTunnelErrors\": 4, \"numHttpErrors\": 2, \"ipTosCountList\": {\"17\": \"1\", \"1\": \"13\", \"4\": \"99\"}, \"ipTosList\": [\"17\", \"1\", \"4\"], \"mobileQciCosCountList\": {\"65\": \"122\", \"conversational\": \"11\"}, \"mobileQciCosList\": [\"65\", \"conversational\"], \"tcpFlagCountList\": {\"CWR\": \"10\", \"URG\": \"121\"}, \"tcpFlagList\": [\"CWR\", \"URG\"]}, \"ipProtocolType\": \"UDP\", \"ipVersion\": \"IPv6\", \"otherEndpointIpAddress\": \"2.3.4.2\", \"otherEndpointPort\": 2342, \"reportingEndpointIpAddr\": \"4.2.3.2\", \"reportingEndpointPort\": 4322, \"applicationType\": \"Demo application\", \"appProtocolType\": \"GSM\", \"appProtocolVersion\": \"1\", \"cid\": \"65535\", \"connectionType\": \"S1-U\", \"ecgi\": \"e65535\", \"gtpProtocolType\": \"GTP-U\", \"gtpVersion\": \"1\", \"httpHeader\": \"http://www.something.com\", \"imei\": \"209917614823\", \"imsi\": \"355251/05/850925/8\", \"lac\": \"1\", \"mcc\": \"410\", \"mnc\": \"04\", \"msisdn\": \"6017123456789\", \"otherFunctionalRole\": \"MME\", \"rac\": \"514\", \"radioAccessTechnology\": \"LTE\", \"sac\": \"1\", \"samplingAlgorithm\": 1, \"tac\": \"2099\", \"tunnelId\": \"Tunnel 1\", \"vlanId\": \"15\", \"mobileFlowFieldsVersion\": \"4.0\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1157,6 +926,8 @@ void test_encode_mobile_opts()
4322);
assert(mobile_flow != NULL);
+ evel_source_name_set(&mobile_flow->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&mobile_flow->header, "VM-VirtualBox");
evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
@@ -1190,303 +961,21 @@ void test_encode_mobile_opts()
compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
assert((json_size == strlen(json_body)) && "Bad size returned");
- evel_free_event(mobile_flow);
-}
-/********
-void test_encode_report()
-{
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"measurementsForVfReporting\", "
- "\"eventId\": \"report000000001\", "
- "\"eventName\": \"report_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 125, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Perf reporting...\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"measurementsForVfReportingFields\": "
- "{\"measurementInterval\": 1.100000, "
- "\"featureUsageArray\": ["
- "{\"featureIdentifier\": \"FeatureA\", "
- "\"featureUtilization\": 123}, "
- "{\"featureIdentifier\": \"FeatureB\", "
- "\"featureUtilization\": 567}], "
- "\"additionalMeasurements\": ["
- "{\"name\": \"Group1\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}]}, "
- "{\"name\": \"Group2\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}, "
- "{\"name\": \"Name2\", "
- "\"value\": \"Value2\"}]}], "
- "\"measurementFieldsVersion\": 1.1}}}";
-
- size_t json_size = 0;
- char json_body[EVEL_MAX_JSON_BODY];
- EVENT_REPORT * report = NULL;
-
-// 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);
- evel_report_feature_use_add(report, "FeatureB", 567);
- evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
- evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
- evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
-
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(report);
-}
-****************/
-/********************
-void test_encode_service()
-{
- test_encode_service_subset(SERVICE_NONE);
- test_encode_service_subset(SERVICE_CODEC);
- test_encode_service_subset(SERVICE_TRANSCODING);
- test_encode_service_subset(SERVICE_RTCP);
- 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\": \"sipSignal0000000001\", "
- "\"eventName\": \"sipSignal_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 2000, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Service Event\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"serviceEventsFields\": {"
- "\"eventInstanceIdentifier\": "
- "{"
- "\"vendorId\": \"vendor_x_id\", "
- "\"eventId\": \"vendor_x_event_id\", "
- "\"productId\": \"vendor_x_product_id\", "
- "\"subsystemId\": \"vendor_x_subsystem_id\", "
- "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
- "}, "
- "\"serviceEventsFieldsVersion\": 1.1, "
- "\"correlator\": \"vendor_x_correlator\", "
- "\"additionalFields\": ["
- "{\"name\": \"Name1\", \"value\": \"Value1\"}, "
- "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
- "{\"name\": \"Name3\", \"value\": \"Value3\"}, "
- "{\"name\": \"Name4\", \"value\": \"Value4\"}]";
- char * expected_codec =
- ", "
- "\"codecSelected\": {"
- "\"codec\": \"PCMA\""
- "}";
- char * expected_transcoding =
- ", "
- "\"codecSelectedTranscoding\": {"
- "\"calleeSideCodec\": \"PCMA\", "
- "\"callerSideCodec\": \"G729A\""
- "}";
- char * expected_rtcp =
- ", "
- "\"midCallRtcp\": {"
- "\"rtcpData\": \"some_rtcp_data\""
- "}";
- char * expected_eoc_vqm =
- ", "
- "\"endOfCallVqmSummaries\": {"
- "\"adjacencyName\": \"vendor_x_adjacency\", "
- "\"endpointDescription\": \"Caller\", "
- "\"endpointJitter\": 66, "
- "\"endpointRtpOctetsDiscarded\": 100, "
- "\"endpointRtpOctetsReceived\": 200, "
- "\"endpointRtpOctetsSent\": 300, "
- "\"endpointRtpPacketsDiscarded\": 400, "
- "\"endpointRtpPacketsReceived\": 500, "
- "\"endpointRtpPacketsSent\": 600, "
- "\"localJitter\": 99, "
- "\"localRtpOctetsDiscarded\": 150, "
- "\"localRtpOctetsReceived\": 250, "
- "\"localRtpOctetsSent\": 350, "
- "\"localRtpPacketsDiscarded\": 450, "
- "\"localRtpPacketsReceived\": 550, "
- "\"localRtpPacketsSent\": 650, "
- "\"mosCqe\": 12.255000, "
- "\"packetsLost\": 157, "
- "\"packetLossPercent\": 0.232000, "
- "\"rFactor\": 11, "
- "\"roundTripDelay\": 15"
- "}";
- char * expected_marker =
- ", "
- "\"marker\": {"
- "\"phoneNumber\": \"0888888888\""
- "}";
- char * expected_end =
- "}}}";
-
- char * expected_middle = NULL;
- switch (service_test)
+ if(evel_post_event((EVENT_HEADER *)mobile_flow) == EVEL_SUCCESS)
{
- case SERVICE_NONE:
- expected_middle = "";
- break;
- case SERVICE_CODEC:
- expected_middle = expected_codec;
- break;
- case SERVICE_TRANSCODING:
- expected_middle = expected_transcoding;
- break;
- case SERVICE_RTCP:
- expected_middle = expected_rtcp;
- break;
- case SERVICE_EOC_VQM:
- expected_middle = expected_eoc_vqm;
- break;
- case SERVICE_MARKER:
- expected_middle = expected_marker;
- break;
+ printf("Message sent to Collector successfully\n");
}
- assert(expected_middle != NULL);
-
- int offset = 0;
- char expected[EVEL_MAX_JSON_BODY];
- offset = snprintf(expected + offset,
- EVEL_MAX_JSON_BODY - offset,
- "%s%s%s",
- expected_start,
- expected_middle,
- expected_end);
-
- size_t json_size = 0;
- char json_body[EVEL_MAX_JSON_BODY];
- 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");
- evel_signaling_correlator_set(event, "vendor_x_correlator");
- evel_signaling_vnfmodule_name_set(event, "vendor_x_module");
- evel_signaling_vnfname_set(event, "vendor_x_vnf");
-
- switch (service_test)
+ else
{
- case SERVICE_NONE:
- break;
- case SERVICE_CODEC:
- evel_signaling_addl_info_add(event, "codec", "PCMA");
- break;
- case SERVICE_TRANSCODING:
- evel_signaling_addl_info_add(event, "calleecodec", "PCMA");
- evel_signaling_addl_info_add(event, "callercodec", "G729A");
- break;
- case SERVICE_RTCP:
- evel_signaling_addl_info_add(event, "rtcpdata", "abcdefgh");
- 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);
- break;
- case SERVICE_MARKER:
- evel_signaling_addl_info_add(event, "service_phone", "0888888888");
- break;
+ printf("Message sending Error\n");
}
-
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(event);
+// evel_free_event(mobile_flow);
}
-*******************/
+
void test_encode_signaling()
{
char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"signaling\", "
- "\"eventId\": \"sipSignal0000000001\", "
- "\"eventName\": \"sipSignal_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 2001, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Signaling\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"signalingFields\": {"
- "\"eventInstanceIdentifier\": "
- "{"
- "\"vendorId\": \"vendor_x_id\", "
- "\"eventId\": \"vendor_x_event_id\", "
- "\"productId\": \"vendor_x_product_id\", "
- "\"subsystemId\": \"vendor_x_subsystem_id\", "
- "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
- "}, "
- "\"signalingFieldsVersion\": 1.1, "
- "\"correlator\": \"vendor_x_correlator\", "
- "\"localIpAddress\": \"1.0.3.1\", "
- "\"localPort\": \"1031\", "
- "\"remoteIpAddress\": \"5.3.3.0\", "
- "\"remotePort\": \"5330\", "
- "\"compressedSip\": \"compressed_sip\", "
- "\"summarySip\": \"summary_sip\""
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"sipSignaling\", \"eventId\": \"sipSignal0000000001\", \"eventName\": \"sipSignal_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Signaling\"}, \"sipSignalingFields\": {\"compressedSip\": \"compressed_sip\", \"correlator\": \"correlator\", \"localIpAddress\": \"1.0.3.1\", \"localPort\": \"1234\", \"remoteIpAddress\": \"192.168.1.3\", \"remotePort\": \"3456\", \"sipSignalingFieldsVersion\": \"3.0\", \"summarySip\": \"summary_sip\", \"vendorNfNameFields\": {\"vendorName\": \"vendor_x_id\", \"nfModuleName\": \"vendor_x_module\", \"nfName\": \"vendor_x_vnf\"}, \"additionalInformation\": {\"name2\": \"value2\", \"name3\": \"value3\", \"name1\": \"value1\", \"name4\": \"value4\"}}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1496,6 +985,8 @@ void test_encode_signaling()
"sipSignal0000000001", "vendor_x_id",
"correlator", "1.0.3.1", "1234", "192.168.1.3","3456");
assert(event != NULL);
+ evel_source_name_set(&event->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&event->header, "VM-VirtualBox");
evel_signaling_addl_info_add(event, "name1", "value1");
evel_signaling_addl_info_add(event, "name2", "value2");
@@ -1533,7 +1024,9 @@ void test_encode_signaling()
void test_encode_notif()
{
- char * expected = " ";
+ char * expected =
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"notification\", \"eventId\": \"Notification0000000001\", \"eventName\": \"notif_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Event_type\"}, \"notificationFields\": {\"changeIdentifier\": \"ChangeId\", \"changeType\": \"ChangeType\", \"newState\": \"maintenance\", \"oldState\": \"outOfService\", \"changeContact\": \"ChangeContact\", \"stateInterface\": \"STInterface\", \"additionalFields\": {\"name2\": \"value2\", \"name3\": \"value3\", \"name1\": \"value1\", \"name4\": \"value4\"}, \"arrayOfNamedHashMap\": [{\"name\": \"hmNam1\", \"hashMap\": {\"hmnap1\": \"hmvalue1\", \"hmnap3\": \"hmvalue3\", \"hmnap2\": \"hmvalue2\", \"hmnap4\": \"hmvalue4\"}}, {\"name\": \"hmNam2\", \"hashMap\": {\"hmnap24\": \"hmvalue24\", \"hmnap21\": \"hmvalue21\", \"hmnap22\": \"hmvalue22\", \"hmnap23\": \"hmvalue23\"}}], \"notificationFieldsVersion\": \"2.0\"}}}";
+
HASHTABLE_T * ht1 = NULL;
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1543,6 +1036,8 @@ void test_encode_notif()
"ChangeType");
assert(event != NULL);
+ evel_source_name_set(&event->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&event->header, "VM-VirtualBox");
evel_notification_type_set(event, "Event_type");
evel_notification_changeContact_set(event, "ChangeContact");
@@ -1586,7 +1081,8 @@ void test_encode_notif()
void test_encode_voiceQ()
{
- char * expected = " ";
+ char * expected =
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"voiceQuality\", \"eventId\": \"VoiceQuality0000000001\", \"eventName\": \"voiceQ_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\"}, \"voiceQualityFields\": {\"calleeSideCodec\": \"Callee_cdc1\", \"callerSideCodec\": \"Caller_cdc1\", \"correlator\": \"CorrNew\", \"midCallRtcp\": \"RTCPNew\", \"vendorNfNameFields\": {\"vendorName\": \"Vendor_x\", \"nfModuleName\": \"vendor_x_module\", \"nfName\": \"vendor_x_vnf\"}, \"voiceQualityFieldsVersion\": \"4.0\", \"phoneNumber\": \"1234567890\", \"additionalInformation\": {\"name2\": \"value2\", \"name3\": \"value3\", \"name1\": \"value1\", \"name4\": \"value4\"}, \"endOfCallVqmSummaries\": {\"adjacencyName\": \"Adj_name\", \"endpointDescription\": \"Callee\", \"localRtpOctetsLost\": 1, \"endpointRtpOctetsDiscarded\": 2, \"endpointRtpOctetsReceived\": 3, \"endpointRtpOctetsSent\": 4, \"endpointRtpPacketsDiscarded\": 5, \"endpointRtpPacketsReceived\": 6, \"endpointRtpPacketsSent\": 7, \"localMaxJitterBufferDelay\": 8, \"localRtpOctetsDiscarded\": 9, \"localRtpOctetsReceived\": 10, \"localRtpOctetsSent\": 11, \"localRtpPacketsDiscarded\": 12, \"localRtpPacketsReceived\": 1, \"localRtpPacketsSent\": 2, \"mosCqe\": 3, \"localRtpPacketsLost\": 16, \"packetLossPercent\": 17, \"rFactor\": 18, \"roundTripDelay\": 19, \"endpointAverageJitter\": 20, \"endpointMaxJitter\": 21, \"endpointRtpOctetsLost\": 22, \"endpointRtpPacketsLost\": 23, \"localAverageJitter\": 24, \"localAverageJitterBufferDelay\": 25, \"localMaxJitter\": 26, \"oneWayDelay\": 27}}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1596,14 +1092,16 @@ void test_encode_voiceQ()
"VoiceQuality0000000001", "Called_Codec",
"Caller_codec", "Correlator", "RTCP", "Vendor_x");
assert(event != NULL);
+ evel_source_name_set(&event->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&event->header, "VM-VirtualBox");
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_callee_codec_set(event, "Callee_cdc1");
+ evel_voice_quality_caller_codec_set(event, "Caller_cdc1");
evel_voice_quality_correlator_set(event, "CorrNew");
evel_voice_quality_rtcp_data_set(event, "RTCPNew");
@@ -1632,35 +1130,7 @@ void test_encode_voiceQ()
void test_encode_state_change()
{
char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"stateChange\", "
- "\"eventId\": \"stateChange000000001\", "
- "\"eventName\": \"stateChange_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 128, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"SC Type\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"stateChangeFields\": {"
- "\"newState\": \"inService\", "
- "\"oldState\": \"outOfService\", "
- "\"stateInterface\": \"An Interface\", "
- "\"additionalFields\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}, "
- "{\"name\": \"Name2\", "
- "\"value\": \"Value2\"}"
- "], "
- "\"stateChangeFieldsVersion\": 1.1"
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"stateChange\", \"eventId\": \"stateChange000000001\", \"eventName\": \"stateChange_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"SC Type\"}, \"stateChangeFields\": {\"newState\": \"inService\", \"oldState\": \"maintenance\", \"stateInterface\": \"An Interface\", \"additionalFields\": {\"Name2\": \"Value2\", \"Name1\": \"Value1\"}, \"stateChangeFieldsVersion\": \"4.0\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1672,6 +1142,8 @@ void test_encode_state_change()
EVEL_ENTITY_STATE_MAINTENANCE,
"An Interface");
assert(state_change != NULL);
+ evel_source_name_set(&state_change->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&state_change->header, "VM-VirtualBox");
evel_state_change_type_set(state_change, "SC Type");
evel_state_change_addl_field_add(state_change, "Name1", "Value1");
evel_state_change_addl_field_add(state_change, "Name2", "Value2");
@@ -1696,35 +1168,8 @@ void test_encode_state_change()
void test_encode_syslog()
{
char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"syslog\", "
- "\"eventId\": \"syslog000000001\", "
- "\"eventName\": \"syslog_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 126, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"SL Type\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"syslogFields\": {"
- "\"eventSourceType\": \"virtualNetworkFunction\", "
- "\"syslogMsg\": \"SL Message\", "
- "\"syslogTag\": \"SL Tag\", "
- "\"syslogFieldsVersion\": 1.1, "
- "\"eventSourceHost\": \"SL Host\", "
- "\"syslogFacility\": 6, "
- "\"syslogProc\": \"SL Proc\", "
- "\"syslogProcId\": 2, "
- "\"syslogSData\": \"SL SDATA\", "
- "\"syslogVer\": 1"
- "}}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"syslog\", \"eventId\": \"syslog000000001\", \"eventName\": \"syslog_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"SL Type\"}, \"syslogFields\": {\"additionalFields\": {\"Name2\": \"Value2\", \"Name4\": \"Value4\", \"Name5\": \"Value5\", \"Name3\": \"Value3\", \"Name1\": \"Value1\"}, \"eventSourceType\": \"virtualNetworkFunction\", \"syslogMsg\": \"SL Message\", \"syslogTag\": \"SL Tag\", \"syslogFieldsVersion\": \"4.0\", \"eventSourceHost\": \"SL Host\", \"syslogFacility\": 6, \"syslogPri\": 15, \"syslogProc\": \"SL Proc\", \"syslogProcId\": 2, \"syslogSData\": \"SL SDATA\", \"syslogSdId\": \"ourSDID@12345\", \"syslogSev\": \"Alert\", \"syslogVer\": 1, \"syslogMsgHost\": \"hostName123\", \"syslogTs\": \"12-DEC-2018\"}}}";
+
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
EVENT_SYSLOG * syslog = NULL;
@@ -1734,6 +1179,8 @@ void test_encode_syslog()
"SL Message",
"SL Tag");
assert(syslog != NULL);
+ evel_source_name_set(&syslog->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&syslog->header, "VM-VirtualBox");
evel_syslog_type_set(syslog, "SL Type");
evel_syslog_event_source_host_set(syslog, "SL Host");
evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
@@ -1773,30 +1220,7 @@ void test_encode_syslog()
void test_encode_other()
{
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\"}"
- "]"
- "}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"other\", \"eventId\": \"other000000001\", \"eventName\": \"other_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"Other Type\"}, \"otherFields\": {\"hashMap\": {\"Name2\": \"Value2\", \"Name4\": \"Value4\", \"Name5\": \"Value5\", \"Name3\": \"Value3\", \"Name1\": \"Value1\"}, \"arrayOfNamedHashMap\": [{\"name\": \"hmap1\", \"hashMap\": {\"Name14\": \"Value14\", \"Name11\": \"Value11\", \"Name12\": \"Value12\", \"Name13\": \"Value13\"}}, {\"name\": \"hmap2\", \"hashMap\": {\"Name21\": \"Value21\", \"Name22\": \"Value22\", \"Name23\": \"Value23\", \"Name24\": \"Value24\"}}], \"otherFieldsVersion\": \"3.0\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1807,6 +1231,8 @@ void test_encode_other()
// evel_set_next_event_sequence(129);
other = evel_new_other("other_err", "other000000001");
assert(other != NULL);
+ evel_source_name_set(&other->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&other->header, "VM-VirtualBox");
evel_other_type_set(other, "Other Type");
ht1 = evel_other_add_new_hashmap_to_hmarray(other, "hmap1");
@@ -1847,30 +1273,7 @@ void test_encode_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\"}"
- "]"
- "}}";
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"pnfRegistration\", \"eventId\": \"pnfreg000000001\", \"eventName\": \"pnfreg_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\"}, \"pnfRegistrationFields\": {\"lastServiceDate\": \"10FEB2019\", \"macAddress\": \"FF:28:22:34:45:56\", \"manufactureDate\": \"FEB2011\", \"modelNumber\": \"FE934567\", \"oamV4IpAddress\": \"10.255.1.254\", \"oamV6IpAddress\": \"::20\", \"serialNumber\": \"1234567890\", \"softwareVersion\": \"SW1234\", \"unitFamily\": \"Unit_Fam_123\", \"unitType\": \"Unit_type_123\", \"vendorName\": \"Vend_nam_123\", \"additionalFields\": {\"Name2\": \"Value2\", \"Name4\": \"Value4\", \"Name5\": \"Value5\", \"Name3\": \"Value3\", \"Name1\": \"Value1\"}, \"pnfRegistrationFieldsVersion\": \"2.0\"}}}";
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
@@ -1878,6 +1281,8 @@ void test_encode_pnfreg()
pnfreg = evel_new_pnf_registration("pnfreg_err", "pnfreg000000001");
assert(pnfreg != NULL);
+ evel_source_name_set(&pnfreg->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&pnfreg->header, "VM-VirtualBox");
evel_pnf_registration_addl_field_add(pnfreg, "Name1", "Value1");
evel_pnf_registration_addl_field_add(pnfreg, "Name2", "Value2");
@@ -1918,7 +1323,9 @@ void test_encode_pnfreg()
void test_encode_tca()
{
- char * expected = "123456789";
+ char * expected =
+"{\"event\": {\"commonEventHeader\": {\"domain\": \"thresholdCrossingAlert\", \"eventId\": \"tca000000001\", \"eventName\": \"tca_err\", \"vesEventListenerVersion\": \"7.1\", \"lastEpochMicrosec\": 1000002, \"priority\": \"Normal\", \"reportingEntityName\": \"VM-VirtualBox\", \"sequence\": 0, \"sourceName\": \"VM-VirtualBox\", \"startEpochMicrosec\": 1000002, \"version\": \"4.1\", \"eventType\": \"node\"}, \"thresholdCrossingAlertFields\": {\"additionalParameters\": [{\"criticality\": \"CRIT\", \"thresholdCrossed\": \"LastThresh\", \"hashMap\": {\"key1\": \"value1\", \"key2\": \"value2\"}}, {\"criticality\": \"CRIT\", \"thresholdCrossed\": \"LastThresh\", \"hashMap\": {\"key4\": \"value4\", \"key3\": \"value3\"}}], \"alertAction\": \"CLEAR\", \"alertDescription\": \"NE-CPUMEM\", \"alertType\": \"CARD-ANOMALY\", \"collectionTimestamp\": \"1234567\", \"eventSeverity\": \"CRITICAL\", \"eventStartTimestamp\": \"8765432\", \"alertValue\": \"AlertVal\", \"dataCollector\": \"dataCollector\", \"elementType\": \"elementtype\", \"interfaceName\": \"ens04\", \"networkService\": \"nwservice\", \"possibleRootCause\": \"prootcause\", \"associatedAlertIdList\": [\"Alert1\", \"Alert2\", \"Alert3\"], \"additionalFields\": {\"addnam3\": \"addval3\", \"addnam1\": \"addval1\", \"addnam2\": \"addval2\"}, \"thresholdCrossingFieldsVersion\": \"4.0\"}}}";
+
size_t json_size = 0;
char json_body[EVEL_MAX_JSON_BODY];
EVENT_THRESHOLD_CROSS * tca = NULL;
@@ -1926,6 +1333,8 @@ void test_encode_tca()
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);
+ evel_source_name_set(&tca->header, "VM-VirtualBox");
+ evel_reporting_entity_name_set(&tca->header, "VM-VirtualBox");
perf = evel_threshold_cross_add_addl_parameters(tca, "CRIT", "LastThresh");
evel_threshold_cross_addl_parameters_hashmap_set(perf, "key1", "value1");
@@ -1972,7 +1381,7 @@ void compare_strings(char * expected,
int max_size,
char * description)
{
- sleep(5);
+ sleep(2);
if (strncmp(expected, actual, max_size) != 0)
{
int diff = 0;
@@ -1985,11 +1394,17 @@ void compare_strings(char * expected,
diff++;
}
-// printf("Comparison Failure at Offset %d\n\n", diff);
-// printf("Expected:\n%s\n", expected);
printf("Description: %s\n", description);
+ printf("Comparison Failure at Offset %d\n\n", diff);
+ printf("Expected:\n%s\n", expected);
+ printf("Actual:\n%s\n\n\n", actual);
+ assert(0);
+ }
+ else
+ {
+ printf("Description: %s\n", description);
+ printf("Comparison Success \n");
printf("Actual:\n%s\n\n\n", actual);
-// assert(0);
}
}
@@ -2031,1947 +1446,3 @@ void handle_json_response(char * json, MEMORY_CHUNK * post)
free(chunk.memory);
}
-/**************************************************************************//**
- * Test that a non-"commandList" JSON buffer leaves the throttle state off.
- *****************************************************************************/
-/****************
-void test_json_response_junk()
-{
- MEMORY_CHUNK post;
- int domain;
- char * json_junk =
- "{"
- "\"junk1\": ["
- "\"1\", \"2\", \"3\"], "
- "\"junk2\": ["
- "\"1\", \"2\", \"3\"]"
- "}";
-
- evel_throttle_initialize();
- handle_json_response(json_junk, &post);
-
- for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
-
- assert(post.memory == NULL);
-
- evel_throttle_terminate();
-}
-**********************/
-
-char * json_command_list_provide =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"provideThrottlingState\""
- "}"
- "}"
- "]"
- "}";
-
-char * json_command_list_fault_clear =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\""
- "}"
- "}"
- "}"
- "]"
- "}";
-
-char * json_command_list_syslog_clear =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"syslog\""
- "}"
- "}"
- "}"
- "]"
- "}";
-
-char * expected_throttle_state_normal =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"normal\"}"
- "}";
-
-/**************************************************************************//**
- * Test that we can return the default throttling state.
- *****************************************************************************/
-/*******************
-void test_json_provide_throttle_state()
-{
- MEMORY_CHUNK post;
- int domain;
-
- char * expected_post = expected_throttle_state_normal;
-
- evel_throttle_initialize();
- handle_json_response(json_command_list_provide, &post);
-
- for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
-
- assert(post.memory != NULL);
- compare_strings(expected_post, post.memory, strlen(expected_post),
- "Throttle State Normal");
- free(post.memory);
-
- evel_throttle_terminate();
-}
-*************************/
-/**************************************************************************//**
- * Test the measurement interval handling and API.
- *****************************************************************************/
-/********************
-void test_json_measurement_interval()
-{
- MEMORY_CHUNK post;
- char * json_command_list_interval_only =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"measurementInterval\": 60"
- "}"
- "}"
- "]"
- "}";
-
- char * json_command_list_interval_first =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"measurementInterval\": 30, "
- "\"commandType\": \"measurementIntervalChange\""
- "}"
- "}"
- "]"
- "}";
-
- char * json_command_list_command_first =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"measurementIntervalChange\", "
- "\"measurementInterval\": 60"
- "}"
- "}"
- "]"
- "}";
-
- evel_throttle_initialize();
- assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
-
- handle_json_response(json_command_list_interval_only, &post);
- assert(post.memory == NULL);
- assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
-
- handle_json_response(json_command_list_interval_first, &post);
- assert(post.memory == NULL);
- assert(evel_get_measurement_interval() == 30);
-
- 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;
- int domain;
-
- char * json_command_list_fault_single =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
- "}"
- "}"
- "}"
- "]"
- "}";
-
- char * json_command_list_fault_double =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": ["
- "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
- "}"
- "}"
- "}"
- "]"
- "}";
-
- char * expected_post_fault_single =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
- "}"
- "]"
- "}"
- "}";
-
- char * expected_post_fault_double =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": ["
- "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
- "}"
- "]"
- "}"
- "}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list_fault_single, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
- for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- if (domain != EVEL_DOMAIN_FAULT)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_post_fault_single,
- post.memory,
- strlen(expected_post_fault_single),
- "Fault - Single Field");
- free(post.memory);
- post.memory = NULL;
-
- handle_json_response(json_command_list_fault_double, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
- for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- if (domain != EVEL_DOMAIN_FAULT)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_post_fault_double,
- post.memory,
- strlen(expected_post_fault_double),
- "Fault - Double Field");
- free(post.memory);
- post.memory = NULL;
-
- handle_json_response(json_command_list_fault_clear, &post);
- for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
-
- evel_throttle_terminate();
-}
-*******************************/
-/**************************************************************************//**
- * Test a single domain, nv_pair suppression.
- *****************************************************************************/
-/**************
-void test_json_throttle_spec_nv_pair()
-{
- MEMORY_CHUNK post;
- int domain;
-
- char * json_command_list_fault_pair_single =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}"
- "]"
- "}"
- "}"
- "}"
- "]"
- "}";
-
- char * json_command_list_fault_pair_double =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
- "}"
- "]"
- "}"
- "}"
- "}"
- "]"
- "}";
-
- char * expected_post_fault_pair_single =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventohrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}"
- "]"
- "}"
- "]"
- "}"
- "}";
-
- char * expected_post_fault_pair_double =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
- "}"
- "]"
- "}"
- "]"
- "}"
- "}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list_fault_pair_single, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
- for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- if (domain != EVEL_DOMAIN_FAULT)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_post_fault_pair_single,
- post.memory,
- strlen(expected_post_fault_pair_single),
- "Fault - Single Pair, Single Field");
- free(post.memory);
- post.memory = NULL;
-
- handle_json_response(json_command_list_fault_pair_double, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
- for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- if (domain != EVEL_DOMAIN_FAULT)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_post_fault_pair_double,
- post.memory,
- strlen(expected_post_fault_pair_double),
- "Fault - Double Field");
- free(post.memory);
- post.memory = NULL;
-
- handle_json_response(json_command_list_fault_clear, &post);
- for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
-
- evel_throttle_terminate();
-}
-********************/
-/**************************************************************************//**
- * Test two domains, nv_pair suppression.
- *****************************************************************************/
-/*********************
-void test_json_throttle_spec_two_domains()
-{
- MEMORY_CHUNK post;
- int domain;
-
- char * json_command_list_two_domains =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}, "
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"syslog\", "
- "\"suppressedFieldNames\": [\"syslogProcId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"additionalFields\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * expected_post_two_domains =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}, "
- "{"
- "\"eventDomain\": \"syslog\", "
- "\"suppressedFieldNames\": [\"syslogProcId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"additionalFields\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}"
- "]"
- "}"
- "}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list_two_domains, &post);
-
- 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++)
- {
- if ((domain != EVEL_DOMAIN_FAULT) && (domain != EVEL_DOMAIN_SYSLOG))
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_post_two_domains,
- post.memory,
- strlen(expected_post_two_domains),
- "Fault - Two Domains");
- free(post.memory);
- post.memory = NULL;
-
- 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);
- handle_json_response(json_command_list_syslog_clear, &post);
- for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
-
- evel_throttle_terminate();
-}
-******************/
-/**************************************************************************//**
- * Test bad command type.
- *****************************************************************************/
-/*********************
-void test_json_throttle_spec_bad_command_type()
-{
- MEMORY_CHUNK post;
- int domain;
-
- #define NUM_BAD_COMMANDS 8
- char * json_command_list_dodgy_command =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"dodgyCommand\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_spec =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"dodgyEventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_event_domain_key =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"dodgyEventDomainKey\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_event_domain =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"dodgyEventDomain\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_field_names_key =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_pair_names_list_key =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"dodgySuppressedNvPairsListKey\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_pair_field_name_key =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"dodgyNvPairFieldNameKey\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_pair_names_key =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"dodgySuppressedNvPairNamesKey\": [\"name1\"]"
- "}]}}}"
- "]"
- "}";
-
- char * json_command_list_dodgy_depth =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"dodgySuppressedNvPairNamesKey\": "
- "[\"name1\", [[[[[[[[]]]]]]]]]"
- "}]}}}"
- "]"
- "}";
-
- char * expected_throttle_state_dodgy_field_names_key =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name1\"]"
- "}]}"
- "]"
- "}"
- "}";
-
- char * expected_throttle_state_dodgy_pair_names_list_key =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
- "}"
- "]"
- "}"
- "}";
-
- char * expected_throttle_state_dodgy_pair_field_name_key =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
- "}"
- "]"
- "}"
- "}";
-
- char * expected_throttle_state_dodgy_pair_names_key =
- "{"
- "\"eventThrottlingState\": {"
- "\"eventThrottlingMode\": \"throttled\", "
- "\"eventDomainThrottleSpecificationList\": ["
- "{"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
- "}"
- "]"
- "}"
- "}";
-
- char * json_command_lists[] = {
- json_command_list_dodgy_command,
- json_command_list_dodgy_spec,
- json_command_list_dodgy_event_domain_key,
- json_command_list_dodgy_event_domain,
- json_command_list_dodgy_depth,
- json_command_list_dodgy_field_names_key,
- json_command_list_dodgy_pair_names_list_key,
- json_command_list_dodgy_pair_field_name_key,
- json_command_list_dodgy_pair_names_key
- };
-
- char * expected_posts[] = {
- expected_throttle_state_normal,
- expected_throttle_state_normal,
- expected_throttle_state_normal,
- expected_throttle_state_normal,
- expected_throttle_state_normal,
- expected_throttle_state_dodgy_field_names_key,
- expected_throttle_state_dodgy_pair_names_list_key,
- expected_throttle_state_dodgy_pair_field_name_key,
- expected_throttle_state_dodgy_pair_names_key
- };
-
- const int num_commands =
- sizeof(json_command_lists) / sizeof(json_command_lists[0]);
- const int num_posts =
- sizeof(expected_posts) / sizeof(expected_posts[0]);
- assert(num_commands == num_posts);
-
- evel_throttle_initialize();
-
- int ii;
- for (ii = 0; ii < num_commands; ii++)
- {
- EVEL_DEBUG("Testing commandList[%d] = %s\n", ii, json_command_lists[ii]);
- handle_json_response(json_command_lists[ii], &post);
-
- for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
- {
- assert(evel_get_throttle_spec(domain) == NULL);
- }
- if (expected_posts[ii] == expected_throttle_state_normal)
- {
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL);
- }
- else
- {
- assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
- }
- assert(post.memory == NULL);
-
- handle_json_response(json_command_list_provide, &post);
- assert(post.memory != NULL);
- compare_strings(expected_posts[ii],
- post.memory,
- strlen(expected_posts[ii]),
- "Throttle State Normal");
- free(post.memory);
- post.memory = NULL;
- }
-
- evel_throttle_terminate();
-}
-**************************/
-/****************
-void test_encode_fault_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"fault\", "
- "\"suppressedFieldNames\": ["
- "\"alarmInterfaceA\", "
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
- "\"suppressedNvPairNames\": [\"name3\", \"name4\"]"
- "}]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": {"
- "\"commonEventHeader\": {"
- "\"domain\": \"fault\", "
- "\"eventId\": \"fault000000001\", "
- "\"eventName\": \"fault_eNodeB_alarm\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 122, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"faultFields\": {"
- "\"alarmCondition\": \"My alarm condition\", "
- "\"eventSeverity\": \"MAJOR\", "
- "\"eventSourceType\": \"other\", "
- "\"specificProblem\": \"It broke very badly\", "
- "\"vfStatus\": \"Active\", "
- "\"faultFieldsVersion\": 1.1, "
- "\"alarmAdditionalInformation\": ["
- "{\"name\": \"name1\", "
- "\"value\": \"value1\"}, "
- "{\"name\": \"name2\", "
- "\"value\": \"value2\"}]"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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("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);
- assert(fault != NULL);
- evel_fault_type_set(fault, "Bad things happen...");
- evel_fault_addl_info_add(fault, "name1", "value1");
- evel_fault_addl_info_add(fault, "name2", "value2");
-
- evel_fault_interface_set(fault, "My Interface Card");
- evel_fault_addl_info_add(fault, "name3", "value3");
- evel_fault_addl_info_add(fault, "name4", "value4");
-
- 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);
- evel_throttle_terminate();
-}
-***********************/
-/***********************
-void test_encode_measurement_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"measurementsForVfScaling\", "
- "\"suppressedFieldNames\": ["
- "\"errors\", "
- "\"vnfcScalingMetric\", "
- "\"numberOfMediaPortsInUse\", "
- "\"aggregateCpuUsage\", "
- "\"requestRate\", "
- "\"memoryUsed\", "
- "\"memoryConfigured\", "
- "\"meanRequestLatency\", "
- "\"latencyDistribution\", "
- "\"concurrentSessions\", "
- "\"configuredEntities\", "
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"cpuUsageArray\", "
- "\"suppressedNvPairNames\": [\"cpu3\", \"cpu4\"]"
- "}, "
- "{"
- "\"nvPairFieldName\": \"filesystemUsageArray\", "
- "\"suppressedNvPairNames\": [\"00-11-22\", \"33-44-55\"]"
- "}, "
- "{"
- "\"nvPairFieldName\": \"vNicUsageArray\", "
- "\"suppressedNvPairNames\": [\"eth1\", \"eth0\"]"
- "}, "
- "{"
- "\"nvPairFieldName\": \"featureUsageArray\", "
- "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
- "},"
- "{"
- "\"nvPairFieldName\": \"codecUsageArray\", "
- "\"suppressedNvPairNames\": [\"G729ab\"]"
- "},"
- "{"
- "\"nvPairFieldName\": \"additionalMeasurements\", "
- "\"suppressedNvPairNames\": [\"Group2\"]"
- "}"
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"measurementsForVfScaling\", "
- "\"eventId\": \"mvfs000000001\", "
- "\"eventName\": \"mvfs_perfUnit_issue\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 123, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"measurementsForVfScalingFields\": "
- "{"
- "\"measurementInterval\": 5.500000, "
- "\"cpuUsageArray\": ["
- "{\"cpuIdentifier\": \"cpu1\", "
- "\"percentUsage\": 11.110000}, "
- "{\"cpuIdentifier\": \"cpu2\", "
- "\"percentUsage\": 22.220000}], "
- "\"filesystemUsageArray\": ["
- "{\"blockConfigured\": 500.110000, "
- "\"blockIops\": 77, "
- "\"blockUsed\": 500.220000, "
- "\"ephemeralConfigured\": 500.110000, "
- "\"ephemeralIops\": 88, "
- "\"ephemeralUsed\": 600.220000, "
- "\"filesystemName\": \"66-77-88\"}], "
- "\"featureUsageArray\": ["
- "{\"featureIdentifier\": \"FeatureA\", "
- "\"featureUtilization\": 123}], "
- "\"codecUsageArray\": ["
- "{\"codecIdentifier\": \"G711a\", "
- "\"numberInUse\": 91}], "
- "\"additionalMeasurements\": ["
- "{\"name\": \"Group1\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}]}], "
- "\"measurementsForVfScalingVersion\": 1.1}}}";
- MEASUREMENT_CPU_USE *cpu_use;
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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, "mvfs_perfUnit_issue", "mvfs000000001");
- MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
- MEASUREMENT_NIC_PERFORMANCE * vnic_use = NULL;
- assert(measurement != NULL);
-
- evel_measurement_type_set(measurement, "Perf management...");
- 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_mem_cfg_set(measurement, 6.6);
- evel_measurement_mem_used_set(measurement, 3.3);
- evel_measurement_request_rate_set(measurement, 7);
-
- cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", 11.11);
- evel_measurement_cpu_use_idle_set(cpu_use,22.22);
- evel_measurement_cpu_use_interrupt_set(cpu_use,33.33);
- evel_measurement_cpu_use_nice_set(cpu_use,44.44);
- evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
- evel_measurement_cpu_use_steal_set(cpu_use,66.66);
- 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);
-
- 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);
- evel_measurement_cpu_use_nice_set(cpu_use,44.44);
- evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
- evel_measurement_cpu_use_steal_set(cpu_use,66.66);
- 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_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_measurement_fsys_use_add(measurement, "66-77-88",
- 500.11, 500.22, 77,
- 600.11, 600.22, 88);
-
- bucket = evel_new_meas_latency_bucket(20);
- evel_meas_latency_bucket_add(measurement, bucket);
-
- 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 = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4);
- evel_vnic_use_bcast_pkt_in_set(vnic_use, 1);
- evel_vnic_use_bcast_pkt_out_set(vnic_use, 2);
- evel_vnic_use_mcast_pkt_in_set(vnic_use, 5);
- evel_vnic_use_mcast_pkt_out_set(vnic_use, 6);
- evel_vnic_use_ucast_pkt_in_set(vnic_use, 7);
- evel_vnic_use_ucast_pkt_out_set(vnic_use, 8);
- evel_meas_vnic_use_add(measurement, vnic_use);
-
- 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_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");
-
- 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);
- evel_throttle_terminate();
-}
-***************/
-/*******************`
-void test_encode_mobile_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"mobileFlow\", "
- "\"suppressedFieldNames\": ["
- "\"applicationType\", "
- "\"appProtocolType\", "
- "\"appProtocolVersion\", "
- "\"cid\", "
- "\"connectionType\", "
- "\"ecgi\", "
- "\"gtpProtocolType\", "
- "\"gtpVersion\", "
- "\"httpHeader\", "
- "\"imei\", "
- "\"imsi\", "
- "\"lac\", "
- "\"mcc\", "
- "\"mnc\", "
- "\"msisdn\", "
- "\"otherFunctionalRole\", "
- "\"rac\", "
- "\"radioAccessTechnology\", "
- "\"sac\", "
- "\"samplingAlgorithm\", "
- "\"tac\", "
- "\"tunnelId\", "
- "\"vlanId\", "
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"mobileFlow\", "
- "\"eventId\": \"mobileFlow000000001\", "
- "\"eventName\": \"mobileFlow_error\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 1242, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"mobileFlowFields\": {"
- "\"flowDirection\": \"Inbound\", "
- "\"gtpPerFlowMetrics\": {"
- "\"avgBitErrorRate\": 132.000100, "
- "\"avgPacketDelayVariation\": 31.200000, "
- "\"avgPacketLatency\": 101, "
- "\"avgReceiveThroughput\": 2101, "
- "\"avgTransmitThroughput\": 501, "
- "\"flowActivationEpoch\": 1470409422, "
- "\"flowActivationMicrosec\": 988, "
- "\"flowDeactivationEpoch\": 1470409432, "
- "\"flowDeactivationMicrosec\": 12, "
- "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
- "\"flowStatus\": \"Inactive\", "
- "\"maxPacketDelayVariation\": 88, "
- "\"numActivationFailures\": 4, "
- "\"numBitErrors\": 18, "
- "\"numBytesReceived\": 123655, "
- "\"numBytesTransmitted\": 4562, "
- "\"numDroppedPackets\": 1, "
- "\"numL7BytesReceived\": 13, "
- "\"numL7BytesTransmitted\": 11, "
- "\"numLostPackets\": 2, "
- "\"numOutOfOrderPackets\": 4, "
- "\"numPacketErrors\": 8, "
- "\"numPacketsReceivedExclRetrans\": 900, "
- "\"numPacketsReceivedInclRetrans\": 902, "
- "\"numPacketsTransmittedInclRetrans\": 303, "
- "\"numRetries\": 7, "
- "\"numTimeouts\": 3, "
- "\"numTunneledL7BytesReceived\": 1, "
- "\"roundTripTime\": 111, "
- "\"timeToFirstByte\": 226, "
- "\"ipTosCountList\": ["
- "[\"1\", 13], "
- "[\"4\", 99], "
- "[\"17\", 1]], "
- "\"ipTosList\": [\"1\", \"4\", \"17\"], "
- "\"tcpFlagList\": [\"CWR\", \"URG\"], "
- "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
- "\"mobileQciCosList\": [\"conversational\", \"65\"], "
- "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
- "\"durConnectionFailedStatus\": 12, "
- "\"durTunnelFailedStatus\": 13, "
- "\"flowActivatedBy\": \"Remote\", "
- "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
- "\"flowDeactivatedBy\": \"Remote\", "
- "\"gtpConnectionStatus\": \"Connected\", "
- "\"gtpTunnelStatus\": \"Not tunneling\", "
- "\"largePacketRtt\": 80, "
- "\"largePacketThreshold\": 600.000000, "
- "\"maxReceiveBitRate\": 1357924680, "
- "\"maxTransmitBitRate\": 235711, "
- "\"numGtpEchoFailures\": 1, "
- "\"numGtpTunnelErrors\": 4, "
- "\"numHttpErrors\": 2"
- "}, "
- "\"ipProtocolType\": \"UDP\", "
- "\"ipVersion\": \"IPv6\", "
- "\"otherEndpointIpAddress\": \"2.3.4.2\", "
- "\"otherEndpointPort\": 2342, "
- "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
- "\"reportingEndpointPort\": 4322"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_MOBILE_FLOW) != NULL);
- assert(post.memory == NULL);
-
- size_t json_size = 0;
- char json_body[EVEL_MAX_JSON_BODY];
- MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
- EVENT_MOBILE_FLOW * mobile_flow = NULL;
-
-// evel_set_next_event_sequence(1242);
-
- metrics = evel_new_mobile_gtp_flow_metrics(132.0001,
- 31.2,
- 101,
- 2101,
- 501,
- 1470409422,
- 988,
- 1470409432,
- 12,
- (time_t)1470409432,
- "Inactive",
- 88,
- 4,
- 18,
- 123655,
- 4562,
- 1,
- 13,
- 11,
- 2,
- 4,
- 8,
- 900,
- 902,
- 303,
- 7,
- 3,
- 1,
- 111,
- 226);
- assert(metrics != NULL);
-
- evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12);
- evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13);
- evel_mobile_gtp_metrics_act_by_set(metrics, "Remote");
- evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423);
- 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_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);
- evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711);
- 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_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",
- "2.3.4.2",
- 2342,
- "4.2.3.2",
- 4322);
- assert(mobile_flow != NULL);
-
- evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
- evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
- evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
- evel_mobile_flow_app_prot_ver_set(mobile_flow, "1");
- evel_mobile_flow_cid_set(mobile_flow, "65535");
- evel_mobile_flow_con_type_set(mobile_flow, "S1-U");
- evel_mobile_flow_ecgi_set(mobile_flow, "e65535");
- evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U");
- evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1");
- evel_mobile_flow_http_header_set(mobile_flow,
- "http://www.something.com");
- evel_mobile_flow_imei_set(mobile_flow, "209917614823");
- evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8");
- evel_mobile_flow_lac_set(mobile_flow, "1");
- evel_mobile_flow_mcc_set(mobile_flow, "410");
- evel_mobile_flow_mnc_set(mobile_flow, "04");
- evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789");
- evel_mobile_flow_other_func_role_set(mobile_flow, "MME");
- evel_mobile_flow_rac_set(mobile_flow, "514");
- evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE");
- evel_mobile_flow_sac_set(mobile_flow, "1");
- evel_mobile_flow_samp_alg_set(mobile_flow, 1);
- 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");
-
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(mobile_flow);
- evel_throttle_terminate();
-}
-*****************/
-/**************
-void test_encode_other_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"other\", "
- "\"suppressedFieldNames\": ["
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "]}}}"
- "]"
- "}";
-
- 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"
- "}, "
- "\"otherFields\": ["
- "{\"name\": \"Other field 1\", "
- "\"value\": \"Other value 1\"}, "
- "{\"name\": \"Other field 2\", "
- "\"value\": \"Other value 2\"}"
- "]"
- "}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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("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");
-
- 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);
- evel_throttle_terminate();
-}
-*******************/
-/*********************
-void test_encode_report_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"report\", "
- "\"suppressedFieldNames\": ["
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"featureUsageArray\", "
- "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
- "},"
- "{"
- "\"nvPairFieldName\": \"additionalMeasurements\", "
- "\"suppressedNvPairNames\": [\"Group2\"]"
- "}"
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"measurementsForVfReporting\", "
- "\"eventId\": \"report000000001\", "
- "\"eventName\": \"report_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 125, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"measurementsForVfReportingFields\": "
- "{\"measurementInterval\": 1.100000, "
- "\"featureUsageArray\": ["
- "{\"featureIdentifier\": \"FeatureA\", "
- "\"featureUtilization\": 123}], "
- "\"additionalMeasurements\": ["
- "{\"name\": \"Group1\", "
- "\"measurements\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}]}], "
- "\"measurementFieldsVersion\": 1.1}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- assert(evel_get_throttle_spec(EVEL_DOMAIN_REPORT) != NULL);
- assert(post.memory == NULL);
-
- size_t json_size = 0;
- char json_body[EVEL_MAX_JSON_BODY];
- EVENT_REPORT * report = NULL;
-
-// 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);
- evel_report_feature_use_add(report, "FeatureB", 567);
- evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
- evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
- evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
-
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(report);
- evel_throttle_terminate();
-}
-**********************/
-/********************************************
-void test_encode_service_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"serviceEvents\", "
- "\"suppressedFieldNames\": ["
- "\"eventType\", "
- "\"correlator\", "
- "\"codecSelected\", "
- "\"codecSelectedTranscoding\", "
- "\"endOfCallVqmSummaries\", "
- "\"midCallRtcp\", "
- "\"marker\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"additionalFields\", "
- "\"suppressedNvPairNames\": [\"Name1\", \"Name3\"]"
- "}"
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"serviceEvents\", "
- "\"eventId\": \"2000\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 2000, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"serviceEventsFields\": {"
- "\"eventInstanceIdentifier\": "
- "{"
- "\"vendorId\": \"vendor_x_id\", "
- "\"eventId\": \"vendor_x_event_id\", "
- "\"productId\": \"vendor_x_product_id\", "
- "\"subsystemId\": \"vendor_x_subsystem_id\", "
- "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
- "}, "
- "\"serviceEventsFieldsVersion\": 1.1, "
- "\"additionalFields\": ["
- "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
- "{\"name\": \"Name4\", \"value\": \"Value4\"}]"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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);
- event = evel_new_service("vendor_x_id", "vendor_x_event_id");
- assert(event != NULL);
- evel_service_type_set(event, "Service Event");
- evel_service_product_id_set(event, "vendor_x_product_id");
- evel_service_subsystem_id_set(event, "vendor_x_subsystem_id");
- evel_service_friendly_name_set(event, "vendor_x_frieldly_name");
- evel_service_correlator_set(event, "vendor_x_correlator");
- evel_service_codec_set(event, "PCMA");
- evel_service_codec_set(event, "PCMA");
- evel_service_callee_codec_set(event, "PCMA");
- evel_service_caller_codec_set(event, "G729A");
- evel_service_rtcp_data_set(event, "some_rtcp_data");
- 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_phone_number_set(event, "0888888888");
- evel_service_addl_field_add(event, "Name1", "Value1");
- evel_service_addl_field_add(event, "Name2", "Value2");
- evel_service_addl_field_add(event, "Name3", "Value3");
- evel_service_addl_field_add(event, "Name4", "Value4");
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(event);
- evel_throttle_terminate();
-}
-****************************/
-
-/************************
-void test_encode_signaling_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"signaling\", "
- "\"suppressedFieldNames\": ["
- "\"correlator\", "
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\", "
- "\"localIpAddress\", "
- "\"localPort\", "
- "\"remoteIpAddress\", "
- "\"remotePort\", "
- "\"compressedSip\", "
- "\"summarySip\"], "
- "\"suppressedNvPairsList\": ["
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"signaling\", "
- "\"eventId\": \"sipSignal0000000001\", "
- "\"eventName\": \"sipSignal_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 2001, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"signalingFields\": {"
- "\"eventInstanceIdentifier\": "
- "{"
- "\"vendorId\": \"vendor_x_id\", "
- "\"eventId\": \"vendor_x_event_id\", "
- "\"productId\": \"vendor_x_product_id\", "
- "\"subsystemId\": \"vendor_x_subsystem_id\", "
- "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
- "}, "
- "\"signalingFieldsVersion\": 1.1"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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("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_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_compressed_sip_set(event, "compressed_sip");
- evel_signaling_summary_sip_set(event, "summary_sip");
- 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);
- evel_throttle_terminate();
-}
-***********************/
-/**********************
-void test_encode_state_change_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"stateChange\", "
- "\"suppressedFieldNames\": ["
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"additionalFields\", "
- "\"suppressedNvPairNames\": [\"Name1\"]"
- "},"
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"stateChange\", "
- "\"eventId\": \"stateChange000000001\", "
- "\"eventName\": \"stateChange_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 128, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"stateChangeFields\": {"
- "\"newState\": \"inService\", "
- "\"oldState\": \"outOfService\", "
- "\"stateInterface\": \"An Interface\", "
- "\"additionalFields\": ["
- "{\"name\": \"Name2\", "
- "\"value\": \"Value2\"}"
- "], "
- "\"stateChangeFieldsVersion\": 1.1"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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("stateChange_err",
- "stateChange000000001",
- EVEL_ENTITY_STATE_IN_SERVICE,
- EVEL_ENTITY_STATE_OUT_OF_SERVICE,
- "An Interface");
- assert(state_change != NULL);
- evel_state_change_type_set(state_change, "SC Type");
- evel_state_change_addl_field_add(state_change, "Name1", "Value1");
- evel_state_change_addl_field_add(state_change, "Name2", "Value2");
-
- json_size = evel_json_encode_event(
- json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) 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);
- evel_throttle_terminate();
-}
-********************/
-/*****************
-void test_encode_syslog_throttled()
-{
- MEMORY_CHUNK post;
-
- char * json_command_list =
- "{"
- "\"commandList\": ["
- "{"
- "\"command\": {"
- "\"commandType\": \"throttlingSpecification\", "
- "\"eventDomainThrottleSpecification\": {"
- "\"eventDomain\": \"syslog\", "
- "\"suppressedFieldNames\": ["
- "\"eventSourceHost\", "
- "\"syslogFacility\", "
- "\"syslogProc\", "
- "\"syslogProcId\", "
- "\"syslogSData\", "
- "\"syslogVer\", "
- "\"eventType\", "
- "\"reportingEntityId\", "
- "\"sourceId\"], "
- "\"suppressedNvPairsList\": ["
- "{"
- "\"nvPairFieldName\": \"additionalFields\", "
- "\"suppressedNvPairNames\": [\"Name2\"]"
- "},"
- "]}}}"
- "]"
- "}";
-
- char * expected =
- "{\"event\": "
- "{\"commonEventHeader\": {"
- "\"domain\": \"syslog\", "
- "\"eventId\": \"syslog000000001\", "
- "\"eventName\": \"syslog_err\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 126, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2"
- "}, "
- "\"syslogFields\": {"
- "\"eventSourceType\": \"virtualNetworkFunction\", "
- "\"syslogMsg\": \"SL Message\", "
- "\"syslogTag\": \"SL Tag\", "
- "\"syslogFieldsVersion\": 1.1, "
- "\"additionalFields\": ["
- "{\"name\": \"Name1\", "
- "\"value\": \"Value1\"}"
- "]"
- "}}}";
-
- evel_throttle_initialize();
- handle_json_response(json_command_list, &post);
-
- 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("syslog_err", "syslog000000001",
- EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION,
- "SL Message",
- "SL Tag");
- assert(syslog != NULL);
- evel_syslog_type_set(syslog, "SL Type");
- evel_syslog_event_source_host_set(syslog, "SL Host");
- evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
- evel_syslog_proc_set(syslog, "SL Proc");
- evel_syslog_proc_id_set(syslog, 2);
- evel_syslog_version_set(syslog, 1);
- evel_syslog_s_data_set(syslog, "SL SDATA");
- 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);
- compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog");
- assert((json_size == strlen(json_body)) && "Bad size returned");
-
- evel_free_event(syslog);
- evel_throttle_terminate();
-}
-**********************/
-/********************
-void test_encode_fault_with_escaping()
-{
- char * expected =
- "{\"event\": {"
- "\"commonEventHeader\": {"
- "\"domain\": \"fault\", "
- "\"eventId\": \"fault000000001\", "
- "\"eventName\": \"fault_eNodeB_alarm\", "
- "\"functionalRole\": \"UNIT TEST\", "
- "\"lastEpochMicrosec\": 1000002, "
- "\"priority\": \"Normal\", "
- "\"reportingEntityName\": \"prakash-VirtualBox\", "
- "\"sequence\": 122, "
- "\"sourceName\": \"prakash-VirtualBox\", "
- "\"startEpochMicrosec\": 1000002, "
- "\"version\": 1.2, "
- "\"eventType\": \"Bad things happen...\\\\\", "
- "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
- "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
- "}, "
- "\"faultFields\": {"
- "\"alarmCondition\": \"My alarm condition\", "
- "\"eventSeverity\": \"MAJOR\", "
- "\"eventSourceType\": \"other\", "
- "\"specificProblem\": \"It broke \\\"very\\\" badly\", "
- "\"vfStatus\": \"Active\", "
- "\"faultFieldsVersion\": 1.1, "
- "\"alarmAdditionalInformation\": ["
- "{\"name\": \"name1\", "
- "\"value\": \"value1\"}, "
- "{\"name\": \"name2\", "
- "\"value\": \"value2\"}], "
- "\"alarmInterfaceA\": \"My Interface Card\""
- "}}}";
-
- size_t json_size = 0;
- char json_body[EVEL_MAX_JSON_BODY];
-// 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);
- 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");
-
- 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);
-}
-***********************/
diff --git a/veslibrary/ves_clibrary/readme.md b/veslibrary/ves_clibrary/readme.md
index 784fade..90edac2 100644
--- a/veslibrary/ves_clibrary/readme.md
+++ b/veslibrary/ves_clibrary/readme.md
@@ -28,3 +28,46 @@ the included Makefile. See the [readme file](./code/evel_library/readme.md).
Clone this repo and load the [user guide](./docs/source/evel/html/index.html)
in your web browser.
+
+# Package installation
+Following packages are to be installed using apt-get as below
+sudo apt-get install gcc
+sudo apt-get install libcurl3-dev
+
+# Compiling the VES Library code
+Go to /vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/bldjobs directory and run the below commands
+
+make all - to create the VES library
+make package - to create the VES package if needed
+
+make install- can also be given to make a package and install the package in another machine - see Makefile for more details
+
+# Loading the VES library(evel)
+Go to vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/libs/x86_64 directory and run below commands
+
+sudo cp libevel.so /usr/lib
+sudo ldconfig
+
+# Sample Agent application information
+
+There are 4 sample agent codes reside in below directories. These events are driven by the JSON configure which are getting populated while generating the events. Each directory has readme.md file that explains how to configure JSON config file and procedure to run. You can compile the code using 'make all'.
+
+- /vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_HB - Sample heartbeat event generated periodically
+
+- /vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_fault - Sample fault event based on low byte/packet count on interface.
+
+- /vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_syslog - Sample syslog event based on pattern being logged into any file
+
+- /vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting_vFW - Sample Firewall application that generates measurement event periodically.
+
+Apart from the above there is a virtual Firewall application at the below location.
+
+- /vnfsdk/ves-agent/veslibrary/ves_clibrary/VESreporting_vFW - This generates the periodic heartbeat and measurement events. It also gives fault event.
+
+Care to be taken to compile the virtual Firewall agent
+
+- Copy the contents of the directory into ~/vnfsdk/ves-agent/veslibrary/ves_clibrary/evel/evel-library/code/VESreporting directory
+
+- run 'make all' to create an executable (alternatively, this agent gets compiled during compilation of evel library when VESreporting directory has all relevant files specific to that event
+
+- run the application using go-client.sh command (see readme.md for details)