Code Duplication    Length = 15-22 lines in 5 locations

plumd/plugins/readers/linux/proc/stat.py 1 location

@@ 28-43 (lines=16) @@
25
        'per_cpu': False,
26
    }
27
28
    def __init__(self, log, config):
29
        """Plugin to measure various kernel metrics from /proc/stat
30
31
        :param log: A logger
32
        :type log: logging.RootLogger
33
        :param config: a plumd.config.Conf configuration helper instance.
34
        :type config: plumd.config.Conf
35
        """
36
        super(Stat, self).__init__(log, config)
37
        self.config.defaults(Stat.defaults)
38
        self.calc = Differential()
39
        self.proc_file = "{0}/stat".format(config.get('proc_path'))
40
        self.per_cpu = self.config.get('per_cpu')
41
        self.cpu_metrics = self.config.get('cpu_metrics')
42
        self.gauges = self.config.get('proc_stat_gauges')
43
        self.rates = self.config.get('proc_stat_rates')
44
45
46
    def poll(self):

plumd/plugins/readers/linux/proc/netsnmp.py 1 location

@@ 45-59 (lines=15) @@
42
        'proc_netsnmp_rates': {}
43
    }
44
45
    def __init__(self, log, config):
46
        """Plugin to measure various kernel metrics from /proc.
47
48
        :param log: A logger
49
        :type log: logging.RootLogger
50
        :param config: a plumd.config.Conf configuration helper instance.
51
        :type config: plumd.config.Conf
52
        """
53
        super(NetSnmp, self).__init__(log, config)
54
        self.config.defaults(NetSnmp.defaults)
55
        self.calc = Differential()
56
        self.proc_file = "{0}/net/snmp".format(config.get('proc_path'))
57
        self.filter = Filter()
58
        self.gauges = self.config.get('proc_netsnmp_gauges')
59
        self.rates = self.config.get('proc_netsnmp_rates')
60
61
62
    def poll(self):

plumd/plugins/readers/linux/proc/sockstat.py 1 location

@@ 24-41 (lines=18) @@
21
        'proc_path': '/proc'
22
    }
23
24
    def __init__(self, log, config):
25
        """Plugin to measure various kernel metrics from /proc.
26
27
        :param log: A logger
28
        :type log: logging.RootLogger
29
        :param config: a plumd.config.Conf configuration helper instance.
30
        :type config: plumd.config.Conf
31
        """
32
        super(SockStat, self).__init__(log, config)
33
        self.config.defaults(SockStat.defaults)
34
        self.calc = Differential()
35
        proc_path = config.get('proc_path')
36
        self.proc_file = "{0}/net/sockstat".format(proc_path)
37
        # sys/net/ipv4/tcp_mem format: min, pressure, max
38
        self.fname_limits = "{0}/sys/net/ipv4/tcp_mem".format(proc_path)
39
        # orphan limit: /proc/sys/net/ipv4/tcp_max_orphans
40
        self.fname_orph = "{0}/sys/net/ipv4/tcp_max_orphans".format(proc_path)
41
        self.filter = Filter()
42
43
44
    def poll(self):

plumd/plugins/readers/memcache.py 1 location

@@ 97-118 (lines=22) @@
94
        # memcached connection
95
        host = self.config.get('host')
96
        port = self.config.get('port')
97
        self.addr = (host, port)
98
        self.socket = None
99
        self.timeout = config.get('timeout')
100
        self.calc = Differential()
101
102
103
    def poll(self):
104
        """Query memcache for stats.
105
106
        :rtype: ResultSet
107
        """
108
        result = plumd.Result("memcache")
109
110
        name = self.name
111
        stats = self.get_stats()
112
        ts = time.time()
113
114
        # record gauges
115
        for stat in self.gauges:
116
            if stat in stats:
117
                mname = "{0}.{1}".format(name, stat)
118
                result.add(plumd.Float(mname, stats[stat]))
119
120
        # record rates
121
        for stat in self.rates:

plumd/plugins/readers/mysql.py 1 location

@@ 46-60 (lines=15) @@
43
        'mysql_rates': {}
44
    }
45
46
    def __init__(self, log, config):
47
        """Plugin to measure various MySQL metrics.
48
49
        :param log: A logger
50
        :type log: logging.RootLogger
51
        :param config: a plumd.config.Conf configuration helper instance.
52
        :type config: plumd.config.Conf
53
        """
54
        super(MySql, self).__init__(log, config)
55
        self.config.defaults(MySql.defaults)
56
        self.calc = Differential()
57
        self.hosts = self.config.get('mysql_hosts')
58
        self.filter = Filter()
59
        self.gauges = self.config.get('mysql_gauges')
60
        self.rates = self.config.get('mysql_rates')
61
62
63
    def poll(self):