Skip to content

Commit 27391fc

Browse files
Publish oper_status time to STATE_DB (#3756)
Why I did it Mentioned in sonic-net/sonic-utilities#3956 oper error status last timestamp always shows 'Never' because we never publish the time it last changed. Port Errors Count Last timestamp(UTC) ---------------------------- ------- --------------------- code group error 0 Never crc rate 0 Never data unit crc error 0 Never data unit misalignment error 0 Never data unit size 0 Never fec alignment loss 0 Never fec sync loss 0 Never high ber error 0 Never high ser error 0 Never mac local fault 7 2025-06-27 23:36:28 mac remote fault 5 2025-06-27 23:36:28 no rx reachability 0 Never oper error status 3 Never signal local error 0 Never How I did it Published the time to STATE_DB under oper_error_status_time
1 parent ad80fa5 commit 27391fc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

orchagent/portsorch.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,19 +3613,22 @@ void PortsOrch::updateDbPortOperError(Port& port, PortOperErrorEvent *pevent)
36133613
{
36143614
SWSS_LOG_ENTER();
36153615

3616+
auto time = pevent->getEventTime();
36163617
auto key = pevent->getDbKey();
36173618
vector<FieldValueTuple> tuples;
36183619
FieldValueTuple tup1("oper_error_status", std::to_string(port.m_oper_error_status));
36193620
tuples.push_back(tup1);
36203621

3621-
size_t count = pevent->getErrorCount();
3622-
FieldValueTuple tup2(key + "_count", std::to_string(count));
3622+
FieldValueTuple tup2("oper_error_status_time", time);
36233623
tuples.push_back(tup2);
36243624

3625-
auto time = pevent->getEventTime();
3626-
FieldValueTuple tup3(key + "_time", time);
3625+
size_t count = pevent->getErrorCount();
3626+
FieldValueTuple tup3(key + "_count", std::to_string(count));
36273627
tuples.push_back(tup3);
36283628

3629+
FieldValueTuple tup4(key + "_time", time);
3630+
tuples.push_back(tup4);
3631+
36293632
m_portOpErrTable.set(port.m_alias, tuples);
36303633
}
36313634

0 commit comments

Comments
 (0)