Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Watching mail queues

by bronto (Priest)
on Nov 03, 2004 at 11:01 UTC ( [id://404859]=CUFP: print w/replies, xml ) Need Help??

"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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://404859]
Approved by rob_au
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found