Code Duplication    Length = 20-22 lines in 2 locations

plumd/plugins/readers/linux/proc.py 2 locations

@@ 159-180 (lines=22) @@
156
                break
157
            metric_val = float(val.popleft())
158
            mstr = "{0}.{1}".format(key, map_val)
159
            percent_val = metric_val / total * 100.00
160
            ret.append(plumd.Float(mstr, percent_val))
161
        return ret
162
163
164
    def proc_stat_cpu(self, key, val, ts):
165
        """Return cpu utilization metrics in USER_HZ or Jiffies
166
        (most likely units of 100Hz intervals ie. 100ms intervals).
167
168
        :param key: The metric name (eg. cpu, cpu0, cpu1, etc)
169
        :type key: str
170
        :param val: A deque populated with the metric values from stat
171
        :type val: deque
172
        :rtype: list
173
        """
174
        ret = []
175
        total = sum([ float(i) for i in val])
176
        cpu = self.config.get('cpu_metrics')
177
        for map_val in cpu:
178
            if len(val) < 1:
179
                break
180
            metric_val = float(val.popleft())
181
            mstr = "{0}.{1}".format(key, map_val)
182
            percent_val = float(metric_val / total) * 100.00
183
            mval = self.calc.per_second(key, percent_val, ts)
@@ 137-156 (lines=20) @@
134
        :rtype: ResultSet
135
        """
136
        ret = plumd.ResultSet([])
137
        for func in self.funcs:
138
            ret.add(func())
139
        return ret
140
141
142
    def proc_stat_cpu_percent(self, key, val, ts):
143
        """Return cpu utilization metrics in percentage.
144
145
        :param key: The metric name (eg. cpu, cpu0, cpu1, etc)
146
        :type key: str
147
        :param val: A deque populated with the metric values from stat
148
        :type val: deque
149
        :rtype: list
150
        """
151
        ret = []
152
        total = sum([ float(i) for i in val])
153
        cpu = self.config.get('cpu_metrics')
154
        for map_val in cpu:
155
            if len(val) < 1:
156
                break
157
            metric_val = float(val.popleft())
158
            mstr = "{0}.{1}".format(key, map_val)
159
            percent_val = metric_val / total * 100.00