Grep Stop status from the output of script and send an eamil alert.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep Stop status from the output of script and send an eamil alert.
# 1  
Old 12-02-2010
Grep Stop status from the output of script and send an eamil alert.

Hello Team,

I have script which gives below output.

Server clustServer11 is in a STARTED state

Server clustServer12 is in a STOPPED state

Server clustServer21 is in a STOPPED state

I would like to prepare script which will grep stop word from the above output and send an email alert.
# 2  
Old 12-02-2010
Code:
cat output | grep -i "stop" | mail -s "any subject" yourmail@foobar.com

R0H0N
# 3  
Old 12-02-2010
I am getting this output.

./wsadmin.sh -lang jython -f serverstat.py | grep -i stopped | awk '{ print $2 }'
clustServer12
clustServer21


I have requiremnt to send mail with the server name which is stopped state.

---------- Post updated at 07:41 AM ---------- Previous update was at 05:52 AM ----------

bash-3.00$ ./wsadmin.sh -lang jython -f /opt/app/ccr/home/ccr/scripts/ccrserverstatus.py | grep -i start | awk '{ print $2 }' | while read server;
> do
> if [ $server = "clustServer1*" ]
> then
> echo "$server is running fine on ccrtoolsvcp1"
> else
> echo "$server is running fine on ccrtoolsvcp3"
> fi
> done
clustServer11 is running fine on ccrtoolsvcp3
clustServer12 is running fine on ccrtoolsvcp3
clustServer13 is running fine on ccrtoolsvcp3
clustServer21 is running fine on ccrtoolsvcp3
clustServer22 is running fine on ccrtoolsvcp3


My requirement is if server is clustserver11,12 and 13 then it should execute following echo command.

echo "$server is running fine on ccrtoolsvcp1"

and if server is clustserver21 and 22 then it should execute following echo command.

echo "$server is running fine on ccrtoolsvcp3"


But this is not happening now. It is going in else statement only and not comparing comment in if command.

Can anyone pls help me to correct script?
# 4  
Old 12-02-2010
try

Quote:
if [ "$server" = "clustServer1.*" ]
instead of

Quote:
if [ $server = "clustServer1*" ]
R0H0N
# 5  
Old 12-02-2010
Hello Rohan,

Thanks for the response. But it didnt worked. It is not comparing string in if statement and directly going to else statement.

bash-3.00$ server=clustServer11
bash-3.00$ if [ "$server" = "clustServer1.*" ]
> then
> echo "$server is running fine on ccrtoolsvcp1"
> else
> echo "$server is not running"
> fi
clustServer11 is not running
bash-3.00$
# 6  
Old 12-02-2010
execute

Quote:
prompt> sh -x ./wsadmin.sh
to debug the script
R0H0N
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to send mail alert

Hi I have below shell script to send mail alert , however I want to add more functionality in this script and that is , script should only check that file between 9 am to 5pm , and if there is no activity in this time 9 am to 5 pm for 2hours then it should give me mail alert, please help... (2 Replies)
Discussion started by: scazed
2 Replies

2. Shell Programming and Scripting

Shell script to send mail alert

HI Guys, I am writing one shell script to send the mail alert to some email id's if the file not modified in last 10 mins but its not working, I believe MTIME is null string is wrong . can you please assist me on this. script :- filename="abc.txt" echo "Filename is $filename"... (1 Reply)
Discussion started by: abhigrkist
1 Replies

3. UNIX for Beginners Questions & Answers

Automation script for email alert when a job get complete with status successful.

Guyz, Please let me know about script which is to be sending an automatic email to particular mail id's when a monotoring job get complete with status successful. (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

4. Shell Programming and Scripting

Parse qshape output and send email alert

Hi I need help to do this. This is the output of qshape: user$ qshape deferred|head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 0 0 0 0 0 0 0 0 0 0 0 T stands for minutes elapsed and TOTAL... (1 Reply)
Discussion started by: zorrox
1 Replies

5. Shell Programming and Scripting

Help....script check status if see something then send email

autorep -m bogus Machine Name Max Load Current Load Factor O/S Status ___________ ________ ___________ ______ ________ ______ bogus --- --- 1.00 Sys Agent Online Status ______ Online Offline Missing Unqualified The "Status" always "Online". I like create a script execute run... (6 Replies)
Discussion started by: dotran
6 Replies

6. Shell Programming and Scripting

Script to send alert if any changes are made in crontab.

Hi i want to know how can i write a script to check if any changes are made and send an alert in crontabs . i am using .ksh file extension for writing scripts. (3 Replies)
Discussion started by: honey26
3 Replies

7. Shell Programming and Scripting

How to automatically send a mail alert if the script errors out

I have a script like this, which calls other scripts from that script: #!/usr/ksh moveFiles.sh extract.sh readfile=/home/sample.txt cat $readfile | while read line do file= `echo $line|awk '{print $4}'` if ; then mv $file /home/temp_stage fi (4 Replies)
Discussion started by: ss3944
4 Replies

8. UNIX for Dummies Questions & Answers

Send output of grep as input of kill command

I would appreciate any help. I need to run 'ps -ef | grep 'process', get the process id and kill that process. I have got this far: - Get pid using ps -ef | awk '/process/{ print $2}' after this I'm kind of stuck.. - Use pipe to redirect the output to kill pid=ps -ef | awk '/bmserver/{... (2 Replies)
Discussion started by: foxtron
2 Replies

9. Shell Programming and Scripting

Write a script to send alert for some particular hours in a day

Hi All, I have a have a script which checks for some processes whether they are running or not and if they are not running then it send a mail specifying that the processes are not running. This particular script example abc.ksh is runs in a cron like this 0,5,10,15,20,25,30,35,40,45,50,55 * * *... (5 Replies)
Discussion started by: usha rao
5 Replies

10. Shell Programming and Scripting

cron: try script 4 times then send mail and stop

Hi! I have a simple script i call, and i use CRON to run the script daily between 7 and 8 o'clock. The cron runs 4 times a day between 7 and 8. The code is simple: if <script ran successfully> do something else try again later, with the next time cron runs. BUT If the script failed for... (1 Reply)
Discussion started by: bash100
1 Replies
Login or Register to Ask a Question