summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/xymon')
-rwxr-xr-x[-rw-r--r--]abs/core/xymon/PKGBUILD125
-rw-r--r--abs/core/xymon/alerts.cfg4
-rw-r--r--abs/core/xymon/client-local.cfg.patch10
-rw-r--r--abs/core/xymon/clientlaunch.cfg.patch6
-rw-r--r--abs/core/xymon/hbfunc.py10
-rw-r--r--abs/core/xymon/hbnotes.py486
-rw-r--r--abs/core/xymon/hobbit_myth_data.py109
-rw-r--r--abs/core/xymon/hobbitadd.py182
-rw-r--r--abs/core/xymon/hobbitlaunch.cfg.diff30
-rw-r--r--abs/core/xymon/hobbitstorage.py2
-rw-r--r--abs/core/xymon/hosts.cfg.patch10
-rw-r--r--abs/core/xymon/logrotate-client.xymon6
-rw-r--r--abs/core/xymon/logrotate-server.xymon4
-rw-r--r--abs/core/xymon/tasks.d.mv28
-rw-r--r--abs/core/xymon/xymon-client.install4
-rw-r--r--abs/core/xymon/xymon-server.rules6
-rw-r--r--abs/core/xymon/xymon.install46
-rw-r--r--abs/core/xymon/xymon_ghost_check2
18 files changed, 651 insertions, 419 deletions
diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index 23590a1..8441779 100644..100755
--- a/abs/core/xymon/PKGBUILD
+++ b/abs/core/xymon/PKGBUILD
@@ -1,15 +1,17 @@
pkgbase=xymon
pkgname=(xymonserver xymonclient)
pkgver=4.3.5
-pkgrel=32
+pkgrel=44
pkgdesc="Hobbit is a system for monitoring servers and networks. "
license="GPL"
arch=('i686' 'x86_64')
url="http://www.xymon.com/"
-source=(http://voxel.dl.sourceforge.net/project/xymon/Xymon/4.3.5/xymon-4.3.5.tar.gz hobbitadd.py xymon_ghost_check graph.cfg.diff xymonserver.cfg.diff tasks.d.mv clientlaunch.cfg.patch hobbitstorage.py hbnotes.py hobbit-myth-orphan.sh analysis.cfg hbfunc.py be.png tuner.png tv.png hobbit-mem-myth.sh hobbit_notify.sh alerts.cfg hobbit_myth_data.py logrotate-server.xymon logrotate-client.xymon log_list.sh client-local.cfg.patch led_themes.tar.gz )
-depends=(rrdtool fping pcre python graphviz 'linhes-scripts>=7-24')
+source=(http://voxel.dl.sourceforge.net/project/xymon/Xymon/4.3.5/xymon-4.3.5.tar.gz hobbitadd.py xymon_ghost_check graph.cfg.diff xymonserver.cfg.diff tasks.d.mv clientlaunch.cfg.patch hobbitstorage.py hbnotes.py hobbit-myth-orphan.sh analysis.cfg hbfunc.py be.png tuner.png tv.png hobbit-mem-myth.sh hobbit_notify.sh alerts.cfg hobbit_myth_data.py logrotate-server.xymon logrotate-client.xymon log_list.sh client-local.cfg.patch led_themes.tar.gz xymon-server.rules hosts.cfg.patch)
+
+depends=(rrdtool fping pcre python2 graphviz 'linhes-scripts>=7-24')
+
install=xymon.install
build() {
@@ -19,8 +21,8 @@ build() {
ENABLELDAP=n \
ENABLELDAPSSL=n \
XYMONUSER=nobody \
- XYMONTOPDIR=/data/srv/xymon \
- XYMONVAR=/data/srv/xymon/var \
+ XYMONTOPDIR=/home/xymon \
+ XYMONVAR=/home/xymon/var \
XYMONHOSTURL=/xymon \
CGIDIR=/data/srv/httpd/htdocs/xymon/hobbit-cgi \
XYMONCGIURL=/xymon/hobbit-cgi \
@@ -34,15 +36,16 @@ build() {
BARS=all \
USENEWHIST=y \
PIXELCOUNT=960 \
- INSTALLBINDIR=/data/srv/xymon/server/bin \
- INSTALLETCDIR=/data/srv/xymon/etc \
- INSTALLWEBDIR=/data/srv/xymon/web \
- INSTALLEXTDIR=/data/srv/xymon/server/ext \
- INSTALLTMPDIR=/data/srv/xymon/tmp \
+ INSTALLBINDIR=/home/xymon/server/bin \
+ INSTALLETCDIR=/home/xymon/etc \
+ INSTALLWEBDIR=/home/xymon/web \
+ INSTALLEXTDIR=/home/xymon/server/ext \
+ INSTALLTMPDIR=/home/xymon/tmp \
INSTALLWWWDIR=/data/srv/httpd/htdocs/xymon/ \
./configure
make PKGBUILD=1|| return 1
+
}
package_xymonserver(){
@@ -50,87 +53,93 @@ package_xymonserver(){
cd $startdir/src/xymon-$pkgver
make PKGBUILD=1 INSTALLROOT=$startdir/pkg/xymonserver install
cd $startdir/src
- install -D -m755 $startdir/src/hobbitadd.py $startdir/pkg/xymonserver/data/srv/xymon/server/bin/hobbitadd.py
- install -D -m755 $startdir/src/hobbitstorage.py $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hobbitstorage.py
- install -D -m755 $startdir/src/hobbit-myth-orphan.sh $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hobbit-myth-orphan.sh
- install -D -m755 $startdir/src/hbfunc.py $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hbfunc.py
- install -D -m755 $startdir/src/hbnotes.py $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hbnotes.py
- install -D -m755 $startdir/src/hobbit_myth_data.py $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hobbit_myth_data.py
- install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/xymonserver/data/srv/xymon/server/ext/hobbit-mem-myth.sh
- install -D -m755 $startdir/src/log_list.sh $startdir/pkg/xymonserver/data/srv/xymon/client/bin/log_list.sh
-
-# install -D -m755 xymon_ghost_check $startdir/pkg/xymonserver/etc/cron.tenminutes/xymon_ghost_check
- install -m755 analysis.cfg $startdir/pkg/xymonserver/data/srv/xymon/etc/analysis.cfg
- cat alerts.cfg >> $startdir/pkg/xymonserver/data/srv/xymon/etc/alerts.cfg
-
- install -m755 hobbit_notify.sh $startdir/pkg/xymonserver/data/srv/xymon/server/bin/hobbit_notify.sh
+ install -D -m400 $startdir/src/xymon-server.rules $startdir/pkg/xymonserver/etc/sudoers.d/xymon_server
+ install -D -m755 $startdir/src/hobbitadd.py $startdir/pkg/xymonserver/home/xymon/server/bin/hobbitadd.py
+ install -D -m755 $startdir/src/hobbitstorage.py $startdir/pkg/xymonserver/home/xymon/server/ext/hobbitstorage.py
+ install -D -m755 $startdir/src/hobbit-myth-orphan.sh $startdir/pkg/xymonserver/home/xymon/server/ext/hobbit-myth-orphan.sh
+ install -D -m755 $startdir/src/hbfunc.py $startdir/pkg/xymonserver/home/xymon/server/ext/hbfunc.py
+ install -D -m755 $startdir/src/hbnotes.py $startdir/pkg/xymonserver/home/xymon/server/ext/hbnotes.py
+ install -D -m755 $startdir/src/hobbit_myth_data.py $startdir/pkg/xymonserver/home/xymon/server/ext/hobbit_myth_data.py
+ install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/xymonserver/home/xymon/server/ext/hobbit-mem-myth.sh
+ install -D -m755 $startdir/src/log_list.sh $startdir/pkg/xymonserver/home/xymon/client/bin/log_list.sh
+
+ install -m755 analysis.cfg $startdir/pkg/xymonserver/home/xymon/etc/analysis.cfg
+ cat alerts.cfg >> $startdir/pkg/xymonserver/home/xymon/etc/alerts.cfg
+
+ install -m755 hobbit_notify.sh $startdir/pkg/xymonserver/home/xymon/server/bin/hobbit_notify.sh
install -m755 $startdir/src/tv.png $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/gifs/tv.png
install -m755 $startdir/src/tuner.png $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/gifs/tuner.png
install -m755 $startdir/src/be.png $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/gifs/be.png
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
cd $startdir/src/themes
cp -fp Common/* $DOCDIR/gifs/
cp -fp ModernLED/* $DOCDIR/gifs/
- #apply patches to conf file
-# mkdir -p $startdir/pkg/xymonserver/data/srv/xymon/etc/tasks.d/
-# mkdir -p $startdir/pkg/xymonserver/data/srv/xymon/etc/tasks.d/
- install -D -m755 $startdir/src/tasks.d.mv $startdir/pkg/xymonserver/data/srv/xymon/etc/tasks.d/mv.cfg
-# cat $startdir/src/tasks.d.mv >> $startdir/pkg/xymonserver/data/srv/xymon/etc/tasks.cfg
- cd $startdir/pkg/xymonserver/data/srv/xymon/etc
- patch -p0 < $startdir/src/graph.cfg.diff || return 1
+ #apply patches to conf file
+ install -D -m775 $startdir/src/tasks.d.mv $startdir/pkg/xymonserver/home/xymon/etc/tasks.d/mv.cfg
+ cd $startdir/pkg/xymonserver/home/xymon/etc
+ patch -p0 < $startdir/src/graph.cfg.diff || return 1
patch -p0 < $startdir/src/xymonserver.cfg.diff || return 1
- patch -p4 < $startdir/src/client-local.cfg.patch || return 1
-
-
-
+ patch -p3 < $startdir/src/client-local.cfg.patch || return 1
+ patch -p3 < $startdir/src/hosts.cfg.patch || return 1
+
+ #fix permissions
+ chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/
+ chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/
+ chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/notes/
+ chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/gifs/
+ chmod 750 $startdir/pkg/xymonserver/etc/sudoers.d
}
package_xymonclient(){
#create client package as well
depends=()
- backup=('data/srv/xymon/client/etc/xymonclient.cfg')
+ backup=('data/srv/xymon/client/etc/xymonclient.cfg')
install=xymon-client.install
- install -D -m755 $startdir/src/log_list.sh $startdir/pkg/xymonclient/data/srv/xymon/client/bin/log_list.sh
+ install -D -m755 $startdir/src/log_list.sh $startdir/pkg/xymonclient/home/xymon/client/bin/log_list.sh
install -D -m644 $startdir/src/logrotate-client.xymon $startdir/pkg/xymonclient/etc/logrotate.d/xymon-client
- install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/xymonclient/data/srv/xymon/client/ext/hobbit-mem-myth.sh
- cp -rp /$startdir/pkg/xymonserver/data/srv/xymon/client/ $startdir/pkg/xymonclient/data/srv/xymon/
-
- cd -
- cd $startdir/pkg/xymonclient/data/srv/xymon/client/etc
- patch -p0 < $startdir/src/clientlaunch.cfg.patch
- cd -
-
+ install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/xymonclient/home/xymon/client/ext/hobbit-mem-myth.sh
+ cp -rp /$startdir/pkg/xymonserver/home/xymon/client/ $startdir/pkg/xymonclient/home/xymon/
+ cd -
+ cd $startdir/pkg/xymonclient/home/xymon/client/etc
+ patch -p0 < $startdir/src/clientlaunch.cfg.patch
+ cd -
}
md5sums=('31923ec126fe1c264fceb459d2175161'
- '28399d002ace27f01c6cfee3edd407ee'
- '0f79d9715a827fa845a114b74b2c190c'
+ 'a0fbb9cbeb3600a40943e6205790f22f'
+ 'c60b0d59bb39505ee3d62c6dd65429c5'
'a45dd4cdb84817bcf3e51b25cc713799'
'034658a1084510ecbbb0dc166c0401eb'
- 'cc845b5aedc33dda8e3103b915fe4967'
- '650b523d879f32c1bad3b4a9e10e7c93'
- '093648dabb0d1da0fdcc37b327737f43'
- 'cac3478de106d875ddbdaa377d26692d'
+ '2d88e59ab17114030da514ba3f0a5b64'
+ 'ee608dcafc050d790e28647a670f6b60'
+ 'b2f98ac0df013332deedc1efae0a270d'
+ 'fc24435b97254f0954233319ba09689b'
'0f70e76a164f648f0a4a01110137cb20'
'f6921f0413215ae174e81306be80d37f'
- 'be02f5d21373f97224ffa4727ec9718a'
+ '80d9cfac86c6d96836e6f406e35e7cf5'
'd210c43fb9ee9ad6cd7648e0c2e0efea'
'0c808fa12672289f86b0651545381308'
'0469d775db9fdd18ea95dd41937ada82'
'0757294eec13771f8e63da23cf066796'
'622f400fd098cbc43c203e3210a6694e'
- 'd06c4327cc69aeead3fa05f39660f33e'
- 'eb502ce1be9b658be74911b53832caa8'
- 'f6ff1fb4bacee930007b877424619b30'
- 'e06147db25d75cf246886137a4ea164a'
+ '84442377c6e914b65519076bda4e17a4'
+ 'd7116dc59319b893e90a26e6beb83994'
+ '67621b6c5a766ac03c5f407bdbdca810'
+ '7ad4871af35f82c7824bb682b9325dba'
'98e9242ae346f729b14cb195786571f2'
- '40fa09bdb1ae60f3fe767f1c6a979b65'
- 'c7178bbf384bbe86c318b60fef6faf10')
+ '31ac5c1f6dcc9408b64c4107b325a9a6'
+ 'c7178bbf384bbe86c318b60fef6faf10'
+ '72bf7caf0f53928d97ff5cd9810d6d4d'
+ '606f535a49f32b35802ed9d46bd7d068')
diff --git a/abs/core/xymon/alerts.cfg b/abs/core/xymon/alerts.cfg
index 84c3ead..e458655 100644
--- a/abs/core/xymon/alerts.cfg
+++ b/abs/core/xymon/alerts.cfg
@@ -1,6 +1,6 @@
HOST=* SERVICE=disk
- SCRIPT /data/srv/xymon/server/bin/hobbit_notify.sh 1234567890 FORMAT=SMS REPEAT=10h COLOR=yellow
- SCRIPT /data/srv/xymon/server/bin/hobbit_notify.sh 1234567890 FORMAT=SMS REPEAT=1h COLOR=red
+ SCRIPT /home/xymon/server/bin/hobbit_notify.sh 1234567890 FORMAT=SMS REPEAT=10h COLOR=yellow
+ SCRIPT /home/xymon/server/bin/hobbit_notify.sh 1234567890 FORMAT=SMS REPEAT=1h COLOR=red
diff --git a/abs/core/xymon/client-local.cfg.patch b/abs/core/xymon/client-local.cfg.patch
index 17ffd56..23754fb 100644
--- a/abs/core/xymon/client-local.cfg.patch
+++ b/abs/core/xymon/client-local.cfg.patch
@@ -1,11 +1,11 @@
---- data/srv/xymon/etc/client-local.cfg.orig 2011-12-07 18:46:45.391534998 +0000
-+++ data/srv/xymon/etc/client-local.cfg 2011-12-07 18:47:29.488200337 +0000
+--- home/xymon/etc/client-local.cfg.orig 2011-12-07 18:46:45.391534998 +0000
++++ home/xymon/etc/client-local.cfg 2011-12-07 18:47:29.488200337 +0000
@@ -79,7 +79,7 @@
log:/var/log/messages:10240
-
+
[linux]
-log:/var/log/messages:10240
-+log:`/data/srv/xymon/client/bin/log_list.sh`:10240
++log:`/home/xymon/client/bin/log_list.sh`:10240
ignore MARK
-
+
[linux22]
diff --git a/abs/core/xymon/clientlaunch.cfg.patch b/abs/core/xymon/clientlaunch.cfg.patch
index bb0e1c6..ec475f9 100644
--- a/abs/core/xymon/clientlaunch.cfg.patch
+++ b/abs/core/xymon/clientlaunch.cfg.patch
@@ -1,12 +1,12 @@
--- clientlaunch.cfg.orig 2011-11-25 19:07:19.000000000 -0600
+++ clientlaunch.cfg 2011-11-25 19:09:55.000000000 -0600
@@ -25,4 +25,9 @@
- CMD $XYMONCLIENTHOME/bin/xymonclient.sh
+ CMD $XYMONCLIENTHOME/bin/xymonclient.sh
LOGFILE $XYMONCLIENTLOGS/xymonclient.log
INTERVAL 5m
+[memmyth]
+ ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
-+ CMD /data/srv/xymon/client/ext/hobbit-mem-myth.sh
++ CMD /home/xymon/client/ext/hobbit-mem-myth.sh
+ LOGFILE $XYMONCLIENTLOGS/mythmem.log
+ INTERVAL 5m
-
+
diff --git a/abs/core/xymon/hbfunc.py b/abs/core/xymon/hbfunc.py
index 39e1680..029e3ee 100644
--- a/abs/core/xymon/hbfunc.py
+++ b/abs/core/xymon/hbfunc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
#checks that the MBE can connect to the minions
# ===============================================
@@ -12,7 +12,7 @@ import datetime
BBLINE = ''
BBCOLOR="green"
DATE = time.strftime("%a %b %d %H:%M:%S %Z %Y", time.localtime(time.time()))
-BB="/data/srv/xymon/server/bin/xymon"
+BB="/home/xymon/server/bin/xymon"
BBDISP="127.0.01"
@@ -119,7 +119,7 @@ def readbb():
global mythtype
try:
- infile = open('/data/srv/xymon/etc/hosts.cfg', 'r')
+ infile = open('/home/xymon/etc/hosts.cfg', 'r')
except(IOError), e:
#print "couldn't open xymon hosts file"
sys.exit(1)
@@ -207,8 +207,8 @@ local_myth_version=find_local_myth_version()
for currentclient_a in hostlist:
currentclient=currentclient_a.lower()
- print currentclient
- cmd='/data/srv/xymon/server/bin/xymon 127.0.0.1 "query '
+ #print currentclient
+ cmd='/home/xymon/server/bin/xymon 127.0.0.1 "query '
cmd+=currentclient
cmd+='.conn"'
bbresults=os.popen(cmd,'r' ).readline().strip().split()
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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp
+ <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:])
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
diff --git a/abs/core/xymon/hobbitadd.py b/abs/core/xymon/hobbitadd.py
index cb2fbed..4ce32a2 100644
--- a/abs/core/xymon/hobbitadd.py
+++ b/abs/core/xymon/hobbitadd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
#polls the hobbit server for ghost clients. If it finds ghosts it will make a new bb-hosts file
#with the new clients.
#Will not add duplicate clients
@@ -6,26 +6,12 @@
import urllib2
import string
import sys
-
-
-def readbb():
- global bblist
- try:
- infile = open('/data/srv/xymon/etc/hosts.cfg', 'r')
- except(IOError), e:
- print "couldn't open bb-hosts file"
- sys.exit(1)
- else:
- bblist = infile.readlines()
-
- infile.close()
+import MySQLdb
+import re
def findghosts():
- global infile
- global bblist
- global ghostitems
- global numberitems
+ ghostitems=[]
try:
f = urllib2.urlopen("http://localhost/xymon/hobbit-cgi/ghostlist.sh?SORT=name&MAXAGE=300&TEXT")
except urllib2.HTTPError, e:
@@ -35,61 +21,127 @@ def findghosts():
else:
ghostitems_full = f.readlines()
f.close()
- ghostitems=[]
+ #'''<h3><center>Failed to retrieve ghostlist from server</center></h3> #'''
for i in ghostitems_full:
- if not i.startswith('127.0.0'):
- ghostitems.append(i)
+ if i.find("Failed to retrieve") >= 0 :
+ print "exiting because xymon ghost list failed"
+ print i
+ sys.exit(1)
+ if i.find('127.0.0') == -1 :
+ ghostitems.append(i.strip())
+ print "ghost host found: %s" %i.strip()
else:
continue
- numberitems = len(ghostitems)
-
-
-def makenewbb():
- global bblist
- global ghostitems
- global numberitems
- global numinserts
- numinserts=0
- outlist = []
- for item in bblist:
- if item not in outlist:
- outlist.append(item)
-
- for item in ghostitems:
- line = item.rstrip()
- nline = "%s #func" % (line)
- nline = nline + '\n'
- if nline not in outlist:
- outlist.append(nline)
- print "adding: " + nline
- numinserts = numinserts + 1
- if numinserts > 0:
- outfile = open("/data/srv/xymon/etc/hosts.cfg","w")
- #outfile = open("/tmp/new-bb","w")
- for i in outlist:
- outfile.write(i + '\n' )
- outfile.close
+ #ghostitems = ['192.168.1.233\t\tfeste32', '192.168.1.127\t\tjams3']
+ return ghostitems
+def readbb():
+ bblist = []
+ strip_list = []
+ try:
+ infile = open('/home/xymon/etc/hosts.cfg', 'r')
+ #infile = open('/tmp/old-bb', 'r')
+ except(IOError), e:
+ print "couldn't open hosts.cfg file"
+ sys.exit(1)
+ else:
+ bblist = infile.readlines()
+ for line in bblist:
+ strip_list.append(line.strip())
+
+
+ infile.close()
+ return strip_list
+
+
+def ghost_type(ghostlist):
+ match_gdict={}
+ #query db with ghostname
+ db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
+ # create a cursor
+ cursor = db.cursor()
+ for item in ghostlist:
+ host = item.split()[1].strip()
+ cursor.execute("select value,data from settings where hostname=%s and value in ('HostSystemType');",(host))
+ hostvalues=cursor.fetchall()
+ #this is here in case the db fails
+ if len(hostvalues) == 0:
+ hostvalues = (('HostSystemType','unknown system'),)
+
+ #should return something like this(('HostSystemType', 'Frontend_only'),)
+ #hostvalues = (('HostSystemType', 'Frontend_only'),)
+ if len(hostvalues) == 1:
+ #get current systemtype and make it all lowercase
+ current_hostvalue = hostvalues[0][1].lower()
+ try:
+ value = match_gdict[current_hostvalue]
+ value.append(item)
+ match_gdict[current_hostvalue] = value
+ except:
+ match_gdict[current_hostvalue] = [item]
+
+
+ #{'Frontend_only': ['feste32', 'feste3', 'feste33']}
+ return match_gdict
+
+def check_duplicate(host_list,server):
+ server_no_space=re.sub(r'\s', '',server)
+ for line in host_list:
+ line_no_space=re.sub(r'\s', '',line)
+
+ if line_no_space.find(server_no_space) > -1 :
+ #print "server in hostlist"
+ return True
+ else:
+ continue
+
+
+ return False
+
+def create_new_hosts(matched_gdict,host_list):
+ #loop over key in gdict
+ for key,value in matched_gdict.iteritems():
+ groupline = "title %s" %key
+ #print key
+ if key == "unknown system":
+ host_append_line = "%s #"
+ else:
+ host_append_line = "%s #func"
+
+ if groupline in host_list:
+ insert_index = host_list.index(groupline) + 1
+ for server in value:
+ if check_duplicate(host_list,server) == False :
+ #host_append_line = "%s #func" %(server)
+ host_list.insert(insert_index,host_append_line %server)
+ else:
+ host_list.append(groupline)
+ for server in value:
+ #host_append_line = "%s #func" %(server)
+ host_list.append(host_append_line %server)
+
+
+ outfile = open("/home/xymon/etc/hosts.cfg","w")
+ #outfile = open("/tmp/new-bb","w")
+ for i in host_list:
+ outfile.write(i + '\n' )
+ outfile.close
+ return
-global infile
-global bblist
-global ghostitems
-global numberitems
-global numinserts
-numinserts=0
-readbb()
-findghosts()
-if numberitems > 0:
- makenewbb()
-#else:
-# print "No hosts to add"
+def go():
+ ghostlist = findghosts()
+ #print ghostlist
+ if len(ghostlist) == 0 :
+ sys.exit()
-if numinserts < 1:
- sys.exit(1)
-else:
- sys.exit(0)
+ #match ghosts to system type
+ matched_gdict = ghost_type(ghostlist)
+ host_list = readbb()
+ create_new_hosts(matched_gdict,host_list)
+if __name__ == "__main__":
+ go()
diff --git a/abs/core/xymon/hobbitlaunch.cfg.diff b/abs/core/xymon/hobbitlaunch.cfg.diff
index 6239125..47da067 100644
--- a/abs/core/xymon/hobbitlaunch.cfg.diff
+++ b/abs/core/xymon/hobbitlaunch.cfg.diff
@@ -3,38 +3,38 @@
@@ -204,3 +204,37 @@
LOGFILE $BBSERVERLOGS/hobbitclient.log
INTERVAL 5m
-
+
+[storage]
-+
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD /data/srv/hobbit/server/ext/hobbitstorage.py
++
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD /home/xymonserver/ext/hobbitstorage.py
+ LOGFILE $BBSERVERLOGS/bb-storage.log
+ INTERVAL 5m
+[notes]
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD /data/srv/hobbit/server/ext/hbnotes.py
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD /home/xymonserver/ext/hbnotes.py
+ LOGFILE $BBSERVERLOGS/bb-notes.log
+ INTERVAL 5m
+[orphan]
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD /data/srv/hobbit/server/ext/hobbit-myth-orphan.sh
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD /home/xymonserver/ext/hobbit-myth-orphan.sh
+ LOGFILE $BBSERVERLOGS/orphan.log
+ INTERVAL 5m
-+
++
+[func]
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD sudo /data/srv/hobbit/server/ext/hbfunc.py
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD sudo /home/xymonserver/ext/hbfunc.py
+ LOGFILE $BBSERVERLOGS/hbfunc.log
+ INTERVAL 5m
+
+[memmyth]
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD /data/srv/hobbit/server/ext/hobbit-mem-myth.sh
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD /home/xymonserver/ext/hobbit-mem-myth.sh
+ LOGFILE $BBSERVERLOGS/mythmem.log
+ INTERVAL 5m
+
+[mtc]
-+ ENVFILE /data/srv/hobbit/server/etc/hobbitserver.cfg
-+ CMD /data/srv/hobbit/server/ext/hobbit_myth_data.py
++ ENVFILE /home/xymonserver/etc/hobbitserver.cfg
++ CMD /home/xymonserver/ext/hobbit_myth_data.py
+ LOGFILE $BBSERVERLOGS/mtc
+ INTERVAL 5m
diff --git a/abs/core/xymon/hobbitstorage.py b/abs/core/xymon/hobbitstorage.py
index e79f8d1..a82adcb 100644
--- a/abs/core/xymon/hobbitstorage.py
+++ b/abs/core/xymon/hobbitstorage.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
# import MySQL module
import MySQLdb
diff --git a/abs/core/xymon/hosts.cfg.patch b/abs/core/xymon/hosts.cfg.patch
new file mode 100644
index 0000000..6968a07
--- /dev/null
+++ b/abs/core/xymon/hosts.cfg.patch
@@ -0,0 +1,10 @@
+--- home/xymon/etc/hosts.cfg.orig 2012-09-30 23:04:38.229515544 +0000
++++ home/xymon/etc/hosts.cfg 2012-09-30 23:04:50.676181831 +0000
+@@ -11,6 +11,6 @@
+ # man-page.
+ #
+ # You need to define at least the Xymon server itself here.
+-
++title primary server
+ 127.0.0.1 localhost # bbd http://localhost/
+
diff --git a/abs/core/xymon/logrotate-client.xymon b/abs/core/xymon/logrotate-client.xymon
index e1051aa..a312b64 100644
--- a/abs/core/xymon/logrotate-client.xymon
+++ b/abs/core/xymon/logrotate-client.xymon
@@ -1,7 +1,7 @@
-/data/srv/xymon/client/logs/* {
+/home/xymon/client/logs/* {
missingok
- daily
- rotate 2
+ size 512K
+ rotate 0
compress
postrotate
if [ -f /service/xymon-client/run ]
diff --git a/abs/core/xymon/logrotate-server.xymon b/abs/core/xymon/logrotate-server.xymon
index e69c5d9..2267da8 100644
--- a/abs/core/xymon/logrotate-server.xymon
+++ b/abs/core/xymon/logrotate-server.xymon
@@ -1,7 +1,7 @@
/var/log/hobbit/* {
missingok
- daily
- rotate 2
+ size 512K
+ rotate 0
compress
postrotate
if [ -f /service/xymon-server/run ]
diff --git a/abs/core/xymon/tasks.d.mv b/abs/core/xymon/tasks.d.mv
index 696cb4e..e113f37 100644
--- a/abs/core/xymon/tasks.d.mv
+++ b/abs/core/xymon/tasks.d.mv
@@ -1,39 +1,39 @@
[storage]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hobbitstorage.py
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hobbitstorage.py
LOGFILE $BBSERVERLOGS/bb-storage.log
INTERVAL 5m
[notes]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hbnotes.py
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hbnotes.py
LOGFILE $BBSERVERLOGS/bb-notes.log
INTERVAL 5m
[orphan]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hobbit-myth-orphan.sh
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hobbit-myth-orphan.sh
LOGFILE $BBSERVERLOGS/orphan.log
INTERVAL 5m
[func]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hbfunc.py
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hbfunc.py
LOGFILE $BBSERVERLOGS/hbfunc.log
INTERVAL 5m
[memmyth]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hobbit-mem-myth.sh
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hobbit-mem-myth.sh
LOGFILE $BBSERVERLOGS/mythmem.log
INTERVAL 5m
[mtc]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/ext/hobbit_myth_data.py
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/ext/hobbit_myth_data.py
LOGFILE $BBSERVERLOGS/mtc
INTERVAL 5m
[ghost]
- ENVFILE /data/srv/xymon/server/etc/xymonserver.cfg
- CMD /data/srv/xymon/server/bin/hobbitadd.py
+ ENVFILE /home/xymon/server/etc/xymonserver.cfg
+ CMD /home/xymon/server/bin/hobbitadd.py
LOGFILE $BBSERVERLOGS/hobbitadd.log
INTERVAL 5m
diff --git a/abs/core/xymon/xymon-client.install b/abs/core/xymon/xymon-client.install
index 301fc1f..80210f1 100644
--- a/abs/core/xymon/xymon-client.install
+++ b/abs/core/xymon/xymon-client.install
@@ -1,7 +1,7 @@
post_install() {
. /etc/systemconfig
- sed -i -e "s/127.0.0.1/$dbhost/" /data/srv/xymon/client/etc/xymonclient.cfg
- chown -R nobody /data/srv/xymon
+ sed -i -e "s/127.0.0.1/$dbhost/" /home/xymon/client/etc/xymonclient.cfg
+ chown -R nobody /home/xymon
}
diff --git a/abs/core/xymon/xymon-server.rules b/abs/core/xymon/xymon-server.rules
new file mode 100644
index 0000000..b0f6100
--- /dev/null
+++ b/abs/core/xymon/xymon-server.rules
@@ -0,0 +1,6 @@
+#These rules are used by xymon-server
+nobody ALL = NOPASSWD:/usr/bin/certmaster-ca
+http ALL = NOPASSWD:/usr/LH/bin/lh_system_backup_job
+http ALL = NOPASSWD:/usr/LH/bin/lh_system_restore_job
+http ALL = NOPASSWD:/sbin/sv
+
diff --git a/abs/core/xymon/xymon.install b/abs/core/xymon/xymon.install
index 067030e..3c9680b 100644
--- a/abs/core/xymon/xymon.install
+++ b/abs/core/xymon/xymon.install
@@ -1,9 +1,9 @@
post_install() {
. /etc/systemconfig
- if [ ! -f /data/srv/xymon/server/ext/ignoreclient.py ]
+ if [ ! -f /home/xymon/server/ext/ignoreclient.py ]
then
- echo "#this is a list of hosts to ignore" > /data/srv/xymon/server/ext/ignoreclient.py
- echo ignorehosts=\"\'ignoreme1\',\'ignoreme2\'\" >> /data/srv/xymon/server/ext/ignoreclient.py
+ echo "#this is a list of hosts to ignore" > /home/xymon/server/ext/ignoreclient.py
+ echo ignorehosts=\"\'ignoreme1\',\'ignoreme2\'\" >> /home/xymon/server/ext/ignoreclient.py
fi
if [ ! -f /data/srv/httpd/htdocs/failed_func_hosts ]
@@ -14,40 +14,16 @@ post_install() {
chmod 777 /data/srv/httpd/htdocs/failed_func_hosts
- sed -i -e "s/localhost/$hostname/" /data/srv/xymon/server/etc/hosts.cfg
- sed -i -e "s/\#/\# func/" /data/srv/xymon/server/etc/hosts.cfg
- sed -i -e "s/localhost/$hostname/" /data/srv/xymon/server/etc/xymonserver.cfg
- chown -R nobody /data/srv/xymon
+ sed -i -e "s/localhost/$hostname/" /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
chown -R nobody /var/log/hobbit
- chown root /data/srv/xymon/server/bin/xymonping
- chmod +s /data/srv/xymon/server/bin/xymonping
- echo "Adding sudo permissions for nobody {certmaster-ca}"
- echo "Adding sudo permissions for http {backup_job}"
- echo "Adding sudo permissions for http {sv}"
- LINE="nobody ALL = NOPASSWD:/usr/bin/certmaster-ca"
- LINE1="http ALL = NOPASSWD:/usr/LH/bin/lh_system_backup_job"
- LINE2="http ALL = NOPASSWD:/sbin/sv"
- setfacl -R -m u:nobody:rwx /data/srv/httpd/htdocs
- for i in "$LINE" "$LINE1" "$LINE2"
- do
- cp /etc/sudoers /etc/sudoers.bak
- grep -q "$i" /etc/sudoers
- if [ $? != 0 ]
- then
- echo "$i" >> /etc/sudoers
- visudo -cf /etc/sudoers
- if [ ! $? = 0 ]
- then
- cp /etc/sudoers.bak /etc/sudoers
- echo $i
- echo "Error adding files"
- exit 1
- fi
- fi
- done
-
-
+ chown root /home/xymon/server/bin/xymonping
+ chmod +s /home/xymon/server/bin/xymonping
+
+
diff --git a/abs/core/xymon/xymon_ghost_check b/abs/core/xymon/xymon_ghost_check
index e51efb6..3660e50 100644
--- a/abs/core/xymon/xymon_ghost_check
+++ b/abs/core/xymon/xymon_ghost_check
@@ -1,2 +1,2 @@
#!/bin/bash
-/usr/bin/sudo -u nobody /data/srv/xymon/server/bin/hobbitadd.py
+/usr/bin/sudo -u nobody /home/xymon/server/bin/hobbitadd.py