Custom SMS notification

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
stslov
Posts: 5
Joined: Mon Jul 19, 2010 7:43 am

Custom SMS notification

Post by stslov »

Hi team,

in our company we have an hotline support - every week one agent is on emergency. I would like to setup sms notification this way: if agent is in emergency he just enable "Mobile text" in "Notification Methods" setup. But i have little problem to use it. Because there is predefined list of providers - and we have a local sms gateway - so i am forced to use custom send notification command instead of this "Notification Methods" setup.

Can you please point me to the right direction how can I achieve that normal user - not admin - can start/stop such notifications by himself? Because i can see that the only one accessible parameter for user is in "Notification methods" -> "Mobile text" setup. And in our environment I am unable to use it.

Thanks a lot for any help.
Tomas
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Custom SMS notification

Post by mguthrie »

We're going to add this feature soon to the interface, but it's not currently available. However, SMS messages for a custom gateway can be sent through the email notifications. An example is posted in this thread:

http://support.nagios.com/forum/viewtop ... 1196#p5039

You could probably use this notification method with a defined timeperiod to achieve what you need.
stslov
Posts: 5
Joined: Mon Jul 19, 2010 7:43 am

Re: Custom SMS notification

Post by stslov »

Hi, thanks for quick reply.

I already checked the forum post you mentioned, and yes i can use it, but it is not exactly what I am looking for.

The best for me should be if I can use Nagios core command as notification method - because now, I use sendsms program to send sms using local, directly to server attached gsm modem.
/usr/local/bin/sendsms -d $CONTACTPAGER$ -m "Type: $NOTIFICATIONTYPE$ ..

In case that I will be forced to use email notification - than I have to somehow convert it to sms and send it. Probably it is possible, but i have no experiances with - maybe can you suggest me suitable application?

Thanks a lot
Tomas
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Custom SMS notification

Post by mguthrie »

XI has an addon that allows you to add a custom global event handler, but I think that might get more complicated than what you need.

The XI SMS notifications are all sent by email, so setting up an SMS notification via email wouldn't function any differently than if it were using the SMS notification. Is it a necessity that you have your carrier listed as one of the options in the dropdown list? I could send you the lines of code you'd need to manually add it to the list if you wanted, but that would be a very unofficial solution. We intend to add a "define a custom carrier" feature in the net release, but at the moment it's not built in.
stslov
Posts: 5
Joined: Mon Jul 19, 2010 7:43 am

Re: Custom SMS notification

Post by stslov »

Hi mguthrie

please, if possible show me what part of code should be changed to add new entry to dropdown list. It helps me because, it will not be needed to create another user, just for sms notification.

Btw: as the only supported way how to send sms using XI is email, can you please give me some advice what application can I use to convert email to sms? Because i want to use local sms gateway if possible, instead of operator service outside of our datacenter.

Thanks a lot
Tomas
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Custom SMS notification

Post by mguthrie »

The file you'd need to edit is /usr/local/nagiosxi/html/includes/utils-notifications.inc.php.

Around line 130 there's an array that you'll need to add your provider to for the dropdown list.

Code: Select all

function get_mobile_providers(){

	$mobile_providers=array(
		"alltel" => "Alltel",
		"att" => "AT&T",
		"cingular" => "Cingular",
		"metropcs" => "Metro PCS",
		"nextel" => "Nextel",
		"powertel" => "Powertel",
		"sprint" => "Sprint",
		"suncom" => "SunCom",
		"tmobile" => "T-Mobile",
		"uscellular" => "US Cellular",
		"verizon" => "Verizon",
		"virginmobile" => "Virgin Mobile",
		);
		
	return $mobile_providers;
	}
And then around line 200, you'll need to add your provider again.

Code: Select all

		
        case "verizon":
			$email=$number."@vtext.com";
			break;
		case "virginmobile":
			$email=$number."@vmobl.com";
			break;
   
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Custom SMS notification

Post by mguthrie »

This has also just been posted to our library, it might have what you need.
http://library.nagios.com/library/prod ... g-tutorial
stslov
Posts: 5
Joined: Mon Jul 19, 2010 7:43 am

Re: Custom SMS notification

Post by stslov »

Hi,

thanks for your reply. I have a little problem :) to change the source code you mentioned, because my version of utils-notifications.inc.php file is encoded using sourceguardian.
So this is not a way.

But maybe in case that you can/want to help me - and I know, that this will be big favor for me if you do it ... but maybe you can edit the file and post modified version with this little modification:

function get_mobile_providers(){

$mobile_providers=array(
"alltel" => "Alltel",
"att" => "AT&T",
"cingular" => "Cingular",
"metropcs" => "Metro PCS",
"nextel" => "Nextel",
"powertel" => "Powertel",
"sprint" => "Sprint",
"suncom" => "SunCom",
"tmobile" => "T-Mobile",
"uscellular" => "US Cellular",
"verizon" => "Verizon",
"virginmobile" => "Virgin Mobile",
"localhost" => "localhost",
);

return $mobile_providers;
}


case "verizon":
$email=$number."@vtext.com";
break;
case "virginmobile":
$email=$number."@vmobl.com";
break;
case "localhost":
$email=$number."@localhost";
break;


Thank you very much
Tomas
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Custom SMS notification

Post by mguthrie »

Sent an email to the address listed under your account with a patched file. Backup the original just in case.

We'll probably include the localhost option in the next update, which should be out in the next few weeks.
stslov
Posts: 5
Joined: Mon Jul 19, 2010 7:43 am

Re: Custom SMS notification

Post by stslov »

Hi mguthrie,

Thank you very much for your effort. It works like a charm.
I am looking forward for official release of this feature.

I combine it with small script that convert email to sms text, and sending sms using smsd daemon: http://smstools3.kekekasvi.com/

Again, thanks for your support.
Tomas
Locked