Nagios Integration

Steps to Use Nagios with PageGate

Send Text and SMS Messages from Nagios
Follow these steps to use Nagios Server Monitoring with PageGate

PageGate can be easily integrated with Nagios by having Nagios submit alerts and notifications to PageGate's GetWeb interface. Before you configure things in Nagios, you'll need to prepare PageGate's GetWeb module. To do so, have a look at this video tutorial:
https://www.notepage.net/videos/how-to-configure-web-interface.htm

Once you have GetWeb ready for the data, you'll need to do the following in Nagios:

1) Create a Linux shell that submits the monitored information to PageGate's web service and place that file in the 'libexec' folder contained in the Nagios directory. By defulat, /usr/local/nagios/libexec/

While you can name the script anything you like, we recommend giving it a straightforward name like smsalert.sh or pgsms.sh
--
#!/bin/bash
# set each part of the URL to send
UrlToCgi=$(printf "http://127.0.0.1/scripts/webgate.exe")
RecipientVar=$(printf "?USER=")
Recipient=$(printf "$2")
SenderVar=$(printf "&FRM=")
Sender=$(printf "fromme")
MessageVar=$(printf "&MSG=")
# set message to all the text sent on the command line
Message=$@
# url encode message text
Message=$(php -r "echo urlencode(\"$Message\");")
# build the request URL
FullUrl=$UrlToCgi$RecipientVar$Recipient$SenderVar$Sender$MessageVar$Message
# send the request
wget -O- "$FullUrl"
--

2a) In the above script, be sure to update the UrlToCgi value to the hostname or IP of the system hosting GetWeb.
2b) Update the 'Sender' value from 'fromme' to the what you would like displayed as the 'sender'.

3) Next you'll need to define a free variable for your contacts or services.
3a) In the Contact Management section of a contact or service, select 'Misc Settings'
3b) Click 'Manage Free Variables'
3c) Define the name, which will be called on in the command, and its' value. We recommend using _recipient for the name and the value will be what Nagios passes to PageGate when this contact is messaged.
3d) The free variable called on changes depending on location.
If the free variable is under contacts, you would use '$_CONTACTRECIPIENT



If the free variable is under services, you would use '$_SERVICESRECIPIENT

4) Once the .sh file is in place, open 'commands.cfg' with the 'vi' editor.
Command: vi /usr/local/nagios/etc/objects/commands.cfg

5) Find the 'notify-host-by-email' section and insert this after that section:

# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/local/nagios/libexec/smsalert.sh "--PageGate Service Alert-- Host: $HOSTNAME$, State: $HOSTSTATE$ Service $SERVICEDESC$ Description: $SERVICESTATE$ Time: $LONGDATETIME$" '$_CONTACTRECIPIENT

}

# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/nagios/libexec/smsalert.sh "--PageGate Host Alert-- Host: $HOSTNAME$, State: $HOSTSTATE$, Time: $LONGDATETIME$" '$_CONTACTRECIPIENT
}

6) Hit Escape on your keyboard and type the following to save the file:
:wq

7) Open 'contacts.cfg' with the 'vi' editor.
Command: vi /usr/local/nagios/etc/objects/contacts.cfg

8) Insert the following before the 'email' section:
service_notification_commands notify-service-by-sms
host_notification_commands notify-host-by-sms

9) Hit Escape on your keyboard and type the following to save the file:
:wq

10) Restart the Nagios service to have the changes take effect.
Command: service nagios restart

After Nagios has restarted, you can log in to the Nagios web utility to verify that alerts are being sent.

NotePage, Inc.
PO Box 296
Hanover, MA 02339