Code Duplication    Length = 20-22 lines in 2 locations

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

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