procmail
[Top] [All Lists]

Re: Filtering complex mails bodies

1999-10-15 08:10:17
On Fri, 15 Oct 1999 16:48:04 +0200, Aaron Optimizer Digulla
<dia(_at_)unix(_dot_)swx(_dot_)com> wrote:
As sysadmin, I get a lot of "status" mails (the system X is
ok, etc). Example:
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/data1/sybdumps 14399925 7742124 5217809    60%    
/export/dat/sybdumps
total 36
drwxr-xr-x   2 sybase   swxadm       512 Sep 30 16:50 SYB_IMISREP
<...>
drwx------   2 root     root        8192 Dec  2  1998 lost+found
drwxr-xr-x   2 sybase   swxadm      2560 Sep 30 15:51 tmp

I want to get this mail only when the available blocks go below
100MB. If the available blocks are above 100MB, the mail
should be saved in some folder (for statistics).

I can write a filter in awk, perl or python but what should
the condition look like ?

Assuming you are talking about the third field of the du(1) output,
and that it tells you the size in bytes (not kilobytes or sectors),
you could do something like

    :0:
    * ^Subject: something, perhaps?
    * B ?? ? script-which-exits-with-exit-code-0-if-du-says-more-than-100M
    some-folder-for-statistics

    # otherwise fall through to here, processing continues as usual

But you can do better than that; use scoring:

    :0:
    * ^Subject: something, perhaps?
    * B ?? ^^Filesystem\<+kbytes\<+used\<+capacity\<+Mounted on$\
                /[^     ]+\<+[0-9]+\<+\/[0-9]+
    * $ -$MATCH^0
    * 104857600^0
    some-filder-for-statistics

You generally want to avoid calling an external script if you can, so
the scoring solution is better (but not much, if you only receive like
one of these per day).

Hope this helps,

/* era */

Untested, but you get the idea.

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

<Prev in Thread] Current Thread [Next in Thread>