summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f6f4269)
raw | patch | inline | side by side (parent: f6f4269)
author | Sven Velt <sven@velt.de> | |
Thu, 17 Dec 2009 23:59:30 +0000 (00:59 +0100) | ||
committer | Sven Velt <sven@velt.de> | |
Thu, 17 Dec 2009 23:59:30 +0000 (00:59 +0100) |
Moved config files from examples/ to sample-configs/conf/, new config
files for daemons in sample-configs/
Changed path names in QUICKSTART.de.txt
files for daemons in sample-configs/
Changed path names in QUICKSTART.de.txt
QUICKSTART.de.txt | patch | blob | history | |
examples/nagixsc_debian.conf | [deleted file] | patch | blob | history |
examples/nagixsc_usrlocal.conf | [deleted file] | patch | blob | history |
nagixsc_conf2http.py | patch | blob | history | |
nagixsc_http2nagios.py | patch | blob | history | |
sample-configs/conf/nagixsc_debian.conf | [new file with mode: 0644] | patch | blob |
sample-configs/conf/nagixsc_usrlocal.conf | [new file with mode: 0644] | patch | blob |
sample-configs/conf2http.cfg | [new file with mode: 0644] | patch | blob |
sample-configs/http2nagios.cfg | [new file with mode: 0644] | patch | blob |
diff --git a/QUICKSTART.de.txt b/QUICKSTART.de.txt
index 2bf3728b590eb03c68f86f63ff07258046614498..9d74516fb9b4a7b0418732dff700315caf25a8b7 100644 (file)
--- a/QUICKSTART.de.txt
+++ b/QUICKSTART.de.txt
Zur Zeit wird ein INI-Datei ähnliches Format verwendet. Dies kann sich aber in
Zukunft noch ändern!
-Als Vorlage können die Dateien "examples/nagixsc_debian.conf" (Nagios mit
-Hilfe der Debian-Packages installiert) und "examples/nagixsc_usrlocal.conf"
-(selbst kompiliert nach /usr/local/nagios) dienen.
+Als Vorlage können die Dateien "sample-configs/conf/nagixsc_debian.conf"
+(Nagios mit Hilfe der Debian-Packages installiert) und
+"sample-configs/conf/nagixsc_usrlocal.conf" (selbst kompiliert nach
+/usr/local/nagios) dienen.
Je Rechner, der überwacht werden soll, wird ein Abschnitt in eckigen Klammern
angelegt. Der Abschnittsname entspricht dabei dem Nagios-Hostname. Innerhalb
Zum ersten Test lässt man sich das XML am Besten an der Konsole ausgeben:
-% ./nagixsc_conf2xml.py -e plain -c examples/nagixsc.conf
+% ./nagixsc_conf2xml.py -e plain -c sample-configs/conf/nagixsc.conf
Zur Lesbarkeit wird das Encoding ausgeschaltet ("-e plain"). Dies ist nicht
für den Produktivbetrieb gedacht!
Hat man diese (zur Not geht's natürlich auch mit den Beispielen weiter),
erstellt man nun ein XML, welches zur Weiterverarbeitung geeignet ist:
-% ./nagixsc_conf2xml.py -c examples/nagixsc.conf -o /tmp/nagixsc.xml
+% ./nagixsc_conf2xml.py -c sample-configs/conf/nagixsc.conf -o /tmp/nagixsc.xml
In der Praxis kann man diese XML-Datei auf einen Web-Server legen, damit sie
direkt vom Nagios aus abrufbar ist.
diff --git a/examples/nagixsc_debian.conf b/examples/nagixsc_debian.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-[nagixsc]
-Reserved: For future use
-
-[host1]
-_underscores_at_start: reserved
-_use_section_name_as: host_name in nagios
-_host_check: /usr/lib/nagios/plugins/check_host -H 127.0.0.1
-Disk_Home: /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -m -p /home
-Disk_Root: /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -m -p /
-Load: /usr/lib/nagios/plugins/check_load -w 5,5,5 -c 10,10,10
-
-[host2]
-_host_name: host2.foo.bar
-Procs_Total: /usr/lib/nagios/plugins/check_procs -w 200 -c 250
-Swap: /usr/lib/nagios/plugins/check_swap -w 50% -c 25%
-Users: /usr/lib/nagios/plugins/check_users -w 10 -c 15
-
diff --git a/examples/nagixsc_usrlocal.conf b/examples/nagixsc_usrlocal.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-[nagixsc]
-Reserved: For future use
-
-[host1]
-_underscores_at_start: reserved
-_use_section_name_as: host_name in nagios
-_host_check: /usr/local/nagios/libexec/check_host -H 127.0.0.1
-Disk_Home: /usr/local/nagios/libexec/check_disk -w 10% -c 5% -m -p /home
-Disk_Root: /usr/local/nagios/libexec/check_disk -w 10% -c 5% -m -p /
-Load: /usr/local/nagios/libexec/check_load -w 5,5,5 -c 10,10,10
-
-[host2]
-_host_name: host2.foo.bar
-Procs_Total: /usr/local/nagios/libexec/check_procs -w 200 -c 250
-Swap: /usr/local/nagios/libexec/check_swap -w 50% -c 25%
-Users: /usr/local/nagios/libexec/check_users -w 10 -c 15
-
diff --git a/nagixsc_conf2http.py b/nagixsc_conf2http.py
index 995fa453f85e288958390823fbda4a2be7883c41..941fa1ccb122438ac01fd8b68df70dbed6d442bd 100755 (executable)
--- a/nagixsc_conf2http.py
+++ b/nagixsc_conf2http.py
#!/usr/bin/python
import BaseHTTPServer
+import ConfigParser
import base64
+import optparse
import os
import re
import subprocess
+import sys
try:
from hashlib import md5
except ImportError:
from md5 import md5
-config = { 'ip': '',
- 'port': 15666,
- }
+##############################################################################
-users = { 'nagixsc': '019b0966d98fb71d1a4bc4ca0c81d5cc', # PW: nagixsc
- }
+parser = optparse.OptionParser()
-CONFDIR='./examples'
-C2X='./nagixsc_conf2xml.py'
+parser.add_option('-c', '', dest='cfgfile', help='Config file')
+
+parser.set_defaults(cfgfile='conf2http.cfg')
+
+(options, args) = parser.parse_args()
+
+cfgread = ConfigParser.SafeConfigParser()
+cfgread.optionxform = str # We need case-sensitive options
+cfg_list = cfgread.read(options.cfgfile)
+
+if cfg_list == []:
+ print 'Config file "%s" could not be read!' % options.cfgfile
+ sys.exit(1)
+
+config = {}
+try:
+ config['ip'] = cfgread.get('server', 'ip')
+ config['port'] = cfgread.getint('server', 'port')
+
+ config['conf_dir'] = cfgread.get('server', 'conf_dir')
+ config['conf2xml_cmdline'] = cfgread.get('server', 'conf2xml_cmdline')
+
+except ConfigParser.NoOptionError, e:
+ print 'Config file error: %s ' % e
+ sys.exit(1)
+
+users = {}
+for u in cfgread.options('users'):
+ users[u] = cfgread.get('users', u)
+
+##############################################################################
class Conf2HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
- cmdline = C2X
+ cmdline = config['conf2xml_cmdline']
path = self.path.split('/')
if configfile:
configfile += '.conf'
- cmdline += ' -c ' + os.path.join(CONFDIR, configfile)
+ cmdline += ' -c ' + os.path.join(config['conf_dir'], configfile)
if host:
cmdline += ' -H %s' % host
diff --git a/nagixsc_http2nagios.py b/nagixsc_http2nagios.py
index e0a639b3218cd6595624b13cbe46fb358ddf4052..085609d8d7fb8e12d9e83ac9c23d6fa83ff0af84 100755 (executable)
--- a/nagixsc_http2nagios.py
+++ b/nagixsc_http2nagios.py
#!/usr/bin/python
import BaseHTTPServer
+import ConfigParser
import base64
import cgi
+import optparse
import os
import re
import subprocess
+import sys
try:
from hashlib import md5
except ImportError:
from md5 import md5
-config = { 'ip': '',
- 'port': 15667,
- }
+##############################################################################
-users = { 'nagixsc': '019b0966d98fb71d1a4bc4ca0c81d5cc', # PW: nagixsc
- }
+parser = optparse.OptionParser()
-XMLFILESIZE=102400
-X2N='./nagixsc_xml2nagios.py -O passive -vvv -f -'
+parser.add_option('-c', '', dest='cfgfile', help='Config file')
+
+parser.set_defaults(cfgfile='http2nagios.cfg')
+
+(options, args) = parser.parse_args()
+
+cfgread = ConfigParser.SafeConfigParser()
+cfgread.optionxform = str # We need case-sensitive options
+cfg_list = cfgread.read(options.cfgfile)
+
+if cfg_list == []:
+ print 'Config file "%s" could not be read!' % options.cfgfile
+ sys.exit(1)
+
+config = {}
+try:
+ config['ip'] = cfgread.get('server', 'ip')
+ config['port'] = cfgread.getint('server', 'port')
+
+ config['max_xml_file_size'] = cfgread.get('server', 'max_xml_file_size')
+ config['xml2nagios_cmdline'] = cfgread.get('server', 'xml2nagios_cmdline')
+
+except ConfigParser.NoOptionError, e:
+ print 'Config file error: %s ' % e
+ sys.exit(1)
+
+users = {}
+for u in cfgread.options('users'):
+ users[u] = cfgread.get('users', u)
+
+##############################################################################
class HTTP2NagiosHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(self):
- cmdline = X2N
+ cmdline = config['xml2nagios_cmdline']
# Check Basic Auth
try:
diff --git a/sample-configs/conf/nagixsc_debian.conf b/sample-configs/conf/nagixsc_debian.conf
--- /dev/null
@@ -0,0 +1,17 @@
+[nagixsc]
+Reserved: For future use
+
+[host1]
+_underscores_at_start: reserved
+_use_section_name_as: host_name in nagios
+_host_check: /usr/lib/nagios/plugins/check_host -H 127.0.0.1
+Disk_Home: /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -m -p /home
+Disk_Root: /usr/lib/nagios/plugins/check_disk -w 10% -c 5% -m -p /
+Load: /usr/lib/nagios/plugins/check_load -w 5,5,5 -c 10,10,10
+
+[host2]
+_host_name: host2.foo.bar
+Procs_Total: /usr/lib/nagios/plugins/check_procs -w 200 -c 250
+Swap: /usr/lib/nagios/plugins/check_swap -w 50% -c 25%
+Users: /usr/lib/nagios/plugins/check_users -w 10 -c 15
+
diff --git a/sample-configs/conf/nagixsc_usrlocal.conf b/sample-configs/conf/nagixsc_usrlocal.conf
--- /dev/null
@@ -0,0 +1,17 @@
+[nagixsc]
+Reserved: For future use
+
+[host1]
+_underscores_at_start: reserved
+_use_section_name_as: host_name in nagios
+_host_check: /usr/local/nagios/libexec/check_host -H 127.0.0.1
+Disk_Home: /usr/local/nagios/libexec/check_disk -w 10% -c 5% -m -p /home
+Disk_Root: /usr/local/nagios/libexec/check_disk -w 10% -c 5% -m -p /
+Load: /usr/local/nagios/libexec/check_load -w 5,5,5 -c 10,10,10
+
+[host2]
+_host_name: host2.foo.bar
+Procs_Total: /usr/local/nagios/libexec/check_procs -w 200 -c 250
+Swap: /usr/local/nagios/libexec/check_swap -w 50% -c 25%
+Users: /usr/local/nagios/libexec/check_users -w 10 -c 15
+
diff --git a/sample-configs/conf2http.cfg b/sample-configs/conf2http.cfg
--- /dev/null
@@ -0,0 +1,11 @@
+[server]
+ip: 0.0.0.0
+port: 15666
+
+conf2xml_cmdline: ./nagixsc_conf2xml.py
+conf_dir: ./sample-configs/conf
+
+[users]
+; echo -n "Password" | md5sum -
+nagixsc: 019b0966d98fb71d1a4bc4ca0c81d5cc ; PW: nagixsc
+
diff --git a/sample-configs/http2nagios.cfg b/sample-configs/http2nagios.cfg
--- /dev/null
@@ -0,0 +1,11 @@
+[server]
+ip: 0.0.0.0
+port: 15667
+
+max_xml_file_size: 102400
+xml2nagios_cmdline: ./nagixsc_xml2nagios.py -O passive -vvv -f -
+
+[users]
+; echo -n "Password" | md5sum -
+nagixsc: 019b0966d98fb71d1a4bc4ca0c81d5cc ; PW: nagixsc
+