VOL-1171 Do not collect stats before olt up (and Voltha connected)

Change-Id: I2a7e109a51d7ea1a21481a84a96c755a5471bc55
diff --git a/src/stats_collection.cc b/src/stats_collection.cc
index 0416ef4..5e23d11 100644
--- a/src/stats_collection.cc
+++ b/src/stats_collection.cc
@@ -4,6 +4,7 @@
 
 #include <openolt.grpc.pb.h>
 #include "indications.h"
+#include "core.h"
 
 extern "C"
 {
@@ -147,6 +148,15 @@
 
 void* stats_collection() {
 
+    if (!state.is_connected()) {
+        std::cout << "Voltha is not connected, do not collect stats" << std::endl;
+        return;
+    }
+    if (!state.is_activated()) {
+        std::cout << "The OLT is not up, do not collect stats" << std::endl;
+        return;
+    }
+
     time_t now;
 
     std::cout << "Collecting statistics" << std::endl;