A collection of opinions, thoughts, tricks and misc. information.
Okay, so I've been thinking for a while how nice it would be to have a little message pop up on my screen whenever something was added to one of my logs, and I didn't really want to work on something I'd get rid of quickly, so I never worked on the program. Today though I learned about xmessage (Which shows I've still got a long way to go with this whole linux thing :)). I threw together a quick python script that monitors logs for you:
#! /usr/bin/env python
""" A very simple monitor, using xmessage to display information about an update to any file... """
import os, time
# Will check each item, takes the form of 'command to read log, identifier, and last line read (leave empty)...
reader = [
['dmesg', 'System Logs', ''],
['cat /var/log/apache/error_log', 'Apache Error', ''],
['cat /var/log/apache/access_log', 'Apache', '']
for command in reader:
read = os.popen("%s | tail -n 1" % command)
line = read.readlines()
if line <> command:
if command <> "":
os.popen("echo \"%s: %s\" | xmessage -center -file - -timeout 3" % (command, line))
command = line