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

Rsu health monitor #564

Merged
merged 54 commits into from
Nov 14, 2023
Merged

Rsu health monitor #564

merged 54 commits into from
Nov 14, 2023

Conversation

dan-du-car
Copy link
Collaborator

@dan-du-car dan-du-car commented Nov 8, 2023

PR Details

Description

RSU health monitor plugin is a V2xHub plugin that interface with its connected RSU directly via SNMP protocol. The plugin is responsible for monitoring the connected RSU status by constantly ping RSU device. For detailed design of this plugin, refer to https://usdot-carma.atlassian.net/wiki/spaces/WFD2/pages/2640740360/RSU+Health+Monitor+Plugin+Design .

Related Issue

WFD-435
#591

Motivation and Context

In support of WFD telematics testing (Data visualization)

How Has This Been Tested?

Integration test

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • I have added any new packages to the sonar-scanner.properties file
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
    V2XHUB Contributing Guide
  • I have added tests to cover my changes.
  • All new and existing tests passed.

}
catch (nmea::NMEAParseError &e)
{
fprintf(stderr, "Error:%s\n", e.message.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using fprintf instead of PLOG

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

result.insert({std::stod(latitude_str), std::stod(longitude_str)});
PLOG(logDEBUG) << "Parse GPS NMEA string: " << gps_nmea_data << ". Result (Latitude, Longitude): (" << latitude_str << "," << longitude_str << ")";
}
catch (nmea::NMEAParseError &e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be constant

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

if (rsuStatusConfigTbl.size() == 0)
{
PLOG(logERROR) << "RSU status update call failed due to the RSU status config table is empty!";
return Json::nullValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we printing error and returning null instead of throwing an exception

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We encourage users to update the RSU config table by updating the mib version with the supported version, but it is not a fatal program issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptions do not need to be fatal but this is fine for now.

snmp_pdu *response;

std::string result = "";
auto pdu = snmp_pdu_create(SNMP_MSG_GET);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a member variable with the same name and overlapping scope. We should probably reconsider naming here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

};

/**
* RSUStatusTable is custome defined RSU status information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*custom

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e


/**
* RSUStatusTable is custome defined RSU status information.
* The fields are the subset of fields from RSU MIB definition https://github.com/certificationoperatingcouncil/COC_TestSpecs/blob/master/AppNotes/RSU/RSU-MIB.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields are a subset of the fields from the RSU MIB definition used to quantify the health of the RSU.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

{
private:
// A map of RSU MIB version used and RSUStatusTable
shared_ptr<map<RSUMibVersion, RSUStatusConfigTable>> _RSUSTATUSConfigMapPtr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a map between mib version and RSU Status Config table? Will we populate this map with all versions regardless of the configured version and then just use the configured version?

Copy link
Collaborator Author

@dan-du-car dan-du-car Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we will populate the map with all versions if exist like NTCIP1218 and RSU4.1. But the users can choose which version to use by specifying the mib version through the UI.

* @param vector<string> Input RSU fields to verify
* @return True if all required fields found. Otherwise, false.
*/
bool isAllRequiredFieldsPresent(const RSUMibVersion &mibVersion, const vector<string> &fields) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this method to validate. Also I am not sure I understand this method. Is it meant to validate a RSU status message or is it meant to confirm all the required OIDs are obtainable from SNMP client?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, update to validate. Yes, it is to make sure we obtain all the required fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

return rsuStatusTbl;
}

bool RSUHealthMonitorWorker::isAllRequiredFieldsPresent(const RSUMibVersion &mibVersion, const vector<string> &fields) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a validation method I suggest for clarity sake you pass in the config directly instead of passing in the mib version and calling Get config. I think it is cleaner for the validate method to take parameters ( message to validate, list of required fields)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed a49366e

_timerThId = _rsuStatusTimer->AddPeriodicTick([this]()
{
// Periodic SNMP call to get RSU status based on RSU MIB version 4.1
auto rsuStatusJson = _rsuWorker->getRSUStatus(_rsuMibVersion, _rsuIp, _snmpPort, _securityUser, _authPassPhrase, _securityLevel, SEC_TO_MICRO);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing to me. So you get the RSU status here by querying the SNMP server and you return a JSON. Then you wait until the broadcast method to check that the required information is present? You do not have to change this, it just seems weird to me. I would imagine that the method that gets the RSU status either directly turns it into the tmx message (including validation) or the next method turns it into a tmx message.

Copy link
Collaborator Author

@dan-du-car dan-du-car Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the JSON is empty due to some SNMP timeout or other issues, we stop any further logic like creating TMX message, broadcasting message.

@paulbourelly999 paulbourelly999 merged commit a098635 into develop Nov 14, 2023
8 of 9 checks passed
@paulbourelly999 paulbourelly999 deleted the rsu_health_monitor branch November 14, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants