Page 1 of 1

Checking the log file for updates

Posted: Mon Nov 08, 2010 10:01 pm
by radioz
I like to periodically check the hda-updates log (among other things) to see what has been modified on my system and when it changed. My HDA has been running for almost a year, so the logfile is getting very large (over 20 MB so far!; hey devs - how about using logrotate?)

I hate wading through the huge file looking at which files have been modified, so I decided to write a little script to extract just the updates/additions for me. I thought that this might be useful for others, so I would like to share it with you:

Code: Select all

#!/usr/bin/python # # Dump update information from /var/log/hda-updates.log #!/usr/bin/python # # Display the date and files that were modified/installed. # # Reads the hda-updates log file and parses out just the file updates/additions. # It helps to see what has been modified and when. # # radioz # 11/8/2010 # log = '/var/log/hda-updates.log' f = open(log, 'r') lines = f.readlines() f.close() gotUpdates = False firstUpdate = False dateInfo = '' for ll in lines : l = ll.strip() # Ignore dependency heading if l == 'Installing for dependencies:' : continue if l == '' : # A blank line terminates the updates for a particular date if gotUpdates : # Display a blank line between dates print gotUpdates = False continue if gotUpdates : if firstUpdate : # Display the date above the first update print '%s:' % dateInfo firstUpdate = False # Reformat the file info slightly updateInfo = l.split() print ' %-16s %-6s %-20s %-16s %-5s %s' % (tuple(updateInfo)) if 'hda update attempt' in l : # This header appears once per hour in the log. Very few represent real updates. # Save the date information in case this is a real update. dateInfo = ' '.join(l.split()[5:]) if 'Updating:' in l : # This is a real update, set up the flags gotUpdates = True firstUpdate = True
Save this file to a convenient place on your hda (I used ~/bin/hda-updates) and make it executable.

Then just type hda-updates and it will print out all of the Amahi file updates.

This is an example of its output:

Code: Select all

Tue Aug 31 05:01:23 PDT 2010: hda-platform noarch 5.5-1 amahi 1.1 M hdactl i386 3.5-1 amahi 218 k wol i686 0.7.1-4.fc12 fedora 38 k Sat Sep 4 15:02:32 PDT 2010: hdactl i386 3.5.1-1 amahi 218 k Sat Oct 30 22:02:14 PDT 2010: hda-greyhole i386 0.6.28-1 amahi 47 k hda-platform noarch 5.6-1 amahi 1.0 M hdactl i386 3.6-1 amahi 218 k Sun Nov 7 20:01:29 PST 2010: hda-platform noarch 5.6-8 amahi 1.0 M
Let me know if you have any questions.

Re: Checking the log file for updates

Posted: Tue Nov 09, 2010 6:07 am
by bigfoot65
That is awesome. Can you please add it to the wiki? We want to try and capture as much as we can there to make it easy for users to find.

Let us know once complete, if you can do it :) We can then add a link to the main page for User Tips and add a link to it.

Thanks so much for sharing.

Re: Checking the log file for updates

Posted: Tue Nov 09, 2010 12:29 pm
by radioz
Sure!

I'll post back when I've added it.

Re: Checking the log file for updates

Posted: Tue Nov 09, 2010 1:12 pm
by radioz
Ok, I added it to the wiki.

http://wiki.amahi.org/index.php/Install ... leshooting

That seemed like the logical place for it.

Re: Checking the log file for updates

Posted: Mon Nov 22, 2010 7:26 am
by rgmhtt
What would be REALLY nice is a daily cron job that emailed only the last update and avoid a running commentary.

But for now this is nice.

Re: Checking the log file for updates

Posted: Mon Nov 22, 2010 7:49 am
by radioz
Great idea!
When I get some time, I'll take a look at it.

Re: Checking the log file for updates

Posted: Tue Nov 23, 2010 7:57 am
by rgmhtt
Consider adding this to logwatch, I just updated the instructions for installing logwatch:

http://wiki.amahi.org/index.php/Monitor ... via_E-mail

This refers to: http://www.logwatch.org/tabs/docs/HOWTO ... atch.html/ for customizing logwatch. This should make it easier and not give admins yet one more email to read.