Пример #1
0
    def health(self):
        if self.cfg.get(
                'globals/stats_socket') != '/var/run/haproxy-stats.sock':
            self.cfg.set('globals/stats_socket', '/var/run/haproxy-stats.sock')
            self.cfg.set('globals/spread-checks', '5')
            self.cfg.save()
            self.svc.reload()

        stats = haproxy.StatSocket().show_stat()

        # filter the stats
        relevant_keys = [
            "pxname",
            "svname",
            "status",
            "act",
            "bck",
            "chkfail",
            "chkdown",
            "downtime",
            "check_status",
            "check_duration",
        ]

        stats = filter(
            lambda health: health["svname"] not in ("FRONTEND", "BACKEND"),
            stats)
        for health in stats:
            for key in health.keys():
                if key not in relevant_keys:
                    del health[key]

        # TODO: return data in different format
        return stats
Пример #2
0
    def get_servers_health(self, ipaddr=None):
        try:
            if self.cfg.defaults['stats'][''] == 'enable' and \
                            self.cfg.globals['stats']['socket'] == '/var/run/haproxy-stats.sock':
                pass
        except:
            self.cfg.globals['stats']['socket'] = '/var/run/haproxy-stats.sock'
            self.cfg.defaults['stats'][''] = 'enable'
            self.cfg.save()
            self.svc.reload()

        #TODO: select parameters what we need with filter by ipaddr
        stats = haproxy.StatSocket().show_stat()
        return stats
Пример #3
0
    def get_servers_health(self, ipaddr=None):
        """
        APIDOC TBD.
        """

        if self.cfg.get('globals/stats_socket') != '/var/run/haproxy-stats.sock' \
            or not self.cfg.get('defaults/stats_enable'):
            self.cfg.set('globals/stats_socket', '/var/run/haproxy-stats.sock')
            self.cfg.set('defaults/stats_enable')
            self.cfg.save()
            self.svc.reload()

        #TODO: select parameters what we need with filter by ipaddr
        stats = haproxy.StatSocket().show_stat()
        return stats
Пример #4
0
    def health(self):
        try:
            # if self.cfg.defaults['stats'][''] == 'enable' and \
            if self.cfg.globals['stats'][
                    'socket'] == '/var/run/haproxy-stats.sock':
                pass
        except:
            self.cfg.globals['stats']['socket'] = '/var/run/haproxy-stats.sock'
            self.cfg.globals['spread-checks'] = 5
            self.cfg.save()
            self.svc.reload()

        stats = haproxy.StatSocket().show_stat()

        # filter the stats
        relevant_keys = [
            "pxname",
            "svname",
            "status",
            "act",
            "bck",
            "chkfail",
            "chkdown",
            "downtime",
            "check_status",
            "check_duration",
        ]

        stats = filter(
            lambda health: health["svname"] not in ("FRONTEND", "BACKEND"),
            stats)
        for health in stats:
            for key in health.keys():
                if key not in relevant_keys:
                    del health[key]

        # TODO: return data in different format

        return stats