[Mimedefang] Sendmail's {load_avg} Macro

Cormack, Ken Ken.Cormack at Roadway.com
Mon Jul 9 16:58:36 EDT 2007


The thread that referenced wanting to use the sendmail "load_avg" macro in
check_relay got me thinking.

I felt it would be nice to have MD log "load_avg" with each message, so that
I could see after the fact, when reviewing the logs, what forces may have
been at work on the system if problems like timeouts and such, creep in.
Just another tool to add to the toolbox.

If interested, here's what I did:

In sendmail.mc I inserted the following two lines just above my
INPUT_MAIL_FILTER(`mimedefang', ....) line

	define(`confMILTER_MACROS_ENVFROM',
	confMILTER_MACROS_ENVFROM `, i, f, {load_avg}')

For those who for whatever reason edit the sendmail.cf file directly, it
yields the following result (watch out for any line-wrap in this email):

	O Milter.macros.envfrom=i, {auth_type}, {auth_authen}, {auth_ssf},
{auth_author}, {mail_mailer}, {mail_host}, {mail_addr} , i, f, {load_avg}

In /etc/sysconfig/mimedefang (this is a RH Linux server), I added the
following:

	MD_EXTRA="-a load_avg"

In mimedefang-filter I defined a function to log the load average:

	sub print_sendmail_load_avg
	{
	  if (defined($SendmailMacros{"load_avg"})) {
	    my $sm_load_avg = ($SendmailMacros{"load_avg"});
	    md_syslog ('info', "sm_load_avg: $sm_load_avg");
	  }
	  return;
	}

	... And added a call to the function in sub filter_begin.

This yields the following log entries:

	Jul  9 16:48:41 mail01 mimedefang.pl[7821]: sm_load_avg: XX
	(where XX is whatever your load average happens to be)

Now when I review logs and see timeouts and such, I can see what sendmail's
load average was at the time the messages were being processed.  Combined
with sar data and other info, I think it'll help from time to time, with
troubleshooting.  (At least it cant hurt.)

Ken



More information about the MIMEDefang mailing list