364 |
{ 0 } |
{ 0 } |
365 |
}; |
}; |
366 |
|
|
367 |
|
kvm_handle = kvm_open(NULL, NULL, NULL, O_RDONLY, "monit"); |
|
kvm_handle = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"); |
|
368 |
|
|
369 |
if ( kvm_handle == NULL ) { |
if ( kvm_handle == NULL ) { |
370 |
|
|
375 |
/* ----------------------------- INIT MEM -----------------------------*/ |
/* ----------------------------- INIT MEM -----------------------------*/ |
376 |
/* Got it from libgtop/sysdep/freebsd/mem.c */ |
/* Got it from libgtop/sysdep/freebsd/mem.c */ |
377 |
|
|
378 |
|
/* Initialize nlist structure */ |
379 |
|
if (kvm_nlist (kvm_handle, nlst) < 0) |
380 |
|
{ |
381 |
|
return FALSE; |
382 |
|
} |
383 |
|
|
384 |
/* get the page size with "getpagesize" and calculate pageshift |
/* get the page size with "getpagesize" and calculate pageshift |
385 |
* from it */ |
* from it */ |
386 |
|
|
387 |
pagesize = getpagesize (); |
pagesize = getpagesize (); |
388 |
pageshift = 0; |
pageshift = 0; |
389 |
while (pagesize > 1) { |
while (pagesize > 1) { |
392 |
pagesize >>= 1; |
pagesize >>= 1; |
393 |
|
|
394 |
} |
} |
395 |
|
|
396 |
/* we only need the amount of log(2)1024 for our conversion */ |
/* we only need the amount of log(2)1024 for our conversion */ |
397 |
pageshift -= LOG1024; |
pageshift -= LOG1024; |
398 |
|
|
399 |
/* Get the data from kvm_* */ |
/* Get the data from kvm_* */ |
400 |
if (kvm_read (kvm_handle, nlst[1].n_value, |
if (kvm_read (kvm_handle, nlst[1].n_value, |
401 |
&vmm, sizeof (vmm)) != sizeof (vmm)) { |
&vmm, sizeof (vmm)) != sizeof (vmm)) { |
|
|
|
402 |
return FALSE; |
return FALSE; |
403 |
|
|
404 |
} |
} |