--- projects/pystatgrab/_statgrab.pyx 2004/05/30 16:41:03 1.14 +++ projects/pystatgrab/_statgrab.pyx 2007/07/13 22:19:56 1.19 @@ -1,6 +1,6 @@ # # i-scream pystatgrab -# http://www.i-scream.org +# http://www.i-scream.org/pystatgrab/ # Copyright (C) 2000-2004 i-scream # # This program is free software; you can redistribute it and/or @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -# $Id: _statgrab.pyx,v 1.14 2004/05/30 16:41:03 tdb Exp $ +# $Id: _statgrab.pyx,v 1.19 2007/07/13 22:19:56 tdb Exp $ # ctypedef long time_t @@ -62,8 +62,10 @@ cdef extern from "statgrab.h": SG_ERROR_XSW_VER_MISMATCH cdef extern void sg_set_error(sg_error code, char *arg) + cdef extern void sg_set_error_with_errno(sg_error code, char *arg) cdef extern sg_error sg_get_error() cdef extern char *sg_get_error_arg() + cdef extern int sg_get_error_errno() cdef extern char *sg_str_error(sg_error code) ctypedef struct sg_host_info: @@ -138,6 +140,13 @@ cdef extern from "statgrab.h": long long total_inodes long long used_inodes long long free_inodes + long long avail_inodes + long long io_size + long long block_size + long long total_blocks + long long free_blocks + long long used_blocks + long long avail_blocks cdef extern sg_fs_stats *sg_get_fs_stats(int *entries) @@ -172,7 +181,7 @@ cdef extern from "statgrab.h": ctypedef struct sg_network_iface_stats: char *interface_name int speed - sg_iface_duplex dup + sg_iface_duplex duplex int up cdef extern sg_network_iface_stats *sg_get_network_iface_stats(int *entries) @@ -286,6 +295,18 @@ def py_sg_init(): else: return False +def py_sg_shutdown(): + if sg_shutdown() == 0: + return True + else: + return False + +def py_sg_snapshot(): + if sg_snapshot() == 0: + return True + else: + return False + def py_sg_drop_privileges(): if sg_drop_privileges() == 0: return True @@ -295,6 +316,9 @@ def py_sg_drop_privileges(): def py_sg_set_error(code, arg): sg_set_error(code, arg) +def py_sg_set_error_with_errno(code, arg): + sg_set_error_with_errno(code, arg) + def py_sg_get_error(): cdef sg_error s s = sg_get_error() @@ -304,6 +328,10 @@ def py_sg_get_error_arg(): s = sg_get_error_arg() return s +def py_sg_get_error_errno(): + s = sg_get_error_errno() + return s + def py_sg_str_error(code): s = sg_str_error(code) return s @@ -439,6 +467,13 @@ def py_sg_get_fs_stats(): 'total_inodes': s.total_inodes, 'used_inodes': s.used_inodes, 'free_inodes': s.free_inodes, + 'avail_inodes': s.avail_inodes, + 'io_size': s.io_size, + 'block_size': s.block_size, + 'total_blocks': s.total_blocks, + 'free_blocks': s.free_blocks, + 'used_blocks': s.used_blocks, + 'avail_blocks': s.avail_blocks, } )) s = s + 1 @@ -537,7 +572,7 @@ def py_sg_get_network_iface_stats(): list.append(Result( {'interface_name': s.interface_name, 'speed': s.speed, - 'dup': s.dup, + 'duplex': s.duplex, 'up' : s.up, } )) @@ -574,13 +609,17 @@ def py_sg_get_process_stats(): raise StatgrabException, 'sg_get_process_stats() returned NULL' list = [] for i from 0 <= i < entries: - if s.process_name == NULL: - s.process_name = '' - if s.proctitle == NULL: - s.proctitle = '' + if s.process_name is NULL: + process_name = '' + else: + process_name = s.process_name + if s.proctitle is NULL: + proctitle = '' + else: + proctitle = s.proctitle list.append(Result( - {'process_name': s.process_name, - 'proctitle' : s.proctitle, + {'process_name': process_name, + 'proctitle' : proctitle, 'pid' : s.pid, 'parent' : s.parent, 'pgid' : s.pgid,