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 |
|
|
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 |
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 */ |
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 |
{ |
{ |
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 |
|
|
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 |
|
|