stephb9959
2022-09-22 21:47:11 -07:00
parent 93890a1e99
commit 9c9f2cbf4f
6 changed files with 31 additions and 20 deletions

2
build
View File

@@ -1 +1 @@
16
18

View File

@@ -93,7 +93,7 @@ namespace OpenWifi {
DI_.connected =true;
AnalyticsObjects::DeviceTimePoint DTP;
Logger().information(fmt::format("{}: stats message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: stats message.", DI_.serialNumber));
// find radios first to get associations.
try {
@@ -351,7 +351,7 @@ namespace OpenWifi {
}
DTP.device_info = DI_;
} catch (...) {
Logger().information(fmt::format("{}: stats failed parsing.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: stats failed parsing.", DI_.serialNumber));
}
if(got_base) {
@@ -517,7 +517,7 @@ namespace OpenWifi {
GetJSON("locale", ConnectionData, DI_.locale, std::string{} );
}
} catch (...) {
Logger().information(fmt::format("{}: error parsing connection message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: error parsing connection message.", DI_.serialNumber));
}
}
@@ -528,7 +528,7 @@ namespace OpenWifi {
GetJSON("sanity", *Health, DI_.health, (uint64_t)0 );
poco_debug(Logger(),fmt::format("{}: health message.", DI_.serialNumber));
} catch(...) {
Logger().information(fmt::format("{}: error parsing health message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: error parsing health message.", DI_.serialNumber));
}
}
}

View File

