[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems reading process vitals on FreeBSD when the monitored proces

From: Ralf Hack
Subject: Re: Problems reading process vitals on FreeBSD when the monitored process is swapped out
Date: Thu, 26 Feb 2004 14:32:10 +0000
User-agent: Mozilla Thunderbird 0.5 (Macintosh/20040208)

I ventured down the busy road of Google a bit myself. It appears that somewhere in the distant past even 'ps' reported 0 as memory amount for swapped out processes, not anymore though. Current ps (FreeBSD 5.2, just points to the kvm_getprocs() interface as source of data. Maybe this is a better way to gather information ?

Interestingly enought, the current 'ps' has a '-f' flag:

    -f      Show commandline and environment information about swapped out
processes. This option is honored only if the uid of the user is

implying that the kernel does not track resources completely that are swapped out. Perhaps in this case, it is acceptable for monit to omit the memory test for FreeBSD for processes that are swapped out. There is some logic to this but unreliable from monit's perspective when checking resource usage.

Thanks very much for you input.


Christian Hopp wrote:

On Thu, 26 Feb 2004, Ralf Hack wrote:


I monitor an ssh tunnel and get the following message after several
hours. It appears that kvm_read fails reading the memory size once
the process is swapped out on the monitoring server (STAT
+= W). Once I active the monitored process by simply using the
session, the problem disappears. Sorry, I do not know enough about
FreeBSD programming to offer a fix for this.


I could track down the problem using gdb to line 376 in sysdep_FREEBSD.c

Breakpoint 3, get_process_info_sysdep (p=0x808f4c0)
   at process/sysdep_FREEBSD.c:376
376         return FALSE;
(gdb) c

 /* ----------------------------- MEMORY --------------------------------*/
 /* Got it from libgtop/sysdep/freebsd/procmem.c */

 if (kvm_read (kvm_handle,
#if (__FreeBSD_version > 500000)
               (unsigned long) &pinfo->ki_addr->p_limit,
               (unsigned long) pinfo [0].kp_proc.p_limit,
               (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {

   return FALSE;


Yep, it has to be there!  It's really tricky.  If this kvm_read call
fails, too less data is transmitted from the kernel (see man page or
other implementations).  I am hesitant to guess the amount of memory
at that point (e.g. 0), but it is the only solution I see at that

I would love to have more docs about freebsd and kvm, but I haven't
googled anything useful yet.  I have cursed about all this already a


reply via email to

[Prev in Thread] Current Thread [Next in Thread]