ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/extras/python/statgrab.pyx
(Generate patch)

Comparing projects/libstatgrab/extras/python/statgrab.pyx (file contents):
Revision 1.3 by tdb, Mon Feb 9 23:07:25 2004 UTC vs.
Revision 1.7 by tdb, Fri Feb 13 17:53:15 2004 UTC

# Line 100 | Line 100 | cdef extern from "statgrab.h":
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 +
113      ctypedef struct page_stat_t:
114          long long pages_pagein
115          long long pages_pageout
# Line 119 | Line 129 | cdef extern from "statgrab.h":
129      cdef extern process_stat_t *get_process_stats()
130      cdef extern network_stat_t *get_network_stats(int *entries)
131      cdef extern network_stat_t *get_network_stats_diff(int *entries)
132 +    cdef extern network_iface_stat_t *get_network_iface_stats(int *entries)
133      cdef extern page_stat_t *get_page_stats()
134      cdef extern page_stat_t *get_page_stats_diff()
135      cdef extern int statgrab_init()
136      cdef extern int statgrab_drop_privileges()
137  
138  
139 + py_FULL_DUPLEX = FULL_DUPLEX
140 + py_HALF_DUPLEX = HALF_DUPLEX
141 + py_UNKNOWN_DUPLEX = UNKNOWN_DUPLEX
142 +
143 +
144   class Result:
145      def __init__(self, attrs):
146          self.attrs = attrs
# Line 135 | Line 151 | class Result:
151      def __repr__(self):
152          return str(self.attrs)
153  
154 < class StatgrabException:
154 > class StatgrabException(Exception):
155      def __init__(self, value):
156          self.value = value
157      def __str__(self):
# Line 261 | Line 277 | def py_get_disk_stats():
277      s = get_disk_stats(&entries)
278      if s == NULL:
279          raise StatgrabException, 'get_disk_stats() returned NULL'
280 <    list = [entries]
280 >    list = []
281      for i from 0 <= i < entries:
282          list.append(Result(
283              {'device_name': s.device_name,
# Line 284 | Line 300 | def py_get_diskio_stats():
300      s = get_diskio_stats(&entries)
301      if s == NULL:
302          raise StatgrabException, 'get_diskio_stats() returned NULL'
303 <    list = [entries]
303 >    list = []
304      for i from 0 <= i < entries:
305          list.append(Result(
306              {'disk_name': s.disk_name,
# Line 302 | Line 318 | def py_get_diskio_stats_diff():
318      s = get_diskio_stats_diff(&entries)
319      if s == NULL:
320          raise StatgrabException, 'get_diskio_stats_diff() returned NULL'
321 <    list = [entries]
321 >    list = []
322      for i from 0 <= i < entries:
323          list.append(Result(
324              {'disk_name': s.disk_name,
# Line 334 | Line 350 | def py_get_network_stats():
350      s = get_network_stats(&entries)
351      if s == NULL:
352          raise StatgrabException, 'get_network_stats() returned NULL'
353 <    list = [entries]
353 >    list = []
354      for i from 0 <= i < entries:
355          list.append(Result(
356              {'interface_name': s.interface_name,
# Line 352 | Line 368 | def py_get_network_stats_diff():
368      s = get_network_stats_diff(&entries)
369      if s == NULL:
370          raise StatgrabException, 'get_network_stats_diff() returned NULL'
371 <    list = [entries]
371 >    list = []
372      for i from 0 <= i < entries:
373          list.append(Result(
374              {'interface_name': s.interface_name,
375               'tx': s.tx,
376               'rx': s.rx,
377               'systime': s.systime,
378 +            }
379 +        ))
380 +        s = s + 1
381 +    return list
382 +
383 + def py_get_network_iface_stats():
384 +    cdef network_iface_stat_t *s
385 +    cdef int entries
386 +    s = get_network_iface_stats(&entries)
387 +    if s == NULL:
388 +        raise StatgrabException, 'get_network_iface_stats() returned NULL'
389 +    list = []
390 +    for i from 0 <= i < entries:
391 +        list.append(Result(
392 +            {'interface_name': s.interface_name,
393 +             'speed': s.speed,
394 +             'dup': s.dup,
395              }
396          ))
397          s = s + 1

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines