Logfile analyse | problem with regex


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Logfile analyse | problem with regex
# 1  
Old 07-22-2009
Logfile analyse | problem with regex

Hello there,

i am trying to write a shell script to analyse some of my log files.
I want the script to check if there is a logfile from yesterday or today (some times the script that creates the logfile takes a bit longer and its after 00:00) and search the logfile itself if the script was successfully (indicated by a "successfully completed at Mon Jul 21 02:01:25 CEST 2009)

The script shall return 1 if it found a logfile that were successfully and 0 if there is no logfile found or it was not successfully. (Want to link it with Nagios)


Code:
#!/bin/bash

cd /log
ret=`find . -daystart -mtime 2 -name "*.log" -exec grep -h -c -i "successfully completed at\|terminated successfully without warnings" > step.log {} \;`
EXIT=$?

ret2=`egrep "[1]" step.log`

if [$ret2 = "[1]{1,}"]
 then
   end=1
 else
   end=0
fi

echo $end

Here i am stuck Smilie. My step.log file contains this:

Code:
1
1

and i dont know how i get this Regex to work. I want the script if there is a "1" or more "1" in the stop.log file to end and return 1.

And cuz i am allready here is there a "easy way" to check if the date from today or yesterday matches the one in the logfile ? I tryed but the Format in the logfile is like this "Mon Jul 20 02:01:25 CEST 2009" and i am not sure how to compare this with system time.

Thank you for even reading that :>
Linién
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logfile monitoring with logfile replacement

Bonjour, I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things. The script use the following technique : tail -fn0 $logfile | \ while read line ; do ... some stuff done First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies

2. HP-UX

How to analyse the syslog?

Hi All, When can we see these messages in the syslog. We have service guard cluster software installed on hpux 11iv3 servers. We were able to see the below error so many times in our syslog messages cmdisklockd: Unable to convert device to I/O tree node: I/O tree node does not exist. ... (2 Replies)
Discussion started by: Sachin1987
2 Replies

3. UNIX for Dummies Questions & Answers

Analyse this fdisk -l

Hi, Someone please analyse the following o/p of fdisk -l and tell me what it means for /dev/sda, /dev/sdb, /dev/sdc .... Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start ... (5 Replies)
Discussion started by: stunn3r
5 Replies

4. Shell Programming and Scripting

How to analyse results of grep

Hi all, I'm working with a peice of software that runs on Linux that allows planning trips in cars through maps. This software has different variations depending on the type of car, e.g. BMW, Audi, Hyundai, etc... Each variation has a dependency on common external components that are not... (1 Reply)
Discussion started by: emoshaya
1 Replies

5. Programming

Regex problem

Hi, I am looking for regex to extract following words from text: The word which comes after "Replaced" means Replaced disk Replaced floppy Replaced memory Please suggest the regex for it. Thanks! (4 Replies)
Discussion started by: gunjanamit
4 Replies

6. Shell Programming and Scripting

awk regex problem

hi everyone suppose my input file is ABC-12345 ABCD-12345 BCD-123456 i want to search the specific pattern which looks like - in a file so i used this command cat $file | awk ' { if ($0 ~ /-/) { print } }' so it gives me the result as ABCD-12345 BCD-12345 BCD-12345 ... (31 Replies)
Discussion started by: aishsimplesweet
31 Replies

7. Solaris

I need to analyse some vmcore files

I need to analyse some vmcore files, do you guys know how can i get a free version of the "Solaris Crash Analysis Tool " (2 Replies)
Discussion started by: feg
2 Replies

8. Programming

REGEX problem

Hi there, How can we use regex in perl to store the Route Distinguisher (the bold field) and also the underlined and bold lines in the below file? Note: These highlighted pattern is redundant through the whole input file. Basically, we just need to extract these fields at least to store them... (4 Replies)
Discussion started by: omoyne
4 Replies

9. UNIX for Dummies Questions & Answers

regex problem with +

Hi, Can someone tell me why the first regular expression with the + fails to match the input string? SUN /web>echo cat | grep '+' SUN /web>echo cat | grep '' cat I'm running SunOS 5.10 Thanks. Chris (2 Replies)
Discussion started by: che9000
2 Replies

10. Shell Programming and Scripting

regex problem

Hi, #!/usr/bin/perl -w my $timestamp; my $line = "Fri May 29 18:29:57.357 2009 Morocco Standard Time INFO: pid 3216 tid 1724: 170: 132192: apricocot Native Server: recvd AA_BIN_MSG_VER_CHG"; if ($line =~ /^(.*) INFO: .* recvd AA_BIN_MSG_VER_CHG/) { $timestamp = $1; ... (1 Reply)
Discussion started by: namishtiwari
1 Replies
Login or Register to Ask a Question