Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Watching mail queues

by bronto (Priest)
on Nov 03, 2004 at 11:01 UTC ( #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? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-01-23 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (63 votes). Check out past polls.

    Notices?