openbsd-ports/sysutils/monit/patches/patch-process_sysdep_OPENBSD_c

69 lines
2.5 KiB
Plaintext

$OpenBSD: patch-process_sysdep_OPENBSD_c,v 1.4 2010/10/30 21:14:00 sthen Exp $
--- process/sysdep_OPENBSD.c.orig Sun Jul 29 22:23:26 2007
+++ process/sysdep_OPENBSD.c Tue Oct 26 02:06:53 2010
@@ -90,6 +90,7 @@ static long cpu_syst_old = 0;
int init_process_info_sysdep(void) {
int mib[2];
size_t len;
+ int64_t physmem;
struct clockinfo clock;
mib[0] = CTL_KERN;
@@ -112,14 +113,14 @@ int init_process_info_sysdep(void) {
return FALSE;
}
- mib[1] = HW_PHYSMEM;
- len = sizeof(systeminfo.mem_kbyte_max);
- if(sysctl(mib, 2, &systeminfo.mem_kbyte_max, &len, NULL, 0) == -1)
+ mib[1] = HW_PHYSMEM64;
+ len = sizeof(physmem);
+ if(sysctl(mib, 2, &physmem, &len, NULL, 0) == -1)
{
DEBUG("system statistic error -- cannot get real memory amount: %s\n", STRERROR);
return FALSE;
}
- systeminfo.mem_kbyte_max /= 1024;
+ systeminfo.mem_kbyte_max = physmem / 1024;
mib[1] = HW_PAGESIZE;
len = sizeof(pagesize_kbyte);
@@ -144,7 +145,7 @@ int initprocesstree_sysdep(ProcessTree_T ** reference)
int treesize;
static kvm_t *kvm_handle;
ProcessTree_T *pt;
- struct kinfo_proc *pinfo;
+ struct kinfo_proc2 *pinfo;
if(getuid()!=0) {
LogError("system statistic error -- permission denied\n");
@@ -157,7 +158,7 @@ int initprocesstree_sysdep(ProcessTree_T ** reference)
return FALSE;
}
- pinfo = kvm_getprocs(kvm_handle, KERN_PROC_ALL, 0, &treesize);
+ pinfo = kvm_getproc2(kvm_handle, KERN_PROC_ALL, 0, sizeof(treesize), &treesize);
if(!pinfo || (treesize < 1))
{
LogError("system statistic error -- cannot get process tree\n");
@@ -169,13 +170,13 @@ int initprocesstree_sysdep(ProcessTree_T ** reference)
for(i = 0; i < treesize; i++)
{
- pt[i].pid = pinfo[i].kp_proc.p_pid;
- pt[i].ppid = pinfo[i].kp_eproc.e_ppid;
- pt[i].cputime = (long)((pinfo[i].kp_proc.p_rtime.tv_sec * 10) +
- (pinfo[i].kp_proc.p_rtime.tv_usec / 100000)
+ pt[i].pid = pinfo[i].p_pid;
+ pt[i].ppid = pinfo[i].p_ppid;
+ pt[i].cputime = (long)((pinfo[i].p_rtime_sec * 10) +
+ (pinfo[i].p_rtime_usec / 100000)
);
- pt[i].mem_kbyte = (unsigned long)(pinfo[i].kp_eproc.e_vm.vm_rssize * pagesize_kbyte);
- if(pinfo[i].kp_proc.p_stat == SZOMB)
+ pt[i].mem_kbyte = (unsigned long)(pinfo[i].p_vm_rssize * pagesize_kbyte);
+ if(pinfo[i].p_stat == SZOMB)
{
pt[i].status_flag |= PROCESS_ZOMBIE;
}