This is a discussion on Monitoring Log File within the Shell scripting forums, part of the Development/Scripting category; Hello Friends, I need a help in writing the script to monitor one of the log file and send out ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Hello Friends,
I need a help in writing the script to monitor one of the log file and send out an e-mail when it finds particular value goes above some threshold. Example: sample log entry : 2008.04.29 15:07:45:683 Env/Ajp13Processor[8109][5]:INFO:CORE BEGIN Session=242A84B37BAD5E5FC92D5883DC540AE2.abcxyz6 Active Sessions: 180 In above sample entry if Active Sessions: goes above 250 it should send out an e-mail. This will be very helpful in my project. Can some expert give hint on this. Thanks |
| Sponsored Links | ||
|
|
|
|||
|
check this commands
$ tail -f <logfile> #this will show on your term real time updates of the end of the file $ grep may be you can launch a command with pipes with this commands and a & at the end to go in backgound tail -f <logfile> | grep -e "Session" | mail -s "subject" mail@example.com will be nice if you post your final script here for further reading. |
|
|||
|
Thanks for the hint but it didn't serve my requirement. grepping the session and sending mail is not my requirement. It as to send mail only if value exceeds some threshold say for example 250. Sessions =<value> .
Please suggest what changes I have to do for this. |
|
|||
|
Assuming the above log entry is a single line and session number is the last field,
something like this should work Code:
awk 'BEGIN { threshold = 250 } $NF > threshold ' logfile | mail root
|
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HELP! Port Monitoring! | sunburn | Shell scripting | 1 | 02-11-2008 02:46 PM |
| Monitoring Tools | jhn_daz@yahoo.com | Linux software | 1 | 11-20-2007 09:41 PM |
| Raid Monitoring | vimalgoel | Getting started tutorials | 3 | 08-09-2007 06:08 PM |
| Network Monitoring | puppen | Linux software | 2 | 05-11-2006 12:01 AM |
| Monitoring a NIC | nathan86 | Linux software | 2 | 03-10-2005 04:41 PM |