diff options
-rwxr-xr-x | abs/core/xymon/PKGBUILD | 4 | ||||
-rw-r--r-- | abs/core/xymon/hbnotes.py | 258 |
2 files changed, 138 insertions, 124 deletions
diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD index 4c0eaed..52aabf9 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=40 +pkgrel=41 pkgdesc="Hobbit is a system for monitoring servers and networks. " license="GPL" arch=('i686' 'x86_64') @@ -125,7 +125,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161' '2d88e59ab17114030da514ba3f0a5b64' 'ee608dcafc050d790e28647a670f6b60' 'b2f98ac0df013332deedc1efae0a270d' - 'efa1de1c917b58e00beadf3e386049b5' + 'a652448ebcae3f439c8f23369b69ecf2' '0f70e76a164f648f0a4a01110137cb20' 'f6921f0413215ae174e81306be80d37f' '54ba9d7bff5875150e511c608ffc1e6a' diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py index b4c39bf..158bcd8 100644 --- a/abs/core/xymon/hbnotes.py +++ b/abs/core/xymon/hbnotes.py @@ -7,61 +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 = "/data/storage/disk0/backup/system_backups" - dropdown=" " - dropdown=''' - <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 name="param2" type="radio" value="Backup" checked="checked" />Backup database<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 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() @@ -77,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="" @@ -106,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="" @@ -131,31 +93,31 @@ 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 @@ -166,7 +128,7 @@ def main(argv): 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" ) @@ -182,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: @@ -209,59 +167,51 @@ def main(argv): results=os.popen(cmd,'r') - #-------------------------------------------------- - #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 +def createdropdown(currenthostype): + dir = "/data/storage/disk0/backup/system_backups" + dropdown=" " + dropdown=''' + <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 name="param2" type="radio" value="Backup" checked="checked" />Backup database<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() @@ -448,5 +398,69 @@ function Do_it () 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:]) |