98 |
|
char *interface_name |
99 |
|
long long tx |
100 |
|
long long rx |
101 |
+ |
long long ipackets |
102 |
+ |
long long opackets |
103 |
+ |
long long ierrors |
104 |
+ |
long long oerrors |
105 |
+ |
long long collisions |
106 |
|
time_t systime |
107 |
|
|
108 |
+ |
ctypedef enum statgrab_duplex: |
109 |
+ |
FULL_DUPLEX |
110 |
+ |
HALF_DUPLEX |
111 |
+ |
UNKNOWN_DUPLEX |
112 |
+ |
|
113 |
+ |
ctypedef struct network_iface_stat_t: |
114 |
+ |
char *interface_name |
115 |
+ |
int speed |
116 |
+ |
statgrab_duplex dup |
117 |
+ |
int up |
118 |
+ |
|
119 |
|
ctypedef struct page_stat_t: |
120 |
|
long long pages_pagein |
121 |
|
long long pages_pageout |
135 |
|
cdef extern process_stat_t *get_process_stats() |
136 |
|
cdef extern network_stat_t *get_network_stats(int *entries) |
137 |
|
cdef extern network_stat_t *get_network_stats_diff(int *entries) |
138 |
+ |
cdef extern network_iface_stat_t *get_network_iface_stats(int *entries) |
139 |
|
cdef extern page_stat_t *get_page_stats() |
140 |
|
cdef extern page_stat_t *get_page_stats_diff() |
141 |
|
cdef extern int statgrab_init() |
142 |
|
cdef extern int statgrab_drop_privileges() |
143 |
|
|
144 |
|
|
145 |
+ |
py_FULL_DUPLEX = FULL_DUPLEX |
146 |
+ |
py_HALF_DUPLEX = HALF_DUPLEX |
147 |
+ |
py_UNKNOWN_DUPLEX = UNKNOWN_DUPLEX |
148 |
+ |
|
149 |
+ |
|
150 |
|
class Result: |
151 |
|
def __init__(self, attrs): |
152 |
|
self.attrs = attrs |
283 |
|
s = get_disk_stats(&entries) |
284 |
|
if s == NULL: |
285 |
|
raise StatgrabException, 'get_disk_stats() returned NULL' |
286 |
< |
list = [entries] |
286 |
> |
list = [] |
287 |
|
for i from 0 <= i < entries: |
288 |
|
list.append(Result( |
289 |
|
{'device_name': s.device_name, |
306 |
|
s = get_diskio_stats(&entries) |
307 |
|
if s == NULL: |
308 |
|
raise StatgrabException, 'get_diskio_stats() returned NULL' |
309 |
< |
list = [entries] |
309 |
> |
list = [] |
310 |
|
for i from 0 <= i < entries: |
311 |
|
list.append(Result( |
312 |
|
{'disk_name': s.disk_name, |
324 |
|
s = get_diskio_stats_diff(&entries) |
325 |
|
if s == NULL: |
326 |
|
raise StatgrabException, 'get_diskio_stats_diff() returned NULL' |
327 |
< |
list = [entries] |
327 |
> |
list = [] |
328 |
|
for i from 0 <= i < entries: |
329 |
|
list.append(Result( |
330 |
|
{'disk_name': s.disk_name, |
356 |
|
s = get_network_stats(&entries) |
357 |
|
if s == NULL: |
358 |
|
raise StatgrabException, 'get_network_stats() returned NULL' |
359 |
< |
list = [entries] |
359 |
> |
list = [] |
360 |
|
for i from 0 <= i < entries: |
361 |
|
list.append(Result( |
362 |
|
{'interface_name': s.interface_name, |
363 |
|
'tx': s.tx, |
364 |
|
'rx': s.rx, |
365 |
+ |
'ipackets': s.ipackets, |
366 |
+ |
'opackets': s.opackets, |
367 |
+ |
'ierrors': s.ierrors, |
368 |
+ |
'oerrors': s.oerrors, |
369 |
+ |
'collisions': s.collisions, |
370 |
|
'systime': s.systime, |
371 |
|
} |
372 |
|
)) |
379 |
|
s = get_network_stats_diff(&entries) |
380 |
|
if s == NULL: |
381 |
|
raise StatgrabException, 'get_network_stats_diff() returned NULL' |
382 |
< |
list = [entries] |
382 |
> |
list = [] |
383 |
|
for i from 0 <= i < entries: |
384 |
|
list.append(Result( |
385 |
|
{'interface_name': s.interface_name, |
386 |
|
'tx': s.tx, |
387 |
|
'rx': s.rx, |
388 |
+ |
'ipackets': s.ipackets, |
389 |
+ |
'opackets': s.opackets, |
390 |
+ |
'ierrors': s.ierrors, |
391 |
+ |
'oerrors': s.oerrors, |
392 |
+ |
'collisions': s.collisions, |
393 |
|
'systime': s.systime, |
394 |
+ |
} |
395 |
+ |
)) |
396 |
+ |
s = s + 1 |
397 |
+ |
return list |
398 |
+ |
|
399 |
+ |
def py_get_network_iface_stats(): |
400 |
+ |
cdef network_iface_stat_t *s |
401 |
+ |
cdef int entries |
402 |
+ |
s = get_network_iface_stats(&entries) |
403 |
+ |
if s == NULL: |
404 |
+ |
raise StatgrabException, 'get_network_iface_stats() returned NULL' |
405 |
+ |
list = [] |
406 |
+ |
for i from 0 <= i < entries: |
407 |
+ |
list.append(Result( |
408 |
+ |
{'interface_name': s.interface_name, |
409 |
+ |
'speed': s.speed, |
410 |
+ |
'dup': s.dup, |
411 |
+ |
'up' : s.up, |
412 |
|
} |
413 |
|
)) |
414 |
|
s = s + 1 |