def validate_protocol(self): """Determines the protocol to use and sets it in the object""" if self.http and self.https: end(UNKNOWN, "cannot choose both http and https, they are " \ + "mutually exclusive") elif self.http: self.protocol = "http" elif self.https: self.protocol = "https" else: self.protocol = "svn"
def validate_port(self): """Exits with an error if the port is not valid""" if self.port == None: self.port = "" else: try: self.port = int(self.port) if not 1 <= self.port <= 65535: raise ValueError except ValueError: end(UNKNOWN, "port number must be a whole number between " \ + "1 and 65535")
def validate_port(self): """Exits with an error if the port is not valid""" if self.port is None: self.port = "" else: try: self.port = int(self.port) if not 1 <= self.port <= 65535: raise ValueError except ValueError: end(UNKNOWN, "port number must be a whole number between " \ + "1 and 65535")
def validate_passwdfile(self): """Exits with an error if the passwd file is not given or if the file is non-existent or cannot be accessed for any reason""" if self.passwdfile == None or self.passwdfile == "": end(UNKNOWN, "You must supply a passwd file containing " \ + "the VNC password in order to connect. See --help " \ + "for details") if not os.path.exists(self.passwdfile): end(UNKNOWN, "vnc passwd file '%s' does not exist" \ % self.passwdfile) if not os.path.isfile(self.passwdfile): end(UNKNOWN, "'%s' is not a file, " \ + "cannot be used as the vnc passwd file") if not os.access(self.passwdfile, os.R_OK): end(UNKNOWN, "vnc passwd file '%s' is not " % self.passwdfile \ + "readable, please allow read permission on this file")
def validate_passwdfile(self): """Exits with an error if the passwd file is not given or if the file is non-existent or cannot be accessed for any reason""" if not self.passwdfile: end(UNKNOWN, "You must supply a passwd file containing " \ + "the VNC password in order to connect. See --help " \ + "for details") if not os.path.exists(self.passwdfile): end(UNKNOWN, "vnc passwd file '%s' does not exist" \ % self.passwdfile) if not os.path.isfile(self.passwdfile): end(UNKNOWN, "'%s' is not a file, " \ + "cannot be used as the vnc passwd file") if not os.access(self.passwdfile, os.R_OK): end(UNKNOWN, "vnc passwd file '%s' is not " % self.passwdfile \ + "readable, please allow read permission on this file")
def main(): """Parses args and calls func to test vnc server""" tester = VncTester() parser = OptionParser() parser.add_option( "-H", "--server", dest="server", help="The Hostname or IP Address of the VNC " \ + "server") # vncsnapshot doesn't support ports yet # parser.add_option( "-p", # "--port", # dest="port", # help="The port on the server to test. Defaults to %s" \ # % DEFAULT_PORT) parser.add_option( "-f", "--passwd-file", dest="passwdfile", help="The VNC password file to use. You can generate " \ + "this using 'vncpasswd <filename>' on the " \ + "command line") parser.add_option( "-l", "--label", dest="service", help="Change result prefix (Defaults to \"%s\")" % nagios.CHECK_NAME) parser.add_option( "-t", "--timeout", dest="timeout", help="Sets a timeout after which the the plugin will" \ + " self terminate. Defaults to %s seconds." \ % DEFAULT_TIMEOUT) parser.add_option( "-T", "--timing", action="store_true", dest="timing", help="Enable timer output") parser.add_option( "-v", "--verbose", action="count", dest="verbosity", help="Verbose mode. Good for testing plugin. By " \ + "default only one result line is printed as per" \ + " Nagios standards") parser.add_option( "-V", "--version", action = "store_true", dest = "version", help = "Print version number and exit" ) (options, args) = parser.parse_args() if args: parser.print_help() sys.exit(UNKNOWN) if options.version: print "%s version %s" % (__title__, __version__) sys.exit(UNKNOWN) tester.passwdfile = options.passwdfile #tester.port = options.port tester.server = options.server tester.timeout = options.timeout tester.verbosity = options.verbosity if options.service != None: nagios.CHECK_NAME = options.service if options.timing: start_time = time.time() returncode, output = tester.test_vnc() if options.timing: finish_time = time.time() total_time = finish_time - start_time output += ". Test completed in %.3f seconds" % total_time end(returncode, output) sys.exit(UNKNOWN)
def main(): """Parses args and calls func to test vnc server""" tester = VncTester() parser = OptionParser() parser.add_option( "-H", "--server", dest="server", help="The Hostname or IP Address of the VNC " \ + "server") # vncsnapshot doesn't support ports yet # parser.add_option( "-p", # "--port", # dest="port", # help="The port on the server to test. Defaults to %s" \ # % DEFAULT_PORT) parser.add_option( "-f", "--passwd-file", dest="passwdfile", help="The VNC password file to use. You can generate " \ + "this using 'vncpasswd <filename>' on the " \ + "command line") parser.add_option("-l", "--label", dest="service", help="Change result prefix (Defaults to \"%s\")" % nagios.CHECK_NAME) parser.add_option( "-t", "--timeout", dest="timeout", help="Sets a timeout after which the the plugin will" \ + " self terminate. Defaults to %s seconds." \ % DEFAULT_TIMEOUT) parser.add_option("-T", "--timing", action="store_true", dest="timing", help="Enable timer output") parser.add_option( "-v", "--verbose", action="count", dest="verbosity", help="Verbose mode. Good for testing plugin. By " \ + "default only one result line is printed as per" \ + " Nagios standards") parser.add_option("-V", "--version", action="store_true", dest="version", help="Print version number and exit") (options, args) = parser.parse_args() if args: parser.print_help() sys.exit(UNKNOWN) if options.version: print(("%s version %s" % (__title__, __version__))) sys.exit(UNKNOWN) tester.passwdfile = options.passwdfile #tester.port = options.port tester.server = options.server tester.timeout = options.timeout tester.verbosity = options.verbosity if options.service != None: nagios.CHECK_NAME = options.service if options.timing: start_time = time.time() returncode, output = tester.test_vnc() if options.timing: finish_time = time.time() total_time = finish_time - start_time output += ". Test completed in %.3f seconds" % total_time end(returncode, output) sys.exit(UNKNOWN)
def main(): """Parses args and calls func to test svn server""" tester = SvnTester() parser = OptionParser() parser.add_option( "-H", "--server", dest="server", help="The Hostname or IP Address of the subversion " \ + "server") parser.add_option( "-p", "--port", dest="port", help="The port on the server to test if not using the " \ + "default port which is 3690 for svn://, 80 for " \ + "http:// or 443 for https://.") parser.add_option( "--http", action="store_true", dest="http", help="Connect to the server using the http:// " \ + "protocol (Default is svn://)") parser.add_option( "--https", action="store_true", dest="https", help="Connect to the server using the https:// " \ + "protocol (Default is svn://)") parser.add_option( "-d", "--dir", "--directory", dest="directory", help="The directory on the host. Optional but usually " \ + "necessary if using http/https, eg if using an " \ + "http WebDAV repository " \ + "http://somehost.domain.com/repos/svn so this " \ + "would be --dir /repos/svn. Not usually needed " \ + "for the default svn:// unless you want to test " \ + "a specific directory in the repository") parser.add_option( "-U", "--username", dest="username", help="The username to use to connect to the subversion" \ + " server.") parser.add_option( "-P", "--password", dest="password", help="The password to use to connect to the subversion" \ + " server.") parser.add_option( "-l", "--label", dest="service", help="Change result prefix (Defaults to \"%s\")" % nagios.CHECK_NAME) parser.add_option( "-t", "--timeout", dest="timeout", help="Sets a timeout after which the the plugin will" \ + " self terminate. Defaults to %s seconds." \ % DEFAULT_TIMEOUT) parser.add_option( "-T", "--timing", action="store_true", dest="timing", help="Enable timer output") parser.add_option( "-v", "--verbose", action="count", dest="verbosity", help="Verbose mode. Good for testing plugin. By " \ + "default only one result line is printed as per" \ + " Nagios standards") parser.add_option( "-V", "--version", action = "store_true", dest = "version", help = "Print version number and exit" ) (options, args) = parser.parse_args() if args: parser.print_help() sys.exit(UNKNOWN) if options.version: print "%s version %s" % (__title__, __version__) sys.exit(UNKNOWN) tester.directory = options.directory tester.http = options.http tester.https = options.https tester.password = options.password tester.port = options.port tester.server = options.server tester.timeout = options.timeout tester.username = options.username tester.verbosity = options.verbosity if options.service != None: nagios.CHECK_NAME = options.service if options.timing: start_time = time.time() returncode, output = tester.test_svn() if options.timing: finish_time = time.time() total_time = finish_time - start_time output += ". Test completed in %.3f seconds" % total_time end(returncode, output) sys.exit(UNKNOWN)