Module: check_mk
Branch: master
Commit: cd3c8da303334f90d8f2ff1ff71cea8ca18cd361
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cd3c8da303334f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Nov 29 15:49:28 2010 +0100
wato: create logfile wato-file specific
---
LIESMICH.wato | 56 ++++++---------------------------------------------
web/htdocs/wato.py | 22 +++++++++++---------
2 files changed, 19 insertions(+), 59 deletions(-)
diff --git a/LIESMICH.wato b/LIESMICH.wato
index 1e7281f..7f1b8da 100644
--- a/LIESMICH.wato
+++ b/LIESMICH.wato
@@ -1,56 +1,14 @@
-* Es fehlt noch SNMP. Keine Ahnung, wie ich das am besten umsetze
-
-Inventursteuerung heute
-
-check_mk -I tcp --> Alle TCP Checks
-check_mk -I snmp --> Alle SNMP Checks
-
-Inventurcheck: Prüft alle TCP Checks (falls tag snmp fehlt) und
-alle SNMP Checks, von denen der Host schon mindestens einen hat.
--> irgendwie doof.
-
-Besser wäre es, systematischer Tags einzuführen:
-
-snmp: Host wird per SNMP angesprochen
-tcp: Host wird per TCP angesprochen
-ping: Host wird nur angepingt (kein TCP und kein SNMP)
-tcp+snmp: Host wird per TCP und SNMP angesprochen
-
-gar kein Tag: gleichbedeutend mit tcp
-
-der Inventurcheck wird das berücksichtigen und gleichzeitig
-die Beschränkung aufheben, dass nur nach schon bestehenden
-Checks gesucht wird.
-
-
-Umsetzung:
-
-Erst Funktionen:
-
-is_snmp_host() --> hat Tag 'snmp'
-is_tcp_host() --> hat *nicht* 'ping' oder 'snmp' oder hat 'tcp'
-is_ping_host() --> hat 'ping' ( bzw. ist weder snmp_host noch tcp_host )
-
-Beim Generieren der Services wird aber der 'PING' unabhängig von
-den Tags erzeugt, sondern immer dann, wenn kein Service eingerichtet ist.
-
-Jetzt könnte man den Aufruf von check_mk -I abwandeln. Man könnte das
-tcp oder snmp weglassen und stattdessen nach den Tags gehen.
-
-check_mk -I zbghora50 --> diesen Host inventurisieren, je nach Tag-Lage
-check_mk --checks df,mem.used -I zbghora50 --> Checktypen explizit angeben
-check_mk --checks snmp -I zbghora50 --> Alle snmp checks (Warnung, falls Tags snmp bei dem Host fehlt)
-
-Die Konfigurationsprüfung prüft folgendes:
-
-Wenn ein Host SNMP Checks hat, dann muss es auch ein SNMP-Host sein.
-Gleiches gilt für TCP.
-
-WICHTIG FUER DIE DOKU:
SNMP Hosts *müssen* das Tag snmp bekommen - sonst geht garnichts. Keine Inventur.
Auch nicht mit expliziten Checks. Nichts.
* Doku
+* Logfiles pro Dateiname
+* Berechtigungen für nicht-OMD bzw. OMD 'shared'
+ * check_mk --automation als welcher Benutzer?
+ * check_mk -R ==> check_mk --automation restart
+ * Rechte für die conf.d/hirni.mk
+
+
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 5593e2c..55bebce 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1,9 +1,6 @@
#!/usr/bin/python
# encoding: utf-8
-# TODO: Ein Logfile pro filename anlegen, z.B. mit Unterverzeichnis
-# var/web/wato/windows/audit.log
-
# -----------------------------------------------------------------
# ___ _ _
# |_ _|_ __ (_) |_
@@ -29,7 +26,7 @@ config.declare_permission("use_wato",
"Only with this permission, users are allowed to use Check_MK web configuration GUI.",
[ "admin", ])
-conf_dir = defaults.var_dir + "/wato/"
+conf_dir = defaults.var_dir + "/wato"
# -----------------------------------------------------------------
# __ __ _
@@ -159,14 +156,15 @@ def mode_index(phase):
odd = odd == "odd" and "even" or "odd"
- html.write('<tr class="data %s0"><td><a href="%s">%s</a></td>' %
- (odd, edit_url, hostname))
+ html.write('<tr class="data %s0">' % odd)
+
html.write("<td>")
html.buttonlink(edit_url, "Edit")
html.buttonlink(services_url, "Services")
html.buttonlink(clone_url, "Clone")
html.buttonlink(delete_url, "Delete")
html.write("</td>")
+ html.write('<td><a href="%s">%s</a></td>' % (edit_url, hostname))
html.write("<td>%s</td>" % (alias and alias or ""))
tdclass = ""
if not ipaddress:
@@ -452,9 +450,11 @@ def mode_inventory(phase, firsttime):
#
# -----------------------------------------------------------------
-def log_entry(hostname, action, message, g_filename):
+def log_entry(hostname, action, message, logfilename):
make_nagios_directory(conf_dir)
- log_file = conf_dir + g_filename
+ log_dir = conf_dir + "/" + g_filename
+ make_nagios_directory(log_dir)
+ log_file = log_dir + "/" + logfilename
create_user_file(log_file, "a").write("%d %s %s %s\n" %
(int(time.time()), html.req.user, action, message))
@@ -469,12 +469,12 @@ def log_pending(hostname, what, message):
def log_commit_pending():
- pending = conf_dir + "pending.log"
+ pending = conf_dir + "/" + g_filename + "/pending.log"
if os.path.exists(pending):
os.remove(pending)
def parse_audit_log(what):
- path = "%s%s.log" % (conf_dir, what)
+ path = "%s/%s/%s.log" % (conf_dir, g_filename, what)
if os.path.exists(path):
entries = []
for line in file(path):
@@ -573,6 +573,8 @@ def check_filename():
filename = html.var("filename")
if not filename:
raise MKGeneralException("You called this page without a filename!")
+ if '/' in filename:
+ raise MKGeneralException("You called this page with an invalid filename!")
# Get alias (title) for filename
title = None
Module: check_mk
Branch: master
Commit: c5206f3f1ecc1811938cf48def5b6d2018048351
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c5206f3f1ecc18…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Nov 29 17:54:57 2010 +0100
wato: sudo setup for setup.sh
---
scripts/setup.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/scripts/setup.sh b/scripts/setup.sh
index e43740e..654306e 100755
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -284,6 +284,12 @@ that need to be writable by the Nagios user (which is running check_mk
in check mode). Please specify the user that should own those
directories"
+ask_dir -d wwwuser www-data www-data "User of Apache process" \
+ "Check_MK WATO (Web Administration Tool) needs a sudo configuration,
+such that Apache can run certain commands as $(id -un). If you specify
+the correct user of the apache process here, then we can create a valid
+sudo configuration for you later:"
+
ask_dir -d wwwgroup nagios $(id -un) "Common group of Nagios+Apache" \
"Check_mk creates files and directories while running as $nagiosuser.
Some of those need to be writable by the user that is running the webserver.
@@ -337,7 +343,7 @@ Please specify the complete path (dir + filename) of check_icmp"
ask_title "Integration with Apache"
# -------------------------------------------------------------------
-ask_dir url_prefix / / "URL Prefix for Multisite and addons" \
+ask_dir url_prefix / / "URL Prefix for Web addons" \
"Usually the Multisite GUI is available at /check_mk/ and PNP4Nagios
is located at /pnp4nagios/. In some cases you might want to define some
prefix in order to be able to run more instances of Nagios on one host.
@@ -378,7 +384,7 @@ Those templates make the history graphs look nice. PNP4Nagios
expects such templates in the directory pnp/templates in your
document root for static web pages"
-ask_dir pnprraconf /usr/share/$NAME/pnp-rraconf $HOMEBASEDIR/pnp-rraconf "RRA configuration for PNP4Nagios" \
+ask_dir pnprraconf /usr/share/$NAME/pnp-rraconf $HOMEBASEDIR/pnp-rraconf "RRA config for PNP4Nagios" \
"Check_MK ships RRA configuration files for its checks that
can be used by PNP when creating the RRDs. Per default, PNP
creates RRD such that for each variable the minimum, maximum
@@ -463,7 +469,7 @@ nagios_command_pipe_path = '$nagpipe'
nagios_status_file = '$nagios_status_file'
nagios_conf_dir = '$nagconfdir'
nagios_user = '$nagiosuser'
-logwatch_notes_url = '$url_prefix/check_mk/logwatch.py?host=%s&file=%s'
+logwatch_notes_url = '${url_prefix}check_mk/logwatch.py?host=%s&file=%s'
www_group = '$wwwgroup'
nagios_config_file = '$nagios_config_file'
nagios_startscript = '$nagios_startscript'
@@ -475,10 +481,11 @@ web_dir = '$web_dir'
livestatus_unix_socket = '$livesock'
livebackendsdir = '$livebackendsdir'
url_prefix = '$url_prefix'
-pnp_url = '$url_prefix/pnp4nagios/'
+pnp_url = '${url_prefix}pnp4nagios/'
pnp_templates_dir = '$pnptemplates'
pnp_rraconf_dir = '$pnprraconf'
doc_dir = '$docdir'
+check_mk_automation = 'sudo -u $(id -un) $bindir/check_mk --automation'
EOF
}
@@ -528,6 +535,37 @@ EOF
}
+create_sudo_configuration ()
+{
+ # sudo only possible if running as root
+ if [ $UID != 0 ] ; then
+ return
+ fi
+
+ sudoline="$wwwuser ALL = (root) NOPASSWD: $bindir/check_mk --automation *"
+
+ if [ ! -e /etc/sudoers ] ; then
+ echo "You do not have sudo installed. Please install sudo "
+ echo "and add the following line to /etc/sudoers if you want"
+ echo "to use WATO - the Check_MK Web Administration Tool"
+ echo
+ echo "$sudoline"
+ echo
+ echo
+ return
+ fi
+
+ if fgrep -q 'check_mk --automation' /etc/sudoers 2>/dev/null
+ then
+ # already present. Do not touch.
+ return
+ fi
+
+ echo >> /etc/sudoers
+ echo "# Needed for WATO - the Check_MK Web Administration Tool" >> /etc/sudoers
+ echo "$sudoline" >> /etc/sudoers
+}
+
while true
do
if [ -z "$DESTDIR" -a -z "$YES" ] ; then
@@ -660,7 +698,7 @@ do
# inconveniance.
<IfModule mod_python.c>
- Alias $url_prefix/check_mk $web_dir/htdocs
+ Alias ${url_prefix}check_mk $web_dir/htdocs
<Directory $web_dir/htdocs>
AddHandler mod_python .py
PythonHandler index
@@ -695,7 +733,7 @@ and change the path there. Restart Apache afterwards."
</IfModule>
<IfModule !mod_python.c>
- Alias $url_prefix/check_mk $web_dir/htdocs
+ Alias ${url_prefix}check_mk $web_dir/htdocs
<Directory $web_dir/htdocs>
Deny from all
ErrorDocument 403 "<h1>Check_mk: Incomplete Apache2 Installation</h1>\
@@ -711,10 +749,11 @@ EOF
sed -i "s@$web_dir@$web_dir/htdocs@g" $d
fi
done &&
+ create_sudo_configuration &&
if [ -z "$YES" ] ; then
echo -e "Installation completed successfully.\nPlease restart Nagios and Apache in order to update/active check_mk's web pages."
echo
- echo -e "You can access the new Multisite GUI at http://localhost$url_prefix/check_mk/"
+ echo -e "You can access the new Multisite GUI at http://localhost${url_prefix}check_mk/"
fi ||
echo "ERROR!"
exit