diff options
author | James Meyer <james.meyer@operamail.com> | 2013-02-19 21:10:18 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2013-02-19 21:10:18 (GMT) |
commit | 2648e999d277eac5c3d331a3609bcc73fafbea71 (patch) | |
tree | 40951fb8e7fdbe28a0baa324ae615055203f1e2e /abs/core/xymon/hbnotes.py | |
parent | c759b5e0c4aa6fc37412b4dee2cf9ad993fd376d (diff) | |
parent | 7e6f7ca174e1af67178dc5293a312a4a733eb095 (diff) | |
download | linhes_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/hbnotes.py')
-rw-r--r-- | abs/core/xymon/hbnotes.py | 486 |
1 files changed, 324 insertions, 162 deletions
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py index 2a1b221..be34dc6 100644 --- a/abs/core/xymon/hbnotes.py +++ b/abs/core/xymon/hbnotes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 # -*- coding: utf-8 -*- # import MySQL module @@ -7,52 +7,22 @@ import sys import getopt import socket import os -global ignorehostlist -try: - import ignoreclient - ignorehostlist=ignoreclient.ignorehosts -except: - print "could not find the ignore list" - ignorehostlist="'ignoreme'" +def create_dot_file(): + try: + import ignoreclient + ignorehostlist=ignoreclient.ignorehosts + except: + print "could not find the ignore list" + ignorehostlist="'ignoreme'" -def createdropdown(currenthostype): - dir = "/myth/system_backup" - dropdown=" " - #dropdown=''' - #<input name="param2" type="radio" value="Restore" />Restore database </> - #<select name="param1"> - #''' - #if os.path.exists(dir): - #files = os.listdir(dir) - #for file in os.listdir(dir): - #if (file.endswith(".tgz")): - #dropdown+='<option value="' + file + '">' + file + '</option> ' - dropdown+='</select> <br><input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br /> ' - dropdown+='<input name="param2" type="radio" value="Optimize" />Optimize database<br /> ' - if currenthostype == "Master_backend": - dropdown+='<input name="param2" type="radio" value="ShutdownAll" />Shutdown All Systems (expect MBE)<br /> ' - #dropdown+='''<input name="param2" type="radio" value="UpdateAll" />Update All Systems </> <select name="param5"> - #<option value="Myth_only">Myth only</option> - #<option value="All"> Full System</option> - #</select> - #</br> - #</br> - #</br>''' - dropdown+=''' </br></br>''' - return dropdown - -def main(argv): db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") - - # create a cursor cursor = db.cursor() -#------------------------------write client-config------------------------------------------------ SQL="SELECT DISTINCT(hostname) from settings where hostname not in(%s)" cursor.execute(SQL %ignorehostlist) result = cursor.fetchall() @@ -68,19 +38,20 @@ def main(argv): dotslavefe=list() tunerdict = {} for row in result: - #print row[0] - #Find the system type + hostname = row[0] + dot_hostname = row[0].replace('.','_') + #Find the system type cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType','HostRunFrontend');",(row)) hostvalues=cursor.fetchall() if len(hostvalues) == 2: if hostvalues[1][1] == 'Frontend_only': - frontonly+=","+row[0] - dotfrontend.append(row[0]) + frontonly+=","+dot_hostname + dotfrontend.append(dot_hostname) elif hostvalues[1][1] == 'Standalone': - stand_alone+=","+row[0] - dotMBE="MBE" + " [ label=\"" + row[0] + " \\n Standalone \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " - dotfrontend.append(row[0]) + stand_alone+=","+dot_hostname + dotMBE="MBE" + " [ label=\"" + dot_hostname + " \\n Standalone \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " + dotfrontend.append(dot_hostname) cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row)) tuners=cursor.fetchall() tstring="" @@ -97,12 +68,12 @@ def main(argv): elif hostvalues[1][1] == 'Master_backend': if hostvalues[0][1]=='0': - masterbackend+=","+row[0] - dotMBE="MBE" + " [ label=\"" + row[0] + " \\n Master Backend \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " + masterbackend+=","+dot_hostname + dotMBE="MBE" + " [ label=\"" + dot_hostname + " \\n Master Backend \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " else: - masterbacked_w_fe+=","+row[0] - dotMBE="MBE" + " [ label=\"" + row[0] + " \\n Master Backend with frontend \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " - dotfrontend.append(row[0]) + masterbacked_w_fe+=","+dot_hostname + dotMBE="MBE" + " [ label=\"" + dot_hostname + " \\n Master Backend with frontend \" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=blue4 style=filled ] " + dotfrontend.append(dot_hostname) cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row)) tuners=cursor.fetchall() tstring="" @@ -122,42 +93,42 @@ def main(argv): tuners=cursor.fetchall() #slave withoutfe if hostvalues[0][1]=='0': - slave+=","+row[0] - dotslave.append(row[0]) + slave+=","+dot_hostname + dotslave.append(dot_hostname) tstring="" if len(tuners) <= 0: - tunerdict["STUNER"+row[0]]="No Tuners" + tunerdict["STUNER"+dot_hostname]="No Tuners" else: for t in tuners: tstring+=t[0] tstring+=t[1] tstring+='\\n' - tunerdict["STUNER"+row[0]]=tstring + tunerdict["STUNER"+dot_hostname]=tstring else: #slave with fe tstring="" if len(tuners) <= 0: - tunerdict["STUNER"+row[0]]="No Tuners" + tunerdict["STUNER"+dot_hostname]="No Tuners" else: for t in tuners: tstring+=t[0] tstring+=t[1] tstring+='\\n' - tunerdict["STUNER"+row[0]]=tstring - slave_w_fe+=","+row[0] - dotslave.append(row[0]) - dotfrontend.append(row[0]) + tunerdict["STUNER"+dot_hostname]=tstring + slave_w_fe+=","+dot_hostname + dotslave.append(dot_hostname) + dotfrontend.append(dot_hostname) #----------------------------------Create graphviz dot files - dotfilename="/data/srv/xymon/server/etc/mythdot" + dotfilename="/home/xymon/server/etc/mythdot" dotfile=open(dotfilename,'w') dotfile.write("digraph G { " + "\n" ) dotfile.write("graph [bgcolor=transparent]" + "\n" ) #print tunerdict -#define the nodes + #define the nodes dotfile.write( dotMBE + " \n" ) dotfile.write("tunermbe"+ " [ label= \"" + tunerdict["MBE"] + "\" , shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/tuner.png\" fontcolor=\"white\" color=red ] \n" ) @@ -173,11 +144,7 @@ def main(argv): #adding slave to dot file dotfile.write("SLAVE"+fe + "[ label=\"slave backend \\n " + fe + "\" shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/be.png\" fontcolor=\"white\" color=green ] \n" ) - - - - -#connect up the nodes! + #connect up the nodes! dotfile.write("tunermbe -> MBE [color=\"red\"] \n " ) for fe in dotfrontend: @@ -200,91 +167,220 @@ def main(argv): results=os.popen(cmd,'r') - #-------------------------------------------------- - #hobbitfile="/data/srv/xymon/server/etc/hobbit-clients.cfg" - ###WHY WAS THIS HERE?? - #hobbitfile="/data/srv/xymon/server/etc/tasks.cfg" - #hobbitf=open(hobbitfile,'r') - #hobbitconfig=hobbitf.readlines() - #hobbitf.close() - #hobbitf=open(hobbitfile,'w') - #print "FE",frontonly - #print "MBE",masterbackend - #print "MBEwFW",masterbacked_w_fe - #print "SLAVEwFW",slave_w_fe - #print "SLAVE",slave - #print "STD",stand_alone - #for line in hobbitconfig: - #if line.startswith("HOST"): - #cline=line.split("=") - #if cline[1].startswith("_FRONTEND_"): - #pline="HOST=" - #pline+=frontonly.strip() - #hobbitf.write(pline + "\n") - #elif cline[1].startswith("_MASTERBACKEND_"): - #pline="HOST=" - #pline+=masterbackend.strip() - ##print pline - #hobbitf.write(pline+ "\n") - #elif cline[1].startswith("_MASTERFRONTEND_"): - #pline="HOST=" - #pline+=masterbacked_w_fe.strip() - ##print pline - #hobbitf.write(pline+ "\n") - #elif cline[1].startswith("_SLAVEBACKEND_"): - #pline="HOST=" - #pline+=slave.strip() - ##print pline - #hobbitf.write(pline+ "\n") - #elif cline[1].startswith("_SLAVEFE_"): - #pline="HOST=" - #pline+=slave_w_fe.strip() - ##print pline - #hobbitf.write(pline+ "\n") - #else: - ##print line - #hobbitf.write(line) - #else: - ##print line - #hobbitf.write(line) -#-----------------------------------------------------------END CLIENT CONFIG - # execute SQL statement +def createdropdown(currenthostype): + dir = "/data/storage/disk0/backup/system_backups" + dropdown=''' + </br> + <input name="param2" type="radio" value="Restore" />Restore database </> + <select name="param1">\n''' + os.chdir(dir) + if os.path.exists(dir): + files = os.listdir(dir) + files.sort(key=lambda x: os.path.getmtime(x) , reverse=True) + #for file in os.listdir(dir): + if len(files) > 20: + del files[20:] + + for file in files: + if (file.endswith(".tgz")): + dropdown+=' <option value="' + file + '">' + file + '</option> \n' + dropdown+=''' + </select> + </br>   + <input type="checkbox" name="param8" >Partial Restore<br> + + <br> + <input name="param2" type="radio" value="Upload" />Upload file to restore </> + <input name="uFile" type="file" size="40"> + + <br><br> + <input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br /> + ''' + + #This is for the d/l backup option + dropdown+=''' + + + <input name="param2" type="radio" value="Dbackup" />Download backup </> + <select name="param7">\n\n </br>''' + + for file in files: + if (file.endswith(".tgz")): + dropdown+=' <option value="' + file + '">' + file + '</option> \n' + + dropdown+=''' + </select> + + <br> + <input name="param2" type="radio" value="Optimize" />Optimize database<br /> + ''' + if currenthostype == "Master_backend": + dropdown+='<input name="param2" type="radio" value="ShutdownAll" />Shutdown All Systems (expect MBE)<br /> \n' + #dropdown+='''<input name="param2" type="radio" value="UpdateAll" />Update All Systems </> <select name="param5"> + #<option value="Myth_only">Myth only</option> + #<option value="All"> Full System</option> + #</select> + #</br> + #</br> + #</br>''' + + dropdown+=''' </br></br>\n''' + return dropdown + + +def create_notes(): + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() cursor.execute("SELECT DISTINCT(hostname) from settings") result = cursor.fetchall() - for row in result: - cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType','HostHwuuid');",(row)) + #cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType','HostHwuuid');",(row)) + cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType','HardwareProfilePublicUUID');",(row)) hostvalues=cursor.fetchall() + #This is here to ignore non LinHES hosts, or those that don't have a HostSystemType + if len(hostvalues) == 0: + continue found_uuid="false" - filename="/data/srv/xymon/server/www/notes/" + filename="/home/xymon/server/www/notes/" filename+=str(row[0]) filename+=(".html") file = open(filename,'w') string=''' - <html> - <head> - <style type="text/css">@import "/frame.css";</style> - </head> - ''' +<html> +<head> <style type="text/css">@import "/frame.css";</style> +<SCRIPT> + +function do_submission() +{ + document.form.submit(); +} + + +function Do_it () +{ + chosen = "" + len = document.form.param2.length + for (i = 0; i <len; i++) + { + if (document.form.param2[i].checked) + { + chosen = document.form.param2[i].value + } + } + + + if (chosen == "Restore") + { + if (confirm('Continue with database restore?')) + { + do_submission(); + } + else + { + alert(" database was not restored"); + } + } + else if (chosen == "Backup") + { + if (confirm('Continue with database backup?')) + { + do_submission(); + } + else + { + alert(" backup cancelled"); + } + } + else if (chosen == "Upload") + { + if (confirm('About to upload the backup file to server')) + { + alert("Uploading file to server"); + do_submission(); + } + } + else if (chosen == "Optimize") + { + if (confirm('Continue with database maintenance?')) + { + do_submission(); + } + else + { + alert("Optimization cancelled"); + } + } + + + + else if (chosen == "Shutdown") + { + if (confirm('Continue with server shutdown?')) + { + do_submission(); + alert("system is powering off"); + } + } + + else if (chosen == "Reboot") + { + if (confirm('Continue with server restart?')) + { + do_submission(); + alert("system is restarting"); + } + } + + else if (chosen == "ShutdownAll") + { + if (confirm('Continue with powering off all servers except master backend?')) + { + do_submission(); + alert("systems are powering off"); + } + + } + + else if (chosen == "Update") + { + if (confirm('Continue with applying updates?')) + { + do_submission(); + alert("system is updating"); + } + + } + + else + { + //alert("not restore") + do_submission(); + } +} + +</SCRIPT> +</head> + +''' file.write(string) - for i in range( 0 , len(hostvalues)): value=hostvalues[i][0] data=hostvalues[i][1] currenthostype='' currenthostname='' - if value == "HostHwuuid" : + #if value == "HostHwuuid" : + if value == "HardwareProfilePublicUUID" : if data != "blank" : found_uuid="true" uuid=data if value == "HostSystemType" : - currenthostname= str(row[0]).strip() currenthostype=str(data).strip() header="<h1>" + currenthostname + " (" + currenthostype + ") </h1>" @@ -292,53 +388,55 @@ def main(argv): if found_uuid == "true" : - string=str("http://smolt.mythvantage.com/client/show?uuid=") + string=str("http://smolt.mythtv.org/client/show?uuid=") string+=str(uuid) file.write("<A href=\"" ) file.write(string) file.write("\" >" + str(uuid) + "</A>") else: file.write( "uuid not found, please submit a hardware profile" ) - - - buttonform_top=''' - <div class="content" style="solid #aaa; width:500px; height:350px; overflow:auto; color:#FFF;text-align:left;"> - <form action="/process.py" method="get"> - ''' + <div id="resultbox" > + <form name="form" action="/process.py" enctype="multipart/form-data" method="POST" > + ''' buttonform_bottom=''' - <input name="param2" type="radio" value="Update" />Update System </> - <select name="param3"> - <option value="Myth_only">Myth only</option> - <option value="All"> Full System</option> - </select> - </br> - <input name="param2" type="radio" value="Kill" />Restart interface: </> - <select name="param6"> - <option value="killX">Full UI</option> - <option value="killmyth">MythFrontend</option> - </select> - </br> - <input name="param2" type="radio" value="Shutdown" />Shutdown System<br /> - <input name="param2" type="radio" value="Reboot" />Reboot System<br /> - <input name="param2" type="radio" value="WOL" />Wake on Lan<br /> - <input name="hiddenparam" type="hidden" value=" - ''' - oldurlform=''' - "/> - <input name="param4" type="hidden" value=" - ''' - - + <input name="param2" type="radio" value="Update" />Update System </> + <select name="param3"> + <option value="Myth_only">Myth only</option> + <option value="All"> Full System</option> + </select> + </br> + + <input name="param2" type="radio" value="Kill" />Restart interface: </> + <select name="param6"> + <option value="killX">Full UI</option> + <option value="killmyth">MythFrontend</option> + </select> + </br> + + <input name="param2" type="radio" value="Shutdown" />Shutdown System<br /> + <input name="param2" type="radio" value="Reboot" />Reboot System<br /> + <input name="param2" type="radio" value="WOL" />Wake on Lan<br /> + <input name="hiddenparam" type="hidden" value=" + ''' + + oldurlform=''' "/> + <input name="param4" type="hidden" value=" + ''' closetag=''' "/> - </br> - <input id="submitbutton" type="submit" /> - </form> - </div> - ''' + </br> + </div> + </br> + <div id="center_button" > + <!--<input id="submitbutton" type="submit" />--> + <a href="Javascript:Do_it();"> + <img src="/go.png"></a> + </form> + </div> +''' if currenthostype == "Master_backend" or currenthostype == "Standalone": mbeoptions=createdropdown(currenthostype) @@ -356,8 +454,72 @@ def main(argv): file.write(returnurl) file.write(closetag) - string=(' </html>') + string=('</html>') file.write(string) + +def main(argv): + create_dot_file() + create_notes() + + +#------------------------------write client-config------------------------------------------------ + + + #-------------------------------------------------- + #hobbitfile="/home/xymon/server/etc/hobbit-clients.cfg" + + ###WHY WAS THIS HERE?? + #hobbitfile="/home/xymon/server/etc/tasks.cfg" + #hobbitf=open(hobbitfile,'r') + #hobbitconfig=hobbitf.readlines() + #hobbitf.close() + #hobbitf=open(hobbitfile,'w') + #print "FE",frontonly + #print "MBE",masterbackend + #print "MBEwFW",masterbacked_w_fe + #print "SLAVEwFW",slave_w_fe + #print "SLAVE",slave + #print "STD",stand_alone + + #for line in hobbitconfig: + #if line.startswith("HOST"): + #cline=line.split("=") + #if cline[1].startswith("_FRONTEND_"): + #pline="HOST=" + #pline+=frontonly.strip() + #hobbitf.write(pline + "\n") + #elif cline[1].startswith("_MASTERBACKEND_"): + #pline="HOST=" + #pline+=masterbackend.strip() + ##print pline + #hobbitf.write(pline+ "\n") + #elif cline[1].startswith("_MASTERFRONTEND_"): + #pline="HOST=" + #pline+=masterbacked_w_fe.strip() + ##print pline + #hobbitf.write(pline+ "\n") + #elif cline[1].startswith("_SLAVEBACKEND_"): + #pline="HOST=" + #pline+=slave.strip() + ##print pline + #hobbitf.write(pline+ "\n") + #elif cline[1].startswith("_SLAVEFE_"): + #pline="HOST=" + #pline+=slave_w_fe.strip() + ##print pline + #hobbitf.write(pline+ "\n") + #else: + ##print line + #hobbitf.write(line) + #else: + ##print line + #hobbitf.write(line) + +#-----------------------------------------------------------END CLIENT CONFIG + + # execute SQL statement + + if __name__ == "__main__": main(sys.argv[1:]) |