Skip to content

Commit

Permalink
Add heart beat interval parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Jan 9, 2025
1 parent 381c014 commit 8ddc11b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uint32_t create_switch_timeout = 0;

void usage()
{
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout] [-v VRF]" << endl;
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout] [-v VRF] [-I heart_beat_interval]" << endl;
cout << " -h: display this message" << endl;
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
cout << " Bit 0: sairedis.rec, Bit 1: swss.rec, Bit 2: responsepublisher.rec. For example:" << endl;
Expand All @@ -95,6 +95,7 @@ void usage()
cout << " -c counter mode (traditional|asic_db), default: asic_db" << endl;
cout << " -t Override create switch timeout, in sec" << endl;
cout << " -v vrf: VRF name (default empty)" << endl;
cout << " -I heart_beat_interval: Heart beat interval in millisecond (default 10)" << endl;
}

void sighup_handler(int signo)
Expand Down Expand Up @@ -450,6 +451,12 @@ int main(int argc, char **argv)
vrf = optarg;
}
break;
case 'I':
if (optarg)
{
g_heart_beat_interval = atoi(optarg);
}
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
Expand Down
5 changes: 3 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ using namespace swss;
#define APP_FABRIC_MONITOR_DATA_TABLE_NAME "FABRIC_MONITOR_TABLE"

/* orchagent heart beat message interval */
#define HEART_BEAT_INTERVAL_MSECS 10 * 1000
#define HEART_BEAT_INTERVAL_MSECS_DEFAULT 10 * 1000
long int g_heart_beat_interval = HEART_BEAT_INTERVAL_MSECS_DEFAULT;

extern sai_switch_api_t* sai_switch_api;
extern sai_object_id_t gSwitchId;
Expand Down Expand Up @@ -1093,7 +1094,7 @@ void OrchDaemon::heartBeat(std::chrono::time_point<std::chrono::high_resolution_
{
// 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)
if (diff.count() >= g_heart_beat_interval)
{
m_lastHeartBeat = tcurrent;
// output heart beat message to supervisord with 'PROCESS_COMMUNICATION_STDOUT' event: http://supervisord.org/events.html
Expand Down
2 changes: 2 additions & 0 deletions orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

using namespace swss;

extern long int g_heart_beat_interval;

class OrchDaemon
{
public:
Expand Down

0 comments on commit 8ddc11b

Please sign in to comment.