The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Noob, script formatting query benjo Shell Programming and Scripting 2 03-03-2008 04:37 AM
Why does my script not work? (Noob Alert) bronkeydain Shell Programming and Scripting 4 02-21-2008 01:45 PM
can we create a GUI by shall script johnray31 Shell Programming and Scripting 1 07-24-2007 07:47 AM
Using PHP script with crontab (NOOB) Bobafart UNIX for Dummies Questions & Answers 5 04-26-2007 06:32 PM
how do I create an ftp script leonard905 UNIX for Dummies Questions & Answers 2 01-14-2005 03:25 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-09-2007
Registered User
 

Join Date: Jul 2007
Posts: 1
noob. need help to create a script.

Hi All.

im a noob to scripting. could somone help me with a script please.

what i want to do is.

1. run a cmd in the script - qmqtool -s

this will give me an output similar to this.

Messages in local queue: 790
Messages in remote queue: 306
Messages in todo queue: 23

i then want to check if the message in the local queue is larger than the number of for example 100 ( but id like to be able to change this)

if its larger i want to do.

2. send email to me@mydomain.com with the output of the qmqtool -s and saying something like this

mail checker script has detected more than 100 emails in the local queue.

Messages in local queue: 790
Messages in remote queue: 306
Messages in todo queue: 23

the script will automatically fix this issue.

3. service stop spamd
4. service stop drwebd
5. service restart xinetd

thats all for now. ill run this script as a cron job every 1 hr.

appreciate any help.

cheers aron.
Reply With Quote
Forum Sponsor
  #2  
Old 07-09-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
To get the local queue, pipe the output of 'qmqtool -s' through awk.
Code:
lqueue_length=$(qmqtool -s | awk '/local queue/ {print $NF}')
if [ $lqueue_length -gt 100 ]; then
   # send mail using mailx or whatever tool you use
   # fix the problem in the next three lines
   service stop spamd
   service stop drwebd
   service restart xinet
fi
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0