Skip to content
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
24 changes: 20 additions & 4 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ string gRecordFile;

void usage()
{
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size]" << 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]" << endl;
cout << " -h: display this message" << endl;
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
cout << " 0: do not record logs" << endl;
Expand All @@ -81,6 +81,8 @@ void usage()
cout << " -s: enable synchronous mode (deprecated, use -z)" << endl;
cout << " -z: redis communication mode (redis_async|redis_sync|zmq_sync), default: redis_async" << endl;
cout << " -k max bulk size in bulk mode (default 1000)";
cout << " -f swss_rec_filename: swss record log filename(default 'swss.rec')" << endl;
cout << " -j sairedis_rec_filename: sairedis record log filename(default sairedis.rec)" << endl;
}

void sighup_handler(int signo)
Expand Down Expand Up @@ -164,8 +166,10 @@ int main(int argc, char **argv)
sai_status_t status;

string record_location = ".";
string swss_rec_filename = "swss.rec";
string sairedis_rec_filename = "sairedis.rec";

while ((opt = getopt(argc, argv, "b:m:r:d:i:hsz:k:")) != -1)
while ((opt = getopt(argc, argv, "b:m:r:f:j:d:i:hsz:k:")) != -1)
{
switch (opt)
{
Expand Down Expand Up @@ -244,6 +248,18 @@ int main(int argc, char **argv)
}
}
break;
case 'f':
if (optarg)
{
swss_rec_filename = optarg;
}
break;
case 'j':
if (optarg)
{
sairedis_rec_filename = optarg;
}
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
Expand All @@ -252,7 +268,7 @@ int main(int argc, char **argv)
SWSS_LOG_NOTICE("--- Starting Orchestration Agent ---");

initSaiApi();
initSaiRedis(record_location);
initSaiRedis(record_location, sairedis_rec_filename);

sai_attribute_t attr;
vector<sai_attribute_t> attrs;
Expand All @@ -267,7 +283,7 @@ int main(int argc, char **argv)
/* Disable/enable SwSS recording */
if (gSwssRecord)
{
gRecordFile = record_location + "/" + "swss.rec";
gRecordFile = record_location + "/" + swss_rec_filename;
gRecordOfs.open(gRecordFile, std::ofstream::out | std::ofstream::app);
if (!gRecordOfs.is_open())
{
Expand Down
15 changes: 14 additions & 1 deletion orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void initSaiApi()
sai_log_set((sai_api_t)SAI_API_NAT, SAI_LOG_LEVEL_NOTICE);
}

void initSaiRedis(const string &record_location)
void initSaiRedis(const string &record_location, const std::string &record_filename)
{
/**
* NOTE: Notice that all Redis attributes here are using SAI_NULL_OBJECT_ID
Expand All @@ -235,6 +235,19 @@ void initSaiRedis(const string &record_location)
record_location.c_str(), status);
exit(EXIT_FAILURE);
}

attr.id = SAI_REDIS_SWITCH_ATTR_RECORDING_FILENAME;
attr.value.s8list.count = (uint32_t)record_filename.size();
attr.value.s8list.list = (int8_t*)const_cast<char *>(record_filename.c_str());

status = sai_switch_api->set_switch_attribute(gSwitchId, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set SAI Redis recording logfile to %s, rv:%d",
record_filename.c_str(), status);
exit(EXIT_FAILURE);
}

}

/* Disable/enable SAI Redis recording */
Expand Down
2 changes: 1 addition & 1 deletion orchagent/saihelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#include <string>

void initSaiApi();
void initSaiRedis(const std::string &record_location);
void initSaiRedis(const std::string &record_location, const std::string &record_filename);
sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy);