(self, parsed_url)
return info, stat, tables
Hit a given stats socket and return the stats lines.
Hit a given stats socket and return the stats lines.
Hit a given stats socket and return the stats lines .
def _fetch_socket_data(self, parsed_url):
        """Hit a given stats socket and return the stats lines."""

        self.log.debug("Fetching haproxy stats from socket: %s", parsed_url.geturl())
        info, stat = self._run_socket_commands(parsed_url, (b"show info", b"show stat"))

        # the "show table" command was introduced in 1.5. Sending "show table"
        # to a haproxy <1.5 results in no output at all even when multiple
        # commands were sent, so we have to check the version and only send the
        # command when supported
        tables = []
        raw_version = ''
        try:
            raw_version = get_version_from_socket(info)
            haproxy_major_version = tuple(int(vernum) for vernum in raw_version.split('.')[:2])

            if len(haproxy_major_version) == 2 and haproxy_major_version >= (1, 5):
                (tables,) = self._run_socket_commands(parsed_url, (b"show table",))
        except (IndexError, ValueError) as e:
            self.log.error("Could not parse version number '%s': %s", raw_version, e)
        except CheckException:
            # We got an empty response, which made _run_socket_commands raise an error
            self.log.debug("No tables returned")

        return info, stat, tables
def _fetch_socket_data ( self , parsed_url ) : self . log . debug ( "Fetching haproxy stats from socket: %s" , parsed_url . geturl ( ) ) info , stat = self . _run_socket_commands ( parsed_url , ( b"show info" , b"show stat" ) ) # the "show table" command was introduced in 1.5. Sending "show table" # to a haproxy <1.5 results in no output at all even when multiple # commands were sent, so we have to check the version and only send the # command when supported tables = [ ] raw_version = '' try : raw_version = get_version_from_socket ( info ) haproxy_major_version = tuple ( int ( vernum ) for vernum in raw_version . split ( '.' ) [ : 2 ] ) if len ( haproxy_major_version ) == 2 and haproxy_major_version >= ( 1 , 5 ) : ( tables , ) = self . _run_socket_commands ( parsed_url , ( b"show table" , ) ) except ( IndexError , ValueError ) as e : self . log . error ( "Could not parse version number '%s': %s" , raw_version , e ) except CheckException : # We got an empty response, which made _run_socket_commands raise an error self . log . debug ( "No tables returned" ) return info , stat , tables