log monitor shell script
Hi Guys,
i have requirement for log monitor shell script as per below a)grep WARNING or EXCEPTION or SEVERE from log file b) count the grep results c)send an email notification for grep results please help me . thanks, Arun |
Welcome to LQ!!!
As you are new to LQ go through LQ rules here We will not do your homework or the job / work which has been assigned to you. We as a community are here to help / assist you but you have to let us know what you have tried so far and where you are stuck. |
failed to open
|
You have pasted the script but you did not mention which section of the script you are facing issue with? Whenever you are pasting a script it is good idea to use code tags as I have used below to keep indentation:
Code:
#!/bin/bash |
failed to open
|
I have put comment in your script:
Code:
#!/bin/bash |
checking
|
This here won't work:
Code:
E_count = grep -c "ERROR" /home/user001/Error_details.txt Code:
var=value Code:
var = value Code:
var=$(grep whatever) Code:
if($E_count>=0) Code:
if [ $E_count -ge 0 ];then The initial loop looks very strange to me, too, I don't understand what exactly you are trying to accomplish there, but whatever it is I am sure it is very inefficiently coded... |
Maybe one additional consideration. Put together a grep command that only gives you output if something is wrong.
Put that into a cronjob and set up cron such that it can email you. Whenever your grep produces output it will be emailed to you automatically. That should get you going and is probably an order of magnitude simpler and cleaner than what you are looking at right now... |
@joe_2000: Good catch.
Yes it should be without spaces. Infact you could put it like this and it should work: Code:
E_count=`grep "ERROR" /home/user001/Error_details.txt | wc -l` |
Code:
for ((i = 0 ; i < 10000 ; i++ )); Pointer: If you want to record 10000 lines anyways you can go with tail -n 1 instead. Example: Code:
statusvar=`tail -n 1 /DBA/capsqa2/JavaCAPS62/appserver/domains/domain1/logs/server.log` >> /VZ/EAIworkspace/narender/Error_Temp_details.txt |
will check and provide the details
|
Quote:
Code:
var=$(grep whatever) |
All times are GMT -5. The time now is 06:42 PM. |