(self, line)
Parse and submit the metrics from a line of perfdata output
Parse and submit the metrics from a line of perfdata output
Parse and submit the metrics from a line of perfdata output
def _process_line(self, line):
        """Parse and submit the metrics from a line of perfdata output
        """
        fields = self._extract_fields(line)
        if not self._fields_valid(fields):
            self.log.warning("Missing required fields for line: {line}".format(
                line=line))

        metric_path_base = []
        graphite_prefix = fields.get('GRAPHITEPREFIX')
        graphite_postfix = fields.get('GRAPHITEPOSTFIX')

        if graphite_prefix:
            metric_path_base.append(graphite_prefix)

        hostname = fields['HOSTNAME'].lower()
        metric_path_base.append(hostname)

        datatype = fields['DATATYPE']
        if datatype == 'HOSTPERFDATA':
            metric_path_base.append('host')
        elif datatype == 'SERVICEPERFDATA':
            service_desc = fields.get('SERVICEDESC')
            graphite_postfix = fields.get('GRAPHITEPOSTFIX')
            if graphite_postfix:
                metric_path_base.append(graphite_postfix)
            else:
                metric_path_base.append(service_desc)

        perfdata = fields[datatype]
        counters = self._parse_perfdata(perfdata)

        for (counter, value) in counters:
            metric_path = metric_path_base + [counter]
            metric_path = [self._sanitize(x) for x in metric_path]
            metric_name = '.'.join(metric_path)
            self.publish(metric_name, value)
def _process_line ( self , line ) : fields = self . _extract_fields ( line ) if not self . _fields_valid ( fields ) : self . log . warning ( "Missing required fields for line: {line}" . format ( line = line ) ) metric_path_base = [ ] graphite_prefix = fields . get ( 'GRAPHITEPREFIX' ) graphite_postfix = fields . get ( 'GRAPHITEPOSTFIX' ) if graphite_prefix : metric_path_base . append ( graphite_prefix ) hostname = fields [ 'HOSTNAME' ] . lower ( ) metric_path_base . append ( hostname ) datatype = fields [ 'DATATYPE' ] if datatype == 'HOSTPERFDATA' : metric_path_base . append ( 'host' ) elif datatype == 'SERVICEPERFDATA' : service_desc = fields . get ( 'SERVICEDESC' ) graphite_postfix = fields . get ( 'GRAPHITEPOSTFIX' ) if graphite_postfix : metric_path_base . append ( graphite_postfix ) else : metric_path_base . append ( service_desc ) perfdata = fields [ datatype ] counters = self . _parse_perfdata ( perfdata ) for ( counter , value ) in counters : metric_path = metric_path_base + [ counter ] metric_path = [ self . _sanitize ( x ) for x in metric_path ] metric_name = '.' . join ( metric_path ) self . publish ( metric_name , value )