summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/hobbit_myth_data.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2013-02-19 21:10:18 (GMT)
committerJames Meyer <james.meyer@operamail.com>2013-02-19 21:10:18 (GMT)
commit2648e999d277eac5c3d331a3609bcc73fafbea71 (patch)
tree40951fb8e7fdbe28a0baa324ae615055203f1e2e /abs/core/xymon/hobbit_myth_data.py
parentc759b5e0c4aa6fc37412b4dee2cf9ad993fd376d (diff)
parent7e6f7ca174e1af67178dc5293a312a4a733eb095 (diff)
downloadlinhes_pkgbuild-2648e999d277eac5c3d331a3609bcc73fafbea71.zip
linhes_pkgbuild-2648e999d277eac5c3d331a3609bcc73fafbea71.tar.gz
linhes_pkgbuild-2648e999d277eac5c3d331a3609bcc73fafbea71.tar.bz2
Merge branch 'testing'
# By James Meyer (1091) and others # Via James Meyer (5) and others * testing: (1148 commits) LinHES-config: during install don't kill off lirc. This keeps the remote active all the way to the finish Change version numbers to 8.0 to match the release number. LinHES-conifg LinHES-system mythdb-initial runit-scripts supplemental-web LinHES-conifig: mv_install.py for the last partition don't go all the way to the end. Gotta leave room for gpt tables. xf86-video-ati: xorg ati driver. LinHES-config: timezip.py add syncing up of parental lvl passwords and starting level with MBE. LinHES-system: correct the logic for breaking out of the wmctrl loop. As written it would break out of the inner loop..but not the 60 iteration loop. e16_theme_settings: remove slide-in prop for new windows. For whatever reason this was preventing mplayer from being positioned correctly for appletrailers. LinHES-config, mythinstall: change case of hd_pvr and serial to all lower refs #902 zilog-firmware: firmware for TX support of the hdpvr and pvr-150 In general I can't recommend anybody using these transmitters but including the firmware just in case someone really wants to linhes-udev-rules: added hdprv_lirc rule. All of these lirc rules are limited to exactly one device. If more then one device is present then only the last device in init will get the symlink runit-scripts: fix logging for igdeamon, add support to remote init script so that the blaster is always the first device in the chain. added support specificly for hd_pvr LinHES-system: add lh_system_restore and lh_system_backup. These scripts are called from the mythmenu. refs #900 iguanair: rebuild with python 2.7 LinHES-system: msg_daemon.py fix init and nasty bug related to timeout. In a nutshell timeout wouldn't work unless a msg without a timeout was called first. linhes-udev-rules: add rules for mce,streamzap,serial lirc devices. mythinstall: recompile for matching libs mythtv: latest .25-fixes and change mythbackup/restore call lh_system_$op to replace mythbackup/mythrestore. mythbackup no longer works correctly with the new windowmanager linhes-scripts: myth2mp3, myth2x264, myth2xvid: use mythutil to get cutlist LinHES-config, supplimental-web: Fix proxy numbering for Ceton infiniTV linhes-system: add additional stuff to the system backup and also introduced an exclude file. The exclude/include files are locate in /home/mythtv/backup_config/ ...
Diffstat (limited to 'abs/core/xymon/hobbit_myth_data.py')
-rw-r--r--abs/core/xymon/hobbit_myth_data.py109
1 files changed, 63 insertions, 46 deletions
diff --git a/abs/core/xymon/hobbit_myth_data.py b/abs/core/xymon/hobbit_myth_data.py
index 1acca67..8b38fc6 100644
--- a/abs/core/xymon/hobbit_myth_data.py
+++ b/abs/core/xymon/hobbit_myth_data.py
@@ -1,15 +1,20 @@
-#!/usr/bin/python
+#!/usr/bin/python2
# checks for the number of days of guide data left
# make sure myth_mtc ran ok
import urllib2
import string
-import time
+import time , datetime
import sys,os
+from MythTV import MythBE,MythDB,MythLog
+
+
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']
@@ -17,77 +22,89 @@ if os.environ['BBDISP']:
#print os.environ['BBDISP']
BBDISP=os.environ['BBDISP']
if os.environ['MACHINE']:
- #print os.environ['MACHINE']
- MACHINE=os.environ['MACHINE']
+ #print os.environ['MACHINE']
+ MACHINE=os.environ['MACHINE']
-def check_mtc():
+def check_mtc(mtc_file):
try:
- infile = open('/var/log/mythtv/myth_mtc.log', 'r')
+ infile = open(mtc_file, 'r')
except(IOError), e:
- print "couldn't open myth_mtc.log file"
+ print "couldn't open %s file" %mtc_file
return False
else:
mtc = infile.readlines()
- for i in mtc:
- line=i
infile.close()
- if line.split()[0] == "Finished":
- return True
- else:
- return False
+ for i in mtc:
+ line=i
+ if line.split()[0] == "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()
+ days_left = 0
+ today = datetime.datetime.today()
+ try:
+ be=MythBE()
+ db = MythDB()
+ cursor = db.cursor()
+ except:
+ days_left = -100
+ return days_left
+ try:
+ cmd="select max(starttime) from program ;"
+ cursor.execute(cmd)
+ results=cursor.fetchall()[0][0]
+ days_left = (results - today).days
+ except:
+ days_left = "Undetermined "
+ return days_left
+
+
+now = datetime.datetime.now()
+date = "%s-%s-%s" %(now.year, now.month, now.day)
+mtc_file = "/var/log/%s/myth_mtc.log" %date
+
+mtc=check_mtc(mtc_file)
num_days=find_data_left()
+
+
+
if mtc:
BBCOLOR="green"
- msg="\n Maintenace script ran ok \n "
+ msg="\n Maintenance script ran ok \n %s \n " %mtc_file
else:
BBCOLOR ="yellow"
- msg="\n Maintenance script didn't run \n"
+ msg="\n * Maintenance script didn't run. \n %s \n" %mtc_file
if num_days == 1 :
BBCOLOR="yellow"
- msg+="Only 1 day of guide data left"
+ msg+="\n * Only 1 day of guide data left"
elif num_days == 0 :
- BBCOLOR="yellow"
- msg+="No guide data available"
+ BBCOLOR="red "
+ msg+="\n * No guide data available"
+
elif num_days == -100 :
BBCOLOR="red"
- msg+="Could not connect to master backend"
+ msg+="\n ** Could not connect to database!"
else:
data_check = True
BBCOLOR="green"
- msg+="%s days of guide data" %(num_days)
+ 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"
+else:
+ msg+="\n\n No remote backup jobs queued"
+
+
+
BBLINE=msg
LINE = "status " + MACHINE + ".myth_mtc" + " " + BBCOLOR + " " + DATE + " " + BBLINE