Module: check_mk
Branch: master
Commit: f5baf11b86e966ed1e7ca1ef81d96ccd40acb17c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f5baf11b86e966…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 27 12:03:24 2015 +0200
Added download page for the builtin agents/plugins to agent bakery page
---
web/htdocs/wato.py | 88 ++++++++++++++++++++++++++++
web/plugins/wato/agents.py | 110 -----------------------------------
web/plugins/wato/builtin_modules.py | 8 +++
3 files changed, 96 insertions(+), 110 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 257b7cb..791e393 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -18561,6 +18561,87 @@ def mode_icons(phase):
table.end()
#.
+# .--Builtin Agents------------------------------------------------------.
+# | ____ _ _ _ _ _ _ |
+# | | __ ) _ _(_) | |_(_)_ __ / \ __ _ ___ _ __ | |_ ___ |
+# | | _ \| | | | | | __| | '_ \ / _ \ / _` |/ _ \ '_ \| __/ __| |
+# | | |_) | |_| | | | |_| | | | | / ___ \ (_| | __/ | | | |_\__ \ |
+# | |____/ \__,_|_|_|\__|_|_| |_| /_/ \_\__, |\___|_| |_|\__|___/ |
+# | |___/ |
+# +----------------------------------------------------------------------+
+# | Simple download page for the builtin agents and plugins |
+# '----------------------------------------------------------------------'
+
+import glob
+
+def download_table(title, paths):
+ forms.header(title)
+ forms.container()
+ for path in paths:
+ os_path = path
+ relpath = path.replace(defaults.agents_dir+'/', '')
+ filename = path.split('/')[-1]
+
+ size_kb = os.stat(os_path).st_size / 1024.0
+
+ # FIXME: Rename classes etc. to something generic
+ html.write('<div class="ruleset"><div
class="text" style="width:250px;">')
+ html.write('<a href="agents/%s">%s</a>' % (relpath,
filename))
+ html.write('<span class=dots>%s</span></div>' %
("." * 100))
+ html.write('<div class="rulecount"
style="width:30px;">%d KB</div>' % size_kb)
+ html.write('</div></div>')
+ forms.end()
+
+def mode_download_agents(phase):
+ if phase == "title":
+ return _("Builtin Agents")
+
+ elif phase == "buttons":
+ global_buttons()
+ return
+
+ elif phase == "action":
+ return
+
+ html.write('<div class="rulesets">')
+ packed = glob.glob(defaults.agents_dir + "/*.deb") \
+ + glob.glob(defaults.agents_dir + "/*.rpm") \
+ + glob.glob(defaults.agents_dir + "/windows/c*.msi")
+
+ download_table(_("Packed Agents"), packed)
+
+ titles = {
+ '' : _('Linux / Unix Agents'),
+ '/plugins' : _('Linux / Unix Plugins'),
+ '/windows' : _('Windows Agent'),
+ '/windows/plugins' : _('Windows Plugins'),
+ '/windows/mrpe' : _('Windows MRPE Scripts'),
+ '/cfg_examples' : _('Example Configurations'),
+ '/z_os' : _('z/OS'),
+ '/sap' : _('SAP'),
+ '/special' : _('Special Agents'),
+ }
+
+ others = []
+ for root, dirs, files in os.walk(defaults.agents_dir):
+ file_paths = []
+ relpath = root.split('agents')[1]
+ title = titles.get(relpath, relpath)
+ for filename in files:
+ path = root + '/' + filename
+ if path not in packed and 'deprecated' not in path:
+ file_paths.append(path)
+
+ others.append((title, file_paths))
+
+ others.sort()
+
+ for title, file_paths in others:
+ if file_paths:
+ download_table(title, sorted(file_paths))
+ html.write('</div>')
+
+#.
# .--Hooks-&-API---------------------------------------------------------.
# | _ _ _ ___ _ ____ ___ |
# | | | | | ___ ___ | | _____ ( _ ) / \ | _ \_ _| |
@@ -19714,6 +19795,7 @@ modes = {
"bi_edit_rule" : (["bi_rules"], mode_bi_edit_rule),
"bi_edit_aggregation": (["bi_rules"], mode_bi_edit_aggregation),
"icons" : (["icons"], mode_icons),
+ "download_agents" : (["download_agents"],
mode_download_agents),
}
loaded_with_language = False
@@ -19979,6 +20061,12 @@ def load_plugins():
_("Upload or delete custom icons"),
[ "admin" ])
+ config.declare_permission("wato.download_agents",
+ _("Monitoring Agents"),
+ _("Download the default Check_MK monitoring agents for Linux, "
+ "Windows and other operating systems."),
+ [ "admin", "user", "guest" ])
+
load_web_plugins("wato", globals())
# This must be set after plugin loading to make broken plugins raise
diff --git a/web/plugins/wato/agents.py b/web/plugins/wato/agents.py
deleted file mode 100644
index f6c5018..0000000
--- a/web/plugins/wato/agents.py
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
-# +------------------------------------------------------------------+
-#
-# This file is part of Check_MK.
-# The official homepage is at
http://mathias-kettner.de/check_mk.
-#
-# check_mk is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation in version 2. check_mk is distributed
-# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
-# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# ails. You should have received a copy of the GNU General Public
-# License along with GNU Make; see the file COPYING. If not, write
-# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-# Boston, MA 02110-1301 USA.
-
-import glob
-
-def download_table(title, paths):
- forms.header(title)
- forms.container()
- for path in paths:
- os_path = path
- relpath = path.replace(defaults.agents_dir+'/', '')
- filename = path.split('/')[-1]
-
- size_kb = os.stat(os_path).st_size / 1024.0
-
- # FIXME: Rename classes etc. to something generic
- html.write('<div class="ruleset"><div
class="text" style="width:250px;">')
- html.write('<a href="agents/%s">%s</a>' % (relpath,
filename))
- html.write('<span class=dots>%s</span></div>' %
("." * 100))
- html.write('<div class="rulecount"
style="width:30px;">%d KB</div>' % size_kb)
- html.write('</div></div>')
- forms.end()
-
-def mode_download_agents(phase):
- if phase == "title":
- return _("Monitoring Agents")
-
- elif phase == "buttons":
- global_buttons()
- return
-
- elif phase == "action":
- return
-
- html.write('<div class="rulesets">')
- packed = glob.glob(defaults.agents_dir + "/*.deb") \
- + glob.glob(defaults.agents_dir + "/*.rpm") \
- + glob.glob(defaults.agents_dir + "/windows/c*.msi")
-
- download_table(_("Packed Agents"), packed)
-
- titles = {
- '' : _('Linux / Unix Agents'),
- '/plugins' : _('Linux / Unix Plugins'),
- '/windows' : _('Windows Agent'),
- '/windows/plugins' : _('Windows Plugins'),
- '/windows/mrpe' : _('Windows MRPE Scripts'),
- '/cfg_examples' : _('Example Configurations'),
- '/z_os' : _('z/OS'),
- '/sap' : _('SAP'),
- '/special' : _('Special Agents'),
- }
-
- others = []
- for root, dirs, files in os.walk(defaults.agents_dir):
- file_paths = []
- relpath = root.split('agents')[1]
- title = titles.get(relpath, relpath)
- for filename in files:
- path = root + '/' + filename
- if path not in packed and 'deprecated' not in path:
- file_paths.append(path)
-
- others.append((title, file_paths))
-
- others.sort()
-
- for title, file_paths in others:
- if file_paths:
- download_table(title, sorted(file_paths))
- html.write('</div>')
-
-# Don't do anything when the agent bakery exists. Otherwise register
-# a simple download page for the default agents
-if "agents" not in modes:
- modules.append(
- ("download_agents", _("Monitoring Agents"),
"download_agents", "download_agents",
- _("Downloads the Check_MK monitoring agents"))
- )
-
- modes["download_agents"] = (["download_agents"],
mode_download_agents)
-
- config.declare_permission("wato.download_agents",
- _("Monitoring Agents"),
- _("Download the default Check_MK monitoring agents for Linux, i"
- "Windows and other operating systems."),
- [ "admin", "user", "guest" ])
diff --git a/web/plugins/wato/builtin_modules.py b/web/plugins/wato/builtin_modules.py
index ce202f1..60a3b8c 100644
--- a/web/plugins/wato/builtin_modules.py
+++ b/web/plugins/wato/builtin_modules.py
@@ -83,3 +83,11 @@ modules += [
( "icons", _("Custom Icons"), "icons",
"icons",
_("Upload your own icons that can be used in views or custom
actions")),
]
+
+# Register the builtin agent download page on the top level of WATO only when the agent
bakery
+# does not exist (e.g. when using CRE)
+if "agents" not in modes:
+ modules.append(
+ ("download_agents", _("Monitoring Agents"),
"download_agents", "download_agents",
+ _("Downloads the Check_MK monitoring agents"))
+ )