/*************************************************************************//**
*
- * 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.
void read_vpp_metrics(vpp_metrics_struct *, char *);
-unsigned long long epoch_start = 0;
-
-
int main(int argc, char** argv)
{
EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
EVENT_MEASUREMENT* vpp_m = NULL;
EVENT_HEADER* vpp_m_header = NULL;
+ EVENT_HEADER* batch_header = NULL;
+ MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
int bytes_in_this_round;
int bytes_out_this_round;
int packets_in_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;
+ time_t start_epoch;
+ time_t last_epoch;
char hostname[BUFSIZE];
+ char eventName[BUFSIZE];
+ char eventId[BUFSIZE];
+ char* fqdn2 = NULL;
+ int port2 = 0;
+ char * vnic = NULL;
+ memset(eventName, 0, BUFSIZE);
+ memset(eventId, 0, BUFSIZE);
+ memset(hostname, 0, BUFSIZE);
+
+ strcpy(eventName, "vFirewallBroadcastPackets");
+ strcpy(eventId, "mvfs00000001");
+
char* fqdn = argv[1];
int port = atoi(argv[2]);
- char* vnic = argv[3];
- MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
- //struct timeval tv_start;
+ char* caFile = "/opt/config/onap-ca.crt";
+ char* userName = "sample1";
+ char* passWord = "sample1";
+
+ if(argc == 6)
+ {
+ fqdn2 = argv[3];
+ port2 = atoi(argv[4]);
+ vnic = argv[5];
+ }
+ else
+ vnic = argv[3];
printf("\nVector Packet Processing (VPP) measurement collection\n");
fflush(stdout);
- if (argc != 4)
+ if (!((argc == 4) || (argc == 6)))
{
+ fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <FQDN>|<IP address> <port> <interface> \n", argv[0]);
+ fprintf(stderr, "OR\n");
fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <interface>\n", argv[0]);
exit(-1);
}
/**************************************************************************/
if(evel_initialize(fqdn, /* FQDN */
port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
NULL, /* optional path */
NULL, /* optional topic */
- 0, /* HTTPS? */
- "", /* Username */
- "", /* Password */
+ 100, /* Ring Buffer size */
+ 1, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ caFile, /* ca file */
+ NULL, /* ca directory */
+ 0, /* verify peer */
+ 0, /* verify host */
+ userName, /* Username */
+ passWord, /* 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);
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;
+ start_epoch = time_val.tv_sec * 1000000 + time_val.tv_usec;
sleep(READ_INTERVAL);
/***************************************************************************/
packets_out_this_round = 0;
}
- vpp_m = evel_new_measurement(READ_INTERVAL);
- vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance("eth0", "true");
- evel_meas_vnic_performance_add(vpp_m, vnic_performance);
+ vpp_m = evel_new_measurement(READ_INTERVAL, eventName, eventId);
if(vpp_m != NULL) {
printf("New measurement report created...\n");
+ vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance(vnic, "true");
+ evel_meas_vnic_performance_add(vpp_m, vnic_performance);
+ 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_total_pkt_acc_set(vnic_performance, packets_in_this_round);
- evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, packets_out_this_round);
-
- evel_vnic_performance_rx_octets_acc_set(vnic_performance, bytes_in_this_round);
- evel_vnic_performance_tx_octets_acc_set(vnic_performance, bytes_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;
+ 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;
-
- strcpy(vpp_m_header->reporting_entity_id.value, "No UUID available");
- strcpy(vpp_m_header->reporting_entity_name, hostname);
- evel_rc = evel_post_event(vpp_m_header);
+ vpp_m_header->start_epoch_microsec = start_epoch;
+ vpp_m_header->last_epoch_microsec = last_epoch;
+ evel_reporting_entity_id_set(vpp_m_header, "No UUID available");
+ printf("1111\n");
+ evel_reporting_entity_name_set(vpp_m_header, hostname);
+ printf("1111\n");
+ // evel_rc = evel_post_event(vpp_m_header);
+ batch_header = evel_new_batch("batch_event_name", "bevent_id");
+ evel_batch_add_event(batch_header, vpp_m_header);
+ evel_rc = evel_post_event(batch_header);
if(evel_rc == EVEL_SUCCESS) {
printf("Measurement report correctly sent to the collector!\n");
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;
+ gettimeofday(&time_val, NULL);
+ start_epoch = time_val.tv_sec * 1000000 + time_val.tv_usec;
sleep(READ_INTERVAL);
}