From 1054c80fbd9a4b1d13b92613832e33e3285c0c5b Mon Sep 17 00:00:00 2001 From: twilliam Date: Mon, 27 Sep 2010 09:55:59 +0200 Subject: [PATCH] Patched with Olaf Kolkman advice. Can now be referenced from global Munin configuration. --- plugins/other/weather_ | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/other/weather_ b/plugins/other/weather_ index 7671f157..d91580b7 100755 --- a/plugins/other/weather_ +++ b/plugins/other/weather_ @@ -1,5 +1,6 @@ #!/usr/bin/python +import os import re import sys import urllib @@ -10,7 +11,8 @@ re_tmp = re.compile('realTemp: "(\d+)"') re_hum = re.compile('relativeHumidity: "(\d+)"') re_loc = re.compile('locName: "([\w ]+)"') -code = sys.argv[0][(sys.argv[0].rfind('_') + 1):] +#code = sys.argv[0][(sys.argv[0].rfind('_') + 1):] +code = os.environ.get('code', sys.argv[0][(sys.argv[0].rfind('_') + 1):]) if code == None: sys.exit(1) @@ -47,13 +49,13 @@ else: if len(HUM_list): HUM = HUM_list[0] else: - HUM = 0 + sys.exit(1) if len(TMP_F_list): TMP_F = TMP_F_list[0] TMP_C = (int(TMP_F) - 32) * 5/9 else: - TMP_C = 0 + sys.exit(1) print 'temperature.value %s' % TMP_C print 'humidity.value %s' % HUM