mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
Initial version
This commit is contained in:
parent
efc099b260
commit
7e6774a09c
1 changed files with 50 additions and 0 deletions
50
plugins/other/weather_press_
Executable file
50
plugins/other/weather_press_
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/local/bin/python
|
||||
"""
|
||||
munin US NOAA weather plugin (http://weather.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://weather.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
|
||||
import urllib
|
||||
import re
|
||||
|
||||
url = 'http://weather.noaa.gov/pub/data/observations/metar/decoded/%s.TXT'
|
||||
|
||||
re_hPa = re.compile('Pressure.*\((\d+) hPa\)')
|
||||
|
||||
|
||||
code = sys.argv[0][(sys.argv[0].rfind('_')+1):]
|
||||
if code == None: sys.exit(1)
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||
|
||||
print "yes"
|
||||
|
||||
elif len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||
|
||||
print 'graph_title Atmospheric pressure at code %s' % code
|
||||
print 'graph_vlabel Pressure in hPa'
|
||||
print 'graph_category Weather'
|
||||
|
||||
print 'pressure.label Pressure'
|
||||
print 'pressure.type GAUGE'
|
||||
print 'graph_args --base 1000 -l 850 -u 1050 --rigid'
|
||||
print 'graph_scale no'
|
||||
|
||||
else:
|
||||
|
||||
u = urllib.urlopen(url % code)
|
||||
txt = u.read()
|
||||
u.close()
|
||||
|
||||
hPa = re_hPa.findall(txt)[0]
|
||||
|
||||
print 'pressure.value %s' % hPa
|
Loading…
Add table
Add a link
Reference in a new issue