1 |
|
# |
2 |
|
# i-scream pystatgrab |
3 |
< |
# http://www.i-scream.org |
3 |
> |
# http://www.i-scream.org/pystatgrab/ |
4 |
|
# Copyright (C) 2000-2004 i-scream |
5 |
|
# |
6 |
|
# This program is free software; you can redistribute it and/or |
27 |
|
|
28 |
|
cdef extern from "statgrab.h": |
29 |
|
cdef extern int sg_init() |
30 |
+ |
cdef extern int sg_shutdown() |
31 |
+ |
cdef extern int sg_snapshot() |
32 |
|
cdef extern int sg_drop_privileges() |
33 |
|
|
34 |
|
ctypedef enum sg_error: |
64 |
|
SG_ERROR_XSW_VER_MISMATCH |
65 |
|
|
66 |
|
cdef extern void sg_set_error(sg_error code, char *arg) |
67 |
+ |
cdef extern void sg_set_error_with_errno(sg_error code, char *arg) |
68 |
|
cdef extern sg_error sg_get_error() |
69 |
|
cdef extern char *sg_get_error_arg() |
70 |
+ |
cdef extern int sg_get_error_errno() |
71 |
|
cdef extern char *sg_str_error(sg_error code) |
72 |
|
|
73 |
|
ctypedef struct sg_host_info: |
142 |
|
long long total_inodes |
143 |
|
long long used_inodes |
144 |
|
long long free_inodes |
145 |
+ |
long long avail_inodes |
146 |
+ |
long long io_size |
147 |
+ |
long long block_size |
148 |
+ |
long long total_blocks |
149 |
+ |
long long free_blocks |
150 |
+ |
long long used_blocks |
151 |
+ |
long long avail_blocks |
152 |
|
|
153 |
|
cdef extern sg_fs_stats *sg_get_fs_stats(int *entries) |
154 |
|
|
183 |
|
ctypedef struct sg_network_iface_stats: |
184 |
|
char *interface_name |
185 |
|
int speed |
186 |
< |
sg_iface_duplex dup |
186 |
> |
sg_iface_duplex duplex |
187 |
|
int up |
188 |
|
|
189 |
|
cdef extern sg_network_iface_stats *sg_get_network_iface_stats(int *entries) |
297 |
|
else: |
298 |
|
return False |
299 |
|
|
300 |
+ |
def py_sg_shutdown(): |
301 |
+ |
if sg_shutdown() == 0: |
302 |
+ |
return True |
303 |
+ |
else: |
304 |
+ |
return False |
305 |
+ |
|
306 |
+ |
def py_sg_snapshot(): |
307 |
+ |
if sg_snapshot() == 0: |
308 |
+ |
return True |
309 |
+ |
else: |
310 |
+ |
return False |
311 |
+ |
|
312 |
|
def py_sg_drop_privileges(): |
313 |
|
if sg_drop_privileges() == 0: |
314 |
|
return True |
318 |
|
def py_sg_set_error(code, arg): |
319 |
|
sg_set_error(code, arg) |
320 |
|
|
321 |
+ |
def py_sg_set_error_with_errno(code, arg): |
322 |
+ |
sg_set_error_with_errno(code, arg) |
323 |
+ |
|
324 |
|
def py_sg_get_error(): |
325 |
|
cdef sg_error s |
326 |
|
s = sg_get_error() |
330 |
|
s = sg_get_error_arg() |
331 |
|
return s |
332 |
|
|
333 |
+ |
def py_sg_get_error_errno(): |
334 |
+ |
s = sg_get_error_errno() |
335 |
+ |
return s |
336 |
+ |
|
337 |
|
def py_sg_str_error(code): |
338 |
|
s = sg_str_error(code) |
339 |
|
return s |
469 |
|
'total_inodes': s.total_inodes, |
470 |
|
'used_inodes': s.used_inodes, |
471 |
|
'free_inodes': s.free_inodes, |
472 |
+ |
'avail_inodes': s.avail_inodes, |
473 |
+ |
'io_size': s.io_size, |
474 |
+ |
'block_size': s.block_size, |
475 |
+ |
'total_blocks': s.total_blocks, |
476 |
+ |
'free_blocks': s.free_blocks, |
477 |
+ |
'used_blocks': s.used_blocks, |
478 |
+ |
'avail_blocks': s.avail_blocks, |
479 |
|
} |
480 |
|
)) |
481 |
|
s = s + 1 |
574 |
|
list.append(Result( |
575 |
|
{'interface_name': s.interface_name, |
576 |
|
'speed': s.speed, |
577 |
< |
'dup': s.dup, |
577 |
> |
'duplex': s.duplex, |
578 |
|
'up' : s.up, |
579 |
|
} |
580 |
|
)) |
611 |
|
raise StatgrabException, 'sg_get_process_stats() returned NULL' |
612 |
|
list = [] |
613 |
|
for i from 0 <= i < entries: |
614 |
< |
if s.process_name == NULL: |
615 |
< |
s.process_name = '' |
616 |
< |
if s.proctitle == NULL: |
617 |
< |
s.proctitle = '' |
614 |
> |
if s.process_name is NULL: |
615 |
> |
process_name = '' |
616 |
> |
else: |
617 |
> |
process_name = s.process_name |
618 |
> |
if s.proctitle is NULL: |
619 |
> |
proctitle = '' |
620 |
> |
else: |
621 |
> |
proctitle = s.proctitle |
622 |
|
list.append(Result( |
623 |
< |
{'process_name': s.process_name, |
624 |
< |
'proctitle' : s.proctitle, |
623 |
> |
{'process_name': process_name, |
624 |
> |
'proctitle' : proctitle, |
625 |
|
'pid' : s.pid, |
626 |
|
'parent' : s.parent, |
627 |
|
'pgid' : s.pgid, |