Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add orchagent heart beat message for watchdog. #2737

Merged
merged 9 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "logger.h"
#include <sairedis.h>
#include "warm_restart.h"
#include <iostream>

#define SAI_SWITCH_ATTR_CUSTOM_RANGE_BASE SAI_SWITCH_ATTR_CUSTOM_RANGE_START
#include "sairedis.h"
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<std::chrono::milliseconds>(tend - tstart);

Expand Down Expand Up @@ -958,6 +964,18 @@ void OrchDaemon::addOrchList(Orch *o)
m_orchList.push_back(o);
}

void OrchDaemon::heartBeat(std::chrono::time_point<std::chrono::high_resolution_clock> tcurrent)
{
// output heart beat message to SYSLOG
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(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 << "<!--XSUPERVISOR:BEGIN-->heartbeat<!--XSUPERVISOR:END-->" << endl;
}
}

FabricOrchDaemon::FabricOrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *stateDb, DBConnector *chassisAppDb) :
OrchDaemon(applDb, configDb, stateDb, chassisAppDb),
m_applDb(applDb),
Expand Down
4 changes: 4 additions & 0 deletions orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ class OrchDaemon

std::vector<Orch *> m_orchList;
Select *m_select;

std::chrono::time_point<std::chrono::high_resolution_clock> m_lastHeartBeat;

void flush();

void heartBeat(std::chrono::time_point<std::chrono::high_resolution_clock> tcurrent);
};

class FabricOrchDaemon : public OrchDaemon
Expand Down