diff options
author | Marco Platania <platania@research.att.com> | 2017-05-18 15:02:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-05-18 15:02:10 +0000 |
commit | 0078971a8b764a79ec0a516c022576f7ffe2ed2a (patch) | |
tree | 55a140f432d9e8d8834da24ccd956dd792172c5a /VES5.0/evel/evel-library/code/evel_training | |
parent | 2fa991c3273897940ef0d92e020daa298c68c73b (diff) | |
parent | 6c98a31b980d1d6cbbc9aeb2064d3f1c2252c3da (diff) |
Merge "VES5.0 development changes not for test"
Diffstat (limited to 'VES5.0/evel/evel-library/code/evel_training')
33 files changed, 2384 insertions, 0 deletions
diff --git a/VES5.0/evel/evel-library/code/evel_training/01-hello-world/Makefile b/VES5.0/evel/evel-library/code/evel_training/01-hello-world/Makefile new file mode 100644 index 00000000..eae417d8 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/01-hello-world/Makefile @@ -0,0 +1,13 @@ +CC=gcc + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world hello_evel_world.c + diff --git a/VES5.0/evel/evel-library/code/evel_training/01-hello-world/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/01-hello-world/hello_evel_world.c new file mode 100644 index 00000000..4048c4ea --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/01-hello-world/hello_evel_world.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char ** argv) +{ + printf("Hello AT&T world!!!\n"); + return 0; +} diff --git a/VES5.0/evel/evel-library/code/evel_training/02-library-link/Makefile b/VES5.0/evel/evel-library/code/evel_training/02-library-link/Makefile new file mode 100644 index 00000000..a6013de3 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/02-library-link/Makefile @@ -0,0 +1,22 @@ +CC=gcc + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + diff --git a/VES5.0/evel/evel-library/code/evel_training/02-library-link/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/02-library-link/hello_evel_world.c new file mode 100644 index 00000000..ab1ae83e --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/02-library-link/hello_evel_world.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char ** argv) +{ + printf("Hello AT&T Vendor Event world!\n"); + return 0; +} diff --git a/VES5.0/evel/evel-library/code/evel_training/03-include-header/Makefile b/VES5.0/evel/evel-library/code/evel_training/03-include-header/Makefile new file mode 100644 index 00000000..1fccf915 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/03-include-header/Makefile @@ -0,0 +1,24 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + diff --git a/VES5.0/evel/evel-library/code/evel_training/03-include-header/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/03-include-header/hello_evel_world.c new file mode 100644 index 00000000..1a80aa15 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/03-include-header/hello_evel_world.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "evel.h" + +int main(int argc, char ** argv) +{ + printf("Hello AT&T Vendor Event world!\n"); + return 0; +} diff --git a/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/Makefile b/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/Makefile new file mode 100644 index 00000000..1fccf915 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/Makefile @@ -0,0 +1,24 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + diff --git a/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/hello_evel_world.c new file mode 100644 index 00000000..169a7e4f --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/04-basic-lifecycle/hello_evel_world.c @@ -0,0 +1,69 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 3) + { + fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + "", /* Username */ + "", /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("Initialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + diff --git a/VES5.0/evel/evel-library/code/evel_training/05-raise-event/Makefile b/VES5.0/evel/evel-library/code/evel_training/05-raise-event/Makefile new file mode 100644 index 00000000..1fccf915 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/05-raise-event/Makefile @@ -0,0 +1,24 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + diff --git a/VES5.0/evel/evel-library/code/evel_training/05-raise-event/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/05-raise-event/hello_evel_world.c new file mode 100644 index 00000000..298665bf --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/05-raise-event/hello_evel_world.c @@ -0,0 +1,96 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + EVENT_FAULT * fault = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 3) + { + fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + "", /* Username */ + "", /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a fault */ + /***************************************************************************/ + fault = evel_new_fault("My alarm condition", + "It broke very badly", + EVEL_PRIORITY_NORMAL, + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_HOST, + EVEL_VF_STATUS_PREP_TERMINATE); + if (fault != NULL) + { + printf("New fault created...\n"); + evel_rc = evel_post_event((EVENT_HEADER *)fault); + if (evel_rc == EVEL_SUCCESS) + { + printf("Fault posted OK!\n"); + } + else + { + printf("Post failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("New fault failed (%s)\n", evel_error_string()); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} diff --git a/VES5.0/evel/evel-library/code/evel_training/06-username-password/Makefile b/VES5.0/evel/evel-library/code/evel_training/06-username-password/Makefile new file mode 100644 index 00000000..977c0732 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/06-username-password/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/06-username-password/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/06-username-password/hello_evel_world.c new file mode 100644 index 00000000..37ab5cb0 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/06-username-password/hello_evel_world.c @@ -0,0 +1,98 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + EVENT_FAULT * fault = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a fault */ + /***************************************************************************/ + fault = evel_new_fault("My alarm condition", + "It broke very badly", + EVEL_PRIORITY_NORMAL, + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_HOST, + EVEL_VF_STATUS_PREP_TERMINATE); + if (fault != NULL) + { + printf("New fault created...\n"); + evel_rc = evel_post_event((EVENT_HEADER *)fault); + if (evel_rc == EVEL_SUCCESS) + { + printf("Fault posted OK!\n"); + } + else + { + printf("Post failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("New fault failed (%s)\n", evel_error_string()); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} diff --git a/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/Makefile b/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/hello_evel_world.c new file mode 100644 index 00000000..03b8c145 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/07-raise-measurement/hello_evel_world.c @@ -0,0 +1,196 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_measurement(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a measurement */ + /***************************************************************************/ + demo_measurement(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a measurement event. + *****************************************************************************/ +void demo_measurement(void) +{ + EVENT_MEASUREMENT * measurement = NULL; + MEASUREMENT_LATENCY_BUCKET * bucket = NULL; + MEASUREMENT_VNIC_PERFORMANCE * vnic_use = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + MEASUREMENT_CPU_USE * cpu_use = NULL; + + /***************************************************************************/ + /* Measurement */ + /***************************************************************************/ + measurement = evel_new_measurement(5.5); + if (measurement != NULL) + { + printf("New measurement created...\n"); + 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_request_rate_set(measurement, 6); + + 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); + + bucket = evel_new_meas_latency_bucket(20); + evel_meas_latency_bucket_low_end_set(bucket, 0.0); + evel_meas_latency_bucket_high_end_set(bucket, 10.0); + 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_measurement_new_vnic_performance("eth0", "true"); + evel_vnic_performance_rx_octets_delta_set(vnic_use, 47656465465); + evel_vnic_performance_rx_total_pkt_acc_set(vnic_use, 4765764654444); + evel_vnic_performance_rx_total_pkt_delta_set(vnic_use, 4545665656); + evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_use, 4765745546.); + evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_use, 4768765.78347856); + evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_use, 747665.347647); + evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_use, 3468765.4774); + evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_use, 53625345.53); + evel_vnic_performance_tx_discarded_pkt_delta_set(vnic_use, 5465345.72455); + evel_meas_vnic_performance_add(measurement, vnic_use); + + vnic_use = evel_measurement_new_vnic_performance("eth1", "false"); + evel_vnic_performance_rx_total_pkt_acc_set(vnic_use, 4765764654444); + evel_vnic_performance_rx_total_pkt_delta_set(vnic_use, 4545665656); + evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_use, 4765745546.); + evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_use, 4768765.78347856); + evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_use, 747665.347647); + evel_meas_vnic_performance_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"); + + evel_rc = evel_post_event((EVENT_HEADER *)measurement); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Measurement\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/Makefile b/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/hello_evel_world.c new file mode 100644 index 00000000..597d5da0 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/08-raise-mobile-flow/hello_evel_world.c @@ -0,0 +1,201 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_mobile_flow(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a measurement */ + /***************************************************************************/ + demo_mobile_flow(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send three mobile flow events. + *****************************************************************************/ +void demo_mobile_flow(void) +{ + MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL; + EVENT_MOBILE_FLOW * mobile_flow = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + metrics = evel_new_mobile_gtp_flow_metrics(12.32, + 3.122, + 1002, + 21002, + 5002, + 1470409423, + 9872, + 1470409433, + 112, + (time_t)1470409433, + "Failed", + 872, + 32, + 172, + 1236542, + 45612, + 2, + 122, + 102, + 12, + 32, + 72, + 8992, + 9012, + 3022, + 62, + 22, + 2, + 1102, + 2252); + if (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_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_qci_cos_count_add( + metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); + evel_mobile_gtp_metrics_qci_cos_count_add( + metrics, EVEL_QCI_COS_LTE_65, 122); + + mobile_flow = evel_new_mobile_flow("Outbound", + metrics, + "RTP", + "IPv8", + "2.3.4.3", + 2343, + "4.2.3.3", + 4323); + if (mobile_flow != NULL) + { + evel_mobile_flow_app_type_set(mobile_flow, "Demo application 2"); + evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM"); + evel_mobile_flow_app_prot_ver_set(mobile_flow, "2"); + evel_mobile_flow_cid_set(mobile_flow, "1"); + evel_mobile_flow_con_type_set(mobile_flow, "S1-U"); + evel_mobile_flow_ecgi_set(mobile_flow, "e1"); + 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.google.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, "MMF"); + evel_mobile_flow_rac_set(mobile_flow, "514"); + evel_mobile_flow_radio_acc_tech_set(mobile_flow, "3G"); + evel_mobile_flow_sac_set(mobile_flow, "1"); + evel_mobile_flow_samp_alg_set(mobile_flow, 2); + evel_mobile_flow_tac_set(mobile_flow, "2099"); + evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 2"); + evel_mobile_flow_vlan_id_set(mobile_flow, "4096"); + + evel_rc = evel_post_event((EVENT_HEADER *)mobile_flow); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + printf(" Processed full Mobile Flow\n"); + } + else + { + printf("New GTP Per Flow Metrics failed\n"); + } +} diff --git a/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/Makefile b/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/hello_evel_world.c new file mode 100644 index 00000000..db0ab8b6 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/09-raise-state-change/hello_evel_world.c @@ -0,0 +1,117 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_state_change(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a state change */ + /***************************************************************************/ + demo_state_change(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a state change event. + *****************************************************************************/ +void demo_state_change(void) +{ + EVENT_STATE_CHANGE * state_change = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + /***************************************************************************/ + /* State Change */ + /***************************************************************************/ + state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE, + EVEL_ENTITY_STATE_OUT_OF_SERVICE, + "Interface"); + if (state_change != NULL) + { + evel_state_change_type_set(state_change, "State Change"); + evel_state_change_addl_field_add(state_change, "Name1", "Value1"); + evel_state_change_addl_field_add(state_change, "Name2", "Value2"); + evel_rc = evel_post_event((EVENT_HEADER *)state_change); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed State Change\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/Makefile b/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/hello_evel_world.c new file mode 100644 index 00000000..7557743e --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/10-raise-syslog/hello_evel_world.c @@ -0,0 +1,117 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_syslog(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a syslog */ + /***************************************************************************/ + demo_syslog(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a syslog event. + *****************************************************************************/ +void demo_syslog(void) +{ + EVENT_SYSLOG * syslog = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_MACHINE, + "EVEL library message", + "EVEL"); + if (syslog != NULL) + { + evel_syslog_event_source_host_set(syslog, "Virtual host"); + evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LOCAL0); + evel_syslog_proc_set(syslog, "vnf_process"); + evel_syslog_proc_id_set(syslog, 1423); + evel_syslog_version_set(syslog, 1); + evel_syslog_addl_filter_set(syslog, "Name1=Value1|Name2=Value2|Name3=Value3"); + evel_rc = evel_post_event((EVENT_HEADER *)syslog); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Syslog\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/11-raise-other/Makefile b/VES5.0/evel/evel-library/code/evel_training/11-raise-other/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/11-raise-other/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/11-raise-other/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/11-raise-other/hello_evel_world.c new file mode 100644 index 00000000..b03260b9 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/11-raise-other/hello_evel_world.c @@ -0,0 +1,118 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_other(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a state change */ + /***************************************************************************/ + demo_other(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send an other event. + *****************************************************************************/ +void demo_other(void) +{ + EVENT_OTHER * other = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + other = evel_new_other(); + if (other != NULL) + { + evel_other_field_add(other, + "Other field A", + "Other value A"); + evel_other_field_add(other, + "Other field B", + "Other value B"); + evel_other_field_add(other, + "Other field C", + "Other value C"); + evel_rc = evel_post_event((EVENT_HEADER *)other); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Other\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/Makefile b/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/Makefile new file mode 100644 index 00000000..ee8c3461 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/Makefile @@ -0,0 +1,35 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library +EVEL_DEMO=$(CURDIR)/../../evel_demo +TEST_CONTROL=$(EVEL_DEMO)/evel_test_control.c + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c $(TEST_CONTROL) + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + -I $(EVEL_DEMO) \ + hello_evel_world.c \ + $(TEST_CONTROL) \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world 127.0.0.1 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/hello_evel_world.c new file mode 100644 index 00000000..8943d57b --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/12-suppress-fault-fields/hello_evel_world.c @@ -0,0 +1,180 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" +#include "evel_test_control.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_heartbeat(); +static void demo_fault(void); + +int main(int argc, char ** argv) +{ + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + char * api_fqdn = argv[1]; + int api_port = atoi(argv[2]); + int api_secure = 0; + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(api_fqdn, /* FQDN */ + api_port, /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + api_secure, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Raise a fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Ask for suppression of alarmInterfaceA and alarmAdditionalInformation. */ + /***************************************************************************/ + printf("TestControl: test collector suppress fault fields\n"); + fflush(stdout); + evel_test_control_scenario(TC_FAULT_SUPPRESS_FIELDS, + api_secure, + api_fqdn, + api_port); + sleep(1); + + /***************************************************************************/ + /* Heartbeat to pick up the suppression change. */ + /***************************************************************************/ + demo_heartbeat(); + + /***************************************************************************/ + /* Raise the same fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Ask for removal of fault suppression. */ + /***************************************************************************/ + printf("TestControl: test collector remove fault suppression\n"); + fflush(stdout); + evel_test_control_scenario(TC_FAULT_SUPPRESS_NOTHING, + api_secure, + api_fqdn, + api_port); + sleep(1); + + /***************************************************************************/ + /* Heartbeat to pick up the suppression change. */ + /***************************************************************************/ + demo_heartbeat(); + + /***************************************************************************/ + /* Raise the same fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a heatbeat. + *****************************************************************************/ +void demo_heartbeat() +{ + EVENT_HEADER * heartbeat = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } +} + +/**************************************************************************//** + * Create and send a fault event. + *****************************************************************************/ +void demo_fault(void) +{ + EVENT_FAULT * fault = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + fault = evel_new_fault("My alarm condition", + "It broke very badly", + EVEL_PRIORITY_NORMAL, + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_HOST, + EVEL_VF_STATUS_PREP_TERMINATE); + if (fault != NULL) + { + evel_fault_type_set(fault, "Bad things happen..."); + evel_fault_interface_set(fault, "My Interface Card"); + evel_fault_addl_info_add(fault, "name1", "value1"); + evel_fault_addl_info_add(fault, "name2", "value2"); + evel_fault_addl_info_add(fault, "name3", "value3"); + evel_fault_addl_info_add(fault, "name4", "value4"); + evel_rc = evel_post_event((EVENT_HEADER *)fault); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Fault\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/Makefile b/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/Makefile new file mode 100644 index 00000000..ee8c3461 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/Makefile @@ -0,0 +1,35 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library +EVEL_DEMO=$(CURDIR)/../../evel_demo +TEST_CONTROL=$(EVEL_DEMO)/evel_test_control.c + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c $(TEST_CONTROL) + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + -I $(EVEL_DEMO) \ + hello_evel_world.c \ + $(TEST_CONTROL) \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world 127.0.0.1 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/hello_evel_world.c new file mode 100644 index 00000000..625daa9c --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/13-suppress-fault-pairs/hello_evel_world.c @@ -0,0 +1,181 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" +#include "evel_test_control.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_heartbeat(); +static void demo_fault(void); + +int main(int argc, char ** argv) +{ + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + char * api_fqdn = argv[1]; + int api_port = atoi(argv[2]); + int api_secure = 0; + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(api_fqdn, /* FQDN */ + api_port, /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + api_secure, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Raise a fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Ask for suppression of pairs (under "alarmAdditionalInformation") with */ + /* names "name1" and "name2". */ + /***************************************************************************/ + printf("TestControl: test collector suppress fault pairs\n"); + fflush(stdout); + evel_test_control_scenario(TC_FAULT_SUPPRESS_PAIRS, + api_secure, + api_fqdn, + api_port); + sleep(1); + + /***************************************************************************/ + /* Heartbeat to pick up the suppression change. */ + /***************************************************************************/ + demo_heartbeat(); + + /***************************************************************************/ + /* Raise the same fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Ask for removal of fault suppression. */ + /***************************************************************************/ + printf("TestControl: test collector remove fault suppression\n"); + fflush(stdout); + evel_test_control_scenario(TC_FAULT_SUPPRESS_NOTHING, + api_secure, + api_fqdn, + api_port); + sleep(1); + + /***************************************************************************/ + /* Heartbeat to pick up the suppression change. */ + /***************************************************************************/ + demo_heartbeat(); + + /***************************************************************************/ + /* Raise the same fault. */ + /***************************************************************************/ + printf("Raise normal fault ...\n"); + fflush(stdout); + demo_fault(); + sleep(1); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a heatbeat. + *****************************************************************************/ +void demo_heartbeat() +{ + EVENT_HEADER * heartbeat = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } +} + +/**************************************************************************//** + * Create and send a fault event. + *****************************************************************************/ +void demo_fault(void) +{ + EVENT_FAULT * fault = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + fault = evel_new_fault("My alarm condition", + "It broke very badly", + EVEL_PRIORITY_NORMAL, + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_HOST, + EVEL_VF_STATUS_PREP_TERMINATE); + if (fault != NULL) + { + evel_fault_type_set(fault, "Bad things happen..."); + evel_fault_interface_set(fault, "My Interface Card"); + evel_fault_addl_info_add(fault, "name1", "value1"); + evel_fault_addl_info_add(fault, "name2", "value2"); + evel_fault_addl_info_add(fault, "name3", "value3"); + evel_fault_addl_info_add(fault, "name4", "value4"); + evel_rc = evel_post_event((EVENT_HEADER *)fault); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Fault\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/Makefile b/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/Makefile new file mode 100644 index 00000000..ee8c3461 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/Makefile @@ -0,0 +1,35 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library +EVEL_DEMO=$(CURDIR)/../../evel_demo +TEST_CONTROL=$(EVEL_DEMO)/evel_test_control.c + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c $(TEST_CONTROL) + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + -I $(EVEL_DEMO) \ + hello_evel_world.c \ + $(TEST_CONTROL) \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world 127.0.0.1 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/hello_evel_world.c new file mode 100644 index 00000000..269262aa --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/14-measurement-interval/hello_evel_world.c @@ -0,0 +1,293 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/time.h> + +#include "evel.h" +#include "evel_test_control.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_heartbeat(); +static void demo_measurement(const int interval); + +unsigned long long epoch_start = 0; + +int main(int argc, char ** argv) +{ + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + char * api_fqdn = argv[1]; + int api_port = atoi(argv[2]); + int api_secure = 0; + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(api_fqdn, /* FQDN */ + api_port, /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + api_secure, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Work out a start time for measurements, and sleep for initial period. */ + /***************************************************************************/ + int sleep_time = 1; + struct timeval tv_start; + gettimeofday(&tv_start, NULL); + epoch_start = tv_start.tv_usec + 1000000 * tv_start.tv_sec; + sleep(sleep_time); + + int index; + for (index = 0; index < 10; index++) + { + /*************************************************************************/ + /* On the second and fifth iteration, get the test_collector to change */ + /* the interval. */ + /*************************************************************************/ + if (index == 2) + { + printf("TestControl: measurement interval -> 2s\n"); + evel_test_control_meas_interval(2, api_secure, api_fqdn, api_port); + } + if (index == 5) + { + printf("TestControl: measurement interval -> 5s\n"); + evel_test_control_meas_interval(5, api_secure, api_fqdn, api_port); + } + + /*************************************************************************/ + /* Heartbeat to pick up the suppression change. */ + /*************************************************************************/ + demo_heartbeat(); + + /*************************************************************************/ + /* Raise a measurement and sleep. */ + /*************************************************************************/ + printf("Report measurements\n"); + fflush(stdout); + demo_measurement(sleep_time); + printf("Sleeping for %ds\n", sleep_time); + fflush(stdout); + sleep(sleep_time); + + /*************************************************************************/ + /* Update measurement interval. */ + /*************************************************************************/ + int measurement_interval; + measurement_interval = evel_get_measurement_interval(); + if (measurement_interval == EVEL_MEASUREMENT_INTERVAL_UKNOWN) + { + sleep_time = 1; + } + else + { + sleep_time = measurement_interval; + } + printf("EVEL measurement interval = %d\n\n", measurement_interval); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a heatbeat. + *****************************************************************************/ +void demo_heartbeat() +{ + EVENT_HEADER * heartbeat = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } +} + +/**************************************************************************//** + * Create and send a measurement event. + *****************************************************************************/ +void demo_measurement(const int interval) +{ + EVENT_MEASUREMENT * measurement = NULL; + MEASUREMENT_LATENCY_BUCKET * bucket = NULL; + MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + MEASUREMENT_CPU_USE *cpu_use; + + /***************************************************************************/ + /* Measurement */ + /***************************************************************************/ + measurement = evel_new_measurement(interval); + if (measurement != NULL) + { + printf("New measurement created...\n"); + 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_request_rate_set(measurement, 6); + + 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); + + bucket = evel_new_meas_latency_bucket(20); + evel_meas_latency_bucket_low_end_set(bucket, 0.0); + evel_meas_latency_bucket_high_end_set(bucket, 10.0); + 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_performance = evel_measurement_new_vnic_performance("eth0", "true"); + + evel_vnic_performance_rx_bcast_pkt_acc_set(vnic_performance, 1000000.023); + evel_vnic_performance_rx_bcast_pkt_delta_set(vnic_performance,1234.767346); + evel_vnic_performance_rx_discard_pkt_acc_set(vnic_performance, 127146784.234738587); + evel_vnic_performance_rx_discard_pkt_delta_set(vnic_performance, 123445); + evel_vnic_performance_rx_error_pkt_acc_set(vnic_performance, 2736448376); + evel_vnic_performance_rx_error_pkt_delta_set(vnic_performance, 3474438764); + evel_vnic_performance_rx_mcast_pkt_acc_set(vnic_performance, 42464676); + evel_vnic_performance_rx_mcast_pkt_delta_set(vnic_performance, 42678657654); + evel_vnic_performance_rx_octets_acc_set(vnic_performance, 47658745); + evel_vnic_performance_rx_octets_delta_set(vnic_performance, 47656465465); + evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, 4765764654444); + evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, 4545665656); + evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_performance, 4765745546.); + evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_performance, 4768765.78347856); + evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_performance, 747665.347647); + evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_performance, 3468765.4774); + evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_performance, 53625345.53); + evel_vnic_performance_tx_discarded_pkt_delta_set(vnic_performance, 5465345.72455); + evel_vnic_performance_tx_error_pkt_acc_set(vnic_performance, 7632754.754); + evel_vnic_performance_tx_error_pkt_delta_set(vnic_performance, 34646875444.); + evel_vnic_performance_tx_mcast_pkt_acc_set(vnic_performance, 2734875.5534); + evel_vnic_performance_tx_mcast_pkt_delta_set(vnic_performance, 562346534.654); + evel_vnic_performance_tx_octets_acc_set(vnic_performance, 2785845.76874); + evel_meas_vnic_performance_add(measurement, vnic_performance); + + vnic_performance = evel_measurement_new_vnic_performance("eth1", "false"); + evel_vnic_performance_rx_mcast_pkt_delta_set(vnic_performance, 42678657654); + evel_vnic_performance_rx_octets_acc_set(vnic_performance, 47658745); + evel_vnic_performance_rx_octets_delta_set(vnic_performance, 47656465465); + evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, 4765764654444); + evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, 4545665656); + evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_performance, 4765745546.); + evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_performance, 4768765.78347856); + evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_performance, 747665.347647); + evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_performance, 3468765.4774); + evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_performance, 53625345.53); + evel_meas_vnic_performance_add(measurement, vnic_performance); + + 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"); + + /*************************************************************************/ + /* Work out the time, to use as end of measurement period. */ + /*************************************************************************/ + 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(&measurement->header, epoch_start); + evel_last_epoch_set(&measurement->header, epoch_now); + epoch_start = epoch_now; + evel_reporting_entity_name_set(&measurement->header, "measurer"); + evel_reporting_entity_id_set(&measurement->header, "measurer_id"); + + evel_rc = evel_post_event((EVENT_HEADER *)measurement); + if (evel_rc == EVEL_SUCCESS) + { + printf("Post OK!\n"); + } + else + { + printf("Post Failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else + { + printf("Failed to create event (%s)\n", evel_error_string()); + } + + printf(" Processed Measurement\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/Makefile b/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/hello_evel_world.c new file mode 100644 index 00000000..c97290ac --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/15-raise-signaling/hello_evel_world.c @@ -0,0 +1,115 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_signaling(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a Signaling event */ + /***************************************************************************/ + demo_signaling(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a Signaling event. + *****************************************************************************/ +void demo_signaling(void) +{ + EVENT_SIGNALING * event = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + event = evel_new_signaling("vendor_x_id", + "correlator", "1.0.3.1", "1234", "192.168.1.3","3456"); + if (event != NULL) + { + evel_signaling_type_set(event, "Signaling"); + evel_signaling_vnfmodule_name_set(event, "vendor_x_module"); + evel_signaling_vnfname_set(event, "vendor_x_vnf"); + 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"); + evel_rc = evel_post_event((EVENT_HEADER *) event); + if (evel_rc != EVEL_SUCCESS) + { + EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + EVEL_ERROR("New Signaling failed"); + } + printf(" Processed Signaling\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/16-raise-service/Makefile b/VES5.0/evel/evel-library/code/evel_training/16-raise-service/Makefile new file mode 100644 index 00000000..6acfdd42 --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/16-raise-service/Makefile @@ -0,0 +1,31 @@ +CC=gcc + +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=$(CURDIR)/../../.. +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: hello_evel_world + +hello_evel_world: hello_evel_world.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_evel_world \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + hello_evel_world.c \ + -lpthread \ + -level \ + -lcurl + +#****************************************************************************** +# Configure the vel_username and vel_password to +# vel_username = username +# vel_password = password +#****************************************************************************** +run: all + ./hello_evel_world localhost 30000 username password diff --git a/VES5.0/evel/evel-library/code/evel_training/16-raise-service/hello_evel_world.c b/VES5.0/evel/evel-library/code/evel_training/16-raise-service/hello_evel_world.c new file mode 100644 index 00000000..53a7bd7e --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/16-raise-service/hello_evel_world.c @@ -0,0 +1,119 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "evel.h" + +/*****************************************************************************/ +/* Local prototypes. */ +/*****************************************************************************/ +static void demo_service(void); + +int main(int argc, char ** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_HEADER * heartbeat = NULL; + + printf("\nHello AT&T Vendor Event world!\n"); + fflush(stdout); + + if (argc != 5) + { + fprintf(stderr, + "Usage: %s <FQDN>|<IP address> <port> " + "<username> <password>\n", argv[0]); + exit(-1); + } + + /***************************************************************************/ + /* Initialize */ + /***************************************************************************/ + if (evel_initialize(argv[1], /* FQDN */ + atoi(argv[2]), /* Port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + argv[3], /* Username */ + argv[4], /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "EVEL training demo", /* Role */ + 0)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + /***************************************************************************/ + /* Send a heartbeat just to show we're alive! */ + /***************************************************************************/ + heartbeat = evel_new_heartbeat(); + if (heartbeat != NULL) + { + evel_rc = evel_post_event(heartbeat); + if (evel_rc != EVEL_SUCCESS) + { + printf("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + printf("New heartbeat failed"); + } + + /***************************************************************************/ + /* Raise a service event */ + /***************************************************************************/ + demo_service(); + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +/**************************************************************************//** + * Create and send a Service event. + *****************************************************************************/ +void demo_service(void) +{ + EVENT_SIGNALING * event = NULL; + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + + event = evel_new_signaling("vendor_x_id", + "correlator", "1.0.3.1", "1234", "192.168.1.3","3456"); + if (event != NULL) + { + evel_signaling_vnfmodule_name_set(event, "vendor_x_module"); + evel_signaling_vnfname_set(event, "vendor_x_vnf"); + evel_signaling_type_set(event, "Service Event"); + evel_signaling_correlator_set(event, "vendor_x_correlator"); + evel_signaling_addl_info_add(event, "prodid", "vendor_x_product_id"); + evel_signaling_addl_info_add(event, "subsys", "vendor_x_subsystem_id"); + evel_signaling_addl_info_add(event, "friendly_name", "vendor_x_friend"); + + evel_signaling_addl_info_add(event, "callee", "PCMA"); + evel_signaling_addl_info_add(event, "caller", "G729A"); + + evel_signaling_addl_info_add(event, "Name1", "Value1"); + evel_signaling_addl_info_add(event, "Name2", "Value2"); + + evel_rc = evel_post_event((EVENT_HEADER *) event); + if (evel_rc != EVEL_SUCCESS) + { + EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); + } + } + else + { + EVEL_ERROR("New Service failed"); + } + printf(" Processed Service Events\n"); +} diff --git a/VES5.0/evel/evel-library/code/evel_training/_gitignore b/VES5.0/evel/evel-library/code/evel_training/_gitignore new file mode 100644 index 00000000..ee7aeafd --- /dev/null +++ b/VES5.0/evel/evel-library/code/evel_training/_gitignore @@ -0,0 +1 @@ +*/hello_evel_world |