diff options
Diffstat (limited to 'abs')
-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) |