nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Monitoring Log File

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 ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 04-30-2008, 04:43 AM
Junior Member
User
 
Join Date: Jan 2008
My distro: Debian
Posts: 4
Rep Power: 0
nageshms is on a distinguished road
Smile Monitoring Log File

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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-08-2008, 06:46 PM
Junior Member
User
 
Join Date: May 2008
Location: barcelona
My distro: fc1,4,7&8,debian3&4,SLES10,opensuse11
Posts: 23
Rep Power: 0
permalac is on a distinguished road
Default

check this commands


$ tail -f <logfile> #this will show on your term real time updates of the end of the file


$ grep
$ mail

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.
Reply With Quote
  #3 (permalink)  
Old 05-08-2008, 11:21 PM
Junior Member
User
 
Join Date: Jan 2008
My distro: Debian
Posts: 4
Rep Power: 0
nageshms is on a distinguished road
Smile

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.
Reply With Quote
  #4 (permalink)  
Old 05-13-2008, 06:32 PM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

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
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT +5.5. The time now is 03:11 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36