#ifndef __AlertDelayCheck_h_ #define __AlertDelayCheck_h_ #include "../shared/ContainerThread.h" #include "../shared/SimpleLogFile.h" #include "RecordDispatcher.h" /* This is a way to monitor the speed at which alerts move through the system. * We know alerts are slow sometimes, but where is the slowness? * * This can be installed almost anywhere. Just create one of these objects. * It will spit out results to the log file. * * For simplicity we grab one alert every 5 seconds. That's not 100% fair * because alerts are not all reported in order. * * We report the late time in seconds. The current time is precise to the * microsecond, but the alert time is only precise to the second. So if there * were no delays you'd expect all the values to be between 0 and 1 second * late. */ class AlertDelayCheck : public ForeverThreadUser { private: time_t _nextReportTime; virtual void handleRequestInThread(Request *original) { const time_t now = time(NULL); if (now < _nextReportTime) return; _nextReportTime = now + 5; NewRecord *current = dynamic_cast< NewRecord * >(original); const ValueBox timeBox = current->record->lookUpValue((FieldId)MainFields::timestamp); bool valid; int64_t alertTime; timeBox.getInt(valid, alertTime); if (!valid) { TclList msg; msg< 1.0) { TclList msg; msg<listenForRecords(this, 0); start(); }; }; #endif