summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-12-26 20:13:40 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-12-26 20:13:40 (GMT)
commitaf515b99f692bcf1f0af57aabe8f7c1a950b32c5 (patch)
treed2cbd0bd7a159adac8ebc749e6c76d005ad4a42e /abs/core/xymon
parent45f667c9512475b4cb5c5290557dea854d056634 (diff)
parent816f6f419c662354f4224f8d82387fc27693b0fb (diff)
downloadlinhes_pkgbuild-af515b99f692bcf1f0af57aabe8f7c1a950b32c5.zip
linhes_pkgbuild-af515b99f692bcf1f0af57aabe8f7c1a950b32c5.tar.gz
linhes_pkgbuild-af515b99f692bcf1f0af57aabe8f7c1a950b32c5.tar.bz2
Merge branch 'testing'
Diffstat (limited to 'abs/core/xymon')
-rwxr-xr-xabs/core/xymon/PKGBUILD28
-rwxr-xr-x[-rw-r--r--]abs/core/xymon/alerts.cfg128
-rw-r--r--abs/core/xymon/analysis.cfg147
-rw-r--r--abs/core/xymon/hbnotes.py130
-rwxr-xr-x[-rw-r--r--]abs/core/xymon/hobbit_myth_data.py85
-rw-r--r--abs/core/xymon/hobbit_notify.sh67
-rw-r--r--abs/core/xymon/login_notify.sh64
7 files changed, 475 insertions, 174 deletions
diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index 0c797ee..8163f32 100755
--- a/abs/core/xymon/PKGBUILD
+++ b/abs/core/xymon/PKGBUILD
@@ -1,14 +1,14 @@
pkgbase=xymon
pkgname=(xymonserver xymonclient)
pkgver=4.3.5
-pkgrel=49
+pkgrel=55
pkgdesc="Hobbit is a system for monitoring servers and networks. "
license="GPL"
arch=('i686' 'x86_64')
url="http://www.xymon.com/"
-source=(http://hivelocity.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)
+source=(http://hivelocity.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 login_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-system>=8.0-5')
@@ -67,13 +67,14 @@ package_xymonserver(){
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 login_notify.sh $startdir/pkg/xymonserver/home/xymon/server/bin/login_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
+ # fix env for mythtb bindingds
echo "MYTHCONFDIR=/usr/share/mythtv" >> $startdir/pkg/xymonserver/home/xymon/etc/xymonserver.cfg
@@ -91,6 +92,14 @@ package_xymonserver(){
patch -p3 < $startdir/src/client-local.cfg.patch || return 1
patch -p3 < $startdir/src/hosts.cfg.patch || return 1
+ #make dir for login alerts
+ mkdir $startdir/pkg/xymonserver/home/xymon/var/login_alerts
+
+ #add custom module descriptions
+ COLDOC=$pkgdir/home/xymon/etc/columndoc.csv
+ echo "myth_mtc;The <b>myth_mtc</b> column shows the status of the MythTV maintenance script.;" >> $COLDOC
+ echo "orphan;The <b>orphan</b> column shows the status of the find_orphans.py script.;" >> $COLDOC
+
#fix permissions
chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/
chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/
@@ -99,6 +108,8 @@ package_xymonserver(){
chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/snap/
chmod 775 $startdir/pkg/xymonserver/data/srv/httpd/htdocs/xymon/rep/
chmod 750 $startdir/pkg/xymonserver/etc/sudoers.d
+ chmod 775 $startdir/pkg/xymonserver/home/xymon/var/login_alerts
+
}
@@ -128,17 +139,18 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
'758cdd9f1ba5ae3e1b42e811172806f3'
'ee608dcafc050d790e28647a670f6b60'
'b2f98ac0df013332deedc1efae0a270d'
- 'c31bcb503a227ed5ff7b218581793bfc'
+ '1141fc6f846e91f380bbcdb212b44f7d'
'0f70e76a164f648f0a4a01110137cb20'
- 'f6921f0413215ae174e81306be80d37f'
+ '166279c006c3ef7bf0c21537cf89fc83'
'80d9cfac86c6d96836e6f406e35e7cf5'
'd210c43fb9ee9ad6cd7648e0c2e0efea'
'0c808fa12672289f86b0651545381308'
'0469d775db9fdd18ea95dd41937ada82'
'0757294eec13771f8e63da23cf066796'
- '622f400fd098cbc43c203e3210a6694e'
- '84442377c6e914b65519076bda4e17a4'
- 'd7116dc59319b893e90a26e6beb83994'
+ '270e13da6cbc9d49079d994edaa71e64'
+ '4bc37b700146e4f4206a729c835903b0'
+ '9af2ad60ac4c3cb653754618f603e311'
+ 'b8eb10070f2ad6a245d3da15091694ba'
'b4e8641e97e6b689dbc634af785e6799'
'e2844513e2c92e8b5084818f3b2a478d'
'98e9242ae346f729b14cb195786571f2'
diff --git a/abs/core/xymon/alerts.cfg b/abs/core/xymon/alerts.cfg
index e458655..a5e5bc2 100644..100755
--- a/abs/core/xymon/alerts.cfg
+++ b/abs/core/xymon/alerts.cfg
@@ -1,6 +1,128 @@
+#
+# The alerts.cfg file controls who receives alerts
+# when a status in the XYmon system goes into a critical
+# state (usually: red, yellow or purple).
+#
+# This file is made up from RULES and RECIPIENTS.
+#
+# A RULE is a filter made from the PAGE where a host
+# is located in XYmon; the HOST name, the SERVICE name,
+# the COLOR of the status, the TIME of day, and the
+# DURATION of the event.
+#
+# A RECIPIENT can be a MAIL address, or a SCRIPT.
+#
+# Recipients can also have rules associated with them,
+# that modify the rules for a single recipient, e.g.
+# you can define a rule for alerting, then add an
+# extra criteria e.g. so a single recipient does not get
+# alerted until after 20 minutes.
+#
+# A sample rule:
+#
+# HOST=www.foo.com SERVICE=http
+# MAIL webadmin@foo.com REPEAT=20 RECOVERED
+# MAIL cio@foo.com DURATION>60 COLOR=red
+# SCRIPT /usr/local/bin/sendsms 1234567890 FORMAT=SMS
+#
+# The first line sets up a rule that catches alerts
+# for the host "www.foo.com" and the "http" service.
+# There are three recipients for these alerts: The first
+# one is the "webadmin@foo.com" - they get alerted
+# immediately when the status goes into an alert state,
+# and the alert is repeated every 20 minutes until it
+# recovers. When it recovers, a message is sent about
+# the recovery.
+#
+# The second recipient is "cio@foo.com". He gets alerted
+# only when the service goes "red" for more than 60 minutes.
+#
+# The third recipient is a script, "/usr/local/bin/sendsms".
+# The real recipient is "1234567890", but it is handled
+# by the script - the script receives a set of environment
+# variables with the details about the alert, including the
+# real recipient. The alert message is preformatted for
+# an SMS recipient.
+#
+# You can use Perl-compatible "regular expressions" for
+# the PAGE, HOST and SERVICE definitions, by putting a "%"
+# in front of the regex. E.g.
+#
+# HOST=%^www.*
+# MAIL webadmin@foo.com EXHOST=www.testsite.foo.com
+#
+# This sets up a rule so that alerts from any hostname
+# beginning with "www" goes to "webadmin@foo.com", EXCEPT
+# alerts from "www.testsite.foo.com"
+#
+# The following keywords are recognized:
+# PAGE - rule matching an alert by the name of the
+# page in XYmon. This is the name following
+# the "page", "subpage" or "subparent" keyword
+# in the hosts.cfg file.
+# EXPAGE - rule excluding an alert if the pagename matches.
+# HOST - rule matching an alert by the hostname.
+# EXHOST - rule excluding an alert by matching the hostname.
+# SERVICE - rule matching an alert by the service name.
+# EXSERVICE - rule excluding an alert by matching the hostname.
+# GROUP - rule matching an alert by the group ID.
+# (Group ID's are associated with a status through the
+# analysis.cfg configuration).
+# EXGROUP - rule excluding an alert by matching the group ID.
+# COLOR - rule matching an alert by color. Can be "red",
+# "yellow", or "purple".
+# TIME - rule matching an alert by the time-of-day. This
+# is specified as the DOWNTIME timespecification
+# in the hosts.cfg file (see hosts.cfg(5)).
+# DURATION - Rule matcing an alert if the event has lasted
+# longer/shorter than the given duration. E.g.
+# DURATION>10 (lasted longer than 10 minutes) or
+# DURARION<30 (only sends alerts the first 30 minutes).
+# RECOVERED - Rule matches if the alert has recovered from an
+# alert state.
+# NOTICE - Rule matches if the message is a "notify" message
+# (typically sent when a status is enabled or disabled).
+# MAIL - Recipient who receives an e-mail alert. This takes
+# one parameter, the e-mail address.
+# SCRIPT - Recipient that invokes a script. This takes two
+# parameters: The script filename, and the recipient
+# that gets passed to the script.
+# FORMAT - format of the text message with the alert. Default
+# is "TEXT" (suitable for e-mail alerts). "SMS" is
+# a short message with no subject for SMS alerts.
+# "SCRIPT" is a brief message template for scripts.
+# REPEAT - How often an alert gets repeated, in minutes.
+# STOP - Valid for a recipient: If this recipient gets an
+# alert, recipients further down in alerts.cfg
+# are ignored.
+# UNMATCHED - Matches if no alerts have been sent so far.
+#
+#
+# Script get the following environment variables pre-defined so
+# that they can send a meaningful alert:
+#
+# BBCOLORLEVEL - The color of the alert: "red", "yellow" or "purple"
+# BBALPHAMSG - The full text of the status log triggering the alert
+# ACKCODE - The "cookie" that can be used to acknowledge the alert
+# RCPT - The recipient, from the SCRIPT entry
+# BBHOSTNAME - The name of the host that the alert is about
+# MACHIP - The IP-address of the host that has a problem
+# BBSVCNAME - The name of the service that the alert is about
+# BBSVCNUM - The numeric code for the service. From SVCCODES definition.
+# BBHOSTSVC - HOSTNAME.SERVICE that the alert is about.
+# BBHOSTSVCCOMMAS - As BBHOSTSVC, but dots in the hostname replaced with commas
+# BBNUMERIC - A 22-digit number made by BBSVCNUM, MACHIP and ACKCODE.
+# RECOVERED - Is "1" if the service has recovered.
+# DOWNSECS - Number of seconds the service has been down.
+# DOWNSECSMSG - When recovered, holds the text "Event duration : N" where
+# N is the DOWNSECS value.
-HOST=* SERVICE=disk
- 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
+HOST=* SERVICE=func
+ SCRIPT /home/xymon/server/bin/hobbit_notify.sh dummy_notice FORMAT=plain DURATION>4h REPEAT=48h COLOR=red
+
+HOST=* SERVICE=* EXSERVICE=conn
+ SCRIPT /home/xymon/server/bin/hobbit_notify.sh dummy_notice FORMAT=plain DURATION>4h REPEAT=12h COLOR=red
+ SCRIPT /home/xymon/server/bin/login_notify.sh dummy_notice FORMAT=plain DURATION>5m REPEAT=5m COLOR=!purple RECOVERED
+
diff --git a/abs/core/xymon/analysis.cfg b/abs/core/xymon/analysis.cfg
index 0de317b..460d157 100644
--- a/abs/core/xymon/analysis.cfg
+++ b/abs/core/xymon/analysis.cfg
@@ -317,7 +317,7 @@
# the alert module, which can then use it to control who gets an alert when
# a failure occurs. E.g. the following associates the "httpd" process check
# with the "web" group, and the "sshd" check with the "admins" group:
-# PROC httpd 5 GROUP=web
+# PROC httpd ?5 GROUP=web
# PROC sshd 1 GROUP=admins
# In the alerts.cfg file, you could then have rules like
# GROUP=web
@@ -348,81 +348,98 @@
HOST=_MASTERBACKEND_
- PROC sshd 1
- PROC lighttpd
- PROC hobbitd
- PROC crond
- PROC mysql
- PROC mythbackend
- DISK * 95 99
- PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
- PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
+ PROC sshd 1
+ PROC lighttpd
+ PROC xymond
+ PROC crond
+ PROC mysql
+ PROC mythbackend
+ PROC msg_daemon.py
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 95 99
+ PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
+ PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
HOST=_MASTERFRONTEND_
- PROC mythfrontend
- PROC sshd 1
- PROC lighttpd
- PROC hobbitd
- PROC crond
- PROC mysql
- PROC mythbackend
- DISK * 95 99
- PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
- PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
- PORT "LOCAL=%([.:]5000)$" state=LISTEN TEXT=ghosd
- PORT "LOCAL=%([.:]5001)$" state=LISTEN TEXT=ghosd
+ PROC mythfrontend 1 5 yellow
+ PROC sshd 1
+ PROC lighttpd
+ PROC xymond
+ PROC crond
+ PROC mysql
+ PROC mythbackend
+ PROC msg_daemon.py
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 95 99
+ PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
+ PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
+
HOST=_FRONTEND_
- PROC sshd 1
- PROC crond
- PROC mythfrontend
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
- PORT "LOCAL=%([.:]5000)$" state=LISTEN TEXT=ghosd
- PORT "LOCAL=%([.:]5001)$" state=LISTEN TEXT=ghosd
+ PROC sshd 1
+ PROC crond
+ PROC mythfrontend 1 5 yellow
+ PROC msg_daemon.py
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
HOST=_SLAVEBACKEND_
- PROC sshd 1
- PROC crond
- PROC mythbackend
- DISK * 95 99
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
+ PROC sshd 1
+ PROC crond
+ PROC mythbackend
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 95 99
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
HOST=_SLAVEFRONTEND_
- PROC sshd 1
- PROC lighttpd
- PROC hobbitd
- PROC crond
- PROC mythbackend
- PROC mythfrontend
- DISK * 95 99
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
- PORT "LOCAL=%([.:]5000)$" state=LISTEN TEXT=ghosd
- PORT "LOCAL=%([.:]5001)$" state=LISTEN TEXT=ghosd
+ PROC sshd 1
+ PROC lighttpd
+ PROC hobbitd
+ PROC crond
+ PROC mythbackend
+ PROC mythfrontend 1 5 yellow
+ PROC msg_daemon.py
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 95 99
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
+
HOST=_STANDALONE_
- PROC sshd 1
- PROC lighttpd
- PROC hobbitd
- PROC crond
- PROC mysql
- PROC mythbackend
- DISK * 95 99
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
- PORT "LOCAL=%([.:]5000)$" state=LISTEN TEXT=ghosd
- PORT "LOCAL=%([.:]5001)$" state=LISTEN TEXT=ghosd
- PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
- PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
- PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
+ PROC mythfrontend 1 5 yellow
+ PROC sshd 1
+ PROC lighttpd
+ PROC xymond
+ PROC crond
+ PROC mysql
+ PROC mythbackend
+ PROC msg_daemon.py
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 95 99
+ PORT "LOCAL=%([.:]80)$" state=LISTEN TEXT=http
+ PORT "LOCAL=%([.:]1337)$" state=LISTEN TEXT=cgi
+ PORT "LOCAL=%([.:]22)$" state=LISTEN TEXT=ssh
DEFAULT
- # These are the built-in defaults.
- UP 1h
- LOAD 5.0 10.0
- DISK * 99 100
- MEMPHYS 100 101
- MEMSWAP 50 80
- MEMACT 90 97
+ # These are the built-in defaults.
+ UP 1h
+ LOAD 5.0 10.0
+ DISK %^/cdrom.* IGNORE
+ DISK %^/mnt.* IGNORE
+ DISK %^/media.* IGNORE
+ DISK * 99 100
+ MEMPHYS 100 101
+ MEMSWAP 50 80
+ MEMACT 90 97
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py
index d643044..b5ad72a 100644
--- a/abs/core/xymon/hbnotes.py
+++ b/abs/core/xymon/hbnotes.py
@@ -28,7 +28,7 @@ def create_dot_file():
result = cursor.fetchall()
frontonly="_FRONTEND_"
masterbackend="_MASTERBACKEND_"
- masterbacked_w_fe="_MASTERFE_"
+ masterbacked_w_fe="_MASTERFRONTEND_"
slave_w_fe="_SLAVEFE_"
slave="_SLAVEBACKEND_"
stand_alone="_STANDALONE_"
@@ -166,7 +166,8 @@ def create_dot_file():
# cmd="/usr/bin/circo -Tpng -o/data/srv/httpd/htdocs/xymon/gifs/network.png " + dotfilename
results=os.popen(cmd,'r')
-
+ return frontonly,masterbackend,masterbacked_w_fe,slave_w_fe,slave,stand_alone
+
@@ -458,68 +459,73 @@ function Do_it ()
file.write(string)
-def main(argv):
- create_dot_file()
- create_notes()
-
+def create_hobbit_analysis(frontonly,
+ masterbackend,
+ masterbacked_w_fe,
+ slave_w_fe,
+ slave,
+ stand_alone):
-#------------------------------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
+ hobbitfile="/home/xymon/server/etc/analysis.cfg"
+ hobbitf=open(hobbitfile,'r')
+ hobbitconfig=hobbitf.readlines()
+ hobbitf.close()
+ try:
+ 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)
+ hobbitf.close()
+ except:
+ print "problem writing analysis.cfg"
+def main(argv):
+ frontonly,masterbackend,masterbacked_w_fe,slave_w_fe,slave,stand_alone = create_dot_file()
+ create_notes()
+ create_hobbit_analysis(frontonly,
+ masterbackend,
+ masterbacked_w_fe,
+ slave_w_fe,
+ slave,
+ stand_alone)
+
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 8b38fc6..ac56903 100644..100755
--- a/abs/core/xymon/hobbit_myth_data.py
+++ b/abs/core/xymon/hobbit_myth_data.py
@@ -10,6 +10,12 @@ import sys,os
from MythTV import MythBE,MythDB,MythLog
+#0=green
+#1=yellow
+#2=red
+
+
+
BBLINE = ''
BBCOLOR="green"
DATE = time.strftime("%a %b %d %H:%M:%S %Z %Y", time.localtime(time.time()))
@@ -25,10 +31,35 @@ if os.environ['MACHINE']:
#print os.environ['MACHINE']
MACHINE=os.environ['MACHINE']
+#MACHINE='a'
+#BB='b'
+#BBDISP='12'
+
+
+def set_color_code (current_color, new_color):
+ if new_color > current_color:
+ color = new_color
+ else:
+ color = current_color
+ return color
+
+def set_color(color_code):
+ color = "unknown"
+ if color_code == 0 :
+ color = "green"
+ elif color_code == 1 :
+ color = "yellow"
+ elif color_code == 2 :
+ color = "red"
+
+ return color
+
+
def check_mtc(mtc_file):
+ line=''
try:
infile = open(mtc_file, 'r')
except(IOError), e:
@@ -60,56 +91,74 @@ def find_data_left():
results=cursor.fetchall()[0][0]
days_left = (results - today).days
except:
- days_left = "Undetermined "
+ days_left = "Undetermined"
return days_left
now = datetime.datetime.now()
-date = "%s-%s-%s" %(now.year, now.month, now.day)
+#date = "%s-%s-%s" %(now.year, now.month, now.day)
+date = (now.strftime('%Y-%m-%d'))
+#2013-12-03
mtc_file = "/var/log/%s/myth_mtc.log" %date
mtc=check_mtc(mtc_file)
num_days=find_data_left()
-
+current_color=0
if mtc:
- BBCOLOR="green"
- msg="\n Maintenance script ran ok \n %s \n " %mtc_file
+ current_color = set_color_code(current_color,0)
+ msg="\n Maintenance script was successful \n Log file: %s\n " %mtc_file
else:
- BBCOLOR ="yellow"
- msg="\n * Maintenance script didn't run. \n %s \n" %mtc_file
+ current_color = set_color_code(current_color,2)
+ msg='''
+ ** Maintenance script did not run. **
+ BACKUP FILE WAS NOT CREATED
+
+ The system may have been busy
+ Log file: %s \n''' %mtc_file
if num_days == 1 :
- BBCOLOR="yellow"
- msg+="\n * Only 1 day of guide data left"
+ current_color = set_color_code(current_color,1)
+ msg+="\n ** Only 1 day of guide data left **"
elif num_days == 0 :
- BBCOLOR="red "
- msg+="\n * No guide data available"
+ current_color = set_color_code(current_color,2)
+ msg+="\n ** No guide data available **"
elif num_days == -100 :
- BBCOLOR="red"
- msg+="\n ** Could not connect to database!"
+ current_color = set_color_code(current_color,2)
+ msg+="\n ** Could not connect to database ** "
+
+elif num_days == "Undetermined" :
+ current_color = set_color_code(current_color,1)
+ msg+="\n ** Could not determine how many days of guide data are available ** "
+
else:
data_check = True
- BBCOLOR="green"
+ current_color = set_color_code(current_color,0)
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"
+ current_color = set_color_code(current_color,1)
+ msg+="\n\n ** Remote backup jobs are queued **"
else:
msg+="\n\n No remote backup jobs queued"
-BBLINE=msg
+BBLINE = msg
+BBCOLOR = set_color(current_color)
+
LINE = "status " + MACHINE + ".myth_mtc" + " " + BBCOLOR + " " + DATE + " " + BBLINE
cmd = BB + ' ' + BBDISP + ' "' + LINE + '"'
os.system(cmd)
+#print cmd
+#print BBLINE
+#print BBCOLOR
+
+
sys.exit(0)
diff --git a/abs/core/xymon/hobbit_notify.sh b/abs/core/xymon/hobbit_notify.sh
index 7569e2a..26b789f 100644
--- a/abs/core/xymon/hobbit_notify.sh
+++ b/abs/core/xymon/hobbit_notify.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+. /etc/systemconfig
#
# BBCOLORLEVEL - The color of the alert: "red", "yellow" or "purple"
# BBALPHAMSG - The full text of the status log triggering the alert
@@ -14,35 +15,65 @@
# RECOVERED - Is "1" if the service has recovered.
# DOWNSECS - Number of seconds the service has been down.
# DOWNSECSMSG - When recovered, holds the text "Event duration : N" where
-echo $BBCOLORLEVEL > /tmp/hobbitout
-echo $BBALPHAMSG >>/tmp/hobbitout
-echo $RCPT >>/tmp/hobbitout
-echo $BBHOSTNAME >>/tmp/hobbitout
-echo $BBSVCNAME >>/tmp/hobbitout
-echo $BBHOSTSVC >>/tmp/hobbitout
+
+
+# echo $BBCOLORLEVEL > /tmp/hobbitout
+# echo $BBALPHAMSG >>/tmp/hobbitout
+# echo $RCPT >>/tmp/hobbitout
+# echo $BBHOSTNAME >>/tmp/hobbitout
+# echo $BBSVCNAME >>/tmp/hobbitout
+# echo $BBHOSTSVC >>/tmp/hobbitout
#BBCOLORLEVEL=red
#BBCOLORLEVEL=yellow
#BBALPHAMSG="vmtest:disk red [751147]"
-#BBHOSTNAME="vmtest"
+#BBHOSTNAME="testcraa"
#BBSVCNAME="disk"
+#BBSVCNAME="func"
#BBHOSTSVC="vmtest.disk"
-if [ x$BBSVCNAME = xdisk ]
-then
- case $BBCOLORLEVEL in
- red )
- /usr/bin/notify.py ALT "$BBHOSTNAME disk is full"
- ;;
- yellow )
+#/usr/LH/bin/msg_client.py --msg "$BBCOLORLEVEL\n$BBHOSTSVC"
+#/usr/bin/func "*" call msg display
+
+function msg_func_out() {
+ /usr/bin/func "*" call msg display "${1}"
+}
+
+function msg_local_out() {
+
+ /usr/LH/bin/msg_client.py --msg "${1}"
+
+ }
+
- /usr/bin/notify.py PHN "$BBHOSTNAME disk almost full "
- ;;
- esac
-fi
+case x$BBSVCNAME in
+ xdisk)
+ case $BBCOLORLEVEL in
+ red )
+ msg_func_out "$BBHOSTNAME disk is at 95% full or greater|alert"
+ ;;
+ yellow )
+ msg_func_out "$BBHOSTNAME disk is almost full"
+ ;;
+ esac
+ ;;
+
+ xfunc)
+ if [ "x$hostname" = "x$BBHOSTNAME" ]
+ then
+ msg_local_out "System can not communicate with itself (func) |alert"
+ else
+ msg_func_out "$hostname can not communicate with $BBHOSTNAME (func)|alert"
+ fi
+ ;;
+ *)
+ #catch all for everything else
+ msg_func_out "Condition $BBCOLORLEVEL $BBSVCNAME on $BBHOSTNAME\nSee the system health webpage.|alert"
+ ;;
+esac
diff --git a/abs/core/xymon/login_notify.sh b/abs/core/xymon/login_notify.sh
new file mode 100644
index 0000000..8c17342
--- /dev/null
+++ b/abs/core/xymon/login_notify.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+. /etc/systemconfig
+#
+# BBCOLORLEVEL - The color of the alert: "red", "yellow" or "purple"
+# BBALPHAMSG - The full text of the status log triggering the alert
+# ACKCODE - The "cookie" that can be used to acknowledge the alert
+# RCPT - The recipient, from the SCRIPT entry
+# BBHOSTNAME - The name of the host that the alert is about
+# MACHIP - The IP-address of the host that has a problem
+# BBSVCNAME - The name of the service that the alert is about
+# BBSVCNUM - The numeric code for the service. From SVCCODES definition.
+# BBHOSTSVC - HOSTNAME.SERVICE that the alert is about.
+# BBHOSTSVCCOMMAS - As BBHOSTSVC, but dots in the hostname replaced with commas
+# BBNUMERIC - A 22-digit number made by BBSVCNUM, MACHIP and ACKCODE.
+# RECOVERED - Is "1" if the service has recovered.
+# DOWNSECS - Number of seconds the service has been down.
+# DOWNSECSMSG - When recovered, holds the text "Event duration : N" where
+
+# LOGIN_OUT=/tmp/login_out
+# echo $BBCOLORLEVEL >> $LOGIN_OUT
+# echo $BBALPHAMSG >>$LOGIN_OUT
+# echo $RCPT >>$LOGIN_OUT
+# echo $BBHOSTNAME >>$LOGIN_OUT
+# echo $BBSVCNAME >>$LOGIN_OUT
+# echo $BBHOSTSVC >>$LOGIN_OUT
+# echo $BBHOME >> $LOGIN_OUT
+# echo $DOWNSECS >> $LOGIN_OUT
+# echo $RECOVERED >> $LOGIN_OUT
+# echo "----------" >> $LOGIN_OUT
+
+#BBCOLORLEVEL=red
+#BBCOLORLEVEL=yellow
+#BBALPHAMSG="vmtest:disk red [751147]"
+#BBHOSTNAME="testcraa"
+#BBSVCNAME="disk"
+#BBSVCNAME="func"
+#BBHOSTSVC="vmtest.disk"
+
+#bbhome ends up as /home/xymon/server which is why I didn't use it here
+NOTICE_DIR="/home/xymon/var/login_alerts"
+if [ ! -d $NOTICE_DIR ]
+then
+ mkdir $NOTICE_DIR
+fi
+
+if [ "x$RECOVERED" == "x1" ]
+then
+ if [ -f $NOTICE_DIR/$BBHOSTSVC ]
+ then
+ rm -f $NOTICE_DIR/$BBHOSTSVC
+ else
+ echo "$NOTICE_DIR/$BBHOSTSVC is not present, didn't remove it"
+ fi
+else
+ echo "DOWN: $DOWNSECS" > $NOTICE_DIR/$BBHOSTSVC
+ echo "SERVICE: $BBSVCNAME" >> $NOTICE_DIR/$BBHOSTSVC
+ echo "HOST: $BBHOSTNAME" >> $NOTICE_DIR/$BBHOSTSVC
+ echo "ACKCODE: $ACKCODE" >> $NOTICE_DIR/$BBHOSTSVC
+ echo "COLOR: $BBCOLORLEVEL" >> $NOTICE_DIR/$BBHOSTSVC
+ echo "MSG $BBALPHAMSG" >> $NOTICE_DIR/$BBHOSTSVC
+fi
+
+
+