diff options
author | James Meyer <james.meyer@operamail.com> | 2013-11-22 19:42:36 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2013-11-22 19:42:36 (GMT) |
commit | 74764ddb511bf2fc7e5b74eda7145a9cdd0497c0 (patch) | |
tree | 08fe4be7e03cb78c5630893ea85af252e3043fa7 | |
parent | 897051449a9bd6636e1d247152ce37760a7b1497 (diff) | |
download | linhes_pkgbuild-74764ddb511bf2fc7e5b74eda7145a9cdd0497c0.zip linhes_pkgbuild-74764ddb511bf2fc7e5b74eda7145a9cdd0497c0.tar.gz linhes_pkgbuild-74764ddb511bf2fc7e5b74eda7145a9cdd0497c0.tar.bz2 |
xymon: fix hobbit_myth_data.py so that higher alerts do not get overwritten by lower level alerts during the various tests.
-rwxr-xr-x[-rw-r--r--] | abs/core/xymon/hobbit_myth_data.py | 80 |
1 files changed, 63 insertions, 17 deletions
diff --git a/abs/core/xymon/hobbit_myth_data.py b/abs/core/xymon/hobbit_myth_data.py index 8b38fc6..52d6a6b 100644..100755 --- a/abs/core/xymon/hobbit_myth_data.py +++ b/abs/core/xymon/hobbit_myth_data.py @@ -10,6 +10,12 @@ import sys,os from MythTV import MythBE,MythDB,MythLog +#0=green +#1=yellow +#2=red + + + BBLINE = '' BBCOLOR="green" DATE = time.strftime("%a %b %d %H:%M:%S %Z %Y", time.localtime(time.time())) @@ -25,6 +31,30 @@ if os.environ['MACHINE']: #print os.environ['MACHINE'] MACHINE=os.environ['MACHINE'] +#MACHINE='a' +#BB='b' +#BBDISP='12' + + +def set_color_code (current_color, new_color): + if new_color > current_color: + color = new_color + else: + color = current_color + return color + +def set_color(color_code): + color = "unknown" + if color_code == 0 : + color = "green" + elif color_code == 1 : + color = "yellow" + elif color_code == 2 : + color = "red" + + return color + + @@ -60,7 +90,7 @@ def find_data_left(): results=cursor.fetchall()[0][0] days_left = (results - today).days except: - days_left = "Undetermined " + days_left = "Undetermined" return days_left @@ -72,44 +102,60 @@ mtc=check_mtc(mtc_file) num_days=find_data_left() - +current_color=0 if mtc: - BBCOLOR="green" - msg="\n Maintenance script ran ok \n %s \n " %mtc_file + current_color = set_color_code(current_color,0) + msg="\n Maintenance script was successful \n Log file: %s\n " %mtc_file else: - BBCOLOR ="yellow" - msg="\n * Maintenance script didn't run. \n %s \n" %mtc_file + current_color = set_color_code(current_color,2) + msg=''' + ** Maintenance script did not run. ** + BACKUP FILE WAS NOT CREATED + + The system may have been busy + Log file: %s \n''' %mtc_file if num_days == 1 : - BBCOLOR="yellow" - msg+="\n * Only 1 day of guide data left" + current_color = set_color_code(current_color,1) + msg+="\n ** Only 1 day of guide data left **" elif num_days == 0 : - BBCOLOR="red " - msg+="\n * No guide data available" + current_color = set_color_code(current_color,2) + msg+="\n ** No guide data available **" elif num_days == -100 : - BBCOLOR="red" - msg+="\n ** Could not connect to database!" + current_color = set_color_code(current_color,2) + msg+="\n ** Could not connect to database ** " + +elif num_days == "Undetermined" : + current_color = set_color_code(current_color,1) + msg+="\n ** Could not determine how many days of guide data are available ** " + else: data_check = True - BBCOLOR="green" + current_color = set_color_code(current_color,0) msg+="\n %s days of guide data" %(num_days) if os.path.isfile("/data/storage/disk0/backup/system_backups/remote_backup_failed.txt"): - if BBCOLOR == "green": - BBCOLOR="yellow" - msg+="\n\n * Remote backup jobs are queued" + current_color = set_color_code(current_color,1) + msg+="\n\n ** Remote backup jobs are queued **" else: msg+="\n\n No remote backup jobs queued" -BBLINE=msg +BBLINE = msg +BBCOLOR = set_color(current_color) + LINE = "status " + MACHINE + ".myth_mtc" + " " + BBCOLOR + " " + DATE + " " + BBLINE cmd = BB + ' ' + BBDISP + ' "' + LINE + '"' os.system(cmd) +#print cmd +#print BBLINE +#print BBCOLOR + + sys.exit(0) |