munin-monitoring / contrib

Contributed stuff for munin (plugins, tools, etc...)
http://munin-monitoring.org
1.05k stars 684 forks source link

[weather_press/temp/hum_]: Bugfixes in noaa based plugins and add humidity #1381

Closed HaseHarald closed 1 year ago

HaseHarald commented 1 year ago

This fixes a few bugs in the noaa.gov based weather plugins and adds a new one for humidity.

There was an issue with the read function of urllib returning an object, which got handled as a string afterwards. This caused issues:

Traceback (most recent call last):
  File "/tmp/weather/./weather_press_LOWW", line 43, in <module>
    hpa = re_hpa.findall(txt)[0]
TypeError: cannot use a string pattern on a bytes-like object

While implicit string casting might work, it's better to do so explicitly. This avoids said bug.

There was another bug in the temperature plugin, that didn't occur every time. It caused the temperature be set to the same value as the dew point. Turned out that, for some reasons, linebreaks were handled differently from time to time. Improving the RegEx to be more specific helped with that.

While at it, I changed the URL to include TLS connections. It's 2023 and https should really be the norm, rather than be the exception.

There's also a new plugin weather_hum_ that monitors the humidity. It is basically a copy&paste from the other two plugins and works quite the same way. While working on the other plugins, I just saw the opportunity for scoring an additional metric without much work.

Changes: