100 |
|
long long rx |
101 |
|
time_t systime |
102 |
|
|
103 |
+ |
ctypedef enum statgrab_duplex: |
104 |
+ |
FULL_DUPLEX |
105 |
+ |
HALF_DUPLEX |
106 |
+ |
UNKNOWN_DUPLEX |
107 |
+ |
|
108 |
+ |
ctypedef struct network_iface_stat_t: |
109 |
+ |
char *interface_name |
110 |
+ |
int speed |
111 |
+ |
statgrab_duplex dup |
112 |
+ |
int up |
113 |
+ |
|
114 |
|
ctypedef struct page_stat_t: |
115 |
|
long long pages_pagein |
116 |
|
long long pages_pageout |
130 |
|
cdef extern process_stat_t *get_process_stats() |
131 |
|
cdef extern network_stat_t *get_network_stats(int *entries) |
132 |
|
cdef extern network_stat_t *get_network_stats_diff(int *entries) |
133 |
+ |
cdef extern network_iface_stat_t *get_network_iface_stats(int *entries) |
134 |
|
cdef extern page_stat_t *get_page_stats() |
135 |
|
cdef extern page_stat_t *get_page_stats_diff() |
136 |
|
cdef extern int statgrab_init() |
137 |
|
cdef extern int statgrab_drop_privileges() |
138 |
|
|
139 |
|
|
140 |
+ |
py_FULL_DUPLEX = FULL_DUPLEX |
141 |
+ |
py_HALF_DUPLEX = HALF_DUPLEX |
142 |
+ |
py_UNKNOWN_DUPLEX = UNKNOWN_DUPLEX |
143 |
+ |
|
144 |
+ |
|
145 |
|
class Result: |
146 |
|
def __init__(self, attrs): |
147 |
|
self.attrs = attrs |
278 |
|
s = get_disk_stats(&entries) |
279 |
|
if s == NULL: |
280 |
|
raise StatgrabException, 'get_disk_stats() returned NULL' |
281 |
< |
list = [entries] |
281 |
> |
list = [] |
282 |
|
for i from 0 <= i < entries: |
283 |
|
list.append(Result( |
284 |
|
{'device_name': s.device_name, |
301 |
|
s = get_diskio_stats(&entries) |
302 |
|
if s == NULL: |
303 |
|
raise StatgrabException, 'get_diskio_stats() returned NULL' |
304 |
< |
list = [entries] |
304 |
> |
list = [] |
305 |
|
for i from 0 <= i < entries: |
306 |
|
list.append(Result( |
307 |
|
{'disk_name': s.disk_name, |
319 |
|
s = get_diskio_stats_diff(&entries) |
320 |
|
if s == NULL: |
321 |
|
raise StatgrabException, 'get_diskio_stats_diff() returned NULL' |
322 |
< |
list = [entries] |
322 |
> |
list = [] |
323 |
|
for i from 0 <= i < entries: |
324 |
|
list.append(Result( |
325 |
|
{'disk_name': s.disk_name, |
351 |
|
s = get_network_stats(&entries) |
352 |
|
if s == NULL: |
353 |
|
raise StatgrabException, 'get_network_stats() returned NULL' |
354 |
< |
list = [entries] |
354 |
> |
list = [] |
355 |
|
for i from 0 <= i < entries: |
356 |
|
list.append(Result( |
357 |
|
{'interface_name': s.interface_name, |
369 |
|
s = get_network_stats_diff(&entries) |
370 |
|
if s == NULL: |
371 |
|
raise StatgrabException, 'get_network_stats_diff() returned NULL' |
372 |
< |
list = [entries] |
372 |
> |
list = [] |
373 |
|
for i from 0 <= i < entries: |
374 |
|
list.append(Result( |
375 |
|
{'interface_name': s.interface_name, |
376 |
|
'tx': s.tx, |
377 |
|
'rx': s.rx, |
378 |
|
'systime': s.systime, |
379 |
+ |
} |
380 |
+ |
)) |
381 |
+ |
s = s + 1 |
382 |
+ |
return list |
383 |
+ |
|
384 |
+ |
def py_get_network_iface_stats(): |
385 |
+ |
cdef network_iface_stat_t *s |
386 |
+ |
cdef int entries |
387 |
+ |
s = get_network_iface_stats(&entries) |
388 |
+ |
if s == NULL: |
389 |
+ |
raise StatgrabException, 'get_network_iface_stats() returned NULL' |
390 |
+ |
list = [] |
391 |
+ |
for i from 0 <= i < entries: |
392 |
+ |
list.append(Result( |
393 |
+ |
{'interface_name': s.interface_name, |
394 |
+ |
'speed': s.speed, |
395 |
+ |
'dup': s.dup, |
396 |
+ |
'up' : s.up, |
397 |
|
} |
398 |
|
)) |
399 |
|
s = s + 1 |