summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/hobbit_myth_data.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-12-07 19:45:02 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-12-07 19:45:02 (GMT)
commit582455878ef98dfadc0618309686c85b135f7a23 (patch)
treea87b677b96c168524576cf32870487758d0b43ba /abs/core/xymon/hobbit_myth_data.py
parent65b2738ba8a6b80a17c5a2953a29be935b15d18c (diff)
downloadlinhes_pkgbuild-582455878ef98dfadc0618309686c85b135f7a23.zip
linhes_pkgbuild-582455878ef98dfadc0618309686c85b135f7a23.tar.gz
linhes_pkgbuild-582455878ef98dfadc0618309686c85b135f7a23.tar.bz2
xymon: first build, includes both server and client builds.
xymon is a system used to monitor various things about each host. Possible to replace rrdtool and monitorx
Diffstat (limited to 'abs/core/xymon/hobbit_myth_data.py')
-rw-r--r--abs/core/xymon/hobbit_myth_data.py99
1 files changed, 99 insertions, 0 deletions
diff --git a/abs/core/xymon/hobbit_myth_data.py b/abs/core/xymon/hobbit_myth_data.py
new file mode 100644
index 0000000..840c293
--- /dev/null
+++ b/abs/core/xymon/hobbit_myth_data.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+# checks for the number of days of guide data left
+# make sure myth_mtc ran ok
+
+
+import urllib2
+import string
+import time
+import sys,os
+BBLINE = ''
+BBCOLOR="green"
+DATE = time.strftime("%a %b %d %H:%M:%S %Z %Y", time.localtime(time.time()))
+if os.environ['BB']:
+ #print os.environ['BB']
+ BB=os.environ['BB']
+if os.environ['BBDISP']:
+ #print os.environ['BBDISP']
+ BBDISP=os.environ['BBDISP']
+if os.environ['MACHINE']:
+ #print os.environ['MACHINE']
+ MACHINE=os.environ['MACHINE']
+
+
+
+
+def check_mtc():
+ try:
+ infile = open('/var/log/mythtv/myth_mtc.log', 'r')
+ except(IOError), e:
+ print "couldn't open myth_mtc.log file"
+ return False
+ else:
+ mtc = infile.readlines()
+ for i in mtc:
+ line=i
+ infile.close()
+ if line.strip() == "Finished":
+ return True
+ else:
+ return False
+
+def find_data_left():
+ try:
+ f = urllib2.urlopen("http://localhost:6544")
+ except:
+ print 'error: could not find Masterbackend'
+ days_left=-100
+ return days_left
+# except urllib2.HTTPError, e:
+# if e.code != 200:
+# print 'error: could not find Masterbackend'
+# days_left=-100
+ else:
+ MBE_data = f.readlines()
+ f.close()
+
+ for line in MBE_data:
+ if line.find("guide data") != -1:
+ if line.find("no guide data") != -1:
+ days_left = 0
+ else:
+ line=line.split("(")
+ line=line[1].split(")")
+ days_left=line[0].split()[0]
+ return days_left
+
+
+mtc=check_mtc()
+num_days=find_data_left()
+
+if mtc:
+ BBCOLOR="green"
+ msg="\n Maintenace script ran ok \n "
+else:
+ BBCOLOR ="yellow"
+ msg="\n Maintenance script didn't run \n"
+
+if num_days == 1 :
+ BBCOLOR="yellow"
+ msg+="Only 1 day of guide data left"
+elif num_days == 0 :
+ BBCOLOR="yellow"
+ msg+="No guide data available"
+elif num_days == -100 :
+ BBCOLOR="red"
+ msg+="Could not connect to master backend"
+else:
+ data_check = True
+ BBCOLOR="green"
+ msg+="%s days of guide data" %(num_days)
+
+BBLINE=msg
+LINE = "status " + MACHINE + ".myth_mtc" + " " + BBCOLOR + " " + DATE + " " + BBLINE
+cmd = BB + ' ' + BBDISP + ' "' + LINE + '"'
+os.system(cmd)
+
+sys.exit(0)
+
+