@@ 141-157 (lines=17) @@ | ||
138 | 'devices': None # all |
|
139 | } |
|
140 | ||
141 | def poll(self): |
|
142 | """Poll for diskio metrics. |
|
143 | ||
144 | :rtype: ResultSet |
|
145 | """ |
|
146 | rset = plumd.ResultSet() |
|
147 | diskio = psutil.disk_io_counters(perdisk=True) |
|
148 | for dev in diskio.keys(): |
|
149 | metrics = [] |
|
150 | dio = diskio[dev] |
|
151 | for dev_f in dio._fields: |
|
152 | val = getattr(dio, dev_f) |
|
153 | metrics.append(plumd.Float(dev_f, val)) |
|
154 | robj = plumd.Result("diskio", metrics) |
|
155 | robj.meta.add(plumd.String("dev", dev)) |
|
156 | rset.add(robj) |
|
157 | return rset |
|
158 | ||
@@ 83-99 (lines=17) @@ | ||
80 | 'nics': None # all |
|
81 | } |
|
82 | ||
83 | def poll(self): |
|
84 | """Poll for net per nic bandwidth metrics. |
|
85 | ||
86 | :rtype: ResultSet |
|
87 | """ |
|
88 | nicios = psutil.net_io_counters(pernic=True) |
|
89 | rset = plumd.ResultSet() |
|
90 | for nic in nicios.keys(): |
|
91 | metrics = [] |
|
92 | nic_io = nicios[nic] |
|
93 | for io_field in nic_io._fields: |
|
94 | val = getattr(nic_io, io_field) |
|
95 | metrics.append(plumd.Float(io_field, val)) |
|
96 | robj = plumd.Result("net", metrics) |
|
97 | robj.meta.add(plumd.String("nic", nic.replace(" ", "_"))) |
|
98 | rset.add(robj) |
|
99 | return rset |
|
100 | ||
101 | ||
102 | class Disk(plumd.Reader): |