So, I found something interesting. I’ve been trying to figure out how to get Nagios to send notifications to cell phones via SMS. I’ve read up on how you can set up SMS gateways and such, but decided I’d rather not go that route (though, ironically enough, the company I work for is an SMS aggregator).
Anywhos, I know that normally, you can send SMS to phones in the form of an email. For example, to send an SMS email to a T-Mobile phone in the United States, you can send a message to <10digitnumber>@tmomail.net. To send to a Cingular Orange phone in the U.S., it would be <10digitnumber>@mobile.mycingular.com.
Now, I come to find that simply listing that address as the email for contacts and using the default notify-by-email and host-notify-by-email doesn’t work. So, on a whim, I created a modified version of the notification command…check it out:
‘host-notify-by-email’ command definition
command_name host-notify-by-email command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /bin/mail -s “Nagios-02 - Host $HOSTSTATE$ alert for $HOSTNAME$!” $CONTACTEMAIL$
Notify My cell - host problem
command_line /bin/mail -s “Nagios-02: $HOSTNAME$ $HOSTSTATE$!” XXXXXXXXXX@mobile.mycingular.com
I’ve similarly modified the default command for service notifications as well.
Taking out the printf bit that gets piped to the mail command worked for me. I created a very basic notification template (don’t need much to arrive on my cell). It’s a pretty sloppy setup right now because it only allows for notifications to my cell phone; I put my actual phone number in the command. However, testing shows that supplying the $CONTACTEMAIL$ macro and identifying it as your mobile e-mail address in contacts.cfg works as well. That way is much better, since you wouldn’t have to write different notification commands for different carriers/phone numbers.
So my question is…any idea why this is the case? I don’t believe that it is because of a character limit in messages to my cell; any other time that happens in a regular e-mail, I just receive multiple messages on my phone.