(self, data)
return data
Main data-processing loop. For each piece of useful data, we'll
        either save a metric, save an event or both.
Main data-processing loop. For each piece of useful data, we'll
        either save a metric, save an event or both.
Main data - processing loop . For each piece of useful data we ll either save a metric save an event or both .
def _process_data(self, data):
        """Main data-processing loop. For each piece of useful data, we'll
        either save a metric, save an event or both."""

        active_tag = []
        if self.include_active_tag:
            active_tag.append("active:%s" % ('true' if 'act' in data else 'false'))

        # Split the first line into an index of fields
        # The line looks like (broken up onto multiple lines)
        # "# pxname,svname,qcur,qmax,scur,smax,slim,
        # stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,
        # wredis,status,weight,act,bck,chkfail,chkdown,lastchg,
        # downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,
        # type,rate,rate_lim,rate_max,"
        fields = []
        for f in data[0].split(','):
            if f:
                f = f.replace('# ', '')
                fields.append(f.strip())

        self.hosts_statuses = defaultdict(int)

        back_or_front = None

        # Sanitize CSV, handle line breaks
        data = self._sanitize_lines(data)

        # Skip the first line, go backwards to set back_or_front
        for line in data[:0:-1]:
            if not line.strip():
                continue

            # Store each line's values in a dictionary
            data_dict = self._line_to_dict(fields, line)

            if self._is_aggregate(data_dict):
                back_or_front = data_dict['svname']

            self._update_data_dict(data_dict, back_or_front)

            self._update_hosts_statuses_if_needed(data_dict)

            # Clone the list to avoid extending the original
            # which would carry over previous iteration tags
            line_tags = list(self.custom_tags)

            regex_tags = self._tag_from_regex(data_dict['pxname'])
            if regex_tags:
                line_tags.extend(regex_tags)

            if self._should_process(data_dict):
                # update status
                # Send the list of data to the metric and event callbacks
                self._process_metrics(
                    data_dict,
                    custom_tags=line_tags,
                    active_tag=active_tag,
                )
            if self.process_events:
                self._process_event(
                    data_dict,
                    custom_tags=line_tags,
                )
            if self.enable_service_check:
                self._process_service_check(
                    data_dict,
                    custom_tags=line_tags,
                )

        if self.collect_status_metrics:
            self._process_status_metric(
                active_tag=active_tag,
            )

            self._process_backend_hosts_metric(
                active_tag=active_tag,
            )

        return data
def _process_data ( self , data ) : active_tag = [ ] if self . include_active_tag : active_tag . append ( "active:%s" % ( 'true' if 'act' in data else 'false' ) ) # Split the first line into an index of fields # The line looks like (broken up onto multiple lines) # "# pxname,svname,qcur,qmax,scur,smax,slim, # stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr, # wredis,status,weight,act,bck,chkfail,chkdown,lastchg, # downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked, # type,rate,rate_lim,rate_max," fields = [ ] for f in data [ 0 ] . split ( ',' ) : if f : f = f . replace ( '# ' , '' ) fields . append ( f . strip ( ) ) self . hosts_statuses = defaultdict ( int ) back_or_front = None # Sanitize CSV, handle line breaks data = self . _sanitize_lines ( data ) # Skip the first line, go backwards to set back_or_front for line in data [ : 0 : - 1 ] : if not line . strip ( ) : continue # Store each line's values in a dictionary data_dict = self . _line_to_dict ( fields , line ) if self . _is_aggregate ( data_dict ) : back_or_front = data_dict [ 'svname' ] self . _update_data_dict ( data_dict , back_or_front ) self . _update_hosts_statuses_if_needed ( data_dict ) # Clone the list to avoid extending the original # which would carry over previous iteration tags line_tags = list ( self . custom_tags ) regex_tags = self . _tag_from_regex ( data_dict [ 'pxname' ] ) if regex_tags : line_tags . extend ( regex_tags ) if self . _should_process ( data_dict ) : # update status # Send the list of data to the metric and event callbacks self . _process_metrics ( data_dict , custom_tags = line_tags , active_tag = active_tag , ) if self . process_events : self . _process_event ( data_dict , custom_tags = line_tags , ) if self . enable_service_check : self . _process_service_check ( data_dict , custom_tags = line_tags , ) if self . collect_status_metrics : self . _process_status_metric ( active_tag = active_tag , ) self . _process_backend_hosts_metric ( active_tag = active_tag , ) return data