summaryrefslogtreecommitdiffstats
path: root/tests/blueprints
diff options
context:
space:
mode:
authorBryan Sullivan <bryan.sullivan@att.com>2016-10-15 09:54:59 -0700
committerBryan Sullivan <bryan.sullivan@att.com>2016-10-15 09:54:59 -0700
commit6a8f06100abf6fcec0ffab5d7c71c4becddb2812 (patch)
tree0ac14277b7495014397bfc06019d202ca960e0a5 /tests/blueprints
parenta939d3cda9fef3a935dc6176ab88241619eb344c (diff)
Fix state change detection, add to monitor
JIRA: VES-1 Change-Id: Icd78d6ff941e46850d4635a7d136e8b1a85baa25 Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
Diffstat (limited to 'tests/blueprints')
-rw-r--r--tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c40
-rw-r--r--tests/blueprints/tosca-vnfd-hello-ves/monitor.py10
2 files changed, 24 insertions, 26 deletions
diff --git a/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c b/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c
index 39cd528..0eb655c 100644
--- a/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c
+++ b/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c
@@ -145,31 +145,26 @@ void check_app_container_state() {
printf("Checking status of app container\n");
FILE *fp;
int status;
- const int JSON_MAX = 1000;
- char json_line[JSON_MAX];
+ char state[100];
- fp = popen("sudo docker inspect vHello", "r");
+ fp = popen("sudo docker inspect vHello | grep Status | sed -- 's/,//g' | sed -- 's/\"//g' | sed -- 's/ Status: //g'", "r");
if (fp == NULL) {
EVEL_ERROR("popen failed to execute command");
}
- while (fgets(json_line, JSON_MAX, fp) != NULL) {
- if (strstr(json_line, "Running") != NULL) {
- if (strstr(json_line, "true") != NULL) {
- if (strcmp(app_prevstate,"Stopped") == 0) {
- printf("App state change detected: Started\n");
- report_app_statechange("Started");
- app_prevstate = "Running";
- }
- }
- else {
- if (strcmp(app_prevstate, "Running") == 0) {
- printf("App state change detected: Stopped\n");
- report_app_statechange("Stopped");
- app_prevstate = "Stopped";
- }
- }
- break;
+ fgets(state, 100, fp);
+ if (strstr(state, "running") != NULL) {
+ if (strcmp(app_prevstate,"Stopped") == 0) {
+ printf("App state change detected: Started\n");
+ report_app_statechange("Started");
+ app_prevstate = "Running";
+ }
+ }
+ else {
+ if (strcmp(app_prevstate, "Running") == 0) {
+ printf("App state change detected: Stopped\n");
+ report_app_statechange("Stopped");
+ app_prevstate = "Stopped";
}
}
status = pclose(fp);
@@ -216,7 +211,6 @@ void measure_traffic() {
if (sec == 0) sec = 59;
sprintf(secs, "%02d", sec);
strncat(period, secs, 9);
- printf("%s\n", period);
strcpy(cmd, "sudo docker logs vHello | grep -c ");
strncat(cmd, period, 100);
@@ -440,7 +434,7 @@ int main(int argc, char ** argv)
while (1)
{
EVEL_INFO("MAI: Starting main loop");
- printf("Starting main loop\n");
+// printf("Starting main loop\n");
printf("Sending heartbeat\n");
heartbeat = evel_new_heartbeat();
@@ -464,7 +458,7 @@ int main(int argc, char ** argv)
/* MAIN RETRY LOOP. Loop every 10 secs. */
/* TODO: Listener for throttling back scheduled reports. */
/*************************************************************************/
- printf("End of main loop, sleeping for 10 seconds\n");
+ // printf("End of main loop, sleeping for 10 seconds\n");
fflush(stdout);
sleep(10);
}
diff --git a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py
index 9f3b7ff..24ad557 100644
--- a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py
+++ b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py
@@ -25,9 +25,13 @@ with open('/home/ubuntu/ves.log') as f:
if line:
# print line,
if "requestRate" in line:
-# print line,
- rate = line[27:-2]
- print 'request rate: {0}'.format(rate)
+# print line,
+ rate = line[27:-2]
+ print 'request rate: {0}'.format(rate)
#....5....1....5....2....5....3....5
# "requestRate": 2264,
+ if "\"specificProblem\": \"Started\"" in line:
+ print 'app state change: Started'
+ if "\"specificProblem\": \"Stopped\"" in line:
+ print 'app state change: Stopped'