check_supervisord.py
def get_status(options):
    """
    Get programs statuses.

    :param options: parsed commandline arguments.
    :type options: optparse.Values.
    :return: supervisord XML-RPC call result.
    :rtype: dict.
    """

    payload = {  # server connection URI formatted string payload
        "username": options.username,
        "password": options.password,
        "server": options.server,
        "port": options.port,
    }

    try:
        if options.server.startswith("/") and stat.S_ISSOCK(os.stat(options.server).st_mode):  # communicate with server via unix socket (simple check is server address is path and path is unix socket)
            try:
                import supervisor.xmlrpc
            except ImportError as error:
                sys.stderr.write("ERROR: Couldn't load module. {error}\n".format(error=error))
                sys.stderr.write("ERROR: Unix socket support not available! Please install nagios-check-supervisord with unix socket support: 'nagios-check-supervisord[unix-socket-support]' or install 'supervisor' separately.\n")
                sys.exit(-1)

            if all([options.username, options.password, ]):  # with auth
                connection = xmlrpclib.ServerProxy("https://", transport=supervisor.xmlrpc.SupervisorTransport(options.username, options.password, serverurl=URI[URI_TPL_SOCKET].format(**payload)))
            else:
                connection = xmlrpclib.ServerProxy("https://", transport=supervisor.xmlrpc.SupervisorTransport(None, None, serverurl=URI[URI_TPL_SOCKET].format(**payload)))

        else:  # communicate with server via http
            if all([options.username, options.password, ]):  # with auth
                connection = xmlrpclib.Server(URI[URI_TPL_HTTP_AUTH].format(**payload))
            else:
                connection = xmlrpclib.Server(URI[URI_TPL_HTTP].format(**payload))

        return connection.supervisor.getAllProcessInfo()

    except Exception as error:
        if not options.quiet:
            sys.stdout.write("ERROR: Server communication problem. {error}\n".format(error=error))
        sys.exit(EXIT_CODES.get(options.network_errors_exit_code, EXIT_CODE_UNKNOWN))
def get_status(options):
    """
    Get programs statuses.

    :param options: parsed commandline arguments.
    :type options: optparse.Values.
    :return: supervisord XML-RPC call result.
    :rtype: dict.
    """

    payload = {  # server connection URI formatted string payload
        "username": options.username,
        "password": options.password,
        "server": options.server,
        "port": options.port,
    }

    try:
        if options.server.startswith("/") and stat.S_ISSOCK(os.stat(options.server).st_mode):  # communicate with server via unix socket (simple check is server address is path and path is unix socket)
            try:
                import supervisor.xmlrpc
            except ImportError as error:
                sys.stderr.write("ERROR: Couldn't load module. {error}\n".format(error=error))
                sys.stderr.write("ERROR: Unix socket support not available! Please install nagios-check-supervisord with unix socket support: 'nagios-check-supervisord[unix-socket-support]' or install 'supervisor' separately.\n")
                sys.exit(-1)

            if all([options.username, options.password, ]):  # with auth
                connection = xmlrpclib.ServerProxy("https://", transport=supervisor.xmlrpc.SupervisorTransport(options.username, options.password, serverurl=URI[URI_TPL_SOCKET].format(**payload)))
            else:
                connection = xmlrpclib.ServerProxy("https://", transport=supervisor.xmlrpc.SupervisorTransport(None, None, serverurl=URI[URI_TPL_SOCKET].format(**payload)))

        else:  # communicate with server via http
            if all([options.username, options.password, ]):  # with auth
                connection = xmlrpclib.Server(URI[URI_TPL_HTTP_AUTH].format(**payload))
            else:
                connection = xmlrpclib.Server(URI[URI_TPL_HTTP].format(**payload))

        return connection.supervisor.getAllProcessInfo()

    except Exception as error:
        if not options.quiet:
            sys.stdout.write("ERROR: Server communication problem. {error}\n".format(error=error))
        sys.exit(EXIT_CODES.get(options.network_errors_exit_code, EXIT_CODE_UNKNOWN))
def get_status ( options ) : payload = { # server connection URI formatted string payload "username" : options . username , "password" : options . password , "server" : options . server , "port" : options . port , } try : if options . server . startswith ( "/" ) and stat . S_ISSOCK ( os . stat ( options . server ) . st_mode ) : # communicate with server via unix socket (simple check is server address is path and path is unix socket) try : import supervisor . xmlrpc except ImportError as error : sys . stderr . write ( "ERROR: Couldn't load module. {error}\n" . format ( error = error ) ) sys . stderr . write ( "ERROR: Unix socket support not available! Please install nagios-check-supervisord with unix socket support: 'nagios-check-supervisord[unix-socket-support]' or install 'supervisor' separately.\n" ) sys . exit ( - 1 ) if all ( [ options . username , options . password , ] ) : # with auth connection = xmlrpclib . ServerProxy ( "https://" , transport = supervisor . xmlrpc . SupervisorTransport ( options . username , options . password , serverurl = URI [ URI_TPL_SOCKET ] . format ( * * payload ) ) ) else : connection = xmlrpclib . ServerProxy ( "https://" , transport = supervisor . xmlrpc . SupervisorTransport ( None , None , serverurl = URI [ URI_TPL_SOCKET ] . format ( * * payload ) ) ) else : # communicate with server via http if all ( [ options . username , options . password , ] ) : # with auth connection = xmlrpclib . Server ( URI [ URI_TPL_HTTP_AUTH ] . format ( * * payload ) ) else : connection = xmlrpclib . Server ( URI [ URI_TPL_HTTP ] . format ( * * payload ) ) return connection . supervisor . getAllProcessInfo ( ) except Exception as error : if not options . quiet : sys . stdout . write ( "ERROR: Server communication problem. {error}\n" . format ( error = error ) ) sys . exit ( EXIT_CODES . get ( options . network_errors_exit_code , EXIT_CODE_UNKNOWN ) )
Get programs statuses.

    :param options: parsed commandline arguments.
    :type options: optparse.Values.
    :return: supervisord XML-RPC call result.
    :rtype: dict.
Get programs statuses .