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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines