-
Notifications
You must be signed in to change notification settings - Fork 18
[change] NetJSON DeviceMonitoring compliance #2 #62
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d46b568
[change] NetJSON DeviceMonitoring compliance #2
purhan 9168a27
[change] Add monitoring info to OpenWRT backend
purhan cfa6650
[chores] Fix failing tests
purhan c9962e2
[chores/qa] Improvements to tests
purhan 8cd7089
[change] Add monitoring info to AirOS backend
purhan da39965
[chores] Some requested changes
purhan 1800332
[chores] Fix neighbor information when mac address is not found
purhan cda0295
[change] Add IP to neighbor information
purhan 0edc93a
[chores] Add comment
purhan acafe93
[change] Add more interfaces, Add RAM_used
purhan 34f05c9
[change] Use one query for neighbors and their states
purhan 034475c
[chores] Fix failing build
purhan 995b703
[change] Implement SNMPDUMP
purhan 83a25de
[change] Add device name, ip to interfaces
purhan 0f37717
[change] Make interface types NetJSON compliant
purhan 5dc3cc6
[change] Change RAM OIDs, add load info, add wireless interfaces
purhan d746f2d
[change] Use Trie instead of Dict in walk function
purhan 56ea551
[docs] Update docs for AirOS and OpenWRT backends
purhan 4e6f1f1
[chores] Move OpenWRT interface type to match AirOS
purhan 5424532
[change] Add CPU_count to airOS
purhan 621f725
[qa] Reformatted code and docs
nemesifier 9b99213
Merge branch 'master' into netjson-compliance
nemesifier 8f9254a
[fix] Added back jsonschema
nemesifier 7bb97e3
[chores] Added device model, OS
nemesifier a32bb7c
[chores] Fixed bugs uncovered by Kilobot
nemesifier e50844e
[fix] Addressed @coderabbitai reviews
nemesifier 4690657
[fix] Fixed more nasty bugs
nemesifier 25db8fb
[fix] Renamed memory "cached" (bogus) to "cache" (correct)
nemesifier a89c8fe
[chores] Follow up with coderabbit
nemesifier 436b1e3
[chores] Addressed @coderabbitai review comments
nemesifier c19ceff
Merge remote-tracking branch 'origin/master' into netjson-compliance
nemesifier 6f0e676
[chores] Addressed @coderabbitai review comments
nemesifier ec706d0
[chores] Addressed @coderabbitai review comments
nemesifier 78c93e1
[chores] Addressed @coderabbitai review comments
nemesifier f32abd8
[chores] Further cleanup
nemesifier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ build | |
| test-settings.json | ||
| *.# | ||
| python | ||
| docs/_build | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| SNMP backend | ||
| ============ | ||
|
|
||
| SNMP | ||
| ---- | ||
|
|
||
| SNMP (Simple Network Management Protocol) retrieves information from a | ||
| device through a tree of object identifiers (OIDs) defined by management | ||
| information bases (MIBs). | ||
|
|
||
| The base SNMP backend contains the following methods (some internal | ||
| methods are not documented and are subject to change in the future): | ||
|
|
||
| ============ ============================================================= | ||
| **to_dict** Returns a dict containing monitoring information depending on | ||
| the type of the device. It follows the `NetJSON | ||
| Devicemonitoring | ||
| <https://netjson.org/rfc.html#name-devicemonitoring>`_ spec | ||
| **to_json** Calls the `to_dict` method and returns a JSON string of the | ||
| dict | ||
| **validate** Checks if connection with the device is working and raises | ||
| `NetEngineError` in case something is wrong | ||
| ============ ============================================================= | ||
|
|
||
| ``to_dict`` and ``to_json`` enable ``autowalk`` by default, collecting the | ||
| required OIDs before serializing the result. To serialize an existing SNMP | ||
| dump without querying the device, call ``to_dict(snmpdump=dump, | ||
| autowalk=False)``. | ||
|
|
||
| Initializing an SNMP backend class requires a host. The optional arguments | ||
| are: | ||
|
|
||
| ============= ========================================================== | ||
| **host** Management ip or hostname of the device | ||
| **community** Community string for the SNMP connection. Default value is | ||
| 'public' | ||
| **agent** Agent string for the SNMP connection. Default value is | ||
| 'my-agent' | ||
| **port** Port for the SNMP connection. Default value is `161` | ||
| ============= ========================================================== | ||
|
|
||
| The SNMP backend provides support for 2 firmwares: | ||
| - AirOS | ||
| - OpenWRT | ||
|
|
||
| .. note:: | ||
|
|
||
| The data collected by Netengine is dependant on the OIDs available on | ||
| your device. Some proprietary manufacturers may not provide the same | ||
| information as others. | ||
|
|
||
| AirOS | ||
| ===== | ||
|
|
||
| With AirOS, Netengine is able to collect the following information which | ||
| is returned in the `NetJSON Devicemonitoring | ||
| <https://netjson.org/rfc.html#name-devicemonitoring>`_ format: | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| - ``general``: uptime, local time, and hostname. | ||
| - ``hardware``: device model. | ||
| - ``operating_system``: name, description, and firmware version. | ||
| - ``resources``: CPU load, memory, and swap usage. | ||
| - ``interfaces``: name, MAC address, type, received bytes, and transmitted | ||
| bytes. | ||
|
|
||
| AirOS example | ||
| ------------- | ||
|
|
||
| :: | ||
|
|
||
| from netengine.backends.snmp import AirOS | ||
| device = AirOS("10.40.0.130") | ||
| device.name() | ||
| 'RM5PomeziaSNode' | ||
| device.uptime() | ||
| 104405 | ||
|
|
||
| We have just called two simple methods on **device**, but we can ask **device** for more specific values or portions of the SNMP tree not included in the API, just type:: | ||
| device.next("1.3.6") | ||
|
|
||
| Otherwise, if you want simply a value of the tree just type:: | ||
| device.get_value("oid_you_want_to_ask_for") | ||
|
|
||
| To collect the whole json:: | ||
| device.to_json() | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| OpenWRT | ||
| ======= | ||
|
|
||
| With OpenWRT, Netengine is able to collect the following information which | ||
| is returned in the `NetJSON Devicemonitoring | ||
| <https://netjson.org/rfc.html#name-devicemonitoring>`_ format: | ||
|
|
||
| - ``general``: uptime, local time, and hostname. | ||
| - ``resources``: CPU count, memory, and swap usage. | ||
| - ``interfaces``: name, type, MAC address, state, traffic counters, MTU, | ||
| and addresses. | ||
| - ``neighbors``: MAC address, state, interface, and IP address. | ||
|
|
||
| OpenWRT example | ||
| --------------- | ||
|
|
||
| The same instructions typed above can be applied to OpenWRT itself. Import | ||
| it with ``from netengine.backends.snmp import OpenWRT`` and use the same | ||
| methods described for AirOS. | ||
This file was deleted.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # NetJSON DeviceMonitoring schema, | ||
| # https://github.com/netjson/netjson/blob/master/schema/device-monitoring.json | ||
| schema = { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://raw.githubusercontent.com/netjson/netjson/master/schema/device-monitoring.json", | ||
| "title": "NetJSON Device Monitoring", | ||
| "description": "Monitoring information sent by a device.", | ||
| "type": "object", | ||
| "additionalProperties": True, | ||
| "required": ["type"], | ||
| "properties": { | ||
| "type": {"type": "string", "enum": ["DeviceMonitoring"]}, | ||
| "general": { | ||
| "type": "object", | ||
| "title": "General", | ||
| "additionalProperties": True, | ||
| "properties": { | ||
| "local_time": {"type": "integer"}, | ||
| "uptime": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "resources": { | ||
| "type": "object", | ||
| "title": "Resources", | ||
| "additionalProperties": True, | ||
| "properties": { | ||
| "load": { | ||
| "type": "array", | ||
| "minItems": 3, | ||
| "maxItems": 3, | ||
| "items": {"type": "number"}, | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| "memory": { | ||
| "id": "memory", | ||
| "type": "object", | ||
| "properties": { | ||
| "total": {"type": "integer"}, | ||
| "free": {"type": "integer"}, | ||
| "buffered": {"type": "integer"}, | ||
| "cache": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "swap": { | ||
| "type": "object", | ||
| "properties": { | ||
| "total": {"type": "integer"}, | ||
| "free": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "connections": { | ||
| "type": "object", | ||
| "properties": { | ||
| "ipv4": { | ||
| "type": "object", | ||
| "properties": { | ||
| "tcp": {"type": "integer"}, | ||
| "udp": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "ipv6": { | ||
| "type": "object", | ||
| "properties": { | ||
| "tcp": {"type": "integer"}, | ||
| "udp": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| "processes": { | ||
| "type": "object", | ||
| "properties": { | ||
| "running": {"type": "integer"}, | ||
| "sleeping": {"type": "integer"}, | ||
| "blocked": {"type": "integer"}, | ||
| "zombie": {"type": "integer"}, | ||
| "stopped": {"type": "integer"}, | ||
| "paging": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "cpu": { | ||
| "type": "object", | ||
| "properties": { | ||
| "frequency": {"type": "integer"}, | ||
| "user": {"type": "integer"}, | ||
| "system": {"type": "integer"}, | ||
| "nice": {"type": "integer"}, | ||
| "idle": {"type": "integer"}, | ||
| "iowait": {"type": "integer"}, | ||
| "irq": {"type": "integer"}, | ||
| "softirq": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "flash": { | ||
| "type": "object", | ||
| "properties": { | ||
| "total": {"type": "integer"}, | ||
| "free": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| "storage": { | ||
| "type": "object", | ||
| "properties": { | ||
| "total": {"type": "integer"}, | ||
| "free": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| "interfaces": { | ||
| "type": "array", | ||
| "title": "Interfaces", | ||
| "uniqueItems": True, | ||
| "additionalItems": True, | ||
| "items": { | ||
| "type": "object", | ||
| "title": "Interface", | ||
| "additionalProperties": True, | ||
| "required": ["name"], | ||
| "properties": { | ||
| "name": {"type": "string"}, | ||
| "uptime": {"type": "integer"}, | ||
| "statistics": { | ||
| "type": "object", | ||
| "properties": { | ||
| "collisions": {"type": "integer"}, | ||
| "rx_frame_errors": {"type": "integer"}, | ||
| "tx_compressed": {"type": "integer"}, | ||
| "multicast": {"type": "integer"}, | ||
| "rx_length_errors": {"type": "integer"}, | ||
| "tx_dropped": {"type": "integer"}, | ||
| "rx_bytes": {"type": "integer"}, | ||
| "rx_missed_errors": {"type": "integer"}, | ||
| "tx_errors": {"type": "integer"}, | ||
| "rx_compressed": {"type": "integer"}, | ||
| "rx_over_errors": {"type": "integer"}, | ||
| "tx_fifo_errors": {"type": "integer"}, | ||
| "rx_crc_errors": {"type": "integer"}, | ||
| "rx_packets": {"type": "integer"}, | ||
| "tx_heartbeat_errors": {"type": "integer"}, | ||
| "rx_dropped": {"type": "integer"}, | ||
| "tx_aborted_errors": {"type": "integer"}, | ||
| "tx_packets": {"type": "integer"}, | ||
| "rx_errors": {"type": "integer"}, | ||
| "tx_bytes": {"type": "integer"}, | ||
| "tx_window_errors": {"type": "integer"}, | ||
| "rx_fifo_errors": {"type": "integer"}, | ||
| "tx_carrier_errors": {"type": "integer"}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.