LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-21-2011, 12:35 AM   #1
Fracker
Member
 
Registered: Mar 2009
Posts: 86

Rep: Reputation: 0
Actively Monitoring Log File


I have an application which generate logs like this

Code:
                                                                2011-05-17 13:21:27 - Msg 2402
File loading terminated.

File information: 3 records in input file found
                  3 records processed
                  0 records skipped
Load statistics:  3 messages loaded correctly
                  0 messages ignored
                  0 messages with errors
Details:
   Destination              OK    ignored     errors    correct  incorrect   not sel.      other
   ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
   house Server (def          3          0          0          0          2          1          0

                                                               2011-05-17 13:21:27 - Msg 2410
Archiving information: File /path/to/xxx.txt
was archived as /path/to/xxx.txt.
now i want to moniter this "house Server (def" and send alert based on 3 0 0 0 2 1 0

say if [ $5 -gt 0 || $6 -gt 0 ]; then
<send email>
 
Old 05-21-2011, 10:35 AM   #2
Fracker
Member
 
Registered: Mar 2009
Posts: 86

Original Poster
Rep: Reputation: 0
no one knows? :/
 
Old 05-21-2011, 11:43 AM   #3
zunder1990
LQ Newbie
 
Registered: Feb 2011
Posts: 29

Rep: Reputation: 3
Take a look at some code that I wrote. this would give you the if then part.
Code:
if [ $? -eq 0 ]; then  # check the exit code
        echo "$ip is up" >> /root/Desktop/iplog #write  the ip of the hosts that are up
        
    else
        echo "$ip is down" # will show on the screen the ips that are not up
        logger -p auth.notice "$ip is down" # will write the down host to syslog
        echo "$ip is down" | mail -v -s alert user@anydomain.com > /dev/null 2> /dev/null #will send mail users about host down
    fi
 
Old 05-23-2011, 12:23 AM   #4
Fracker
Member
 
Registered: Mar 2009
Posts: 86

Original Poster
Rep: Reputation: 0
Code:
# tail -f logfile | grep "house server (def" | awk '{
print $1
print $2
print $3
print $4
print $5
print $6
print $7
print $8
}'
what is problem here?
 
Old 05-23-2011, 01:02 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
I'd try more like
Code:
tail -f logfile | grep "house Server" |awk '{print $5 $6}'
noting that you said you wanted fields 5 & 6 earlier. Also, tricky to tell without seeing the err msg/output you got, but I'd expect that the '(' caused an issue as it's a 'Special Char' in shell scripting.
Also, *nix is case sensitive, so 'server' != 'Server'.
HTH
 
Old 05-23-2011, 05:37 AM   #6
Fracker
Member
 
Registered: Mar 2009
Posts: 86

Original Poster
Rep: Reputation: 0
nope still not working..

ps: i was just using it for testing purpose as if i can get the argument, then i can manipulate them which is why i used "server" instead of "Server"
 
Old 05-23-2011, 06:04 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,721

Rep: Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120
Prove to yourself you have a record to print ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/var/log file system and monitoring health of system drManhattan Red Hat 7 04-30-2011 05:15 PM
log file monitoring qwertyjjj Linux - Server 1 06-28-2010 08:58 PM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
Monitoring log file changes from c++ app shibeaux Linux - General 3 06-16-2009 03:44 AM
Monitoring a Specific Port and Exporting to a log file chrisfirestar Linux - General 0 10-27-2003 04:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration