Sponsored Content
Top Forums Shell Programming and Scripting Getting last section of data from logfile Post 302739445 by Jotne on Tuesday 4th of December 2012 08:07:26 AM
Old 12-04-2012
Getting last section of data from logfile

Hi, I have a log file from Munin like this:
Code:
2012/12/04 13:45:31 [INFO]: Munin-update finished (29.68 sec)
2012/12/04 13:50:01 Opened log file
2012/12/04 13:50:01 [INFO]: Starting munin-update
2012/12/04 13:50:01 [ERROR] Error occured in under [] in the configuration.
2012/12/04 13:50:01 [Warning] Could not parse datafile /var/lib/munin/datafile: [ERROR] Error occured in under [] in the configuration.  Please refer to the log if details are missing here.
2012/12/04 13:50:11 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:50:21 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:50:31 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:50:33 [INFO] Reaping Munin::Master::UpdateWorker<localdomain;localhost.localdomain>.  Exit value/signal: 0/0
2012/12/04 13:50:33 [INFO]: Munin-update finished (31.71 sec)
2012/12/04 13:55:02 Opened log file
2012/12/04 13:55:02 [INFO]: Starting munin-update
2012/12/04 13:55:02 [ERROR] Error occured in under [] in the configuration.
2012/12/04 13:55:02 [Warning] Could not parse datafile /var/lib/munin/datafile: [ERROR] Error occured in under [] in the configuration.  Please refer to the log if details are missing here.
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_stable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_unstable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_testing
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_unstable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_stable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_testing
2012/12/04 13:55:12 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:22 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:32 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:37 [INFO] Reaping Munin::Master::UpdateWorker<localdomain;localhost.localdomain>.  Exit value/signal: 0/0
2012/12/04 13:55:37 [INFO]: Munin-update finished (35.48 sec)

How do I get only the last section from the log starting with last Opened log file so I get output like this:
Code:
2012/12/04 13:55:02 Opened log file
2012/12/04 13:55:02 [INFO]: Starting munin-update
2012/12/04 13:55:02 [ERROR] Error occured in under [] in the configuration.
2012/12/04 13:55:02 [Warning] Could not parse datafile /var/lib/munin/datafile: [ERROR] Error occured in under [] in the configuration.  Please refer to the log if details are missing here.
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_stable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_unstable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_testing
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label pending_unstable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_stable
2012/12/04 13:55:02 [WARNING] Service apt_all on localhost.localdomain/127.0.0.1:4949 returned no data for label hold_testing
2012/12/04 13:55:12 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:22 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:32 [WARNING] Call to accept timed out.  Remaining workers: localdomain;localhost.localdomain
2012/12/04 13:55:37 [INFO] Reaping Munin::Master::UpdateWorker<localdomain;localhost.localdomain>.  Exit value/signal: 0/0
2012/12/04 13:55:37 [INFO]: Munin-update finished (35.48 sec)

 

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

New Section

Just like we have a section "Unix for dummies..." , why not have a section on UNIX BACKUP AND RECOVERY Thanks :) (3 Replies)
Discussion started by: kapilv
3 Replies

2. Shell Programming and Scripting

get last section from large logfile

Hi all, I need to pull the (last section) from the header to the end of file. This logfile will have many sections appended, but I only need to capture the last one and email it to someone. Any ideas? Thanks Kathy Example Logfile: ============= = BOX : SAPCFI = JOB : SAPCFI =... (9 Replies)
Discussion started by: kburrows
9 Replies

3. Post Here to Contact Site Administrators and Moderators

New section

Hi Just a thought if it already hasn't been suggested. While looking at the forums I thought it might be a good idea under somewhere like 'special forums' add a section called 'projects'. I think this would be good for people to be able to post projects they have created. For example I am... (3 Replies)
Discussion started by: woofie
3 Replies

4. Shell Programming and Scripting

Search and Remove No data Section

Hello, I have written a script that removes duplicates within a file and places them in another report. File: ABC1 012345 header ABC2 7890-000 ABC3 012345 Content Header ABC5 593.0000 587.4800 ABC5 593.5000 587.6580 ABC5 593.5000 587.6580 ABC1 67890 header ABC2 1234-0001 ABC3... (2 Replies)
Discussion started by: petersf
2 Replies

5. Shell Programming and Scripting

Extract section of file based on word in section

I have a list of Servers in no particular order as follows: virtualMachines="IIBSBS IIBVICDMS01 IIBVICMA01"And I am generating some output from a pre-existing script that gives me the following (this is a sample output selection). 9/17/2010 8:00:05 PM: Normal backup using VDRBACKUPS... (2 Replies)
Discussion started by: jelloir
2 Replies

6. Shell Programming and Scripting

extracting data froma logfile

You are given a 1 year logfile with each line starting with a date in the form “YYYY-MM-DD”. How would you extract logs from the 4th day of each month and put them into a new file (3 Replies)
Discussion started by: DOkuwa
3 Replies

7. Shell Programming and Scripting

Prepend first line of section to each line until the next section header

I have searched in a variety of ways in a variety of places but have come up empty. I would like to prepend a portion of a section header to each following line until the next section header. I have been using sed for most things up until now but I'd go for a solution in just about anything--... (7 Replies)
Discussion started by: pagrus
7 Replies

8. Shell Programming and Scripting

take a section of a data with conditions

I have a data file like below: 2011 0701 2015 21.2 L 37.692 46.202 18.0 Teh 4 0.3 2.1 LTeh 1 GAP=233 E Iranian Seismological Center, Institute of Geophysics, University of Tehran 6 STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO SNR AR TRES W DIS CAZ7 TBZ SN EPg 0 2015 31.19 -0.3... (3 Replies)
Discussion started by: saeed.soltani
3 Replies

9. 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

10. UNIX for Beginners Questions & Answers

Grep a section from an UNIX file obtaining only part of the data

Hello, I have a log file that has several sections "BEGIN JOB, End of job" like in the following example: 19/06/12 - 16:00:57 (27787398-449294): BEGIN JOB j1(27787398-449294) JOB1 19/06/12 - 16:00:57 (27787398-449294): DIGIT: 0 number of present logs : 1 19/06/12 - 16:00:57... (4 Replies)
Discussion started by: mvalonso
4 Replies
All times are GMT -4. The time now is 01:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy