/[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.6 by martinp, Tue Sep 9 20:42:52 2003 UTC revision 1.7 by chopp, Sun Sep 14 00:03:54 2003 UTC
# Line 126  int get_process_info_sysdep(ProcInfo_T p Line 126  int get_process_info_sysdep(ProcInfo_T p
126    long stat_item_cutime;    long stat_item_cutime;
127    long stat_item_cstime;    long stat_item_cstime;
128    long stat_item_rss;    long stat_item_rss;
129      int statm_item_share;
130      int statm_item_trs;
131      int statm_item_drs;
132    int stat_ppid;    int stat_ppid;
133    
134    if (!read_proc_file(buf,4096, "stat", p->pid)) {    if (!read_proc_file(buf,4096, "stat", p->pid)) {
# Line 153  int get_process_info_sysdep(ProcInfo_T p Line 156  int get_process_info_sysdep(ProcInfo_T p
156       why doesn't C understand this??? */       why doesn't C understand this??? */
157    
158    p->ppid= stat_ppid;    p->ppid= stat_ppid;
159      
   if ( PAGE_TO_KBYTE_SHIFT < 0 ) {  
   
     p->mem_kbyte= stat_item_rss >> abs(PAGE_TO_KBYTE_SHIFT);  
   
   } else {  
   
     p->mem_kbyte= stat_item_rss << abs(PAGE_TO_KBYTE_SHIFT);  
   
   }  
   
   p->mem_percent = (int)( (double)p->mem_kbyte * 1000.0 / mem_kbyte_max);  
   
160    /* jiffies -> seconds = 1 / HZ    /* jiffies -> seconds = 1 / HZ
161       HZ is defined in "asm/param.h"  and it is usually 1/100s but on       HZ is defined in "asm/param.h"  and it is usually 1/100s but on
162       alpha system it is 1/1024s */       alpha system it is 1/1024s */
# Line 195  int get_process_info_sysdep(ProcInfo_T p Line 186  int get_process_info_sysdep(ProcInfo_T p
186    
187    }    }
188    
189    
190      if (!read_proc_file(buf,4096, "statm", p->pid)) {
191    
192        return FALSE;
193    
194      }
195    
196      /* This implementation is done by using fs/procfs/array.c as a basis
197         it is also worth looking into the source of the procps utils.
198    
199         Beware then proc man page has a wrong sorting of the entries!  */
200      
201      sscanf(buf,"%*d %*d %d %d %*d %d %*d\n",
202             &statm_item_share,&statm_item_trs, &statm_item_drs);
203    
204      if ( PAGE_TO_KBYTE_SHIFT < 0 ) {
205    
206        p->mem_kbyte= ( statm_item_trs >> abs(PAGE_TO_KBYTE_SHIFT) ) +
207            ( statm_item_drs >> abs(PAGE_TO_KBYTE_SHIFT) ) -
208            ( statm_item_share >> abs(PAGE_TO_KBYTE_SHIFT) );
209    
210      } else {
211        
212        p->mem_kbyte= ( statm_item_trs << abs(PAGE_TO_KBYTE_SHIFT) ) +
213            ( statm_item_drs << abs(PAGE_TO_KBYTE_SHIFT) ) -
214            ( statm_item_share << abs(PAGE_TO_KBYTE_SHIFT) );
215    
216      }
217    
218      p->mem_percent = (int)( (double)p->mem_kbyte * 1000.0 / mem_kbyte_max);
219      
220    return TRUE;    return TRUE;
221    
222  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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