Background
As a happy owner of a pebble watch I want my op5 Monitor notifications to it. This is a simple guide howto get notifications sent directly tt a pebble watch. My phone is an Android and probably there is similar ways of getting it working on iphone aswell. The guide will work on Nagios and Naemon and other forks that has popped up the last years.
Phone app
I found a pebble app that could recive notifications via a sinple API: Pebble Connect
Install it and choose a good userid and usertoken.
Notification script
A simple notification script is created:
#!/bin/sh
	/bin/logger -t pebble_notify $@
	/usr/bin/curl -v --data "\
	userId=$1&\
	userToken=$2&\
	title=$3&\
	body=$4&\
	type=notification" \
	https://ofkorth.net/pebble/send 
	>/dev/null 2>&1
I send some info to the system log to be able to troubleshoot
Test to make sure it works:
# /opt/plugins/custom/notify_via_pebble.sh <userid>  <usertoken> "This it the test subject" "This is the message"
Notice using the prior defined userid and usertoken and then you should have this on your Pebble

op5 Monitor config
Define a checkcommand in /opt/monitor/etc/checkcommands.cfg
# command 'custom_host_notify_pebble_push'
	define command{
	    command_name                   custom_host_notify_pebble_push
	    command_line                   $USER1$/custom/notify_via_pebble.sh $ARG1$ $ARG2$ "op5 Monitor Host $NOTIFICATIONTYPE$"  "$HOSTNAME$ is $HOSTSTATE$ - $HOSTOUTPUT$"
	    }
# command 'custom_service_notify_pebble_push'
	define command{
	    command_name                   custom_service_notify_pebble_push
	    command_line                   $USER1$/custom/notify_via_pebble.sh $ARG1$ $ARG2$ "op5 Monitor Service $NOTIFICATIONTYPE$" "$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$ - $SERVICEOUTPUT$"
	    }
Define a contact using the notification in /opt/monitor/etc/contacts.cfg
# contact 'peter_notify_via_pebble'
	define contact{
	    use                            default-contact
	    service_notification_commands  custom_service_notify_pebble_push!<userid>!<usertoken>
	    host_notification_commands     custom_host_notify_pebble_push!<userid>!usertoken>
	    contact_name                   peter_notify_via_pebble
	    alias                          peter_notify_via_pebble
	    can_submit_commands            0
	    host_notification_options      d,r,u
	    service_notification_options   c,r,w
	    contactgroups                  peter_pebble_push
	    email                          bla
	    }
Remember to change the <userid> and <usertoken> to to your credentials.
Just add the newly created contact to your normal contacgroups and you will start recieve notifications

Useful links
Leave a Reply
You must be logged in to post a comment.
 
	


