LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 01-24-2007, 10:43 AM   #1
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Rep: Reputation: 30
Mail Queue Script


Hi, can someone help me with this script I am trying to develop a simple script that will email us via postfix when our mail queue
reaches above 200. Here is what I have so far. My problem is how to get the value from mailq | grep " Kbytes " | awk '{print $5}' into the if statement. Am I anywhere even close to obtaining my result. Any insight would be great. Thanks.




Script to check a value then perform an email if higher than a certain value.


#!/bin/bash
#Script for checking the mailq and emailing administrator if queue is above 200
#Date: 01/24/07

mailq | grep " Kbytes " | awk '{print $5}'

if [ -gt 200]
then
mail -x administrator


#END
 
Old 01-24-2007, 11:10 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,610
Blog Entries: 47

Rep: Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413
In it's most crude form something like
Code:
[ `mailq 2>/dev/null| grep " Kbytes " | awk '{print $5}'` -gt 200 ] && doSomething
could work but this doesn't have any errorchecking so if the result is unexpected all hell breaks loose. Then again the idea of *emailing alerts* when the mail queue is full, well... ;-p
 
Old 01-24-2007, 12:31 PM   #3
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Original Poster
Rep: Reputation: 30
Thanks this is a great quick and dirty method of doing it.

I love it

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
exim mail queue alexr186 Linux - Server 1 01-03-2007 07:00 AM
Mail Queue failures Ziggie Linux - General 3 12-06-2005 09:51 AM
sendmail - mail stays in queue... E-Rick Linux - Networking 1 10-21-2004 11:51 PM
qmail mail queue bluestorm Linux - Software 0 10-06-2003 06:52 AM
Mail Queue... shibata Linux - Networking 1 11-24-2001 08:58 AM


All times are GMT -5. The time now is 01:13 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration