User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
sms-alert.png

Nagios is an awesome monitoring tool, if you know how to configure it correctly it will not only help system and network administrators to know where the failure is, but it can help non-IT people such as customer care and sells to know about the system status or specific services actions.

One of the hardest things to carry on with Nagios is that you usually don't have a window always open or not always in front of the computer. If you are an IT guy, that could be easily fixed by installing a Nagios client on your cell phone, I recommend you to give a try to TiNag. But if you are not an IT guy, TiNag is not what you need. Some could say that email would be enough, but the truth is that cell phones usually check email every 15 mins (or longer), and people don't attend emails right away; emails are not meant to be read on the spot. On the other hand, I believe SMS is the solution. Texts are sent almost in real-time, a text is almost read in the next 30 secs (do not believe me, send a text to someone aside of you and check it).

I will show here how to enable the SMS with Nagios.

 Requirements

  • SMS carrier: your provider must give you some kind of API to push an SMS using HTTP. In this example, I will use Apidaze.
  • Phone numbers: obvious, but you never know.

Configuration

Just follow this steps. My directions are for CentOS 7, but you can use them in any Linux flavour.

  1. First, you need to create the command in Nagios. These commands are the ones who do the calling to the API call for your SMS carrier. I put these definitions in the conf.d/ directory.

    define command{
    command_name host_notify_by_sms
    command_line curl --request POST --url 'https://api.apidaze.io/99999999/sms/send?api_secret=XXXXXXXXXXXX' --header 'Content-Type: application/x-www-form-urlencoded' --data 'from=19999999999&to=$CONTACTPAGER$&body=hostname : $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Date/Time: $DATE$'
    }

    define command{
    command_name service_notify_by_sms
    command_line curl --request POST --url 'https://api.apidaze.io/99999999/sms/send?api_secret=XXXXXXXXXXXX' --header 'Content-Type: application/x-www-form-urlencoded' --data 'from=19999999999&to=$CONTACTPAGER$&body=$SERVICEDESC$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$'
    }

    You will need to define it twice, one for the host and another for the services since some variables are not available to the other.
  2. Create your contact like this:

    define contact{
    contact_name dlucio
    use generic-contact
    alias Full name of user
    email This email address is being protected from spambots. You need JavaScript enabled to view it.
    pager 15555555555
    host_notifications_enabled 1
    service_notifications_enabled 1
    host_notification_commands host_notify_by_sms
    service_notification_commands service_notify_by_sms
    }

    Be sure you put the pager, this is the field you will use for texting. You can tell the Nagios if you want to bother this contact when a service or host event happens.
  3. Create your contact group. This is optional, but if you are going to deal with more people than yourself and if they go in/out of the business, creating a group makes the management so easy.

    define contactgroup{
    contactgroup_name infrastructure
    alias Server managers
    members dlucio
    }

  4. Tell your host and service to link to the user. Just add/edit a line, I will put only one host and service definition, but you will need to add it in all the service you want to be reported by SMS. You may use templates as well if you want.

    define host{
    use linux-server
    host_name myserver.company.com
    alias myserver
    contact_groups infrastructure
    }

    define service{
    use local-service
    host_name myserver.company.com
    service_description SSH
    check_command check_ssh
    contact_groups infrastructure
    }

You are done, restart the Nagios, if you did your configurations okay, then you will start getting texts on your cell phone.

OK, I have texts. How can I make this helpful for my business rather than only IT Monitoring?

Good question, and I am glad you keep reading. Nagios can virtually monitor anything you ask for. Writing a specific plugin is really easy. So, what are the use cases where Nagios could help on non-IT matters? Here there are some examples:

  • You have a call centre, at some point all your agents are busy or none of them are logged in (the thing is nobody can take the next call). A new call gets in and it is kept in a hold (with the music) for a while. Because PBX's such as FreeSWITCH can report if a call is in a hold or with an agent, Nagios could discover that and send an SMS to the sales or customer care people to take the call.
  • You have a website with e-commerce. Each time a customer places an order you get an email but you could get a text right away. Depending on your business, you may want to react on the spot.
  • You have installed sensors in your customer's facilities such as heat sensor, smoke sensor. You may get an SMS right away if the sensor sends an alert, this could mean a fire.
  • You may be in the printing business and you are depending on a vendor to upload new stuff to your server before noon. Nagios could review and send you an alert if by 11.55 am, there is no new stuff uploaded.
  • If you are into KPI (performance indicators) for your business, you may link this with Nagios. And then you can have alerts if you are not satisfying an indicator.

These are some examples I just thought where Nagios is very useful. Since I am an IT guy, I can only say I use it to monitor all the server I have under my management.

Good luck!

blog comments powered by Disqus