root / plugins / weather / weather_press_ @ 417bebc3
Historique | Voir | Annoter | Télécharger (1,2 ko)
| 1 |
#!/usr/bin/env python |
|---|---|
| 2 |
""" |
| 3 |
munin US NOAA weather plugin (http://tgftp.nws.noaa.gov) |
| 4 |
|
| 5 |
Draws pressure in hPa. |
| 6 |
Copy/link file as 'weather_pressure_CODE', like: weather_pressure_LOWW for Austria, Vienna. |
| 7 |
|
| 8 |
Get the code by going to http://tgftp.nws.noaa.gov, selecting your |
| 9 |
location, and copying the code from the address bar of your browser; should |
| 10 |
be something like CODE.html. |
| 11 |
|
| 12 |
Linux users might need to adjust the shebang. |
| 13 |
""" |
| 14 |
|
| 15 |
import sys |
| 16 |
import urllib |
| 17 |
import re |
| 18 |
|
| 19 |
url = 'http://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT' |
| 20 |
|
| 21 |
re_hpa = re.compile('Pressure.*\((\d+) hPa\)')
|
| 22 |
|
| 23 |
|
| 24 |
code = sys.argv[0][(sys.argv[0].rfind('_')+1):]
|
| 25 |
if not code: |
| 26 |
sys.exit(1) |
| 27 |
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf": |
| 28 |
print("yes")
|
| 29 |
elif len(sys.argv) == 2 and sys.argv[1] == "config": |
| 30 |
print('graph_title Atmospheric pressure at code %s' % code)
|
| 31 |
print('graph_vlabel Pressure in hPa')
|
| 32 |
print('graph_category sensors')
|
| 33 |
|
| 34 |
print('pressure.label Pressure')
|
| 35 |
print('pressure.type GAUGE')
|
| 36 |
print('graph_args --base 1000 -l 850 -u 1050 --rigid')
|
| 37 |
print('graph_scale no')
|
| 38 |
else: |
| 39 |
u = urllib.urlopen(url % code) |
| 40 |
txt = u.read() |
| 41 |
u.close() |
| 42 |
|
| 43 |
hpa = re_hpa.findall(txt)[0] |
| 44 |
print('pressure.value %s' % hpa)
|
