diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 54745a1038f..85d5a87969e 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -6,6 +6,7 @@ #include "logger.h" #include #include "warm_restart.h" +#include #define SAI_SWITCH_ATTR_CUSTOM_RANGE_BASE SAI_SWITCH_ATTR_CUSTOM_RANGE_START #include "sairedis.h" @@ -18,6 +19,9 @@ using namespace swss; #define SELECT_TIMEOUT 1000 #define PFC_WD_POLL_MSECS 100 +/* orchagent heart beat message interval */ +#define HEART_BEAT_INTERVAL_MSECS 10 * 1000 + extern sai_switch_api_t* sai_switch_api; extern sai_object_id_t gSwitchId; extern bool gSaiRedisLogRotate; @@ -72,6 +76,7 @@ OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector * { SWSS_LOG_ENTER(); m_select = new Select(); + m_lastHeartBeat = std::chrono::high_resolution_clock::now(); } OrchDaemon::~OrchDaemon() @@ -722,6 +727,7 @@ void OrchDaemon::start() ret = m_select->select(&s, SELECT_TIMEOUT); auto tend = std::chrono::high_resolution_clock::now(); + heartBeat(tend); auto diff = std::chrono::duration_cast(tend - tstart); @@ -958,6 +964,18 @@ void OrchDaemon::addOrchList(Orch *o) m_orchList.push_back(o); } +void OrchDaemon::heartBeat(std::chrono::time_point tcurrent) +{ + // output heart beat message to SYSLOG + auto diff = std::chrono::duration_cast(tcurrent - m_lastHeartBeat); + if (diff.count() >= HEART_BEAT_INTERVAL_MSECS) + { + m_lastHeartBeat = tcurrent; + // output heart beat message to supervisord with 'PROCESS_COMMUNICATION_STDOUT' event: http://supervisord.org/events.html + cout << "heartbeat" << endl; + } +} + FabricOrchDaemon::FabricOrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *chassisAppDb) : OrchDaemon(applDb, configDb, stateDb, chassisAppDb), m_applDb(applDb), diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 84bcd627b38..6092be26b44 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -90,8 +90,12 @@ class OrchDaemon std::vector m_orchList; Select *m_select; + + std::chrono::time_point m_lastHeartBeat; void flush(); + + void heartBeat(std::chrono::time_point tcurrent); }; class FabricOrchDaemon : public OrchDaemon