Lines 1-98
Link Here
|
1 |
--- src/libs/zbxsysinfo/freebsd/proc.c.orig 2011-12-28 03:27:42.000000000 -0600 |
|
|
2 |
+++ src/libs/zbxsysinfo/freebsd/proc.c 2012-04-25 21:54:13.877489156 -0500 |
3 |
@@ -36,17 +36,13 @@ |
4 |
# define ZBX_PROC_PID ki_pid |
5 |
# define ZBX_PROC_COMM ki_comm |
6 |
# define ZBX_PROC_STAT ki_stat |
7 |
-# define ZBX_PROC_TSIZE ki_tsize |
8 |
-# define ZBX_PROC_DSIZE ki_dsize |
9 |
-# define ZBX_PROC_SSIZE ki_ssize |
10 |
+# define ZBX_PROC_VSIZE ki_size |
11 |
#else |
12 |
# define ZBX_COMMLEN MAXCOMLEN |
13 |
# define ZBX_PROC_PID kp_proc.p_pid |
14 |
# define ZBX_PROC_COMM kp_proc.p_comm |
15 |
# define ZBX_PROC_STAT kp_proc.p_stat |
16 |
-# define ZBX_PROC_TSIZE kp_eproc.e_vm.vm_tsize |
17 |
-# define ZBX_PROC_DSIZE kp_eproc.e_vm.vm_dsize |
18 |
-# define ZBX_PROC_SSIZE kp_eproc.e_vm.vm_ssize |
19 |
+# define ZBX_PROC_VSIZE kp_eproc.e_vm.vm_map.size |
20 |
#endif |
21 |
|
22 |
static char *get_commandline(struct kinfo_proc *proc) |
23 |
@@ -97,7 +93,7 @@ |
24 |
char procname[MAX_STRING_LEN], |
25 |
buffer[MAX_STRING_LEN], |
26 |
proccomm[MAX_STRING_LEN], *args; |
27 |
- int do_task, pagesize, count, i, |
28 |
+ int do_task, count, i, |
29 |
proc_ok, comm_ok, |
30 |
mib[4], mibs; |
31 |
|
32 |
@@ -152,8 +148,6 @@ |
33 |
if (0 != get_param(param, 4, proccomm, sizeof(proccomm))) |
34 |
*proccomm = '\0'; |
35 |
|
36 |
- pagesize = getpagesize(); |
37 |
- |
38 |
mib[0] = CTL_KERN; |
39 |
mib[1] = KERN_PROC; |
40 |
if (NULL != usrinfo) |
41 |
@@ -164,7 +158,11 @@ |
42 |
} |
43 |
else |
44 |
{ |
45 |
+#if(__FreeBSD_version > 500000) |
46 |
+ mib[2] = KERN_PROC_PROC; |
47 |
+#else |
48 |
mib[2] = KERN_PROC_ALL; |
49 |
+#endif |
50 |
mib[3] = 0; |
51 |
mibs = 3; |
52 |
} |
53 |
@@ -184,11 +182,6 @@ |
54 |
|
55 |
for (i = 0; i < count; i++) |
56 |
{ |
57 |
-#if(__FreeBSD_version > 500000) |
58 |
- if (proc[i].ki_flag & P_KTHREAD) /* skip a system thread */ |
59 |
- continue; |
60 |
-#endif |
61 |
- |
62 |
proc_ok = 0; |
63 |
comm_ok = 0; |
64 |
if (*procname == '\0' || 0 == strcmp(procname, proc[i].ZBX_PROC_COMM)) |
65 |
@@ -205,8 +198,7 @@ |
66 |
|
67 |
if (proc_ok && comm_ok) |
68 |
{ |
69 |
- value = proc[i].ZBX_PROC_TSIZE + proc[i].ZBX_PROC_DSIZE + proc[i].ZBX_PROC_SSIZE; |
70 |
- value *= pagesize; |
71 |
+ value = proc[i].ZBX_PROC_VSIZE; /* vsize is bytes not pages */ |
72 |
|
73 |
if (0 == proccount++) |
74 |
memsize = value; |
75 |
@@ -306,7 +298,11 @@ |
76 |
} |
77 |
else |
78 |
{ |
79 |
+#if(__FreeBSD_version > 500000) |
80 |
+ mib[2] = KERN_PROC_PROC; |
81 |
+#else |
82 |
mib[2] = KERN_PROC_ALL; |
83 |
+#endif |
84 |
mib[3] = 0; |
85 |
mibs = 3; |
86 |
} |
87 |
@@ -326,11 +322,6 @@ |
88 |
|
89 |
for (i = 0; i < count; i++) |
90 |
{ |
91 |
-#if(__FreeBSD_version > 500000) |
92 |
- if (proc[i].ki_flag & P_KTHREAD) /* skip a system thread */ |
93 |
- continue; |
94 |
-#endif |
95 |
- |
96 |
proc_ok = 0; |
97 |
stat_ok = 0; |
98 |
comm_ok = 0; |