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

Log temperature from juniper devices #2364

Merged
merged 3 commits into from
Apr 1, 2022

Conversation

stveit
Copy link
Contributor

@stveit stveit commented Mar 21, 2022

Fixes #2342

Adds capacity for polling temperature data from Juniper devices.
Basically copies code for logging CPU data.

@github-actions
Copy link

github-actions bot commented Mar 21, 2022

Test results

     12 files       12 suites   12m 19s ⏱️
3 075 tests 2 979 ✔️   96 💤 0
8 700 runs  8 412 ✔️ 288 💤 0

Results for commit 6a7675f.

♻️ This comment has been updated with latest results.

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Although this implementation is fine: IMNSHO, temperature logging is better suited for the environment sensors framework of NAV, than it is for the "system" framework.

Sensors are registered as separate entitites in the NAV database, and they can also be associated with known sub-components of the device. Dashboard widgets exist to present temperature readings from sensors, etc.

Retrieving and storing operating contents of a Juniper device may still not be properly supported by NAV, since Juniper is one of very few vendors that do not have proper support for ENTITY-MIB, but we have issues on our roadmap to do something about it - and once we get there, it would be grand to attach these temperature "sensors" to the correct sub-components.

How to make a sensor implementation is described in https://nav.readthedocs.io/en/latest/hacking/adding-environment-probe-support.html - but it basically reduces your effort to implementing a get_all_sensors() method for the JuniperMib subclass.

@stveit stveit force-pushed the juniper-temperature branch 3 times, most recently from 2042cf6 to c4dab9f Compare March 25, 2022 11:37
@@ -77,7 +77,6 @@ def handle(self):
"Found %d sensors from %s", len(all_sensors), type(mib).__name__
)
self._store_sensors(all_sensors)
break
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was done so sensors are collected from all the MIBs listed in JUNIPER_NETWORKS_INC line in the config instead of stopping at the first one where it finds any sensors. This will impact all sensor MIBs, so I'm wondering 1) is there a reason why it should stop after finding sensors in one MIB? 2) If so, ideas for config that will allow only Juniper devices to collect sensors from multiple MIBs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Very good point. The juniper chassis error counts will also need to look into two different MIBs if we are to support all juniper equipment that has these counters.

Copy link
Member

Choose a reason for hiding this comment

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

  1. is there a reason why it should stop after finding sensors in one MIB?

I think the main reason is that some of the first devices this code was tested
on would report the same sensors in multiple MIBs (i.e. the sensors reported in
a proprietary MIB would also appear in ENTITY-SENSOR-MIB, and there is no
generic way of determining that these records represent the same thing).

  1. If so, ideas for config that will allow only Juniper devices to collect
    sensors from multiple MIBs?

Naw. I think the original idea is a bit defeatist. If a device wants to report
multiple versions of the same sensors, that's not our problem, that's the
vendor's problem (and a little bit, the user's: Now ipdevpoll will spend twice
the time collecting data from this device, and twice the storage space to
persist it - but hey, storage is cheap these days).

So, IMO: It's a good idea to remove the break statement!

Copy link
Member

Choose a reason for hiding this comment

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

@hmpf wrote:

Very good point. The juniper chassis error counts will also need to look into
two different MIBs if we are to support all juniper equipment that has these
counters.

The point is good, but I don't see how it related to the ongoing alert count
collection feature. It's unlikely this will touch the sensors framework at all
(unless you plan to also keep time series data of alert counts).

@codecov
Copy link

codecov bot commented Mar 25, 2022

Codecov Report

Merging #2364 (91069ba) into master (8c9c4cf) will decrease coverage by 0.01%.
The diff coverage is 32.00%.

❗ Current head 91069ba differs from pull request most recent head 6a7675f. Consider uploading reports for the commit 6a7675f to get more accurate results

@@            Coverage Diff             @@
##           master    #2364      +/-   ##
==========================================
- Coverage   52.56%   52.55%   -0.02%     
==========================================
  Files         552      552              
  Lines       40118    40130      +12     
==========================================
+ Hits        21089    21091       +2     
- Misses      19029    19039      +10     
Impacted Files Coverage Δ
python/nav/ipdevpoll/config.py 87.71% <ø> (ø)
python/nav/ipdevpoll/plugins/sensors.py 56.00% <ø> (+0.44%) ⬆️
python/nav/mibs/juniper_mib.py 40.81% <32.00%> (-1.72%) ⬇️
python/nav/util.py 75.64% <0.00%> (-1.09%) ⬇️
python/nav/ipdevpoll/plugins/statsystem.py 28.85% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c9c4cf...6a7675f. Read the comment docs.

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I haven't tested it, but found at least one nitpick :)

@@ -77,7 +77,6 @@ def handle(self):
"Found %d sensors from %s", len(all_sensors), type(mib).__name__
)
self._store_sensors(all_sensors)
break
Copy link
Member

Choose a reason for hiding this comment

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

  1. is there a reason why it should stop after finding sensors in one MIB?

I think the main reason is that some of the first devices this code was tested
on would report the same sensors in multiple MIBs (i.e. the sensors reported in
a proprietary MIB would also appear in ENTITY-SENSOR-MIB, and there is no
generic way of determining that these records represent the same thing).

  1. If so, ideas for config that will allow only Juniper devices to collect
    sensors from multiple MIBs?

Naw. I think the original idea is a bit defeatist. If a device wants to report
multiple versions of the same sensors, that's not our problem, that's the
vendor's problem (and a little bit, the user's: Now ipdevpoll will spend twice
the time collecting data from this device, and twice the storage space to
persist it - but hey, storage is cheap these days).

So, IMO: It's a good idea to remove the break statement!

@@ -77,7 +77,6 @@ def handle(self):
"Found %d sensors from %s", len(all_sensors), type(mib).__name__
)
self._store_sensors(all_sensors)
break
Copy link
Member

Choose a reason for hiding this comment

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

@hmpf wrote:

Very good point. The juniper chassis error counts will also need to look into
two different MIBs if we are to support all juniper equipment that has these
counters.

The point is good, but I don't see how it related to the ongoing alert count
collection feature. It's unlikely this will touch the sensors framework at all
(unless you plan to also keep time series data of alert counts).

'description': descr,
'name': descr,
'internal_name': internal_name,
'mib': 'SPAGENT-MIB',
Copy link
Member

Choose a reason for hiding this comment

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

The MIB is definitely not SPAGENT-MIB in this case :-)

Suggested change
'mib': 'SPAGENT-MIB',
'mib': self.get_module_name(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed 🙏

@lunkwill42
Copy link
Member

I haven't tested it, but found at least one nitpick :)

I have tested now, and it seems to work beautifully 👍

@hmpf hmpf self-requested a review March 30, 2022 05:37
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Lovely. Might want to squash some of those last commits, but this works 👍

@stveit stveit force-pushed the juniper-temperature branch from 91069ba to 9a08b33 Compare April 1, 2022 13:25
stveit added 3 commits April 1, 2022 15:27
Previously the code would stop after finding sensors from one of the
Mibs gotten from self.mibfactory().
Now it goes through all the mibs and stores sensors from all of them

This makes it possible to get JuniperDomMib sensors and JuniperMib temperature data
but does it break other stuff?
@stveit stveit force-pushed the juniper-temperature branch from 9a08b33 to 6a7675f Compare April 1, 2022 13:27
@stveit stveit merged commit 7363b53 into Uninett:master Apr 1, 2022
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

Temperatures should be logged from Juniper devices
3 participants