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.14 by tdb, Sun May 30 16:41:03 2004 UTC vs.
Revision 1.20 by tdb, Fri Jul 13 22:26:19 2007 UTC

# Line 1 | Line 1
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
# Line 27 | Line 27 | ctypedef int gid_t
27  
28   cdef extern from "statgrab.h":
29      cdef extern int sg_init()
30 +    cdef extern int sg_shutdown()
31 +    cdef extern int sg_snapshot()
32      cdef extern int sg_drop_privileges()
33  
34      ctypedef enum sg_error:
# Line 62 | Line 64 | cdef extern from "statgrab.h":
64          SG_ERROR_XSW_VER_MISMATCH
65  
66      cdef extern void sg_set_error(sg_error code, char *arg)
67 +    cdef extern void sg_set_error_with_errno(sg_error code, char *arg)
68      cdef extern sg_error sg_get_error()
69      cdef extern char *sg_get_error_arg()
70 +    cdef extern int sg_get_error_errno()
71      cdef extern char *sg_str_error(sg_error code)
72  
73      ctypedef struct sg_host_info:
# Line 138 | Line 142 | cdef extern from "statgrab.h":
142          long long total_inodes
143          long long used_inodes
144          long long free_inodes
145 +        long long avail_inodes
146 +        long long io_size
147 +        long long block_size
148 +        long long total_blocks
149 +        long long free_blocks
150 +        long long used_blocks
151 +        long long avail_blocks
152  
153      cdef extern sg_fs_stats *sg_get_fs_stats(int *entries)
154  
# Line 172 | Line 183 | cdef extern from "statgrab.h":
183      ctypedef struct sg_network_iface_stats:
184          char *interface_name
185          int speed
186 <        sg_iface_duplex dup
186 >        sg_iface_duplex duplex
187          int up
188  
189      cdef extern sg_network_iface_stats *sg_get_network_iface_stats(int *entries)
# Line 286 | Line 297 | def py_sg_init():
297      else:
298          return False
299  
300 + def py_sg_shutdown():
301 +    if sg_shutdown() == 0:
302 +        return True
303 +    else:
304 +        return False
305 +
306 + def py_sg_snapshot():
307 +    if sg_snapshot() == 0:
308 +        return True
309 +    else:
310 +        return False
311 +
312   def py_sg_drop_privileges():
313      if sg_drop_privileges() == 0:
314          return True
# Line 295 | Line 318 | def py_sg_drop_privileges():
318   def py_sg_set_error(code, arg):
319      sg_set_error(code, arg)
320  
321 + def py_sg_set_error_with_errno(code, arg):
322 +    sg_set_error_with_errno(code, arg)
323 +
324   def py_sg_get_error():
325      cdef sg_error s
326      s = sg_get_error()
# Line 304 | Line 330 | def py_sg_get_error_arg():
330      s = sg_get_error_arg()
331      return s
332  
333 + def py_sg_get_error_errno():
334 +    s = sg_get_error_errno()
335 +    return s
336 +
337   def py_sg_str_error(code):
338      s = sg_str_error(code)
339      return s
# Line 439 | Line 469 | def py_sg_get_fs_stats():
469               'total_inodes': s.total_inodes,
470               'used_inodes': s.used_inodes,
471               'free_inodes': s.free_inodes,
472 +             'avail_inodes': s.avail_inodes,
473 +             'io_size': s.io_size,
474 +             'block_size': s.block_size,
475 +             'total_blocks': s.total_blocks,
476 +             'free_blocks': s.free_blocks,
477 +             'used_blocks': s.used_blocks,
478 +             'avail_blocks': s.avail_blocks,
479              }
480          ))
481          s = s + 1
# Line 537 | Line 574 | def py_sg_get_network_iface_stats():
574          list.append(Result(
575              {'interface_name': s.interface_name,
576               'speed': s.speed,
577 <             'dup': s.dup,
577 >             'duplex': s.duplex,
578               'up' : s.up,
579              }
580          ))
# Line 574 | Line 611 | def py_sg_get_process_stats():
611          raise StatgrabException, 'sg_get_process_stats() returned NULL'
612      list = []
613      for i from 0 <= i < entries:
614 <        if s.process_name == NULL:
615 <            s.process_name = ''
616 <        if s.proctitle == NULL:
617 <            s.proctitle = ''
614 >        if s.process_name is NULL:
615 >            process_name = ''
616 >        else:
617 >            process_name = s.process_name
618 >        if s.proctitle is NULL:
619 >            proctitle = ''
620 >        else:
621 >            proctitle = s.proctitle
622          list.append(Result(
623 <            {'process_name': s.process_name,
624 <             'proctitle' : s.proctitle,
623 >            {'process_name': process_name,
624 >             'proctitle' : proctitle,
625               'pid' : s.pid,
626               'parent' : s.parent,
627               'pgid' : s.pgid,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines