Lars Hansson avatar Lars Hansson committed 77e7dbe Draft

Remove -a option.

To scan all services and submit passive checks just dont list
any services on the command-line.

Comments (0)

Files changed (1)

check_monit_service.py

 
 
 def handle_options():
-    usage = "Usage: %prog <-H hostname> [options] service"
+    usage = "Usage: %prog <-H hostname> [options] [service]"
     version = '%prog 0.1'
     parser = OptionParser(usage=usage, version=version)
     parser.add_option("-H", dest="host", help="Hostname or IP address")
                         help="Socket timeout in seconds (Default: %default)")
     parser.add_option("-u", dest="username", default=None, help="Username")
     parser.add_option("-p", dest="password", default=None, help="Password")
-    parser.add_option("-a", dest="checkall", action="store_true", default=False, help="Check all services and submit passive results")
-    parser.add_option("-f", dest="cmdfile", default=None, help="Nagios command file")
-    parser.add_option("-n", dest="host_name", default=None, help="Nagios host_name")
+    parser.add_option("-f", dest="cmdfile", default='/var/lib/nagios/rw/nagios.cmd', help="Nagios command file (Default: %default)")
+    parser.add_option("-n", dest="host_name", default='localhost', help="Nagios host_name (Default: %default)")
     (opts, args) = parser.parse_args()
 
-    if (not opts.host) or (opts.checkall and opts.cmdfile is None):
+    if not opts.host:
         parser.print_usage()
         sys.exit(3)
     return (opts, args)
     """Main loop"""
     (opts, args) = handle_options()
     socket.setdefaulttimeout(opts.timeout)
-    if not opts.checkall:
-        svc = args[0]
     proto = 'http'
     if opts.ssl:
         proto = 'https'
 
     statusdoc = get_status(url, opts.username, opts.password, opts.timeout)
     statusdoc = statusdoc.replace("&", "&amp;")
-    if opts.checkall:
+    if len(args) == 0:
         r = process_status_all(statusdoc)
         submit_results(r, opts)
         code = 0
         msg = 'Data collected from monit daemon.'
     else:
-        (code, msg, perf_data) = process_status(svc, statusdoc)
+        (code, msg, perf_data) = process_status(args[0], statusdoc)
     do_exit(code, msg, perf_data)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.