--- projects/pystatgrab/_statgrab.pyx 2004/02/13 00:16:20 1.5 +++ projects/pystatgrab/_statgrab.pyx 2004/03/20 21:29:59 1.10 @@ -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.5 2004/02/13 00:16:20 tdb Exp $ +# $Id: _statgrab.pyx,v 1.10 2004/03/20 21:29:59 tdb Exp $ # ctypedef long time_t @@ -98,17 +98,23 @@ cdef extern from "statgrab.h": char *interface_name long long tx long long rx + long long ipackets + long long opackets + long long ierrors + long long oerrors + long long collisions time_t systime - ctypedef enum duplex: + ctypedef enum statgrab_duplex: FULL_DUPLEX HALF_DUPLEX - NO_DUPLEX + UNKNOWN_DUPLEX ctypedef struct network_iface_stat_t: char *interface_name int speed - duplex dup + statgrab_duplex dup + int up ctypedef struct page_stat_t: long long pages_pagein @@ -136,6 +142,11 @@ cdef extern from "statgrab.h": cdef extern int statgrab_drop_privileges() +py_FULL_DUPLEX = FULL_DUPLEX +py_HALF_DUPLEX = HALF_DUPLEX +py_UNKNOWN_DUPLEX = UNKNOWN_DUPLEX + + class Result: def __init__(self, attrs): self.attrs = attrs @@ -272,7 +283,7 @@ def py_get_disk_stats(): s = get_disk_stats(&entries) if s == NULL: raise StatgrabException, 'get_disk_stats() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'device_name': s.device_name, @@ -295,7 +306,7 @@ def py_get_diskio_stats(): s = get_diskio_stats(&entries) if s == NULL: raise StatgrabException, 'get_diskio_stats() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'disk_name': s.disk_name, @@ -313,7 +324,7 @@ def py_get_diskio_stats_diff(): s = get_diskio_stats_diff(&entries) if s == NULL: raise StatgrabException, 'get_diskio_stats_diff() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'disk_name': s.disk_name, @@ -345,12 +356,17 @@ def py_get_network_stats(): s = get_network_stats(&entries) if s == NULL: raise StatgrabException, 'get_network_stats() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'interface_name': s.interface_name, 'tx': s.tx, 'rx': s.rx, + 'ipackets': s.ipackets, + 'opackets': s.opackets, + 'ierrors': s.ierrors, + 'oerrors': s.oerrors, + 'collisions': s.collisions, 'systime': s.systime, } )) @@ -363,12 +379,17 @@ def py_get_network_stats_diff(): s = get_network_stats_diff(&entries) if s == NULL: raise StatgrabException, 'get_network_stats_diff() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'interface_name': s.interface_name, 'tx': s.tx, 'rx': s.rx, + 'ipackets': s.ipackets, + 'opackets': s.opackets, + 'ierrors': s.ierrors, + 'oerrors': s.oerrors, + 'collisions': s.collisions, 'systime': s.systime, } )) @@ -381,12 +402,13 @@ def py_get_network_iface_stats(): s = get_network_iface_stats(&entries) if s == NULL: raise StatgrabException, 'get_network_iface_stats() returned NULL' - list = [entries] + list = [] for i from 0 <= i < entries: list.append(Result( {'interface_name': s.interface_name, 'speed': s.speed, 'dup': s.dup, + 'up' : s.up, } )) s = s + 1 @@ -415,7 +437,13 @@ def py_get_page_stats_diff(): ) def py_statgrab_init(): - return statgrab_init() + if statgrab_init() == 0: + return True + else: + return False def py_statgrab_drop_privileges(): - return statgrab_drop_privileges() + if statgrab_drop_privileges() == 0: + return True + else: + return False