From 653c9fdd68704738da04d233dd7bdc8f25e0eaf8 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Tue, 26 Nov 2013 15:53:44 -0600
Subject: xymon-server:  ignore /cdrom /mnt /media for disk checks. Modify
 hbnotes.py so that it adds hosts to analysis.cfg.  This is needed to define
 the proper checks per host type.

refs #943
---
 abs/core/xymon/PKGBUILD     |  12 ++--
 abs/core/xymon/analysis.cfg | 145 +++++++++++++++++++++++++-------------------
 abs/core/xymon/hbnotes.py   | 130 ++++++++++++++++++++-------------------
 3 files changed, 155 insertions(+), 132 deletions(-)

diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index 0c797ee..a0c603b 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=49
+pkgrel=50
 pkgdesc="Hobbit is a system for monitoring servers and networks. "
 license="GPL"
 arch=('i686' 'x86_64')
@@ -128,17 +128,17 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
          '758cdd9f1ba5ae3e1b42e811172806f3'
          'ee608dcafc050d790e28647a670f6b60'
          'b2f98ac0df013332deedc1efae0a270d'
-         'c31bcb503a227ed5ff7b218581793bfc'
+         '1141fc6f846e91f380bbcdb212b44f7d'
          '0f70e76a164f648f0a4a01110137cb20'
-         'f6921f0413215ae174e81306be80d37f'
+         'b0664f3b38717dce911f59bcbd84e7a4'
          '80d9cfac86c6d96836e6f406e35e7cf5'
          'd210c43fb9ee9ad6cd7648e0c2e0efea'
          '0c808fa12672289f86b0651545381308'
          '0469d775db9fdd18ea95dd41937ada82'
          '0757294eec13771f8e63da23cf066796'
-         '622f400fd098cbc43c203e3210a6694e'
-         '84442377c6e914b65519076bda4e17a4'
-         'd7116dc59319b893e90a26e6beb83994'
+         '6baa410da1dfb86435191f4805186ea7'
+         '81715c58ae495812da0e0f18e2f74c76'
+         '77a542c2fd13468791ef23057ba8e77d'
          'b4e8641e97e6b689dbc634af785e6799'
          'e2844513e2c92e8b5084818f3b2a478d'
          '98e9242ae346f729b14cb195786571f2'
diff --git a/abs/core/xymon/analysis.cfg b/abs/core/xymon/analysis.cfg
index 0de317b..da833e1 100644
--- a/abs/core/xymon/analysis.cfg
+++ b/abs/core/xymon/analysis.cfg
@@ -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
+    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
+    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
+    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
+    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:])
-- 
cgit v0.12

