@@ 256-282 (lines=27) @@ | ||
253 | return result |
|
254 | ||
255 | ||
256 | def proc_net_dev(self): |
|
257 | skip = self.config.get('skip_proc_net_dev') |
|
258 | cols = self.config.get('net_dev_cols') |
|
259 | result = plumd.Result("net") |
|
260 | fname = "/proc/net/dev" |
|
261 | dat = {} |
|
262 | # read and process /proc/stat |
|
263 | try: |
|
264 | dat = get_file_map(fname, 0, 0) |
|
265 | except Exception as e: |
|
266 | tb = traceback.format_exc() |
|
267 | self.log.error("proc_net_dev: exception: {0}: {1}".format(e, tb)) |
|
268 | return result |
|
269 | ts = time.time() |
|
270 | for key, val in dat.items(): |
|
271 | key = key.replace(":", "") |
|
272 | if key in skip: |
|
273 | continue |
|
274 | if len(val) < len(cols): |
|
275 | #self.log.error("proc_net_dev: invalid entry: {0}".format(val)) |
|
276 | continue |
|
277 | for mname in cols: |
|
278 | mval = int(val.popleft()) |
|
279 | mstr = "{0}.{1}".format(key, mname) |
|
280 | dval = self.calc.per_second(mstr, mval, ts) |
|
281 | result.add(plumd.Int(mstr, dval)) |
|
282 | return result |
|
283 | ||
284 | ||
285 | def proc_net_snmp(self): |
|
@@ 227-253 (lines=27) @@ | ||
224 | return result |
|
225 | ||
226 | ||
227 | def proc_diskstats(self): |
|
228 | skip = self.config.get('skip_proc_diskstats') |
|
229 | # times in ms |
|
230 | cols = self.config.get('diskstats_cols') |
|
231 | result = plumd.Result("diskstats") |
|
232 | fname = "/proc/diskstats" |
|
233 | dat = {} |
|
234 | # read and process /proc/stat |
|
235 | try: |
|
236 | dat = get_file_map(fname, 2, 0) |
|
237 | except Exception as e: |
|
238 | tb = traceback.format_exc() |
|
239 | self.log.error("proc_diskstats: exception: {0}: {1}".format(e, tb)) |
|
240 | return result |
|
241 | ts = time.time() |
|
242 | for key, val in dat.items(): |
|
243 | if key in skip: |
|
244 | continue |
|
245 | if len(val) != 13: |
|
246 | self.log.error("proc_diskstats: invalid entry: {0}".format(val)) |
|
247 | continue |
|
248 | for mname in cols: |
|
249 | mval = int(val.popleft()) |
|
250 | mstr = "{0}.{1}".format(key, mname) |
|
251 | dval = self.calc.per_second(mstr, mval, ts) |
|
252 | result.add(plumd.Int(mstr, dval)) |
|
253 | return result |
|
254 | ||
255 | ||
256 | def proc_net_dev(self): |