ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/plugins/linux/linux.c
(Generate patch)

Comparing projects/cms/source/host/ihost-perl/plugins/linux/linux.c (file contents):
Revision 1.4 by tdb, Fri Mar 8 16:04:38 2002 UTC vs.
Revision 1.7 by pajs, Tue Mar 19 10:38:05 2002 UTC

# Line 50 | Line 50 | void getLoadAv() {
50  
51   void getMemInfo() {
52      char *line;
53 <    char *mem;
54 <    char *swap;
53 >    char *mem=NULL;
54 >    char *swap=NULL;
55      char *ch;
56      long memstat[6];
57      long swapstat[3];
# Line 80 | Line 80 | void getMemInfo() {
80          errf("Failed to close file (%m).");
81          die();
82      }
83 <    
83 >  
84 >    if (mem==NULL || swap==NULL){
85 >        errf("Failed to obtain information required for memory and swap stats");
86 >        die();
87 >    }
88 >
89      /* Get the info we want from the 2 read in lines */
90      
91      ch = strchr(mem, ' ');
# Line 218 | Line 223 | void cpustats() {
223      usage=((((float)idle)/((float)total))*100.00);
224      printf("packet.cpu.idle %3.2f\n", usage);
225      
226 <    /* Cos i-scream's expexts this to be sent :/ */
226 >    /* Cos i-scream's expects this to be sent :/ */
227      printf("packet.cpu.iowait 0\n");
228 <    
228 >    printf("packet.cpu.swap 0\n");  
229 >
230      free(line[0]);
231      free(line[1]);
232   }
233  
234   void processStats() {
235 <    int sleeping=0;
235 >    int sleeping=-1;
236      int zombie=0;
237      int stopped=0;
238      int running=0;
# Line 243 | Line 249 | void processStats() {
249      }
250      
251      while((line=fpgetline(f)) != NULL) {
252 <        line_p=strchr(line, ' ');
253 <        line_p++;
254 <        if (line_p==NULL) abort();
255 <        /* Ok, we should now be at the state :) .. */
256 <        if (*line_p=='S') sleeping++;
257 <        if (*line_p=='R') running++;
258 <        if (*line_p=='Z') zombie++;
259 <        if (*line_p=='T') stopped++;
252 >
253 >      line_p=line;
254 >      for(; (*line_p == ' ') && (*line_p != '\0'); line_p++);
255 >      line_p=strchr(line_p, ' ');
256 >      for(; (*line_p == ' ') && (*line_p != '\0'); line_p++);
257 >      if (line_p==NULL) abort();
258 >      /* Ok, we should now be at the state :) .. */
259 >      if (*line_p=='S') sleeping++;
260 >      if (*line_p=='R') running++;
261 >      if (*line_p=='Z') zombie++;
262 >      if (*line_p=='T') stopped++;
263      }
264      
265      if((pclose(f)) == -1) {
# Line 269 | Line 278 | void processStats() {
278      
279      printf("\npacket.users.count %d\n", nousers);
280        
281 <    printf("packet.processes.total %d\n",sleeping);
282 <    printf("packet.processes.sleeping %d\n",running);
281 >    printf("packet.processes.sleeping %d\n",sleeping);
282 >    printf("packet.processes.cpu %d\n",running);
283      printf("packet.processes.zombie %d\n",zombie);
284      printf("packet.processes.stopped %d\n", stopped);
285      printf("packet.processes.total %d\n", (sleeping+running+zombie+stopped));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines