${load_avg}

The current load average V8.10 and later

The ${load_avg} macro contains as its value the current one-minute load average of the machine on which sendmail is running. That value is a rounded integer representation of a possible floating-point value.

One use for this ${load_avg} sendmail macro might be to reject SMTP ETRN commands when the load average it too high:

LOCAL_CONFIG
D{OurETRNlimit}5
Karith math

LOCAL_RULESETS
Scheck_etrn
R $*             $: $(math l $@ $&{load_avg} $@ ${OurETRNlimit} $)
R FALSE          $# error $@ 4.7.1 $: "450 The load average is currently too high."

Here, we add two new sections to our mc configuration file. The first, under LOCAL_CONFIG, defines a sendmail macro, ${OurETRNlimit}, that will hold as its value the limit we have set to reject ERTN commands. In this mc section, we also defined a database map of type arith (arith on page 898).

In the second section, following the LOCAL_RULESETS, we declare the check_etrn rule set (check_etrn on page 706). That rule set is called from inside sendmail (just after an SMTP ETRN command is received, but before the reply to that command is sent) and can determine whether the SMTP ETRN command should be allowed. If the rule set returns the $#error delivery agent, the SMTP ETRN command is denied. Otherwise, it is allowed.

The first rule matches anything in the LHS, then ignores that value in the RHS. The RHS looks up the current ($&) value of the ${load_avg} macro, then uses the math database map to compare that value to the limit ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.