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;
char* fqdn = argv[1];
int port = atoi(argv[2]);
char* vnic = argv[3];
+ char* fqdn2 = NULL;
+ int port2 = 0;
+ 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];
+
MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL;
printf("\nVector Packet Processing (VPP) measurement collection\n");
fflush(stdout);
- if (argc != 4)
+ if (!((argc == 6) || (argc == 4)))
{
- fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <interface>\n", argv[0]);
+ 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);
}
+ srand(time(NULL));
+
/**************************************************************************/
/* Initialize */
/**************************************************************************/
if(evel_initialize(fqdn, /* FQDN */
- port, /* Port */
- NULL, /* optional path */
- NULL, /* optional topic */
- 0, /* HTTPS? */
- "", /* Username */
- "", /* Password */
- EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
- "vLoadBalancer", /* Role */
- 1)) /* Verbosity */
+ port, /* Port */
+ fqdn2, /* Backup FQDN */
+ port2, /* Backup port */
+ NULL, /* optional path */
+ NULL, /* optional topic */
+ 100, /* Ring Buffer size */
+ 1, /* HTTPS? */
+ NULL, /* cert file */
+ NULL, /* key file */
+ caFile, /* ca info */
+ NULL, /* ca file */
+ 0, /* verify peer */
+ 0, /* verify host */
+ userName, /* Username */
+ passWord, /* Password */
+ "sample1", /* Username2 */
+ "sample1", /* Password2 */
+ NULL, /* Source ip */
+ NULL, /* Backup Source IP */
+ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
+ "vLoadBalancer", /* Role */
+ 1)) /* Verbosity */
{
fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
exit(-1);
packets_out_this_round = 0;
}
- vpp_m = evel_new_measurement(READ_INTERVAL);
- vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance("eth0", "true");
+ vpp_m = evel_new_measurement(READ_INTERVAL,"vLoadBalancer","TrafficStats_1.2.3.4");
+ vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance(vnic, "true");
evel_meas_vnic_performance_add(vpp_m, vnic_performance);
if(vpp_m != NULL) {
printf("New measurement report created...\n");
- 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_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_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 */
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_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) {