[checkmk-commits] agent_jolokia: Fixed verbose mode and improved help output

Lars Michelsen lm at mathias-kettner.de
Mon Dec 12 13:31:18 CET 2016


Module: check_mk
Branch: master
Commit: 4bb18ed733ac36fcd6179b67dfeafbdabb3a4145
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4bb18ed733ac36fcd6179b67dfeafbdabb3a4145

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Mon Dec 12 13:31:06 2016 +0100

agent_jolokia: Fixed verbose mode and improved help output

Change-Id: I347cae15a4b1b22e12cb4e1a4aa96be92a0cfeea

---

 agents/special/agent_jolokia | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/agents/special/agent_jolokia b/agents/special/agent_jolokia
index 0753eff..09864c8 100755
--- a/agents/special/agent_jolokia
+++ b/agents/special/agent_jolokia
@@ -144,13 +144,13 @@ class HTTPSAuthHandler(urllib2.HTTPSHandler):
 def fetch_var(protocol, server, port, path, suburi, cert_path, itemspec):
     url = "%s://%s:%d/%s/%s" % (protocol, server, port, suburi, path)
     if opt_verbose:
-        sys.stderr.write("DEBUG: Fetching: %s\n" % url)
+        sys.stderr.write("Fetching: %s\n" % url)
     try:
         conn = urllib2.urlopen(url)
         data = conn.read()
 
         if opt_verbose:
-            sys.stderr.write("DEBUG: Result: %s\n\n" % data)
+            sys.stderr.write("Result: %s\n\n" % data)
     except Exception, e:
         if opt_debug:
             raise
@@ -324,33 +324,22 @@ USAGE: mk_jolokia [OPTIONS]
 
 OPTIONS:
   --help                        Show this help message and exit
-  --server                      Host name or IP address of the Jolokia server. Default: localhost
-  --port                        TCP Port of the Jolokia server. Default: 8080
-  --user                        Username to use for the connection. Default: monitoring
-  --password                    Password to use for connecting. Default: none
-  --mode                        Authentication mode. Can be "basic" or "digest". Default: digest
-  --suburi                      Path-component of the uri to query. Default: jolokia
-  --instance                    Name of the instance in the monitoring
+  --server=SERVER               Host name or IP address of the Jolokia server. Default: localhost
+  --port=PORT                   TCP Port of the Jolokia server. Default: 8080
+  --user=USER                   Username to use for the connection. Default: monitoring
+  --password=PASSWORD           Password to use for connecting. Default: none
+  --mode=MODE                   Authentication mode. Can be "basic" or "digest". Default: digest
+  --suburi=SUBURI               Path-component of the URI to query. Default: jolokia
+  --instance=INSTANCE           Name of the instance in the monitoring
   --debug                       Debug mode: let Python exceptions come through
+  --verbose                     Output some more detailed information
 """)
 
 
-
-"""
-    for param in ['server', 'port', 'suburi', 'instance', 'protocol', 'cert_path', 'client_cert', 'client_key']:
-        if param in params:
-            arglist.append('--%s %s' % (param, params[param]))
-
-    if 'login' in params:
-        arglist.append('--user %s' % params['login'][0])
-        arglist.append('--password %s' % params['login'][1])
-"""
-
-
 def parse_arguments():
     short_options = ''
     long_options  = [
-        'help', 'server=', 'port=', 'user=', 'password=', 'mode=', 'suburi=', 'instance=',
+        'help', 'verbose', 'server=', 'port=', 'user=', 'password=', 'mode=', 'suburi=', 'instance=',
         'protocol=', 'cert_path=', 'client_cert=', 'client_key='
     ]
 
@@ -368,6 +357,9 @@ def parse_arguments():
     global opt_debug
     opt_debug = 'debug' in opts
 
+    global opt_verbose
+    opt_verbose = 'verbose' in opts
+
     for optional, default in [('server',      "localhost"),
                               ('user',        "monitoring"),
                               ('password',    None),



More information about the checkmk-commits mailing list