summaryrefslogtreecommitdiffstats
path: root/vnfs
diff options
context:
space:
mode:
authorgokuls <goksing@gmail.com>2017-06-08 22:29:49 -0400
committergokuls <goksing@gmail.com>2017-06-08 22:39:14 -0400
commitd01dc36ebf5dc8869da816379e59ff3a0a4749d2 (patch)
treec1fb4d7a1c827de0ea4b470fa79daa8f0990cb64 /vnfs
parent2eb44078179c00be0ecc94c1763a4c4c4125d72d (diff)
Fix for delta values reported by vFW vLB
Change-Id: I344b2c0af895fbc224f68ebac00aa5113a3b9e73 Signed-off-by: Gokul Singaraju <goksing@gmail.com>
Diffstat (limited to 'vnfs')
-rw-r--r--vnfs/VES5.0/LICENSE.TXT22
-rw-r--r--vnfs/VESreporting_vFW5.0/vpp_measurement_reporter.c134
-rw-r--r--vnfs/VESreporting_vLB5.0/vpp_measurement_reporter.c81
3 files changed, 224 insertions, 13 deletions
diff --git a/vnfs/VES5.0/LICENSE.TXT b/vnfs/VES5.0/LICENSE.TXT
new file mode 100644
index 00000000..ae12da20
--- /dev/null
+++ b/vnfs/VES5.0/LICENSE.TXT
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
diff --git a/vnfs/VESreporting_vFW5.0/vpp_measurement_reporter.c b/vnfs/VESreporting_vFW5.0/vpp_measurement_reporter.c
index 2e54d744..05f52af5 100644
--- a/vnfs/VESreporting_vFW5.0/vpp_measurement_reporter.c
+++ b/vnfs/VESreporting_vFW5.0/vpp_measurement_reporter.c
@@ -38,6 +38,120 @@ void read_vpp_metrics(vpp_metrics_struct *, char *);
unsigned long long epoch_start = 0;
+#ifdef DOCKER
+int measure_traffic()
+{
+
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ FILE *fp;
+ int status;
+ char count[10];
+ time_t rawtime;
+ struct tm * timeinfo;
+ char period [21];
+ char cmd [100];
+ int concurrent_sessions = 0;
+ int configured_entities = 0;
+ double mean_request_latency = 0;
+ double measurement_interval = 1;
+ double memory_configured = 0;
+ double memory_used = 0;
+ int request_rate=0;
+ char secs [3];
+ int sec;
+ double loadavg;
+
+ printf("Checking app traffic\n");
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo);
+ strftime(secs,3,"%S",timeinfo);
+ sec = atoi(secs);
+ if (sec == 0) sec = 59;
+ sprintf(secs, "%02d", sec);
+ strncat(period, secs, 21);
+ // ....x....1....x....2.
+ // 15/Oct/2016:17:51:19
+ strcpy(cmd, "sudo docker logs vHello | grep -c ");
+ strncat(cmd, period, 100);
+
+ fp = popen(cmd, "r");
+ if (fp == NULL) {
+ EVEL_ERROR("popen failed to execute command");
+ }
+
+ if (fgets(count, 10, fp) != NULL) {
+ request_rate = atoi(count);
+ printf("Reporting request rate for second: %s as %d\n", period, request_rate);
+
+ }
+ else {
+ EVEL_ERROR("New Measurement failed");
+ }
+ printf("Processed measurement\n");
+
+ status = pclose(fp);
+ if (status == -1) {
+ EVEL_ERROR("pclose returned an error");
+ }
+ return request_rate;
+}
+
+#endif
+
+
+
+/**************************************************************************//**
+ * tap live cpu stats
+ *****************************************************************************/
+void evel_get_cpu_stats(EVENT_MEASUREMENT * measurement)
+{
+ FILE *fp;
+ char path[1024];
+ double usage=0.0;
+ double idle;
+ double intrpt;
+ double nice;
+ double softirq;
+ double steal;
+ double sys;
+ double user;
+ double wait;
+ MEASUREMENT_CPU_USE *cpu_use = NULL;
+
+ /* Open the command for reading. */
+ //fp = popen("/bin/ls /etc/", "r");
+ fp = popen("/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 ", "r");
+ if (fp == NULL) {
+ printf("Failed to run command\n" );
+ exit(1);
+ }
+
+ /* Read the output a line at a time - output it. */
+ while (fgets(path, sizeof(path)-1, fp) != NULL) {
+ printf("%s", path+10);
+ sscanf(path+10," %lf us, %lf sy, %lf ni, %lf id, %lf wa, %lf hi, %lf si, %lf st",
+ &user,&sys,&nice,&idle,&wait,&intrpt,&softirq,&steal);
+ }
+
+ /* close */
+ pclose(fp);
+
+ cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", usage);
+ if( cpu_use != NULL ){
+ evel_measurement_cpu_use_idle_set(cpu_use,idle);
+ //evel_measurement_cpu_use_interrupt_set(cpu_use,intrpt);
+ //evel_measurement_cpu_use_nice_set(cpu_use,nice);
+ //evel_measurement_cpu_use_softirq_set(cpu_use,softirq);
+ //evel_measurement_cpu_use_steal_set(cpu_use,steal);
+ evel_measurement_cpu_use_system_set(cpu_use,sys);
+ evel_measurement_cpu_use_usageuser_set(cpu_use,user);
+ //evel_measurement_cpu_use_wait_set(cpu_use,wait);
+ //evel_measurement_cpu_use_add(measurement, "cpu2", usage,idle,intrpt,nice,softirq,steal,sys,user,wait);
+ }
+}
+
+
int main(int argc, char** argv)
{
@@ -68,6 +182,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <interface>\n", argv[0]);
exit(-1);
}
+ srand(time(NULL));
/**************************************************************************/
/* Initialize */
@@ -137,12 +252,15 @@ int main(int argc, char** argv)
if(vpp_m != NULL) {
printf("New measurement report created...\n");
+ evel_measurement_type_set(vpp_m, "HTTP request rate");
+ evel_measurement_request_rate_set(vpp_m, rand()%10000);
+
+ evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, packets_in_this_round);
+ evel_vnic_performance_tx_total_pkt_delta_set(vnic_performance, packets_out_this_round);
- evel_vnic_performance_rx_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);
+ evel_get_cpu_stats(vpp_m);
/***************************************************************************/
/* Set parameters in the MEASUREMENT header packet */
@@ -159,8 +277,10 @@ int main(int argc, char** argv)
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);
+ //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, "fwll");
+ evel_reporting_entity_id_set(&vpp_m->header, "No UUID available");
evel_rc = evel_post_event(vpp_m_header);
if(evel_rc == EVEL_SUCCESS) {
diff --git a/vnfs/VESreporting_vLB5.0/vpp_measurement_reporter.c b/vnfs/VESreporting_vLB5.0/vpp_measurement_reporter.c
index 643997ab..afbbce8d 100644
--- a/vnfs/VESreporting_vLB5.0/vpp_measurement_reporter.c
+++ b/vnfs/VESreporting_vLB5.0/vpp_measurement_reporter.c
@@ -39,6 +39,69 @@ void read_vpp_metrics(vpp_metrics_struct *, char *);
unsigned long long epoch_start = 0;
+
+#ifdef DOCKER
+int measure_traffic()
+{
+
+ EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
+ FILE *fp;
+ int status;
+ char count[10];
+ time_t rawtime;
+ struct tm * timeinfo;
+ char period [21];
+ char cmd [100];
+ int concurrent_sessions = 0;
+ int configured_entities = 0;
+ double mean_request_latency = 0;
+ double measurement_interval = 1;
+ double memory_configured = 0;
+ double memory_used = 0;
+ int request_rate=0;
+ char secs [3];
+ int sec;
+ double loadavg;
+
+ printf("Checking app traffic\n");
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo);
+ strftime(secs,3,"%S",timeinfo);
+ sec = atoi(secs);
+ if (sec == 0) sec = 59;
+ sprintf(secs, "%02d", sec);
+ strncat(period, secs, 21);
+ // ....x....1....x....2.
+ // 15/Oct/2016:17:51:19
+ strcpy(cmd, "sudo docker logs vHello | grep -c ");
+ strncat(cmd, period, 100);
+
+ fp = popen(cmd, "r");
+ if (fp == NULL) {
+ EVEL_ERROR("popen failed to execute command");
+ }
+
+ if (fgets(count, 10, fp) != NULL) {
+ request_rate = atoi(count);
+ printf("Reporting request rate for second: %s as %d\n", period, request_rate);
+
+ }
+ else {
+ EVEL_ERROR("New Measurement failed");
+ }
+ printf("Processed measurement\n");
+
+ status = pclose(fp);
+ if (status == -1) {
+ EVEL_ERROR("pclose returned an error");
+ }
+ return request_rate;
+}
+
+#endif
+
+
int main(int argc, char** argv)
{
EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
@@ -67,6 +130,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Usage: %s <FQDN>|<IP address> <port> <interface>\n", argv[0]);
exit(-1);
}
+ srand(time(NULL));
/**************************************************************************/
/* Initialize */
@@ -149,11 +213,14 @@ int main(int argc, char** argv)
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 */
@@ -170,8 +237,10 @@ int main(int argc, char** argv)
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);
+ //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, hostname);
+ evel_reporting_entity_id_set(&vpp_m->header, "No UUID available");
evel_rc = evel_post_event(vpp_m_header);
if(evel_rc == EVEL_SUCCESS) {