diff options
author | James Meyer <james.meyer@operamail.com> | 2012-10-12 20:26:25 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-10-12 20:26:25 (GMT) |
commit | b6fb3906faee03056e4615f070251b8efc5097d9 (patch) | |
tree | 6a2ceb27950bd2b2184d628ff8e3680ab0dbffd0 /abs/core | |
parent | c56daf6743af30b38558199b9a45fdcd3c78e254 (diff) | |
download | linhes_pkgbuild-b6fb3906faee03056e4615f070251b8efc5097d9.zip linhes_pkgbuild-b6fb3906faee03056e4615f070251b8efc5097d9.tar.gz linhes_pkgbuild-b6fb3906faee03056e4615f070251b8efc5097d9.tar.bz2 |
xymon: Change the way mtc check is done. Now program guide check is pulled from the BE instead of the local webpage.
Also move mtc log check to match /var/log/$DATE/myth_mtc.log
Diffstat (limited to 'abs/core')
-rwxr-xr-x | abs/core/xymon/PKGBUILD | 9 | ||||
-rw-r--r-- | abs/core/xymon/hobbit_myth_data.py | 94 | ||||
-rw-r--r-- | abs/core/xymon/xymon.install | 2 |
3 files changed, 57 insertions, 48 deletions
diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD index 91f1256..4c0eaed 100755 --- a/abs/core/xymon/PKGBUILD +++ b/abs/core/xymon/PKGBUILD @@ -1,7 +1,7 @@ pkgbase=xymon pkgname=(xymonserver xymonclient) pkgver=4.3.5 -pkgrel=39 +pkgrel=40 pkgdesc="Hobbit is a system for monitoring servers and networks. " license="GPL" arch=('i686' 'x86_64') @@ -45,6 +45,7 @@ build() { ./configure make PKGBUILD=1|| return 1 + } package_xymonserver(){ @@ -72,6 +73,10 @@ package_xymonserver(){ install -D -m644 $startdir/src/logrotate-server.xymon $startdir/pkg/xymonserver/etc/logrotate.d/xymon-server +# fix env for mythtb bindingds + echo "MYTHCONFDIR=/usr/share/mythtv" >> $startdir/pkg/xymonserver/home/xymon/etc/xymonserver.cfg + + #copy in replacment icon set DOCDIR=$startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon cp -rp $DOCDIR/gifs $DOCDIR/gifs.orig @@ -130,7 +135,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161' '0757294eec13771f8e63da23cf066796' '622f400fd098cbc43c203e3210a6694e' '84442377c6e914b65519076bda4e17a4' - '388dbe22d97198af0cd0bf1d18e96ce5' + 'cd6e52b17f8582614bb52a8157d486c6' '67621b6c5a766ac03c5f407bdbdca810' '7ad4871af35f82c7824bb682b9325dba' '98e9242ae346f729b14cb195786571f2' diff --git a/abs/core/xymon/hobbit_myth_data.py b/abs/core/xymon/hobbit_myth_data.py index 62a6a49..e870754 100644 --- a/abs/core/xymon/hobbit_myth_data.py +++ b/abs/core/xymon/hobbit_myth_data.py @@ -5,11 +5,16 @@ 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,76 @@ 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+="\nOnly 1 day of guide data left" elif num_days == 0 : - BBCOLOR="yellow" - msg+="No guide data available" + BBCOLOR="red " + msg+="\nNo guide data available" + elif num_days == -100 : BBCOLOR="red" - msg+="Could not connect to master backend" + msg+="\nCould 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) BBLINE=msg LINE = "status " + MACHINE + ".myth_mtc" + " " + BBCOLOR + " " + DATE + " " + BBLINE diff --git a/abs/core/xymon/xymon.install b/abs/core/xymon/xymon.install index 36bbbaa..3c9680b 100644 --- a/abs/core/xymon/xymon.install +++ b/abs/core/xymon/xymon.install @@ -15,7 +15,7 @@ post_install() { sed -i -e "s/localhost/$hostname/" /home/xymon/server/etc/hosts.cfg - #sed -i -e "s/\#/\# func/" /home/xymon/server/etc/hosts.cfg + sed -i -e "s/\# bbd/\# bbd func/" /home/xymon/server/etc/hosts.cfg sed -i -e "s/localhost/$hostname/" /home/xymon/server/etc/xymonserver.cfg chown -R nobody /home/xymon chown -R nobody /data/srv/httpd/htdocs/xymon |