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