English
How to use FoxBox for sending SMS from Nagios PDF Print E-mail

OFFICIAL NAGIOS INTEGRATION METHOD for ACME SYSTEMS SMS FoxBox (AVAILABLE ON WIKI)

From NagiosCommunity

NAGIOS SMS ALERT NOTIFICATION

Overview


SMS FoxBox

The SMS FoxBox is a low cost SMS/MMS Gateway. It uses a tiny embeded linux system with a GMS/GPRS modem. You just need to supply the SIM card.

Info from their site:

  • Up to 30 incoming SMS/min with a common SIM card
  • 100% solid state hardware MMS / SMS gateway in just 105x110x45mm
  • Fully featured Web interface for MMS and SMS management
  • Email to SMS and SMS to Email gateway
  • Fully customizable software with PHP, C and Bash coding
  • Quad band GSM modem
  • Linux embedded OS 2.6.x
  • Apache embedded Web server
  • SQLite embedded SQL server
  • Expandable set of gateway functions

 


Initial Setup

SMS FoxBox Unit (older version):

  1. We installed a SIM card into the SMS FoxBox by following the included documentation;
  2. The SMS FoxBox was installed on our network at the IP address 192.168.1.98;
  3. An easy verification on the connection to device in possible by browsing to 192.168.1.98, and using the default credentials of 'Admin' with password 'GsmBox2006!'.

SMS/MMS FoxBox G20 Unit (newer version):

  1. We installed a SIM card into the SMS/MMS FoxBox G20 by following the included documentation;
  2. The SMS/MMS FoxBox G20 was installed on our network at the IP address 192.168.0.98;
  3. An easy verification on the connection to device in possible by browsing to 192.168.0.98, and using the default credentials of 'admin' with password 'admin'.

Monitoring Server:

  1. Nagios 3.0.6 was compiled and installed on the monitoring server
  2. Version 1.4.13 of the Nagios plugins were installed on the monitoring server.
  3. A custom script was installed and titled 'sendSMS.sh'

sendSMS.sh Script

We created a script named 'sendSMS.sh' and placed it in /usr/local/nagios/libexec/ directory. 

You can find the scripts for older and newer FoxBoxes here.


Monitoring Configuration

We modified our Nagios configuration files to include new notification scripts:

# 'notify-host-by-foxbox' command definition
define command{
command_name notify-host-by-foxbox
command_line /usr/local/nagios/libexec/sendSMS.sh Nagios $CONTACTPAGER$ "Host Alert: $HOSTNAME$\nHost State: $HOSTSTATE$\nDate/Time: $LONGDATETIME$"
}

# 'notify-service-by-foxbox' command definition
define command{
command_name notify-service-by-foxbox
command_line /usr/local/nagios/libexec/sendSMS.sh Nagios $CONTACTPAGER$ "Service Alert: $HOSTALIAS$/$SERVICEDESC$\nService State: $SERVICESTATE$\nDate/Time: $LONGDATETIME$"
}

Note: SMS messages in this script will be sent out to the contacts pager number.

We then added a new contact and contact group using the new notification script and having a valid phone number:

define contact{
contact_name test-contact
use generic-contact
alias tester
email This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
host_notification_commands notify-host-by-sendsms
service_notification_commands notify-service-by-sendsms
pager 12453683421
}

define contactgroup{
contactgroup_name test-group
alias test-group
members test-contact
}

Now we need to make sure we have host and service setup for notifications with this user, this is normally done broadly using templates, let us define a generic template that hosts and services should use:

define host{
name generic-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
notification_period 24x7
register 0
max_check_attempts 3
check_interval 5
retry_interval 1
check_command check-host-alive
contact_groups test-group
notification_interval 0
notification_options d,u,r,f,s
register 0 ; a template definition
}
define service{
name generic-service
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 2
notification_options w,u,c,r,f,s
notification_interval 0
notification_period 24x7
contact_groups test-group
register 0 ; a template definition
}

Note: After creating or editing the templates you will then need to make sure that hosts/services are using them. Both hosts and service use the directive 'use <name of template>' inside the brackets of the object definition.

After saving our configuration files, we verified our configuration files and started Nagios:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios restart

Once Nagios was restarted and external commands are enabled, we can force a notification to be sent by clicking on a host/service to open extended information page, then by selecting 'Send custom host notification', and on the next screen selecting 'forced' then 'commit'.


