/[monit]/monit/process/sysdep_LINUX.c
ViewVC logotype

Diff of /monit/process/sysdep_LINUX.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by martinp, Sun Nov 7 16:23:34 2004 UTC revision 1.26 by rory, Tue Dec 14 01:50:35 2004 UTC
# Line 161  int initprocesstree_sysdep(ProcessTree_T Line 161  int initprocesstree_sysdep(ProcessTree_T
161    unsigned long  stat_item_utime = 0;    unsigned long  stat_item_utime = 0;
162    unsigned long  stat_item_stime = 0;    unsigned long  stat_item_stime = 0;
163    ProcessTree_T *pt = NULL;    ProcessTree_T *pt = NULL;
 #ifndef USE_QUICK_MEM_CALC  
   int            statm_item_share = 0;  
   int            statm_item_trs = 0;  
   int            statm_item_drs = 0;  
 #endif  
164    
165    ASSERT(reference);    ASSERT(reference);
166    
# Line 241  int initprocesstree_sysdep(ProcessTree_T Line 236  int initprocesstree_sysdep(ProcessTree_T
236        pt[i].status_flag |= PROCESS_ZOMBIE;        pt[i].status_flag |= PROCESS_ZOMBIE;
237      }      }
238    
 #ifdef USE_QUICK_MEM_CALC  
239      if(PAGE_TO_KBYTE_SHIFT < 0)      if(PAGE_TO_KBYTE_SHIFT < 0)
240      {      {
241        pt[i].mem_kbyte = (stat_item_rss >> abs(PAGE_TO_KBYTE_SHIFT));        pt[i].mem_kbyte = (stat_item_rss >> abs(PAGE_TO_KBYTE_SHIFT));
# Line 250  int initprocesstree_sysdep(ProcessTree_T Line 244  int initprocesstree_sysdep(ProcessTree_T
244      {      {
245        pt[i].mem_kbyte = (stat_item_rss << abs(PAGE_TO_KBYTE_SHIFT));        pt[i].mem_kbyte = (stat_item_rss << abs(PAGE_TO_KBYTE_SHIFT));
246      }      }
 #else  
     if(!read_proc_file(buf, 4096, "statm", pt[i].pid))  
     {  
       DEBUG(  
         "system statistic error -- cannot read /proc/%d/statm\n",  
         pt[i].pid);  
       pt[i].mem_kbyte = 0;  
     }  
     else  
     {  
       /* This implementation is done by using fs/procfs/array.c as a basis  
        * it is also worth looking into the source of the procps utils.  
        * Beware then proc man page has a wrong sorting of the entries!  */  
       if(sscanf(buf,  
            "%*d %*d %d %d %*d %d %*d\n",  
            &statm_item_share,  
            &statm_item_trs,  
            &statm_item_drs) != 3)  
       {  
         DEBUG(  
           "system statistic error -- file /proc/%d/statm parse error\n",  
           pt[i].pid);  
         continue;  
       }  
         
       if(PAGE_TO_KBYTE_SHIFT < 0)  
       {  
         pt[i].mem_kbyte =  
             (statm_item_trs   >> abs(PAGE_TO_KBYTE_SHIFT)) +  
             (statm_item_drs   >> abs(PAGE_TO_KBYTE_SHIFT)) -  
             (statm_item_share >> abs(PAGE_TO_KBYTE_SHIFT));  
           
       }  
       else  
       {  
         pt[i].mem_kbyte =  
             (statm_item_trs   << abs(PAGE_TO_KBYTE_SHIFT)) +  
             (statm_item_drs   << abs(PAGE_TO_KBYTE_SHIFT)) -  
             (statm_item_share << abs(PAGE_TO_KBYTE_SHIFT));  
       }  
     }  
 #endif  
247    }    }
248        
249    *reference = pt;    *reference = pt;

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26