Noel Jones said the following on 01/08/2009 10:34 AM:
Postfix keeps idle processes around for $max_idle (default 100s), so the process count is only an approximation of the number of connections. Idle processes are reused $max_use (default 100) times before they are retired. The number of processes will change with the number of connections until the maximum number of configured connections is reached. I suspect this is similar to what you get when counting "sendmail" processes.

To get an accurate connection count, you will need to parse "netstat" or "lsof" output to count established connections. Even this may give an inaccurate number if there are more connections than available smtpd processes.

I use this perl "one liner" on FreeBSD, you may need to adjust it for another OS.

netstat -an 2>/dev/null | perl -lne '
    $in = "0" if $in == undef;
    $out = "0" if $out == undef;
    ++$in if (/ESTABLISHED/
&& /(?:^|\s)\d+\.\d+\.\d+\.\d+[.:](\d+)\s+\d+\.\d+\.\d+\.\d+[.:]\d+/
        && $1 eq "25");
    ++$out if (/ESTABLISHED/
&& /(?:^|\s)\d+\.\d+\.\d+\.\d+[.:]\d+\s+\d+\.\d+\.\d+\.\d+[.:](\d+)/
             && $1 eq "25");
END {print $ARGV[0], "Port 25 status: ", $in, " Established incoming, ", $out, " Established outgoing"};
'


Parsing netstat seems to work. It doesn't need to be 100% accurate for what I'm doing.

Thanks!


~Cory Coager



------------------------------------------------------------------------
The information contained in this communication is intended
only for the use of the recipient(s) named above. It may
contain information that is privileged or confidential, and
may be protected by State and/or Federal Regulations. If
the reader of this message is not the intended recipient,
you are hereby notified that any dissemination,
distribution, or copying of this communication, or any of
its contents, is strictly prohibited. If you have received
this communication in error, please return it to the sender
immediately and delete the original message and any copy
of it from your computer system. If you have any questions
concerning this message, please contact the sender.
------------------------------------------------------------------------

Reply via email to