ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/examples/process_snapshot.c
(Generate patch)

Comparing projects/libstatgrab/examples/process_snapshot.c (file contents):
Revision 1.2 by tdb, Sat Apr 3 21:02:10 2004 UTC vs.
Revision 1.8 by tdb, Tue Apr 6 14:52:56 2004 UTC

# Line 1 | Line 1
1   /*
2 < * i-scream central monitoring system
2 > * i-scream libstatgrab
3   * http://www.i-scream.org
4   * Copyright (C) 2000-2004 i-scream
5   *
# Line 26 | Line 26
26   #include <unistd.h>
27  
28   int main(){
29 <        proc_state_t *ps;
29 >        sg_process_stats *ps;
30          int ps_size;
31          int x;
32 <        char *state;
32 >        char *state = NULL;
33  
34          /* Initialise statgrab */
35 <        statgrab_init();
35 >        sg_init();
36  
37          /* Drop setuid/setgid privileges. */
38 <        if (statgrab_drop_privileges() != 0) {
38 >        if (sg_drop_privileges() != 0) {
39                  perror("Error. Failed to drop privileges");
40                  return 1;
41          }
42  
43 <        ps_size = get_proc_snapshot(&ps);
43 >        ps = sg_get_process_stats(&ps_size);
44  
45 <        if(ps_size == NULL){
45 >        if(ps == NULL){
46                  fprintf(stderr, "Failed to get process snapshot\n");
47                  exit(1);
48          }
# Line 52 | Line 52 | int main(){
52  
53          for(x=0;x<ps_size;x++){
54                  switch (ps->state) {
55 <                case RUNNING:
55 >                case SG_PROCESS_STATE_RUNNING:
56                          state = "RUNNING";
57                          break;
58 <                case SLEEPING:
58 >                case SG_PROCESS_STATE_SLEEPING:
59                          state = "SLEEPING";
60                          break;
61 <                case STOPPED:
61 >                case SG_PROCESS_STATE_STOPPED:
62                          state = "STOPPED";
63                          break;
64 <                case ZOMBIE:
64 >                case SG_PROCESS_STATE_ZOMBIE:
65                          state = "ZOMBIE";
66 +                        break;
67 +                case SG_PROCESS_STATE_UNKNOWN:
68 +                default:
69 +                        state = "UNKNOWN";
70                          break;
71                  }
72                  printf("%5d %5d %5d %5d %5d %5d %5d %5dM %5dM %8ds %10f %4d %-8s %-20s %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines