Saturday, October 30, 2010

Nagios alarm reporting via SMS

Hi all.
One of the recent projects was the configuration of a NAGIOS alarm system.
Each and everyone I.T.Manager (like any normal human) love to have good nights of relaxed sleep.
There is only one thing worse that a half cut night because a server decided to crash someone wakes you up in agony to "go-fix-it-pleeeeeaase"; and that is walking into your company in a relaxed monday morning, and enter the "chaos zone" of having every user finding out the servers have crashed.

This of course is something I've never experienced in my life. There are several reasons for that:
 1 - I use Linux and Unix... so this alone get's the blue-screens, exploits, memory leakages and random reboots out of the equation.
 2 - I virtualize everything, from servers to vital workstations, to storage and networking. And this is not just eliminating the real layer of the thing... it's also configuration resources watchdog routines and procedures to motion the resources on demand.
 3 - I create multi routes and multi paths.
 4 - I've always used SNMP and solutions like HP OpenView and the beautiful NAGIOS

Now OpenView is common between most I.T.Managers, but at a cost... a HUGE cost.
Most people are so microsoftized that see nothing else other than that poor SMS server... and abandon towards OpenView or IBM'S Tivoli, paying the price.
Don't get me wrong... the huge cost of HP's OpenView on IBM's Tivoli solution is not expensive. In time, it's all returnable... but still I'd rather have that money spent in more vital areas.

This is were the NAGIOS comes in. Nagios e opensource and very flexible. It's so flexible that people usually say it's a bitch to configure.
This statement is not entirely truth. There is a trick to being able to configure Nagios fast and without slashing your wrists - Make a Lab using an already installed and configured appliance... and then use that knowledge to configure one from scratch.

But back to the original title:
In the company I'm working today, the I.T.Manager is using Nagios to monitor the servers and it's services. The problem is finding out what went wrong when he is not looking at the console and it's warnings.
So he installed an old NOKIA phone and plugged it VIA USB.
We installed gsmsendsms and configured as 2 Nagios commands (user and service commands).
There is no black magic to this, and if you Google, you'll discover hundreds of articles explaining how to do this. This one HERE is a good example.

The problem most posts don't explain is that nagios will execute gsmsendsms as 'nagios' user. And gsmsendsms need to send data directly to the usb device port, needing sudo rights to do so.
It that's the case, a look at nagios log will make it ease to understand that Nagios is not being able to open the device to send data to.

The solution? Simple.
1st configure Nagios command files and make sure you type "sudo " prior the gsmsendsms command.
Then:
sudo nano /etc/sudoers
Then add the following line:
nagios ALL=(root)NOPASSWD: /etc/bin/gsmsendsms
Write out and exit.

That's it! Nagios will start sending SMS when the configures alarms fired. All you have to do now is configure those alarms and recharge that mobile phone's sim card with some money every once in a while.
;)