summaryrefslogtreecommitdiffstats
path: root/abs/core
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-11-22 21:14:32 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-11-22 21:14:32 (GMT)
commit0ff96c29e39e71311438585d2334f3bc4277c6db (patch)
tree0ca5092862a19f0db5e3dd5001b41c81c0b0b599 /abs/core
parent1503b7e35c4b1b511010c8ebcba1110a37e28528 (diff)
parent74764ddb511bf2fc7e5b74eda7145a9cdd0497c0 (diff)
downloadlinhes_pkgbuild-0ff96c29e39e71311438585d2334f3bc4277c6db.zip
linhes_pkgbuild-0ff96c29e39e71311438585d2334f3bc4277c6db.tar.gz
linhes_pkgbuild-0ff96c29e39e71311438585d2334f3bc4277c6db.tar.bz2
Merge branch 'testing' of linhes.org:linhes_pkgbuild into testing
Diffstat (limited to 'abs/core')
-rwxr-xr-x[-rw-r--r--]abs/core/xymon/hobbit_myth_data.py80
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)