So I have two files, and if a new line appears on either of these files, I'd like to receive an IM (preferably jabber or gTalk) containing the contents of that line. Do you guys have any suggestions for a Linux daemon or something that could do that?
Tail server logs into XMPP
loggingtailxmpp
Related Topic
- Linux – How to display certain lines from a text file in Linux
- NFS server and delay in using tail -f
- Compression format that supports tail operations
- Windows – Options for real-time web notifications and updates using Comet/XMPP vs WebSocket technologies on a Microsoft stack
- How to aggregate new apache logs lines from multiple machines every hour
- Need help understanding why gtalk will not talk to the xmpp server if it serves root domain. Subdomains and other domains are ok.
- How to “bounce” or proxy XMPP accounts
Best Answer
If you are logging trough syslog, Metalog has support to execute a command whenever a message matching some criterion gets logged. Otherwise, you can use
tailf
to watch for new lines in a log file.sendxmpp is a small perl script to send XMPP messages (possibly already available as a package for your favorite distribution)
You could stitch those two together with a shell script without too much difficulty. For the metalog case, create a script like this one:
And add
command = /path/to/script.sh
to the relevant section of metalog.confFor the tailf case, you could try something like this, run in a persistent way:
sendxmpp needs a valid XMPP account, see the man page for how to configure the account to be used.
(from my experience, XMPP-delivered error messages tend to become quite annoying if they're too frequent...)