SMS integration with SMS API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
vlachopoulosd
Posts: 10
Joined: Thu May 09, 2019 8:30 am
Location: Athens, Greece

SMS integration with SMS API

Post by vlachopoulosd »

Hello,

Unfortunately in Greece no providers will go for the standard SMS notification mechanism of Nagios XI, that is sending an email of type [email protected].

Instead they give us an API we should call by means of a command like:

curl -G --silent --output /dev/null https://corpsms-api.xxxxxxxxx.gr/http/sms.php --data-urlencode "auth_key=XXXXXXXXXXXXXXXXXXXXXXX" --data-urlencode "id=no" --data-urlencode "from=nagios" --data-urlencode "to=697000000" --data-urlencode "text=TestMessageBody"

What is the best way to integrate something like this in Nagios XI?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: SMS integration with SMS API

Post by benjaminsmith »

Hello @vlachopoulosd,

You'll want to create a new notification command for SMS using your API call. This can be done in the Core Configuration Manager, go to Configure > CCM > Commands to create new command.

As an example, here's a screenshot of the notification commands for sending email using the default mail application (Sendmail) on the Linux server.
notification-commands.png
Next, you'll want to add the new command to your contact template, so Nagios will call either or both the email and the SMS notification commands.
contact-template.png
Here's our step-by-step documentation on this process, let us know if you get it setup correctly.

How to Configure Email And Text Notifications in Nagios XI
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vlachopoulosd
Posts: 10
Joined: Thu May 09, 2019 8:30 am
Location: Athens, Greece

Re: SMS integration with SMS API

Post by vlachopoulosd »

Thanks, I will try and report back!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: SMS integration with SMS API

Post by benjaminsmith »

Thanks, I will try and report back!
Sounds good. We'll keep this open.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vlachopoulosd
Posts: 10
Joined: Thu May 09, 2019 8:30 am
Location: Athens, Greece

Re: SMS integration with SMS API

Post by vlachopoulosd »

I haven't had much success by going this way.

It seems to me that in order to use the SMS functionality built into Nagios XI, I will have to use a mail-to-SMS service. An SMS by API solution would be much much cheaper for me, but it is not straightforward to setup and use.

Let me explain:

These are the commands that i created:
Image

https://photos.google.com/album/AF1QipO ... zPV0_z4vKL

notify-host-by-sms
/usr/bin/curl -G --silent --output /dev/null "https://xxxxxxxxxxxxxxx.xxx/sms.php" --data-urlencode "auth_key=xxxxxxxxxxxxxxxxxxxxxG9Er2UJKm" --data-urlencode "id=no" --data-urlencode "from=Nagios" --data-urlencode "to=$CONTACTPAGER$" --data-urlencode "text=$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ Info: $HOSTOUTPUT$"

notify-service-by-sms
/usr/bin/curl -G --silent --output /dev/null "https://xxxxxxxxxxxxxxx.xxx/sms.ph" --data-urlencode "auth_key=xxxxxxxxxxxxxxxxxxxxxG9Er2UJKm" --data-urlencode "id=no" --data-urlencode "from=Nagios" --data-urlencode "to=$CONTACTPAGER$" --data-urlencode "text=$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ Additional Info: $SERVICEOUTPUT$"

My first queston is: Which variable should i put for getting the contacts' phone number? The only one close to it is the $CONTACTPAGER$. But ther is no field for it in the user account settings.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: SMS integration with SMS API

Post by benjaminsmith »

Hello,

The phone in the user settings is not linked to the pager number. You would need to use the Pager Number field in the Contact settings in the CCM as this field is accessible using the macro $CONTACTPAGER$.

Are you able to test the command from the terminal and receive SMS messages?

Also, for more details about the differences between users and contacts, see this guide:

Nagios XI Understanding Users and Contacts
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vlachopoulosd
Posts: 10
Joined: Thu May 09, 2019 8:30 am
Location: Athens, Greece

Re: SMS integration with SMS API

Post by vlachopoulosd »

Hi,

I added the commands to the xi_contact_generic (which seems to be the default contact template for all users created in Nagios XI), after the "xi_host_notification_handler" which was already there.

There are SMS notifications now, although there is not much control over them. When an alert is created, the user gets both an email and an SMS, that is there is no separation between mail and SMS. The user cannot enable or disable SMS notifications from his/hers notifications settings page.

Is this the way its supposed to work or am I missing something? It would be nice to be able to configure a custom "Mobile Carrier". These integrate perfectly in the XI interface.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: SMS integration with SMS API

Post by benjaminsmith »

Hello,

The "Mobile Carrier" simply uses the email to text service provided, and since this is not available this is the next best option.

As far a managing notifications, if you only want to receive SMS notifications you could remove the default notification command for the contact. Another option would be to create separate contacts for email and SMS, and those contacts could be added or removed at the host/service level depending on preferences.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
vlachopoulosd
Posts: 10
Joined: Thu May 09, 2019 8:30 am
Location: Athens, Greece

Re: SMS integration with SMS API

Post by vlachopoulosd »

Thank you for your time Benjamin. You 've been most helpful.

So a recommended path for creating a new user could be this:
1. I create a user account from "Admin", importing it from Active Directory and enabling notifications on it. This way, the user account will be created based on the xi_contact_generic template and inherit the default XI settings.
2. I will not change the xi_contact_generic, but i will create a new contact template named "default-contact-SMS" for the contacts to be notified with SMS. In this template i will add the SMS notification commands for hosts and services.
3. If I want to enable SMS notifications for the user from step 1, I will create an additional contact for it like "Username-SMS" using the "default-contact-SMS" template. In the contact details I will populate the Pager field with the contact's mobile number.
4. I will add the user to a contact group according to the systems the user needs to monitor.
5. When I create a host/service that this user needs to monitor and be notified for by mail, i will add this contact group to the host/service's notifications tab.
6. If the user wants to be notified with mail and SMS for this service/host, I will add the Username-SMS contact created for him in the notifications tab of the service/host.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: SMS integration with SMS API

Post by benjaminsmith »

Hello,

That looks good. As you stated, a template for the default SMS contact ( default-contact-SMS ) is a good idea as individual contacts will inherit those settings and it will be easier to manage.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked