ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/pystatgrab/_statgrab.pyx
Revision: 1.16
Committed: Sat Jul 30 10:49:42 2005 UTC (19 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.15: +3 -3 lines
Log Message:
Chase libstatgrab API changes.

File Contents

# User Rev Content
1 tdb 1.3 #
2 tdb 1.11 # i-scream pystatgrab
3 tdb 1.15 # http://www.i-scream.org/pystatgrab/
4 tdb 1.3 # Copyright (C) 2000-2004 i-scream
5     #
6     # This program is free software; you can redistribute it and/or
7     # modify it under the terms of the GNU General Public License
8     # as published by the Free Software Foundation; either version 2
9     # of the License, or (at your option) any later version.
10     #
11     # This program is distributed in the hope that it will be useful,
12     # but WITHOUT ANY WARRANTY; without even the implied warranty of
13     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     # GNU General Public License for more details.
15     #
16     # You should have received a copy of the GNU General Public License
17     # along with this program; if not, write to the Free Software
18     # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19     #
20 tdb 1.16 # $Id: _statgrab.pyx,v 1.15 2004/08/24 20:43:47 tdb Exp $
21 tdb 1.3 #
22 tdb 1.1
23     ctypedef long time_t
24 tdb 1.14 ctypedef int pid_t
25     ctypedef int uid_t
26     ctypedef int gid_t
27 tdb 1.1
28     cdef extern from "statgrab.h":
29 tdb 1.13 cdef extern int sg_init()
30     cdef extern int sg_drop_privileges()
31    
32 tdb 1.14 ctypedef enum sg_error:
33     SG_ERROR_NONE = 0
34     SG_ERROR_ASPRINTF
35     SG_ERROR_DEVSTAT_GETDEVS
36     SG_ERROR_DEVSTAT_SELECTDEVS
37     SG_ERROR_ENOENT
38     SG_ERROR_GETIFADDRS
39     SG_ERROR_GETMNTINFO
40     SG_ERROR_GETPAGESIZE
41     SG_ERROR_KSTAT_DATA_LOOKUP
42     SG_ERROR_KSTAT_LOOKUP
43     SG_ERROR_KSTAT_OPEN
44     SG_ERROR_KSTAT_READ
45     SG_ERROR_KVM_GETSWAPINFO
46     SG_ERROR_KVM_OPENFILES
47     SG_ERROR_MALLOC
48     SG_ERROR_OPEN
49     SG_ERROR_OPENDIR
50     SG_ERROR_PARSE
51     SG_ERROR_SETEGID
52     SG_ERROR_SETEUID
53     SG_ERROR_SETMNTENT
54     SG_ERROR_SOCKET
55     SG_ERROR_SWAPCTL
56     SG_ERROR_SYSCONF
57     SG_ERROR_SYSCTL
58     SG_ERROR_SYSCTLBYNAME
59     SG_ERROR_SYSCTLNAMETOMIB
60     SG_ERROR_UNAME
61     SG_ERROR_UNSUPPORTED
62     SG_ERROR_XSW_VER_MISMATCH
63    
64     cdef extern void sg_set_error(sg_error code, char *arg)
65 tdb 1.15 cdef extern void sg_set_error_with_errno(sg_error code, char *arg)
66 tdb 1.14 cdef extern sg_error sg_get_error()
67     cdef extern char *sg_get_error_arg()
68 tdb 1.15 cdef extern int sg_get_error_errno()
69 tdb 1.14 cdef extern char *sg_str_error(sg_error code)
70    
71 tdb 1.13 ctypedef struct sg_host_info:
72     char *os_name
73     char *os_release
74     char *os_version
75     char *platform
76     char *hostname
77     time_t uptime
78    
79     cdef extern sg_host_info *sg_get_host_info()
80    
81 tdb 1.12 ctypedef struct sg_cpu_stats:
82 tdb 1.1 long long user
83     long long kernel
84     long long idle
85     long long iowait
86     long long swap
87     long long nice
88     long long total
89     time_t systime
90    
91 tdb 1.13 cdef extern sg_cpu_stats *sg_get_cpu_stats()
92     cdef extern sg_cpu_stats *sg_get_cpu_stats_diff()
93    
94 tdb 1.12 ctypedef struct sg_cpu_percents:
95 tdb 1.1 float user
96     float kernel
97     float idle
98     float iowait
99     float swap
100     float nice
101     time_t time_taken
102    
103 tdb 1.13 cdef extern sg_cpu_percents *sg_get_cpu_percents()
104    
105 tdb 1.12 ctypedef struct sg_mem_stats:
106 tdb 1.1 long long total
107     long long free
108     long long used
109     long long cache
110    
111 tdb 1.13 cdef extern sg_mem_stats *sg_get_mem_stats()
112    
113 tdb 1.12 ctypedef struct sg_load_stats:
114 tdb 1.1 double min1
115     double min5
116     double min15
117    
118 tdb 1.13 cdef extern sg_load_stats *sg_get_load_stats()
119    
120 tdb 1.12 ctypedef struct sg_user_stats:
121 tdb 1.1 char *name_list
122     int num_entries
123    
124 tdb 1.13 cdef extern sg_user_stats *sg_get_user_stats()
125    
126 tdb 1.12 ctypedef struct sg_swap_stats:
127 tdb 1.1 long long total
128     long long used
129     long long free
130    
131 tdb 1.13 cdef extern sg_swap_stats *sg_get_swap_stats()
132 tdb 1.1
133 tdb 1.12 ctypedef struct sg_fs_stats:
134 tdb 1.1 char *device_name
135     char *fs_type
136     char *mnt_point
137     long long size
138     long long used
139     long long avail
140     long long total_inodes
141     long long used_inodes
142     long long free_inodes
143    
144 tdb 1.13 cdef extern sg_fs_stats *sg_get_fs_stats(int *entries)
145    
146 tdb 1.12 ctypedef struct sg_disk_io_stats:
147 tdb 1.1 char *disk_name
148     long long read_bytes
149     long long write_bytes
150     time_t systime
151    
152 tdb 1.13 cdef extern sg_disk_io_stats *sg_get_disk_io_stats(int *entries)
153     cdef extern sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries)
154 tdb 1.1
155 tdb 1.12 ctypedef struct sg_network_io_stats:
156 tdb 1.1 char *interface_name
157     long long tx
158     long long rx
159 tdb 1.9 long long ipackets
160     long long opackets
161     long long ierrors
162     long long oerrors
163     long long collisions
164 tdb 1.1 time_t systime
165    
166 tdb 1.13 cdef extern sg_network_io_stats *sg_get_network_io_stats(int *entries)
167     cdef extern sg_network_io_stats *sg_get_network_io_stats_diff(int *entries)
168    
169 tdb 1.12 ctypedef enum sg_iface_duplex:
170     SG_IFACE_DUPLEX_FULL
171     SG_IFACE_DUPLEX_HALF
172     SG_IFACE_DUPLEX_UNKNOWN
173 tdb 1.5
174 tdb 1.12 ctypedef struct sg_network_iface_stats:
175 tdb 1.5 char *interface_name
176     int speed
177 tdb 1.16 sg_iface_duplex duplex
178 tdb 1.8 int up
179 tdb 1.5
180 tdb 1.13 cdef extern sg_network_iface_stats *sg_get_network_iface_stats(int *entries)
181    
182 tdb 1.12 ctypedef struct sg_page_stats:
183 tdb 1.1 long long pages_pagein
184     long long pages_pageout
185     time_t systime
186    
187 tdb 1.12 cdef extern sg_page_stats *sg_get_page_stats()
188     cdef extern sg_page_stats *sg_get_page_stats_diff()
189 tdb 1.13
190 tdb 1.14 ctypedef enum sg_process_state:
191     SG_PROCESS_STATE_RUNNING
192     SG_PROCESS_STATE_SLEEPING
193     SG_PROCESS_STATE_STOPPED
194     SG_PROCESS_STATE_ZOMBIE
195     SG_PROCESS_STATE_UNKNOWN
196    
197     ctypedef struct sg_process_stats:
198     char *process_name
199     char *proctitle
200     pid_t pid
201     pid_t parent
202     pid_t pgid
203     uid_t uid
204     uid_t euid
205     gid_t gid
206     gid_t egid
207     unsigned long long proc_size
208     unsigned long long proc_resident
209     time_t time_spent
210     double cpu_percent
211     int nice
212     sg_process_state state
213    
214     cdef extern sg_process_stats *sg_get_process_stats(int *entries)
215    
216 tdb 1.13 ctypedef struct sg_process_count:
217     int total
218     int running
219     int sleeping
220     int stopped
221     int zombie
222    
223     cdef extern sg_process_count *sg_get_process_count()
224 tdb 1.12
225    
226 tdb 1.14 py_SG_ERROR_NONE = SG_ERROR_NONE
227     py_SG_ERROR_ASPRINTF = SG_ERROR_ASPRINTF
228     py_SG_ERROR_DEVSTAT_GETDEVS = SG_ERROR_DEVSTAT_GETDEVS
229     py_SG_ERROR_DEVSTAT_SELECTDEVS = SG_ERROR_DEVSTAT_SELECTDEVS
230     py_SG_ERROR_ENOENT = SG_ERROR_ENOENT
231     py_SG_ERROR_GETIFADDRS = SG_ERROR_GETIFADDRS
232     py_SG_ERROR_GETMNTINFO = SG_ERROR_GETMNTINFO
233     py_SG_ERROR_GETPAGESIZE = SG_ERROR_GETPAGESIZE
234     py_SG_ERROR_KSTAT_DATA_LOOKUP = SG_ERROR_KSTAT_DATA_LOOKUP
235     py_SG_ERROR_KSTAT_LOOKUP = SG_ERROR_KSTAT_LOOKUP
236     py_SG_ERROR_KSTAT_OPEN = SG_ERROR_KSTAT_OPEN
237     py_SG_ERROR_KSTAT_READ = SG_ERROR_KSTAT_READ
238     py_SG_ERROR_KVM_GETSWAPINFO = SG_ERROR_KVM_GETSWAPINFO
239     py_SG_ERROR_KVM_OPENFILES = SG_ERROR_KVM_OPENFILES
240     py_SG_ERROR_MALLOC = SG_ERROR_MALLOC
241     py_SG_ERROR_OPEN = SG_ERROR_OPEN
242     py_SG_ERROR_OPENDIR = SG_ERROR_OPENDIR
243     py_SG_ERROR_PARSE = SG_ERROR_PARSE
244     py_SG_ERROR_SETEGID = SG_ERROR_SETEGID
245     py_SG_ERROR_SETEUID = SG_ERROR_SETEUID
246     py_SG_ERROR_SETMNTENT = SG_ERROR_SETMNTENT
247     py_SG_ERROR_SOCKET = SG_ERROR_SOCKET
248     py_SG_ERROR_SWAPCTL = SG_ERROR_SWAPCTL
249     py_SG_ERROR_SYSCONF = SG_ERROR_SYSCONF
250     py_SG_ERROR_SYSCTL = SG_ERROR_SYSCTL
251     py_SG_ERROR_SYSCTLBYNAME = SG_ERROR_SYSCTLBYNAME
252     py_SG_ERROR_SYSCTLNAMETOMIB = SG_ERROR_SYSCTLNAMETOMIB
253     py_SG_ERROR_UNAME = SG_ERROR_UNAME
254     py_SG_ERROR_UNSUPPORTED = SG_ERROR_UNSUPPORTED
255     py_SG_ERROR_XSW_VER_MISMATCH = SG_ERROR_XSW_VER_MISMATCH
256    
257 tdb 1.12 py_SG_IFACE_DUPLEX_FULL = SG_IFACE_DUPLEX_FULL
258     py_SG_IFACE_DUPLEX_HALF = SG_IFACE_DUPLEX_HALF
259     py_SG_IFACE_DUPLEX_UNKNOWN = SG_IFACE_DUPLEX_UNKNOWN
260 tdb 1.1
261 tdb 1.14 py_SG_PROCESS_STATE_RUNNING = SG_PROCESS_STATE_RUNNING
262     py_SG_PROCESS_STATE_SLEEPING = SG_PROCESS_STATE_SLEEPING
263     py_SG_PROCESS_STATE_STOPPED = SG_PROCESS_STATE_STOPPED
264     py_SG_PROCESS_STATE_ZOMBIE = SG_PROCESS_STATE_ZOMBIE
265     py_SG_PROCESS_STATE_UNKNOWN = SG_PROCESS_STATE_UNKNOWN
266    
267 tdb 1.1
268 tdb 1.2 class Result:
269     def __init__(self, attrs):
270     self.attrs = attrs
271     for attr in attrs:
272     setattr(self, attr, attrs[attr])
273     def __getitem__(self, item):
274     return getattr(self, item)
275     def __repr__(self):
276     return str(self.attrs)
277    
278 tdb 1.4 class StatgrabException(Exception):
279 tdb 1.3 def __init__(self, value):
280     self.value = value
281     def __str__(self):
282     return repr(self.value)
283    
284 tdb 1.2
285 tdb 1.13 def py_sg_init():
286     if sg_init() == 0:
287     return True
288     else:
289     return False
290    
291     def py_sg_drop_privileges():
292     if sg_drop_privileges() == 0:
293     return True
294     else:
295     return False
296    
297 tdb 1.14 def py_sg_set_error(code, arg):
298     sg_set_error(code, arg)
299    
300 tdb 1.15 def py_sg_set_error_with_errno(code, arg):
301     sg_set_error_with_errno(code, arg)
302    
303 tdb 1.14 def py_sg_get_error():
304     cdef sg_error s
305     s = sg_get_error()
306     return s
307    
308     def py_sg_get_error_arg():
309     s = sg_get_error_arg()
310 tdb 1.15 return s
311    
312     def py_sg_get_error_errno():
313     s = sg_get_error_errno()
314 tdb 1.14 return s
315    
316     def py_sg_str_error(code):
317     s = sg_str_error(code)
318     return s
319    
320 tdb 1.13 def py_sg_get_host_info():
321     cdef sg_host_info *s
322     s = sg_get_host_info()
323     if s == NULL:
324     raise StatgrabException, 'sg_get_host_info() returned NULL'
325     return Result(
326     {'os_name': s.os_name,
327     'os_release': s.os_release,
328     'os_version': s.os_version,
329     'platform': s.platform,
330     'hostname': s.hostname,
331     'uptime': s.uptime,
332     }
333     )
334    
335 tdb 1.12 def py_sg_get_cpu_stats():
336     cdef sg_cpu_stats *s
337     s = sg_get_cpu_stats()
338 tdb 1.3 if s == NULL:
339 tdb 1.12 raise StatgrabException, 'sg_get_cpu_stats() returned NULL'
340 tdb 1.2 return Result(
341     {'user': s.user,
342     'kernel': s.kernel,
343     'idle': s.idle,
344     'iowait': s.iowait,
345     'swap': s.swap,
346     'nice': s.nice,
347     'total': s.total,
348     'systime': s.systime,
349     }
350     )
351 tdb 1.1
352 tdb 1.12 def py_sg_get_cpu_stats_diff():
353     cdef sg_cpu_stats *s
354     s = sg_get_cpu_stats_diff()
355 tdb 1.3 if s == NULL:
356 tdb 1.12 raise StatgrabException, 'sg_get_cpu_stats_diff() returned NULL'
357 tdb 1.2 return Result(
358     {'user': s.user,
359     'kernel': s.kernel,
360     'idle': s.idle,
361     'iowait': s.iowait,
362     'swap': s.swap,
363     'nice': s.nice,
364     'total': s.total,
365     'systime': s.systime,
366     }
367     )
368 tdb 1.1
369 tdb 1.12 def py_sg_get_cpu_percents():
370     cdef sg_cpu_percents *s
371     s = sg_get_cpu_percents()
372 tdb 1.3 if s == NULL:
373 tdb 1.12 raise StatgrabException, 'sg_get_cpu_percents() returned NULL'
374 tdb 1.2 return Result(
375     {'user': s.user,
376     'kernel': s.kernel,
377     'idle': s.idle,
378     'iowait': s.iowait,
379     'swap': s.swap,
380     'nice': s.nice,
381     'time_taken': s.time_taken,
382     }
383     )
384 tdb 1.1
385 tdb 1.12 def py_sg_get_mem_stats():
386     cdef sg_mem_stats *s
387     s = sg_get_mem_stats()
388 tdb 1.3 if s == NULL:
389 tdb 1.12 raise StatgrabException, 'sg_get_mem_stats() returned NULL'
390 tdb 1.2 return Result(
391     {'total': s.total,
392     'used': s.used,
393     'free': s.free,
394     'cache': s.cache,
395     }
396     )
397 tdb 1.1
398 tdb 1.12 def py_sg_get_load_stats():
399     cdef sg_load_stats *s
400     s = sg_get_load_stats()
401 tdb 1.3 if s == NULL:
402 tdb 1.12 raise StatgrabException, 'sg_get_load_stats() returned NULL'
403 tdb 1.2 return Result(
404     {'min1': s.min1,
405     'min5': s.min5,
406     'min15': s.min15,
407     }
408     )
409 tdb 1.1
410 tdb 1.12 def py_sg_get_user_stats():
411     cdef sg_user_stats *s
412     s = sg_get_user_stats()
413 tdb 1.3 if s == NULL:
414 tdb 1.12 raise StatgrabException, 'sg_get_user_stats() returned NULL'
415 tdb 1.2 return Result(
416     {'name_list': s.name_list,
417     'num_entries': s.num_entries,
418     }
419     )
420 tdb 1.1
421 tdb 1.12 def py_sg_get_swap_stats():
422     cdef sg_swap_stats *s
423     s = sg_get_swap_stats()
424 tdb 1.3 if s == NULL:
425 tdb 1.12 raise StatgrabException, 'sg_get_swap_stats() returned NULL'
426 tdb 1.2 return Result(
427     {'total': s.total,
428     'used': s.used,
429     'free': s.free,
430     }
431     )
432 tdb 1.1
433 tdb 1.12 def py_sg_get_fs_stats():
434     cdef sg_fs_stats *s
435 tdb 1.1 cdef int entries
436 tdb 1.12 s = sg_get_fs_stats(&entries)
437 tdb 1.3 if s == NULL:
438 tdb 1.12 raise StatgrabException, 'sg_get_fs_stats() returned NULL'
439 tdb 1.6 list = []
440 tdb 1.1 for i from 0 <= i < entries:
441 tdb 1.2 list.append(Result(
442     {'device_name': s.device_name,
443     'fs_type': s.fs_type,
444     'mnt_point': s.mnt_point,
445     'size': s.size,
446     'used': s.used,
447     'avail': s.avail,
448     'total_inodes': s.total_inodes,
449     'used_inodes': s.used_inodes,
450     'free_inodes': s.free_inodes,
451     }
452     ))
453 tdb 1.1 s = s + 1
454     return list
455    
456 tdb 1.12 def py_sg_get_disk_io_stats():
457     cdef sg_disk_io_stats *s
458 tdb 1.1 cdef int entries
459 tdb 1.12 s = sg_get_disk_io_stats(&entries)
460 tdb 1.3 if s == NULL:
461 tdb 1.12 raise StatgrabException, 'sg_get_disk_io_stats() returned NULL'
462 tdb 1.6 list = []
463 tdb 1.1 for i from 0 <= i < entries:
464 tdb 1.2 list.append(Result(
465     {'disk_name': s.disk_name,
466     'read_bytes': s.read_bytes,
467     'write_bytes': s.write_bytes,
468     'systime': s.systime,
469     }
470     ))
471 tdb 1.1 s = s + 1
472     return list
473    
474 tdb 1.12 def py_sg_get_disk_io_stats_diff():
475     cdef sg_disk_io_stats *s
476 tdb 1.1 cdef int entries
477 tdb 1.12 s = sg_get_disk_io_stats_diff(&entries)
478 tdb 1.3 if s == NULL:
479 tdb 1.12 raise StatgrabException, 'sg_get_disk_io_stats_diff() returned NULL'
480 tdb 1.6 list = []
481 tdb 1.1 for i from 0 <= i < entries:
482 tdb 1.2 list.append(Result(
483     {'disk_name': s.disk_name,
484     'read_bytes': s.read_bytes,
485     'write_bytes': s.write_bytes,
486     'systime': s.systime,
487     }
488     ))
489 tdb 1.1 s = s + 1
490     return list
491    
492 tdb 1.12 def py_sg_get_network_io_stats():
493     cdef sg_network_io_stats *s
494 tdb 1.1 cdef int entries
495 tdb 1.12 s = sg_get_network_io_stats(&entries)
496 tdb 1.3 if s == NULL:
497 tdb 1.12 raise StatgrabException, 'sg_get_network_io_stats() returned NULL'
498 tdb 1.6 list = []
499 tdb 1.1 for i from 0 <= i < entries:
500 tdb 1.2 list.append(Result(
501     {'interface_name': s.interface_name,
502     'tx': s.tx,
503     'rx': s.rx,
504 tdb 1.9 'ipackets': s.ipackets,
505     'opackets': s.opackets,
506     'ierrors': s.ierrors,
507     'oerrors': s.oerrors,
508     'collisions': s.collisions,
509 tdb 1.2 'systime': s.systime,
510     }
511     ))
512 tdb 1.1 s = s + 1
513     return list
514    
515 tdb 1.12 def py_sg_get_network_io_stats_diff():
516     cdef sg_network_io_stats *s
517 tdb 1.1 cdef int entries
518 tdb 1.12 s = sg_get_network_io_stats_diff(&entries)
519 tdb 1.3 if s == NULL:
520 tdb 1.12 raise StatgrabException, 'sg_get_network_io_stats_diff() returned NULL'
521 tdb 1.6 list = []
522 tdb 1.1 for i from 0 <= i < entries:
523 tdb 1.2 list.append(Result(
524     {'interface_name': s.interface_name,
525     'tx': s.tx,
526     'rx': s.rx,
527 tdb 1.9 'ipackets': s.ipackets,
528     'opackets': s.opackets,
529     'ierrors': s.ierrors,
530     'oerrors': s.oerrors,
531     'collisions': s.collisions,
532 tdb 1.2 'systime': s.systime,
533 tdb 1.5 }
534     ))
535     s = s + 1
536     return list
537    
538 tdb 1.12 def py_sg_get_network_iface_stats():
539     cdef sg_network_iface_stats *s
540 tdb 1.5 cdef int entries
541 tdb 1.12 s = sg_get_network_iface_stats(&entries)
542 tdb 1.5 if s == NULL:
543 tdb 1.12 raise StatgrabException, 'sg_get_network_iface_stats() returned NULL'
544 tdb 1.6 list = []
545 tdb 1.5 for i from 0 <= i < entries:
546     list.append(Result(
547     {'interface_name': s.interface_name,
548     'speed': s.speed,
549 tdb 1.16 'duplex': s.duplex,
550 tdb 1.8 'up' : s.up,
551 tdb 1.2 }
552     ))
553 tdb 1.1 s = s + 1
554     return list
555    
556 tdb 1.12 def py_sg_get_page_stats():
557     cdef sg_page_stats *s
558     s = sg_get_page_stats()
559 tdb 1.3 if s == NULL:
560 tdb 1.12 raise StatgrabException, 'sg_get_page_stats() returned NULL'
561 tdb 1.2 return Result(
562     {'pages_pagein': s.pages_pagein,
563     'pages_pageout': s.pages_pageout,
564     }
565     )
566 tdb 1.1
567 tdb 1.12 def py_sg_get_page_stats_diff():
568     cdef sg_page_stats *s
569     s = sg_get_page_stats_diff()
570 tdb 1.3 if s == NULL:
571 tdb 1.12 raise StatgrabException, 'sg_get_page_stats_diff() returned NULL'
572 tdb 1.2 return Result(
573     {'pages_pagein': s.pages_pagein,
574     'pages_pageout': s.pages_pageout,
575     }
576     )
577 tdb 1.14
578     def py_sg_get_process_stats():
579     cdef sg_process_stats *s
580     cdef int entries
581     s = sg_get_process_stats(&entries)
582     if s == NULL:
583     raise StatgrabException, 'sg_get_process_stats() returned NULL'
584     list = []
585     for i from 0 <= i < entries:
586     if s.process_name == NULL:
587     s.process_name = ''
588     if s.proctitle == NULL:
589     s.proctitle = ''
590     list.append(Result(
591     {'process_name': s.process_name,
592     'proctitle' : s.proctitle,
593     'pid' : s.pid,
594     'parent' : s.parent,
595     'pgid' : s.pgid,
596     'uid' : s.uid,
597     'euid' : s.euid,
598     'gid' : s.gid,
599     'egid' : s.egid,
600     'proc_size' : s.proc_size,
601     'proc_resident' : s.proc_resident,
602     'time_spent' : s.time_spent,
603     'cpu_percent' : s.cpu_percent,
604     'nice' : s.nice,
605     'state' : s.state,
606     }
607     ))
608     s = s + 1
609     return list
610 tdb 1.1
611 tdb 1.13 def py_sg_get_process_count():
612     cdef sg_process_count *s
613     s = sg_get_process_count()
614     if s == NULL:
615     raise StatgrabException, 'sg_get_process_count() returned NULL'
616     return Result(
617     {'total': s.total,
618     'running': s.running,
619     'sleeping': s.sleeping,
620     'stopped': s.stopped,
621     'zombie': s.zombie,
622     }
623     )