Adding snmp support for memory and mount points#379
Draft
rsh2prasad wants to merge 1 commit into
Draft
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
This PR adds support for
HOST-RESOURCES-MIB(RFC 2790 -hrStorageTable(.1.3.6.1.2.1.25.2.3) andhrFSTable(.1.3.6.1.2.1.25.3.8) to monitor disk usage, filesystem inventory, and memory utilization on devices), sourcing data from the newMOUNT_POINTS|*andMEMORY_STATS|*tables thatprocdockerstatsd(sonic-host-services) writes toSTATE_DB.This PR depends on the corresponding
sonic-host-serviceschange that populates thoseSTATE_DBtables. sonic-net/sonic-host-services#392How I did it
Added a new MIB module
src/sonic_ax_impl/mibs/ietf/rfc2790.pyand registered its tables inSonicMIB:hrStorageTable(.1.3.6.1.2.1.25.2.3) viahrStorageHandlerhrStorageDescr(1.3) – filesystem source fromMOUNT_POINTS|*.Filesystem; falls back to<key> MemoryforMEMORY_STATS|*rows.hrStorageAllocationUnits(1.4) – fixed at1024(data is reported in 1K blocks).hrStorageSize(1.5) –1K-blocksfield, returned as integer units of allocation.hrStorageUsed(1.6) –Usedfield.hrFSTable(.1.3.6.1.2.1.25.3.8) viafsHandlerhrFSMountPoint(1.2) – mount path parsed from theSTATE_DBkey (empty string forMEMORY_STATSrows, which are not real filesystems).hrFSType(1.4) – filesystem type fromMOUNT_POINTS|*.Type.Data source / lifecycle
get_nextwith nosub_id), the handlers re-readMOUNT_POINTS|*andMEMORY_STATS|*keys fromSTATE_DB, drop entries that return no data, sort mount-point entries, and append memory entries so indexing is stable within a walk.STATE_DBaccess goes through a small_db_callhelper that catches exceptions and logs them, so a transient Redis hiccup cannot crash the SNMP agent.Registration in
src/sonic_ax_impl/main.py: importedrfc2790and addedrfc2790.hrStorageTableandrfc2790.hrFSTableto theSonicMIBclass hierarchy.How to verify it
tests/test_rfc2790_hrstorage.py–hrStorageTableOID walks, value types, allocation units, descriptions (including memory fallback), and out-of-range indexing.tests/test_rfc2790_fs.py–hrFSTablemount-point and type retrieval, including the empty-mount behavior for memory rows.tests/test_rfc2790_empty_tables.py– behavior whenMOUNT_POINTSand/orMEMORY_STATSare empty or missing inSTATE_DB, ensuring no exceptions and gracefulNonereturns.tests/mock_tables/state_db.jsoncovering both tables.