LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
LinkBack Search this Thread
Old 11-10-2009, 08:48 AM   #1
dellxmax
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Rep: Reputation: 0
Need Help For this Monitor Log Script


this is the format of the log file in my system

Code:
xxxxx_xxx_xxxx_xxxxx_09_10_2009_170457.log

xxxx_xxx_2_0_09_10_2009_163834.log

xxx_xxxxxxxxx_25_10_2009_045020.log

xxx_xxxxxxx_08_11_2009_055728.log
the path of this logs file in on for example

/dellxmax/application/log



what i want to do is

make script

give me this output

----------------------------------------------------------------------

File Name | status | date

----------------------------------------------------------------------

xxxxx_xxx_xxxx_xxxxx_09_10_2009_170457.log | success | 22_10_2009

xxxx_xxx_2_0_09_10_2009_163834.log | success | 22_10_2009

xxx_xxxxxxxxx_25_10_2009_045020.log | success | 22_10_2009

xxx_xxxxxxx_08_11_2009_055728.log | success | 22_10_2009





in this report i want the arrange ascending (the last file modified is the last one in this report)





for the status i want this script search for Successfully in the file

founded give me successfully

if it doesn't give me fail



thanks in advance
 
Old 11-10-2009, 09:17 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
i will give it to you, since its your first post.
Code:
find /dellxmax/application/*.log -printf "%f:%p\n"|awk -F":" 'BEGIN{print "Filename | Status | Date"}
{
    path=$2
    filename=$1
    m=split(filename,fi,"_")
    yr=fi[m-1];mth=fi[m-2];day=fi[m-3]
    f=0
    while( (getline line < path )>0 ) {
         if(line~/Successfully/){
            f=1
         }
    }    
    close(path)
    if (f==1){
        status="success"
    }else{
        status="fail"
    }
    print filename"|"status"|"yr mth day
}'
Now, your task is to go read the bash and gawk link in my sig, and practice.
 
Old 11-10-2009, 10:34 AM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 670

Rep: Reputation: 42
ghostdog's script looks a lot better than what I hacked together...

Code:
for i in `ls -rt /dellmax/application/log/` ; do grep -i success $i > /dev/null && echo $i - success - `ls -l $i | awk '{print $6 " " $7 " " $8}'`|| echo $i - fail - `ls -l $i | awk '{print $6 " " $7 " " $8}'` ; done
I'm including mine just in case you want something else to look at.
 
Old 11-10-2009, 06:34 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
use while read loop instead,
Code:
ls -tr ... | while read f
do
 ..............
done
 
Old 11-14-2009, 01:09 PM   #5
dellxmax
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
very thanks for all of you helping me in this script
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl or PHP Script that can tail /var/log/auth.log - two-factor authentication tdnnash25 Linux - Server 1 06-18-2009 08:36 PM
shell script to monitor log file calipryss Linux - Newbie 14 08-05-2008 10:46 PM
log monitor bash script tronica Programming 5 05-14-2008 02:53 AM
Bash script for server log (namely var/log/messages) tenaciousbob Programming 17 05-24-2007 10:43 AM
A live log monitor script ? ifm Linux - Software 1 07-19-2002 02:54 AM


All times are GMT -5. The time now is 07:15 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration