blog advertising is good for you


blog advertising is good for you
User login

Generating an RSS Feed of Your Own Events

Question

How could one setup an RSS feed of various network events? Ideally the feed would:
a) Announce when a machine ceased to be visible by the others (or I guess a specific one), and when it came back online
b) Announce when any /Applications program was upgrade (using last-modified, I guess?)
c) Announce any problems the network had with reaching the “outside world”

Answer

You’ll want to write scripts to gather the information you need, then log that information, and then convert that log to RSS. Happily, most of this is already done for you.

We can use one of the various local facilities for this purpose. They range from local0 to local7 with local0 in use by the system for the firewall logger. We’ll take over the local7 facility for this project. Append the following line to /etc/syslog.conf:

local7.*  /var/log/events

Then HUP syslogd to activate the new log:

sudo killall -HUP syslogd

Test with the following command, which should put a log line in /var/log/events:

logger -p local7.notice foo

Now you’ll need to setup a script like the following to do the testing, logging on failures:

#!/bin/bash
if ! ping -o bob.local
then
        logger -p local7.notice Could not contact bob.local
fi

Set that to run periodically with cron or launchd or whatnot. Then, at some interval, run the log2rss.pl script we covered previously on the /var/log/events log and then publish and subscribe to that RSS feed (either locally, or by saving to someone’s Sites folder and using Personal Web Sharing).

Voila, a feed of system events that you control.

Average rating
(0 votes)
About Adam Knight
Adam Knight's picture

Author Biography

Adam Knight is one of the founders of Mac Geekery and is a geek at heart. Programmer by day, hacker by night, his daily life revolves around the Macintosh platform, which he has been a user and programmer for since the early days of System 7 when his LCII replaced his Apple //c.

In-between tech jobs, he’s managed to learn the basics of any web hacker: PHP, MySQL, Perl, Apache, Linux, *BSD, and the intricacies of ./configure —prefix=~/bombshelter/. Today, codepoet is concentrating on blogging again, writing some software for the Mac by himself (including Notae) and for his company (such as Switchblade) and has a few other toys coming out soon.

Bug him over AIM or email [link fixed].

Post new comment
The content of this field is kept private and will not be shown publicly.
14 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.