@@ -12,6 +12,7 @@
namespace OpenWifi {
int Storage::Start() {
poco_notice(Logger(),"Starting...");
std::lock_guard Guard(Mutex_);
StorageClass::Start();
@@ -43,14 +44,14 @@ namespace OpenWifi {
uint64_t start = 0 ;
bool done = false;
const uint64_t batch=100;
Logger().information("Starting cleanup of TimePoint Database");
poco_information(Logger(),"Starting cleanup of TimePoint Database");
while(!done) {
if(!BoardsDB().GetRecords(start,batch,BoardList)) {
for(const auto &board:BoardList) {
for(const auto &venue:board.venueList) {
auto now = OpenWifi::Now();
auto lower_bound = now - venue.retention;
Logger().information(fmt::format("Removing old records for board '{}'",board.info.name));
poco_information(Logger(),fmt::format("Removing old records for board '{}'",board.info.name));
BoardsDB().DeleteRecords(fmt::format(" boardId='{}' and timestamp<{}", board.info.id, lower_bound));
}
}
@@ -60,9 +61,9 @@ namespace OpenWifi {
auto MaxDays = MicroService::instance().ConfigGetInt("wificlient.age.limit",14);
auto LowerDate = OpenWifi::Now() - (MaxDays*60*60*24);
Logger().information(fmt::format("Removing WiFi Clients history older than {} days.", MaxDays));
poco_information(Logger(),fmt::format("Removing WiFi Clients history older than {} days.", MaxDays));
StorageService()->WifiClientHistoryDB().DeleteRecords(fmt::format(" timestamp<{} ", LowerDate));
Logger().information(fmt::format("Done cleanup of databases. Next run in {} seconds.", PeriodicCleanup_));
poco_information(Logger(),fmt::format("Done cleanup of databases. Next run in {} seconds.", PeriodicCleanup_));
}
void Storage::run() {
@@ -81,11 +82,12 @@ namespace OpenWifi {
}
void Storage::Stop() {
poco_notice(Logger(),"Stopping...");
Running_=false;
Timer_.stop();
Updater_.wakeUp();
Updater_.join();
Logger().notice("Stopping.");
poco_notice(Logger(),"Stopped...");
}
}

View File

@@ -11,6 +11,7 @@
namespace OpenWifi {
int VenueCoordinator::Start() {
poco_notice(Logger(),"Starting...");
GetBoardList();
Worker_.start(*this);
@@ -26,29 +27,31 @@ namespace OpenWifi {
std::lock_guard G(Mutex_);
Utils::SetThreadName("brd-refresh");
Logger().information("Starting to reconcile board information.");
poco_information(Logger(),"Starting to reconcile board information.");
for(const auto &[board_id, watcher]:Watchers_) {
Logger().information(fmt::format("Updating: {}", board_id));
poco_information(Logger(),fmt::format("Updating: {}", board_id));
UpdateBoard(board_id);
}
Logger().information("Finished reconciling board information.");
poco_information(Logger(),"Finished reconciling board information.");
}
void VenueCoordinator::GetBoardList() {
BoardsToWatch_.clear();
auto F = [&](const AnalyticsObjects::BoardInfo &B) ->bool {
BoardsToWatch_.insert(B);
// Logger().information(fmt::format("Starting watch for {}.", B.info.name));
// poco_information(Logger(),fmt::format("Starting watch for {}.", B.info.name));
return true;
};
StorageService()->BoardsDB().Iterate(F);
}
void VenueCoordinator::Stop() {
poco_notice(Logger(),"Stopping...");
Running_=false;
Worker_.wakeUp();
Worker_.wakeUp();
Worker_.join();
poco_notice(Logger(),"Stopped...");
}
void VenueCoordinator::run() {
@@ -116,7 +119,7 @@ namespace OpenWifi {
ExistingBoards_[B.info.id] = Devices;
Watchers_[B.info.id] = std::make_shared<VenueWatcher>(B.info.id, B.venueList[0].id, Logger(), Devices);
Watchers_[B.info.id]->Start();
Logger().information(fmt::format("Started board {} for venue {}", B.info.name,B.venueList[0].id ));
poco_information(Logger(),fmt::format("Started board {} for venue {}", B.info.name,B.venueList[0].id ));
return true;
}
@@ -125,7 +128,7 @@ namespace OpenWifi {
return false;
}
Logger().information(fmt::format("Could not start board {}",B.info.name));
poco_information(Logger(),fmt::format("Could not start board {}",B.info.name));
return false;
}
@@ -154,9 +157,9 @@ namespace OpenWifi {
it2->second->ModifySerialNumbers(Devices);
}
ExistingBoards_[id] = Devices;
Logger().information(fmt::format("Modified board {}",B.info.name));
poco_information(Logger(),fmt::format("Modified board {}",B.info.name));
} else {
Logger().information(fmt::format("No device changes in board {}",B.info.name));
poco_information(Logger(),fmt::format("No device changes in board {}",B.info.name));
}
}
return;
@@ -167,7 +170,7 @@ namespace OpenWifi {
return;
}
Logger().information(fmt::format("Could not modify board {}",B.info.name));
poco_information(Logger(),fmt::format("Could not modify board {}",B.info.name));
}
}
@@ -183,7 +186,7 @@ namespace OpenWifi {
if(StorageService()->BoardsDB().GetRecord("id",id,B))
BoardsToWatch_.insert(B);
else
Logger().information(fmt::format("Board {} does not seem to exist",id));
poco_information(Logger(),fmt::format("Board {} does not seem to exist",id));
}
void VenueCoordinator::GetDevices(std::string &id, AnalyticsObjects::DeviceInfoList &DIL) {

View File

@@ -10,6 +10,7 @@
namespace OpenWifi {
void VenueWatcher::Start() {
poco_notice(Logger(),"Starting...");
for(const auto &mac:SerialNumbers_) {
auto ap = std::make_shared<AP>(mac, venue_id_, boardId_, Logger());
APs_[mac ] = ap;
@@ -24,6 +25,7 @@ namespace OpenWifi {
}
void VenueWatcher::Stop() {
poco_notice(Logger(),"Stopping...");
Running_ = false;
Queue_.wakeUpAll();
Worker_.join();
@@ -31,6 +33,7 @@ namespace OpenWifi {
StateReceiver()->DeRegister(i,this);
DeviceStatusReceiver()->DeRegister(this);
HealthReceiver()->DeRegister(this);
poco_notice(Logger(),"Stopped...");
}
void VenueWatcher::run() {

View File

@@ -10,6 +10,7 @@
namespace OpenWifi {
int WifiClientCache::Start() {
poco_notice(Logger(),"Starting...");
TimerCallback_ = std::make_unique<Poco::TimerCallback<WifiClientCache>>(*this,&WifiClientCache::onTimer);
Timer_.setStartInterval( 30 * 1000); // first run in 20 seconds
Timer_.setPeriodicInterval( 60 * 60 * 1000); // 1 hours
@@ -18,7 +19,9 @@ namespace OpenWifi {
}
void WifiClientCache::Stop() {
poco_notice(Logger(),"Stopping...");
Timer_.stop();
poco_notice(Logger(),"Stopped...");
}
void WifiClientCache::onTimer([[maybe_unused]] Poco::Timer & timer) {