<commit_before>"""
memcached

"""
import logging

from newrelic_plugin_agent.plugins import base

LOGGER = logging.getLogger(__name__)


class Memcached(base.SocketStatsPlugin):

    GUID = 'com.meetme.newrelic_memcached_agent'
    DEFAULT_PORT = 11211
    KEYS = ['curr_connections',
            'curr_items',
            'connection_struct',
            'cmd_get',
            'cmd_set',
            'cmd_flush',
            'get_hits',
            'get_misses',
            'delete_hits',
            'delete_misses',
            'incr_hits',
            'incr_misses',
            'decr_hits',
            'decr_misses',
            'cas_hits',
            'cas_misses',
            'cas_badval',
            'auth_cmds',
            'auth_errors',
            'bytes_read',
            'bytes_written',
            'bytes',
            'total_items',
            'evictions',
            'rusage_user',
            'conn_yields',
            'rusage_system']

    SOCKET_RECV_MAX = 32768

    def add_datapoints(self, stats):
        """Add all of the data points for a node

        :param dict stats: all of the nodes

        """
        self.command_value('CAS', 'cas', stats)
        self.add_derive_value('Command/Requests/Flush', '', stats['cmd_flush'])
        self.add_derive_value('Command/Errors/CAS', '', stats['cas_badval'])
        self.command_value('Decr', 'decr', stats)
        self.command_value('Delete', 'delete', stats)
        self.command_value('Get', 'get', stats)
        self.command_value('Incr', 'incr', stats)
        self.add_derive_value('Command/Requests/Set', '', stats['cmd_set'])

        self.add_gauge_value('Connection/Count', '',
                             stats['curr_connections'])
        self.add_gauge_value('Connection/Structures', '',
                             stats['connection_struct'])
        self.add_derive_value('Connection/Yields', '',
                              stats['conn_yields'])
        self.add_derive_value('Evictions', '', stats['evictions'])
        self.add_gauge_value('Items', '', stats['curr_items'])

        self.add_derive_value('Network/In', 'bytes', stats['bytes_read'])
        self.add_derive_value('Network/Out', 'bytes', stats['bytes_written'])

        self.add_derive_value('System/CPU/System', 'sec', stats['rusage_user'])
        self.add_derive_value('System/CPU/User', 'sec', stats['rusage_user'])
        self.add_gauge_value('System/Memory', 'bytes', stats['bytes'])
<commit_msg>memcached: fix connection_structures key<commit_after>"""
memcached

"""
import logging

from newrelic_plugin_agent.plugins import base

LOGGER = logging.getLogger(__name__)


class Memcached(base.SocketStatsPlugin):

    GUID = 'com.meetme.newrelic_memcached_agent'
    DEFAULT_PORT = 11211
    KEYS = ['curr_connections',
            'curr_items',
            'connection_structures',
            'cmd_get',
            'cmd_set',
            'cmd_flush',
            'get_hits',
            'get_misses',
            'delete_hits',
            'delete_misses',
            'incr_hits',
            'incr_misses',
            'decr_hits',
            'decr_misses',
            'cas_hits',
            'cas_misses',
            'cas_badval',
            'auth_cmds',
            'auth_errors',
            'bytes_read',
            'bytes_written',
            'bytes',
            'total_items',
            'evictions',
            'rusage_user',
            'conn_yields',
            'rusage_system']

    SOCKET_RECV_MAX = 32768

    def add_datapoints(self, stats):
        """Add all of the data points for a node

        :param dict stats: all of the nodes

        """
        self.command_value('CAS', 'cas', stats)
        self.add_derive_value('Command/Requests/Flush', '', stats['cmd_flush'])
        self.add_derive_value('Command/Errors/CAS', '', stats['cas_badval'])
        self.command_value('Decr', 'decr', stats)
        self.command_value('Delete', 'delete', stats)
        self.command_value('Get', 'get', stats)
        self.command_value('Incr', 'incr', stats)
        self.add_derive_value('Command/Requests/Set', '', stats['cmd_set'])

        self.add_gauge_value('Connection/Count', '',
                             stats['curr_connections'])
        self.add_gauge_value('Connection/Structures', '',
                             stats['connection_structures'])
        self.add_derive_value('Connection/Yields', '',
                              stats['conn_yields'])
        self.add_derive_value('Evictions', '', stats['evictions'])
        self.add_gauge_value('Items', '', stats['curr_items'])

        self.add_derive_value('Network/In', 'bytes', stats['bytes_read'])
        self.add_derive_value('Network/Out', 'bytes', stats['bytes_written'])

        self.add_derive_value('System/CPU/System', 'sec', stats['rusage_user'])
        self.add_derive_value('System/CPU/User', 'sec', stats['rusage_user'])
        self.add_gauge_value('System/Memory', 'bytes', stats['bytes'])

{'fraction_non_alphanumeric': 0.14045281506712082, 'fraction_numerical': 0.004007212983370066, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '921703', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1491, 'n_words': 225}