nagios

Squelching SMS floods from Nagios being sent via a third party SMS provider

So at work they implemented some 'SMS Squelching' methods to interact with a 'mail > sms' gnokii script to try and 'squelch' megaloads of SMSs that come through from Nagios all at once. It's a bunch of perl and very much specific to working with a serial-attached Nokia and gnokii. The way it essentially worked was that if an SMS got queued to mail2smsgnokii/gsm's spool, the timestamp was compared with the last sms that got sent and if the length of time in between SMS was inside a threshold (say 30 minutes), the SMS would not be sent.

Nagios website regex pattern check

Here's a simple perl script that uses curl to search for a regex pattern on a website.

It returns status values that are Nagios compatible. This means you can write a command definition for Nagios that looks like this:

# regex check
define command{
        command_name    check_regex
        command_line    /usr/lib/nagios/plugins/check_regex $ARG1$ $ARG2$
}

And write a couple of service definitions like this:

define service {
        host_name                       foo
        service_description           foo regex

Convert timestamps in Nagios log

/var/log/nagios2/nagios.log prints computer timestamps that aren't that easy to read.

Run this instead:

perl -pe 's/(\d+)/localtime($1)/e' /var/log/nagios2/nagios.log

Or better yet put it in a script and just run it as 'nagioslog' or something...