<commit_before># haproxy-collectd-plugin - haproxy.py
#
# Author: <NAME>
# Description: This is a collectd plugin which runs under the Python plugin to
# collect metrics from haproxy.
# Plugin structure and logging func taken from
# https://github.com/phrawzty/rabbitmq-collectd-plugin
#
# Modified by "<NAME>" <<EMAIL>>

import cStringIO as StringIO
import socket
import csv

import collectd

PLUGIN_NAME = 'haproxy'
RECV_SIZE = 1024
METRIC_TYPES = {
    'MaxConn': ('max_connections', 'gauge'),
    'CumConns': ('connections', 'counter'),
    'CumReq': ('requests', 'counter'),
    'MaxConnRate': ('max_connection_rate', 'gauge'),
    'MaxSessRate': ('max_session_rate', 'gauge'),
    'MaxSslConns': ('max_ssl_connections', 'gauge'),
    'CumSslConns': ('ssl_connections', 'counter'),
    'MaxSslConns': ('max_ssl_connections', 'gauge'),
    'MaxPipes': ('max_pipes', 'gauge'),
    'Idle_pct': ('idle_pct', 'gauge'),
    'Tasks': ('tasks', 'gauge'),
    'Run_queue': ('run_queue', 'gauge'),
    'PipesUsed': ('pipes_used', 'gauge'),
    'PipesFree': ('pipes_free', 'gauge'),
    'Uptime_sec': ('uptime_seconds', 'counter'),
    'bin': ('bytes_in', 'counter'),
    'bout': ('bytes_out', 'counter'),
    'chkfail': ('failed_checks', 'counter'),
    'downtime': ('downtime', 'counter'),
    'dresp': ('denied_response', 'counter'),
    'dreq': ('denied_request', 'counter'),
    'econ': ('error_connection', 'counter'),
    'ereq': ('error_request', 'counter'),
    'eresp': ('error_response', 'counter'),
    'hrsp_1xx': ('response_1xx', 'counter'),
    'hrsp_2xx': ('response_2xx', 'counter'),
    'hrsp_3xx': ('response_3xx', 'counter'),
    'hrsp_4xx': ('response_4xx', 'counter'),
    'hrsp_5xx': ('response_5xx', 'counter'),
    'hrsp_other': ('response_other', 'counter'),
    'qcur': ('queue_current', 'gauge'),
    'rate': ('session_rate', 'gauge'),
    'req_rate': ('request_rate', 'gauge'),
    'stot': ('session_total', 'counter'),
    'scur': ('session_current', 'gauge'),
    'wredis': ('redistributed', 'counter'),
    'wretr': ('retries', 'counter'),
}

METRIC_DELIM = '.'  # for the frontend/backend stats

DEFAULT_SOCKET = '/var/lib/haproxy/stats'
VERBOSE_LOGGING = False
HAPROXY_SOCKET = None


class Logger(object):
    def error(self, msg):
        collectd.error('{name}: {msg}'.format(name=PLUGIN_NAME, msg=msg))

    def notice(self, msg):
        collectd.warning('{name}: {msg}'.format(name=PLUGIN_NAME, msg=msg))
<commit_msg>Added Active Servers to metrics<commit_after># haproxy-collectd-plugin - haproxy.py
#
# Author: <NAME>
# Description: This is a collectd plugin which runs under the Python plugin to
# collect metrics from haproxy.
# Plugin structure and logging func taken from
# https://github.com/phrawzty/rabbitmq-collectd-plugin
#
# Modified by "<NAME>" <<EMAIL>>

import cStringIO as StringIO
import socket
import csv

import collectd

PLUGIN_NAME = 'haproxy'
RECV_SIZE = 1024
METRIC_TYPES = {
    'MaxConn': ('max_connections', 'gauge'),
    'CumConns': ('connections', 'counter'),
    'CumReq': ('requests', 'counter'),
    'MaxConnRate': ('max_connection_rate', 'gauge'),
    'MaxSessRate': ('max_session_rate', 'gauge'),
    'MaxSslConns': ('max_ssl_connections', 'gauge'),
    'CumSslConns': ('ssl_connections', 'counter'),
    'MaxSslConns': ('max_ssl_connections', 'gauge'),
    'MaxPipes': ('max_pipes', 'gauge'),
    'Idle_pct': ('idle_pct', 'gauge'),
    'Tasks': ('tasks', 'gauge'),
    'Run_queue': ('run_queue', 'gauge'),
    'PipesUsed': ('pipes_used', 'gauge'),
    'PipesFree': ('pipes_free', 'gauge'),
    'Uptime_sec': ('uptime_seconds', 'counter'),
    'bin': ('bytes_in', 'counter'),
    'bout': ('bytes_out', 'counter'),
    'chkfail': ('failed_checks', 'counter'),
    'downtime': ('downtime', 'counter'),
    'dresp': ('denied_response', 'counter'),
    'dreq': ('denied_request', 'counter'),
    'econ': ('error_connection', 'counter'),
    'ereq': ('error_request', 'counter'),
    'eresp': ('error_response', 'counter'),
    'hrsp_1xx': ('response_1xx', 'counter'),
    'hrsp_2xx': ('response_2xx', 'counter'),
    'hrsp_3xx': ('response_3xx', 'counter'),
    'hrsp_4xx': ('response_4xx', 'counter'),
    'hrsp_5xx': ('response_5xx', 'counter'),
    'hrsp_other': ('response_other', 'counter'),
    'qcur': ('queue_current', 'gauge'),
    'rate': ('session_rate', 'gauge'),
    'req_rate': ('request_rate', 'gauge'),
    'act': ('active_servers', 'gauge'),
    'stot': ('session_total', 'counter'),
    'scur': ('session_current', 'gauge'),
    'wredis': ('redistributed', 'counter'),
    'wretr': ('retries', 'counter'),
}

METRIC_DELIM = '.'  # for the frontend/backend stats

DEFAULT_SOCKET = '/var/lib/haproxy/stats'
VERBOSE_LOGGING = False
HAPROXY_SOCKET = None


class Logger(object):
    def error(self, msg):
        collectd.error('{name}: {msg}'.format(name=PLUGIN_NAME, msg=msg))

    def notice(self, msg):
        collectd.warning('{name}: {msg}'.format(name=PLUGIN_NAME, msg=msg))

{'fraction_non_alphanumeric': 0.20745967741935484, 'fraction_numerical': 0.00564516129032258, 'mean_word_length': 4.991545893719807, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '440937', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1743, 'n_words': 377}