(self, instance_tags)
Runs local service checks
Runs local service checks
Runs local service checks
def _perform_kubelet_check(self, instance_tags):
        """Runs local service checks"""
        service_check_base = self.NAMESPACE + '.kubelet.check'
        is_ok = True
        url = self.kube_health_url

        try:
            req = self.perform_kubelet_query(url)
            for line in req.iter_lines(decode_unicode=True):
                # avoid noise; this check is expected to fail since we override the container hostname
                if line.find('hostname') != -1:
                    continue

                matches = re.match(r'\[(.)\]([^\s]+) (.*)?', line)
                if not matches or len(matches.groups()) < 2:
                    continue

                service_check_name = service_check_base + '.' + matches.group(2)
                status = matches.group(1)
                if status == '+':
                    self.service_check(service_check_name, AgentCheck.OK, tags=instance_tags)
                else:
                    self.service_check(service_check_name, AgentCheck.CRITICAL, tags=instance_tags)
                    is_ok = False

        except Exception as e:
            self.log.warning('kubelet check %s failed: %s', url, e)
            self.service_check(
                service_check_base,
                AgentCheck.CRITICAL,
                message='Kubelet check %s failed: %s' % (url, str(e)),
                tags=instance_tags,
            )
        else:
            if is_ok:
                self.service_check(service_check_base, AgentCheck.OK, tags=instance_tags)
            else:
                self.service_check(service_check_base, AgentCheck.CRITICAL, tags=instance_tags)
def _perform_kubelet_check ( self , instance_tags ) : service_check_base = self . NAMESPACE + '.kubelet.check' is_ok = True url = self . kube_health_url try : req = self . perform_kubelet_query ( url ) for line in req . iter_lines ( decode_unicode = True ) : # avoid noise; this check is expected to fail since we override the container hostname if line . find ( 'hostname' ) != - 1 : continue matches = re . match ( r'\[(.)\]([^\s]+) (.*)?' , line ) if not matches or len ( matches . groups ( ) ) < 2 : continue service_check_name = service_check_base + '.' + matches . group ( 2 ) status = matches . group ( 1 ) if status == '+' : self . service_check ( service_check_name , AgentCheck . OK , tags = instance_tags ) else : self . service_check ( service_check_name , AgentCheck . CRITICAL , tags = instance_tags ) is_ok = False except Exception as e : self . log . warning ( 'kubelet check %s failed: %s' , url , e ) self . service_check ( service_check_base , AgentCheck . CRITICAL , message = 'Kubelet check %s failed: %s' % ( url , str ( e ) ) , tags = instance_tags , ) else : if is_ok : self . service_check ( service_check_base , AgentCheck . OK , tags = instance_tags ) else : self . service_check ( service_check_base , AgentCheck . CRITICAL , tags = instance_tags )