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 |
62 |
|
SG_ERROR_XSW_VER_MISMATCH |
63 |
|
|
64 |
|
cdef extern void sg_set_error(sg_error code, char *arg) |
65 |
+ |
cdef extern void sg_set_error_with_errno(sg_error code, char *arg) |
66 |
|
cdef extern sg_error sg_get_error() |
67 |
|
cdef extern char *sg_get_error_arg() |
68 |
+ |
cdef extern int sg_get_error_errno() |
69 |
|
cdef extern char *sg_str_error(sg_error code) |
70 |
|
|
71 |
|
ctypedef struct sg_host_info: |
140 |
|
long long total_inodes |
141 |
|
long long used_inodes |
142 |
|
long long free_inodes |
143 |
+ |
long long avail_inodes |
144 |
+ |
long long io_size |
145 |
+ |
long long block_size |
146 |
+ |
long long total_blocks |
147 |
+ |
long long free_blocks |
148 |
+ |
long long used_blocks |
149 |
+ |
long long avail_blocks |
150 |
|
|
151 |
|
cdef extern sg_fs_stats *sg_get_fs_stats(int *entries) |
152 |
|
|
181 |
|
ctypedef struct sg_network_iface_stats: |
182 |
|
char *interface_name |
183 |
|
int speed |
184 |
< |
sg_iface_duplex dup |
184 |
> |
sg_iface_duplex duplex |
185 |
|
int up |
186 |
|
|
187 |
|
cdef extern sg_network_iface_stats *sg_get_network_iface_stats(int *entries) |
295 |
|
else: |
296 |
|
return False |
297 |
|
|
298 |
+ |
def py_sg_shutdown(): |
299 |
+ |
if sg_shutdown() == 0: |
300 |
+ |
return True |
301 |
+ |
else: |
302 |
+ |
return False |
303 |
+ |
|
304 |
+ |
def py_sg_snapshot(): |
305 |
+ |
if sg_snapshot() == 0: |
306 |
+ |
return True |
307 |
+ |
else: |
308 |
+ |
return False |
309 |
+ |
|
310 |
|
def py_sg_drop_privileges(): |
311 |
|
if sg_drop_privileges() == 0: |
312 |
|
return True |
316 |
|
def py_sg_set_error(code, arg): |
317 |
|
sg_set_error(code, arg) |
318 |
|
|
319 |
+ |
def py_sg_set_error_with_errno(code, arg): |
320 |
+ |
sg_set_error_with_errno(code, arg) |
321 |
+ |
|
322 |
|
def py_sg_get_error(): |
323 |
|
cdef sg_error s |
324 |
|
s = sg_get_error() |
328 |
|
s = sg_get_error_arg() |
329 |
|
return s |
330 |
|
|
331 |
+ |
def py_sg_get_error_errno(): |
332 |
+ |
s = sg_get_error_errno() |
333 |
+ |
return s |
334 |
+ |
|
335 |
|
def py_sg_str_error(code): |
336 |
|
s = sg_str_error(code) |
337 |
|
return s |
467 |
|
'total_inodes': s.total_inodes, |
468 |
|
'used_inodes': s.used_inodes, |
469 |
|
'free_inodes': s.free_inodes, |
470 |
+ |
'avail_inodes': s.avail_inodes, |
471 |
+ |
'io_size': s.io_size, |
472 |
+ |
'block_size': s.block_size, |
473 |
+ |
'total_blocks': s.total_blocks, |
474 |
+ |
'free_blocks': s.free_blocks, |
475 |
+ |
'used_blocks': s.used_blocks, |
476 |
+ |
'avail_blocks': s.avail_blocks, |
477 |
|
} |
478 |
|
)) |
479 |
|
s = s + 1 |
572 |
|
list.append(Result( |
573 |
|
{'interface_name': s.interface_name, |
574 |
|
'speed': s.speed, |
575 |
< |
'dup': s.dup, |
575 |
> |
'duplex': s.duplex, |
576 |
|
'up' : s.up, |
577 |
|
} |
578 |
|
)) |
609 |
|
raise StatgrabException, 'sg_get_process_stats() returned NULL' |
610 |
|
list = [] |
611 |
|
for i from 0 <= i < entries: |
612 |
< |
if s.process_name == NULL: |
613 |
< |
s.process_name = '' |
614 |
< |
if s.proctitle == NULL: |
615 |
< |
s.proctitle = '' |
612 |
> |
if s.process_name is NULL: |
613 |
> |
process_name = '' |
614 |
> |
else: |
615 |
> |
process_name = s.process_name |
616 |
> |
if s.proctitle is NULL: |
617 |
> |
proctitle = '' |
618 |
> |
else: |
619 |
> |
proctitle = s.proctitle |
620 |
|
list.append(Result( |
621 |
< |
{'process_name': s.process_name, |
622 |
< |
'proctitle' : s.proctitle, |
621 |
> |
{'process_name': process_name, |
622 |
> |
'proctitle' : proctitle, |
623 |
|
'pid' : s.pid, |
624 |
|
'parent' : s.parent, |
625 |
|
'pgid' : s.pgid, |