Log Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log Script
# 1  
Old 05-03-2011
Log Script

Hello,

I am running running a file that I created to tail our log, stripping out some key words to avoid noise.
I want to script this vs using something bellow, something simple were I could populater a txt file and it would filter content from that text file
my other idea was to add a section on that file were if certain words were seen in the tail it would mailx the alert

I do not claim to be a scripting person but any ideas would be great Smilie

here is my 1.sh file Smilie

Code:
clear
echo "Monitoring ..."
tail -f /var/log/ncolog | egrep -vi "banner content|message repeated|archive_command.sh|cron|CELFSS|DEBUG1 cleanupThread|Log statistics|nexthop|TLD|AMOS|SQL"


Last edited by joeyg; 05-03-2011 at 03:17 PM.. Reason: Please use CodeTags around commands
# 2  
Old 05-03-2011
So just for clarification, you want to call a file you're creating with certain key words instead of calling your whole egrep?

So instead of

Code:
 
egrep -vi "banner content|message repeated|archive_command.sh|cron|CELFSS|DEBUG1 cleanupThread|Log statistics|nexthop|TLD|AMOS|SQL"

You want to call a static file so you can just edit the file and search based on the keywords in the file?
# 3  
Old 05-03-2011
'man grep' yields:
Code:
     -f pattern_file
           Reads one or more patterns from the file named by  the
           path  name  pattern_file. Patterns in pattern_file are
           terminated by a NEWLINE character. A null pattern  can
           be  specified by an empty line in pattern_file. Unless
           the -E or -F option is also specified, each pattern is
           treated as a basic regular expression.

# 4  
Old 05-03-2011
Sort of actually the reverse, I am tailing the log and those are key words I do not want to see
I am filtering them out of the tail.
# 5  
Old 05-03-2011
Quote:
Originally Posted by NelsonC
Sort of actually the reverse, I am tailing the log and those are key words I do not want to see
I am filtering them out of the tail.
Well..... there's always a '-v' option to combine with.....
# 6  
Old 05-03-2011
ah good point will give it a try.
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 newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

3. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

4. Shell Programming and Scripting

Help with a rotate log script

Hi all, Am trying to write my own log rotate script. Curremtly, what I have is as below: #!/bin/ksh file_to_rotate=${1} x=${2} while ] do let curr=${x} let prev=${x}-1 if ] ; then #echo "cp -p ${file_to_rotate} ${file_to_rotate}.${curr}" cp -p... (7 Replies)
Discussion started by: newbie_01
7 Replies

5. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

6. Shell Programming and Scripting

log file script

I have a log which is configured as follows: date time code1 notes: code2 A monthly job is run based on information supplied from this log. The end of each monthly job is clearly indicated by a code within 'code1'. At this time someone is performing a less on the log, moving to the end,... (2 Replies)
Discussion started by: bwatlington
2 Replies

7. Shell Programming and Scripting

Log Script

Can we write any command/Script....to find out the data in a log file for last 5 mins? (2 Replies)
Discussion started by: shilpaamu
2 Replies

8. Shell Programming and Scripting

Script for Log Rotate

Hello, I only know the basic for shell programing. I need help for this, I thinks this is a basic for anyone who know a litle of shell scripting. I need creat a script for a rotatate logs, when a filesystem is full. I have a filesystem. The rotate consist in zip the current log (copy) and... (1 Reply)
Discussion started by: El Rengo
1 Replies

9. Shell Programming and Scripting

Log Search Script

Hi, I am trying to write a script to search a log- IPaddress being the search criteria, I would ideally like the script to ask the ipaddress Enter IP address - 244.258.27.225 And the ideal result would be for the script to get all the entries in the log file for a particular IP address,... (3 Replies)
Discussion started by: fuzion.hyd
3 Replies

10. Shell Programming and Scripting

log in as su from a script

Hi, I am running a script where i need to run another command in a particular folder which I do not have access so I need to login as su to that folder and run that script...what are the options I need so that I can skip interactive mode ..here is what I tried.. #! /usr/bin/sh... (1 Reply)
Discussion started by: mgirinath
1 Replies
Login or Register to Ask a Question