nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell script to monitor syslog.log

This is a discussion on Shell script to monitor syslog.log within the Shell scripting forums, part of the Development/Scripting category; Hi, I'm new to shell scripting. I need to monitor syslog.log hourly and alert us if there is any “error” ...


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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 24-03-2009, 03:20 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
spabba is on a distinguished road
Smile Shell script to monitor syslog.log

Hi, I'm new to shell scripting.
I need to monitor syslog.log hourly and alert us if there is any “error” in the log for the previous hour.

Can any one help in this regard.

Thannks in Advance
Reply With Quote
  #2 (permalink)  
Old 24-03-2009, 05:08 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You can use something as follows from a command line:
Code:
egrep -w 'error|warn|critical|fail' /var/log/syslog.log>/dev/null && echo "Error found" || echo "No error found"
A small script to get stared ...

Code:
#!/bin/bash
warn_us(){
  echo 'Error found' | mail -s 'Error' you@example.com
}


egrep -w 'error|warn|critical|fail' /var/log/syslog.log>/dev/null && warn_us
Run this as hourly cronjob:
Code:
@hourly /path/to/above/script.sh
HTH
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply

Tags
/var/log/syslog.log , egrep , email , mail , monitor syslog.log hourly , syslog


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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
MYSQL master-master replication monitor shell script zafar466 Databases servers 4 08-05-2009 11:35 PM
Binary Conversion Of Shell Script (shell script compiler) chandanperl Shell scripting 3 29-07-2008 10:22 AM
Syslog-ng Documentation kvsmanean Ubuntu / Debian 1 13-06-2008 01:20 PM
Script to monitor a particular directory and send out e-mail.... nageshms Shell scripting 1 11-02-2008 02:01 PM
Shell script to monitor remote local http or port 80 amigo28 Shell scripting 1 12-02-2007 09:58 PM


All times are GMT +5.5. The time now is 01:48 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

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 37 38