2

I am looking for a way to easily define one-time notifications of some events that take place on a Linux box. Events might include things like: file /tmp/my.lock is unlinked or process 666 finished or, maybe, something more complicated, like process 'backup.sh' closed file 'backup.tgz' AND process 'backup.sh' exited with return code 0.

Notifications should be also flexible. Like, notify 192.168.0.100 via org.freedesktop.Notifications.Notify or notify [email protected] via email.

Actually, it's something like Nagios, but designed for non-repeating events, with minimal, almost zero cost of task creation. Am I a dreamer? Should I write it myself? Or should I simply use shell scripting?

3 Answers 3

1

Nagios can exactly notify the events just one time.
We use it to open tickets.
Just set notification_interval = 0 (for both service and host) and you'll get the email/sms just once.

5
  • I didn't mean the notification should only be sent once. Rather, the task is used only once, and it's not worth writing yet another check_file_created plugin for Nagios.
    – minaev
    Jul 14, 2010 at 13:54
  • But exactly what do you want to monitor? File systems? Logs? Apps?
    – PiL
    Jul 14, 2010 at 14:08
  • As a matter of fact, all of them. I did not simply make up the examples, they are taken from real situations. I might be asking too much, I know :)
    – minaev
    Jul 14, 2010 at 14:15
  • I don't think there's something that sum all the tools to monitor everything. As far as i rember nagios is the most flexible in this situations.
    – PiL
    Jul 14, 2010 at 14:48
  • Yes, but what I'm looking for should relate to Nagios as 'at' relates to 'cron'.
    – minaev
    Jul 14, 2010 at 17:08
1

Just to add some more input to the should I write it myself question, you could create either a FIFO or flat file to use as a custom log, and add commands to your custom scripts that write important output to that log file. Or alternatively, you could create a simple script that periodically checks the status of important files and processes, and sends its output to that log.

To create the FIFO on the server:

mkfifo /var/log/mylog

To read the logs from the server:

ssh user@host "tail -f /var/log/mylog"

Source these functions into your custom scripts to easily write to the log:

function warning { echo -e "\e[33;1m :: \e[0m$@" > /var/log/mylog; };
function error { echo -e "\e[31;1m :: \e[0m$@" > /var/log/mylog; };
function information { echo -e "\e[32;1m :: \e[0m$@" > /var/log/mylog; };

And then write entries to the log by issuing these commands:

information "Some text"
warning "Some more text"
error "Some important text"

You can similarly add a shell function that uses sendmail (or similar) to mail you.

1
  • Aha... That looks like a kind of a self-made dedicated message bus... Might be a good idea, thanks!
    – minaev
    Jul 16, 2010 at 5:31
0

I would think a combination of inotifywatch, ps, logger and syslog in some custom scripts might do the trick.

2
  • Definitely, it would, especially if combined with mail and expect :). Unfortunately, these tools will take considerable efforts to set up one simple alert. More than five minutes, that is, which is close to what I consider a threshold.
    – minaev
    Jul 14, 2010 at 13:51
  • @minaev: I was talking about setting up a system to use to create quick, flexible, one-shot alerts. Qualifies under "Should I write it myself?" Jul 15, 2010 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .