summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/hbnotes.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-12-12 15:16:37 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-12-12 15:16:37 (GMT)
commit9f71a641425ac0a8b93d36a09be94c789bb1ec9e (patch)
tree5ebd9207ecca0f0e121ae6a166719a1d45b54d72 /abs/core/xymon/hbnotes.py
parent8b05bc1e3fe1b0d6de459a5972d8828e4a579204 (diff)
downloadlinhes_pkgbuild-9f71a641425ac0a8b93d36a09be94c789bb1ec9e.zip
linhes_pkgbuild-9f71a641425ac0a8b93d36a09be94c789bb1ec9e.tar.gz
linhes_pkgbuild-9f71a641425ac0a8b93d36a09be94c789bb1ec9e.tar.bz2
xymon: add led theme
logrotate: send hup after rotate hbfunc: general rewrite hbnotes: better output formatting for the dot file, fix slave tuners in the dot file
Diffstat (limited to 'abs/core/xymon/hbnotes.py')
-rw-r--r--abs/core/xymon/hbnotes.py172
1 files changed, 91 insertions, 81 deletions
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py
index e08992c..13dbd86 100644
--- a/abs/core/xymon/hbnotes.py
+++ b/abs/core/xymon/hbnotes.py
@@ -50,6 +50,7 @@ def main(argv):
# create a cursor
cursor = db.cursor()
+
#------------------------------write client-config------------------------------------------------
SQL="SELECT DISTINCT(hostname) from settings where hostname not in(%s)"
cursor.execute(SQL %ignorehostlist)
@@ -65,9 +66,8 @@ def main(argv):
dotslave=list()
dotslavefe=list()
tunerdict = {}
- currenthostype=''
for row in result:
- # print row[0]
+ #print row[0]
#Find the system type
cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType','HostRunFrontend');",(row))
hostvalues=cursor.fetchall()
@@ -94,64 +94,67 @@ def main(argv):
tunerdict["MBE"]=tstring
elif hostvalues[1][1] == 'Master_backend':
- print "found MBE"
- print hostvalues
+
if hostvalues[0][1]=='0':
masterbackend+=","+row[0]
- #dotMBE=row[0] + "\\n Master Backend"
- #This is wrong, but it's enough to get it working
- dotMBE=''
+ dotMBE="MBE" + " [ label=\"" + row[0] + " \\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])
cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row))
tuners=cursor.fetchall()
tstring=""
- if len(tuners) == 0:
- tunerdict["MBE"]="no tuners \\n"
+
+ if len(tuners) <= 0:
+ tunerdict["MBE"]="no tuners \\n"
else:
- for t in tuners:
- tstring+=t[0]
- tstring+=t[1]
- tstring+='\\n'
- tunerdict["MBE"]=tstring
- dotfrontend.append(row[0])
+ #print tuners
+ for t in tuners:
+ tstring+=t[0]
+ tstring+=t[1]
+ tstring+='\\n'
+ tunerdict["MBE"]=tstring
elif hostvalues[1][1] == 'Slave_backend':
+ cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row))
+ tuners=cursor.fetchall()
+ #slave withoutfe
if hostvalues[0][1]=='0':
slave+=","+row[0]
dotslave.append(row[0])
- cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row))
- tuners=cursor.fetchall()
tstring=""
- for t in tuners:
- tstring+=t[0]
- tstring+=t[1]
- tstring+='\\n'
- tunerdict["STUNER"+row[0]]=tstring
- #dotfrontend.append(row[0])
+ if len(tuners) <= 0:
+ tunerdict["STUNER"+row[0]]="No Tuners"
+ else:
+ for t in tuners:
+ tstring+=t[0]
+ tstring+=t[1]
+ tstring+='\\n'
+ tunerdict["STUNER"+row[0]]=tstring
else:
- cursor.execute("select cardtype,defaultinput from capturecard where hostname=%s;",(row))
- tuners=cursor.fetchall()
+ #slave with fe
tstring=""
- for t in tuners:
- tstring+=t[0]
- tstring+=t[1]
- tstring+='\\n'
- tunerdict["STUNER"+row[0]]=tstring
- print tstring
-
+ if len(tuners) <= 0:
+ tunerdict["STUNER"+row[0]]="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])
+
#----------------------------------Create graphviz dot files
dotfilename="/data/srv/xymon/server/etc/mythdot"
dotfile=open(dotfilename,'w')
dotfile.write("digraph G { " + "\n" )
dotfile.write("graph [bgcolor=transparent]" + "\n" )
-
+ #print tunerdict
#define the nodes
dotfile.write( dotMBE + " \n" )
@@ -163,11 +166,16 @@ def main(argv):
for fe in dotslave:
cslave="STUNER"+fe
+ #adding tuners to dot file
if tunerdict[cslave] != "" :
- dotfile.write(cslave+ " [ label= \"" + tunerdict[cslave] + "\" , shape=box ] \n" )
+ dotfile.write(cslave+ " [ label= \"" + tunerdict[cslave] + "\" , shapefile=\"/data/srv/httpd/htdocs/xymon/gifs/tuner.png\" fontcolor=\"white\" color=red ] \n" )
+ #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!
dotfile.write("tunermbe -> MBE [color=\"red\"] \n " )
@@ -178,7 +186,7 @@ def main(argv):
cslave="STUNER"+fe
dotfile.write("SLAVE" + fe + "-> MBE [color=\"green\"] \n " )
if tunerdict[cslave] != "" :
- dotfile.write(cslave + "-> SLAVE"+fe + "\n" )
+ dotfile.write(cslave + "-> SLAVE"+fe + "[color=\"red\"]" "\n" )
@@ -186,58 +194,60 @@ def main(argv):
dotfile.close()
- cmd="/usr/bin/unflatten -l6 -c3 -f " + dotfilename + " |/usr/bin/dot -Tpng -o/data/srv/httpd/htdocs/xymon/gifs/network.png "
+ cmd="/usr/bin/unflatten -l1 -c3 -f " + dotfilename + " |/usr/bin/dot -Tpng -o/data/srv/httpd/htdocs/xymon/gifs/network.png "
# cmd="/usr/bin/circo -Tpng -o/data/srv/httpd/htdocs/xymon/gifs/network.png " + dotfilename
results=os.popen(cmd,'r')
#--------------------------------------------------
#hobbitfile="/data/srv/xymon/server/etc/hobbit-clients.cfg"
- 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)
+
+ ###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