"Hey bronto! We would like to monitor our mail queues in *COMMERCIAL_PRODUCT* with a custom plugin. We need to extract from the mailq command the name of the queue and how many messages are in. There must be also an header and a footer. How would you do it?"
This way, with a one-liner:
mailq | perl -ne 'BEGIN { print "HEADER\n" } ; END { print "FOOTER\n" } ; /^\s*(\S+)\s+(?:is empty|\((\d+) requests?\))/ and print $1," ",$2||0,"\n"'Ciao!
--bronto
In theory, there is no difference between theory and practice. In practice, there is.
In reply to Watching mail queues by bronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |