Merge pull request #1381 from HaseHarald/fix_weather-noaa-plugins_cast-to-string
[weather_press/temp/hum_]: Bugfixes in noaa based plugins and add humidity
This commit is contained in:
commit
b1c1d2bce2
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
munin US NOAA weather plugin (http://tgftp.nws.noaa.gov)
|
||||
|
||||
Draws relative humidity in %.
|
||||
Copy/link file as 'weather_humidity_CODE', like: weather_humidity_LOWW for Austria, Vienna.
|
||||
|
||||
Get the code by going to http://tgftp.nws.noaa.gov, selecting your
|
||||
location, and copying the code from the address bar of your browser; should
|
||||
be something like CODE.html.
|
||||
|
||||
Linux users might need to adjust the shebang.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from urllib.request import urlopen
|
||||
import re
|
||||
|
||||
url = 'https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT'
|
||||
|
||||
re_hum = re.compile(r'Relative Humidity:\s*(\d+)%')
|
||||
|
||||
|
||||
code = sys.argv[0][(sys.argv[0].rfind('_') + 1):]
|
||||
if not code:
|
||||
sys.exit(1)
|
||||
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||
print("yes")
|
||||
elif len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||
print('graph_title Relative humidity at code %s' % code)
|
||||
print('graph_vlabel humidity in %')
|
||||
print('graph_category sensors')
|
||||
|
||||
print('humidity.label Humidity')
|
||||
print('graph_args --base 1000 -l 0')
|
||||
else:
|
||||
u = urlopen(url % code)
|
||||
txt = str(u.read())
|
||||
u.close()
|
||||
|
||||
hum = re_hum.findall(txt)[0]
|
||||
print('humidity.value %s' % hum)
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
munin US NOAA weather plugin (http://tgftp.nws.noaa.gov)
|
||||
munin US NOAA weather plugin (https://tgftp.nws.noaa.gov)
|
||||
|
||||
Draws pressure in hPa.
|
||||
Copy/link file as 'weather_pressure_CODE', like: weather_pressure_LOWW for Austria, Vienna.
|
||||
|
||||
Get the code by going to http://tgftp.nws.noaa.gov, selecting your
|
||||
Get the code by going to https://tgftp.nws.noaa.gov, selecting your
|
||||
location, and copying the code from the address bar of your browser; should
|
||||
be something like CODE.html.
|
||||
|
||||
|
@ -16,7 +16,7 @@ import sys
|
|||
from urllib.request import urlopen
|
||||
import re
|
||||
|
||||
url = 'http://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT'
|
||||
url = 'https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT'
|
||||
|
||||
re_hpa = re.compile(r'Pressure.*\((\d+) hPa\)')
|
||||
|
||||
|
@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config":
|
|||
print('graph_scale no')
|
||||
else:
|
||||
u = urlopen(url % code)
|
||||
txt = u.read()
|
||||
txt = str(u.read())
|
||||
u.close()
|
||||
|
||||
hpa = re_hpa.findall(txt)[0]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
munin US NOAA weather plugin (http://tgftp.nws.noaa.gov)
|
||||
munin US NOAA weather plugin (https://tgftp.nws.noaa.gov)
|
||||
|
||||
Draws temperature/dew point in C.
|
||||
Copy/link file as 'weather_temp_CODE', like: weather_temp_LOWW for Austria, Vienna.
|
||||
|
||||
Get the code by going to http://tgftp.nws.noaa.gov, selecting your
|
||||
Get the code by going to https://tgftp.nws.noaa.gov, selecting your
|
||||
location, and copying the code from the address bar of your browser; should
|
||||
be something like CODE.html.
|
||||
|
||||
|
@ -16,10 +16,10 @@ import sys
|
|||
from urllib.request import urlopen
|
||||
import re
|
||||
|
||||
url = 'http://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT'
|
||||
url = 'https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT'
|
||||
|
||||
re_C = re.compile(r'Temperature:.*\((-?\d+\.?\d?) C\)')
|
||||
re_DewC = re.compile(r'Dew.*\((-?\d+\.?\d?) C\)')
|
||||
re_C = re.compile(r'Temperature:\s*[0-9]*\s*[F]*\s*\((-?\d+\.?\d?) C\)')
|
||||
re_DewC = re.compile(r'Dew.*:\s*[0-9]*\s*[F]*\s*\((-?\d+\.?\d?) C\)')
|
||||
|
||||
code = sys.argv[0][(sys.argv[0].rfind('_') + 1):]
|
||||
|
||||
|
@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config":
|
|||
print('graph_args --base 1000 -l 0')
|
||||
else:
|
||||
u = urlopen(url % code)
|
||||
txt = u.read()
|
||||
txt = str(u.read())
|
||||
u.close()
|
||||
|
||||
C = re_C.findall(txt)[0]
|
||||
|
|
Loading…
Reference in New Issue