Module: check_mk
Branch: master
Commit: 2032ea0f0b3cf8960c1c4c8a0e0b0101cfec439f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2032ea0f0b3cf8…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Jan 9 13:23:36 2019 +0100
Move the special agent utilities to the cmk module
Introduce the new module cmk.special_agents and move the special
agent utilities defined in agents/special/lib/cmk_special_agent_api.py
to cmk/special_agents/utils.py. This makes it possible to introduce a
similar module structure like in cmk.notification_scripts later on.
Change-Id: I673934465a9fe0e22468f3ac4c1c93b0cb653815
---
Makefile | 4 ----
agents/special/.f12 | 1 -
agents/special/agent_salesforce | 4 ++--
agents/special/cmk_special_agent_api.py | 1 -
cmk/special_agents/__init__.py | 0
.../cmk_special_agent_api.py => cmk/special_agents/utils.py | 12 ++++++++----
6 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 010af8e..bce07c0 100644
--- a/Makefile
+++ b/Makefile
@@ -202,10 +202,6 @@ $(DISTNAME).tar.gz: mk-livestatus-$(VERSION).tar.gz .werks/werks
web/htdocs/js/m
--exclude "cme.py*" \
cmk_base/* ; \
rm cmk_base/*.pyc
- python -m compileall agents/special/lib ; \
- tar czf $(DISTNAME)/special_agent_api.tar.gz $(TAROPTS) -C agents/special/lib
cmk_special_agent_api.py \
- --exclude ".f12"
- rm agents/special/lib/*.pyc
tar czf $(DISTNAME)/werks.tar.gz $(TAROPTS) -C .werks werks
tar czf $(DISTNAME)/checks.tar.gz $(TAROPTS) -C checks $$(cd checks ; ls)
tar czf $(DISTNAME)/active_checks.tar.gz $(TAROPTS) -C active_checks $$(cd active_checks
; ls)
diff --git a/agents/special/.f12 b/agents/special/.f12
index cf2c7d2..27d708f 100755
--- a/agents/special/.f12
+++ b/agents/special/.f12
@@ -6,4 +6,3 @@ SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE
sudo cp agent_* $ROOT/share/check_mk/agents/special/
-sudo cp lib/cmk_special_agent_api.py $ROOT/lib/python/
diff --git a/agents/special/agent_salesforce b/agents/special/agent_salesforce
index 68dd656..289c3f7 100755
--- a/agents/special/agent_salesforce
+++ b/agents/special/agent_salesforce
@@ -25,9 +25,9 @@
# Boston, MA 02110-1301 USA.
import sys
-import cmk_special_agent_api as special_agent_api
+import cmk.special_agents.utils as utils
-agent = special_agent_api.AgentJSON("salesforce", "Salesforce")
+agent = utils.AgentJSON("salesforce", "Salesforce")
content = agent.get_content()
for section, section_content in content.iteritems():
sys.stdout.write("<<<%s>>>\n" % section)
diff --git a/agents/special/cmk_special_agent_api.py
b/agents/special/cmk_special_agent_api.py
deleted file mode 120000
index 1529cf0..0000000
--- a/agents/special/cmk_special_agent_api.py
+++ /dev/null
@@ -1 +0,0 @@
-lib/cmk_special_agent_api.py
\ No newline at end of file
diff --git a/cmk/special_agents/__init__.py b/cmk/special_agents/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/agents/special/lib/cmk_special_agent_api.py b/cmk/special_agents/utils.py
similarity index 95%
rename from agents/special/lib/cmk_special_agent_api.py
rename to cmk/special_agents/utils.py
index 7a35438..05d930b 100644
--- a/agents/special/lib/cmk_special_agent_api.py
+++ b/cmk/special_agents/utils.py
@@ -23,10 +23,15 @@
# 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 sys, requests, getopt
"""Place for common code shared among different Check_MK special
agents"""
+import getopt
+import json
+import pprint
+import sys
+
+import requests
+
class AgentJSON(object):
def __init__(self, key, title):
@@ -51,7 +56,7 @@ USAGE: agent_%s --section_url [{section_name},{url}]
long_options = ["section_url=", "help",
"newline_replacement=", "debug"]
try:
- opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
+ opts, _args = getopt.getopt(sys.argv[1:], short_options, long_options)
except getopt.GetoptError as err:
sys.stderr.write("%s\n" % err)
sys.exit(1)
@@ -81,7 +86,6 @@ USAGE: agent_%s --section_url [{section_name},{url}]
content[section_name].append(requests.get(url).text.replace("\n",
newline_replacement))
if opt_debug:
- import pprint, json
for line in content:
try:
pprint.pprint(json.loads(line))