Set up Centreon SMS notifications with Android smartphone

This small tutorial will show how to send centreon notifications via SMS with Android smartphone. It is made for android 2.3 gingerbread and using android 4 may be easier. But cheap android smartphones use 2.3 now…

You will need:

  1. Configured nagios with centreon.
  2. Rooted Android smartphone with installed busybox and SD card, connected to centreon server via USB.
  3. Minimum programming and Linux skills.

How it works:

  1. Centreon writes notification log in JSON to phone card.
  2. Persistent service on android smartphone reads JSON, composes a messages and sends it.

Step by step guide:

  1. Use adb shell \ terminal emulator \ SSH shell to issue command “mount”. You will see partition type and mount point for device. For example, it can be vfatand /dev/block/vold/179:1.

  2. Download android program for mounting SD card and compile it, replacing mount point in code with your own. Install it on your phone. Try connecting phone to your computer and selecting USB storage mode. After it, your card will be umounted - so use compiled program to mount in again read only. Use file explorer in root mode (for example, total commander) to make sure that your SD is really mounted. Repeat until successful : )

  3. Download android service for sending Centreon notifications and compile it, replacing mount point in code with your own. Install it on your phone.

  4. Connect your phone to Centreon server. Mount phone card to server file system, like this:

mount -t vfat -o rw  umask=0666 /dev/sdc /mnt/phone/
  1. Configure centreon notification (Configuration - Commands - Notifications). It should issue the following command:
printf "{\"Notification Type\": \"$NOTIFICATIONTYPE$\", \"Service description\" : \"$SERVICEDESC$\", \"Host\" : \"$HOSTNAME$\",\"Host alias\" : \"$HOSTALIAS$\",\"Address\": \"$HOSTADDRESS$\",\"State\" : \"$SERVICESTATE$\", \"PHONE\": \"$CONTACTPAGER$\", \"TIME\": \"`date '+%s'`\"}," >> /mnt/phone/SmsInformer/messages.txt
  1. Launch SMS Informer application - you are ready to receive notifications!

Also, you can set up cron script on centreon server to clear notifications file.