/[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.28 by rory, Wed Jan 26 00:52:11 2005 UTC revision 1.29 by chopp, Tue Apr 12 10:09:25 2005 UTC
# Line 48  Line 48 
48  #include <stdlib.h>  #include <stdlib.h>
49  #endif  #endif
50    
51    #ifdef HAVE_UNISTD_H
52    #include <unistd.h>
53    #endif
54    
55  #ifdef TIME_WITH_SYS_TIME  #ifdef TIME_WITH_SYS_TIME
56  #include <time.h>  #include <time.h>
57    
# Line 66  Line 70 
70  #include <asm/param.h>  #include <asm/param.h>
71  #endif  #endif
72    
 #ifdef HAVE_ASM_PAGE_H  
 #include <asm/page.h>  
 #endif  
   
73  #ifdef HAVE_GLOB_H  #ifdef HAVE_GLOB_H
74  #include <glob.h>  #include <glob.h>
75  #endif  #endif
# Line 95  Line 95 
95  /* ----------------------------------------------------------------- Private */  /* ----------------------------------------------------------------- Private */
96    
97    
 #define PAGE_TO_KBYTE_SHIFT PAGE_SHIFT-10  
   
98  #define MEMTOTAL "MemTotal:"  #define MEMTOTAL "MemTotal:"
99  #define MEMFREE  "MemFree:"  #define MEMFREE  "MemFree:"
100  #define MEMBUF   "Buffers:"  #define MEMBUF   "Buffers:"
101  #define MEMCACHE "Cached:"  #define MEMCACHE "Cached:"
102    
103  static long   old_cpu_user = 0;  static long   old_cpu_user     = 0;
104  static long   old_cpu_syst = 0;  static long   old_cpu_syst     = 0;
105  static long   old_cpu_wait = 0;  static long   old_cpu_wait     = 0;
106  static double old_time     = 0.0;  static double old_time         = 0.0;
107    static int    page_shift_to_kb = 0;
108    
109    
110  /* ------------------------------------------------------------------ Public */  /* ------------------------------------------------------------------ Public */
# Line 114  static double old_time     = 0.0; Line 113  static double old_time     = 0.0;
113  int init_process_info_sysdep(void) {  int init_process_info_sysdep(void) {
114    char *ptr;    char *ptr;
115    char  buf[1024];    char  buf[1024];
116      long  page_size;
117      int   page_shift;  
118    
119    if(!read_proc_file(buf, 1024, "meminfo", -1))    if(!read_proc_file(buf, 1024, "meminfo", -1))
120    {    {
# Line 136  int init_process_info_sysdep(void) { Line 137  int init_process_info_sysdep(void) {
137      return FALSE;      return FALSE;
138    }    }
139    
140      if((page_size = sysconf(_SC_PAGESIZE)) <= 0) {
141        DEBUG("system statistic error -- cannot get page size: %s\n", STRERROR);
142        return FALSE;
143      }
144    
145      for(page_shift=0; page_size!=1; page_size>>=1, page_shift++);
146      page_shift_to_kb=page_shift-10;
147    
148    return TRUE;    return TRUE;
149  }  }
150    
# Line 238  int initprocesstree_sysdep(ProcessTree_T Line 247  int initprocesstree_sysdep(ProcessTree_T
247        pt[i].status_flag |= PROCESS_ZOMBIE;        pt[i].status_flag |= PROCESS_ZOMBIE;
248      }      }
249    
250      if(PAGE_TO_KBYTE_SHIFT < 0)      if(page_shift_to_kb < 0)
251      {      {
252        pt[i].mem_kbyte = (stat_item_rss >> abs(PAGE_TO_KBYTE_SHIFT));        pt[i].mem_kbyte = (stat_item_rss >> abs(page_shift_to_kb));
253      }      }
254      else      else
255      {      {
256        pt[i].mem_kbyte = (stat_item_rss << abs(PAGE_TO_KBYTE_SHIFT));        pt[i].mem_kbyte = (stat_item_rss << abs(page_shift_to_kb));
257      }      }
258    }    }
259        

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

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