Additional Notes

  • This document represents one method of sending notifications. That's using the FoxBox web service to POST data to the FoxBox.
  • Additionally we tested other methods that FoxBox supports, including using SCP to upload files to a spool directory on the device, and by using ACME's email2sms script reported below.

 

METHOD OF INTEGRATION USING MAIL2SMS GATEWAY FUNCTION
(TESTED BY NAGIOS)

Think how nice would be to receive SMS notification from NAGIOS for your monitored services, in this tutorial we will see how to send notifications via SMS.
NAGIOS SMS ALERT NOTIFICATION
Using SMS FoxBox EMAIL to SMS gateway function it is really simple, just setup NAGIOS to send out email notifications and then setup SMS FoxBox gateway to forward email to sms following this guide: http://www.smsfoxbox.it/the_news/latest_news/how_to_join__sms_to_your_server_environment.html

Here there are some sample files to tune up "procmail" configuration, so that the system will divert each message to the designed mobile phone number.

To divert all email messages make sure that the .procmailrc script located inside /etc/ folder looks like this:

SHELL=/bin/sh VERBOSE=OFF
MAILDIR=/mnt/flash/root/procmail
DEFAULT=/mnt/flash/spool/mail/mails
LOGFILE=/mnt/flash/spool/mail/procmail.log
#OUTFILE="/mnt/flash/spool/smsgw.out.XXXXXX"
OUTFILE=$(/bin/mktemp /mnt/flash/spool/outgoing/smsgw.out.XXXXXX)

:0
* ^Subject:.*
{
:0 b
| grep -v ^$ | sed '/To:/G' | /etc/sms/scripts/email2sms
}
Here you can download the script email2sms that you have to put in /etc/sms/scripts/.
Replace in the script the XXXXXXXXXX with the designed mobile number and if you want uncomment blocks to add more destinations.
#!/bin/sh 
#SCRIPT: MAIL2SMS
#AUTHOR: Davide Cantaluppi This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
#DATE: 28.02.06
#REV: 1.1a
#PLATFORM: Not platform dependent
PURPOSE: This is a "parser" for the message passed from procmail
# print the whole email body as the output to OUTFILE

cat > /var/temp.txt OUTFILE=$(mktemp /mnt/flash/spool/outgoing/smsgw.out.XXXXXX)
echo "From: Nagios" > $OUTFILE
echo "To: XXXXXXXXXXX" >> $OUTFILE
echo "" >> $OUTFILE
cat >>$OUTFILE
#NAGIOS SECOND NOTIFICATION
#OUTFILE=$(mktemp /mnt/flash/spool/outgoing/smsgw.out.XXXXXX)
#echo "From: Nagios" > $OUTFILE
#echo "To: 39XXXXXXXX" >> $OUTFILE
#echo "" >> $OUTFILE
#cat /var/temp.txt >>$OUTFILE
A NEW PRODUCT EASY GUARDIAN CAN OFFER TO YOU NETWORK MONITORING IN MINUTES
  Easy Guardian is a small low cost Linux appliance with a fully Web-based system that provides you a complete network monitoring solution. Easy Guardian is a customizable and easy to maintain system, for monitoring the real-time availability of network devices, servers (Windows, Unix, Linux) and all network delivered services in any IT infrastructure.
 Easy Guardian


Easy Guardian displays your system and network status on a color-coded Web page that proactively notifies you of problems immediately via SMS. Easy Guardian is built for System & Network administrators tasked with managing the availability and performance of hundreds or thousands servers and network devices on a limited budget.
Easy Guardian enables you to monitor any server, any device, on any network within minutes.

Features:

  • Monitor Servers (LINUX, WINDOWS, APPLE MACINTOSH, ...)
  • Monitor Networks
  • Monitor Desktops
  • Monitor Devices
  • Monitor Databases
  • Monitor Performance
  • Log all data and draw charts and polls



     Product Tour

 

 
< Prev   Next >

buy foxbox
buy on FoxBox eShop



For further info contact us by mail This e-mail address is being protected from spam bots, you need JavaScript enabled to view it providing us the FoxBox model you need and your company details.

KDEV di Davide Cantaluppi, P.IVA 02984320131

http://www.kdev.it