Use Pushover Notifications on MikroTik

Pushover

Log in or sign up for a Pushover account

Log in to mobile device with same details to register device

Testing can be done from main page to confirm Notifications sent to device

New accounts are allowed 30 days free trial, after that a license is required per end-user device

User Key/Token

On the main page you will see the User Token/Key. Copy this and keep handy

USER TOKEN: u3cdzz34kwefi91wnxcrpcch19xi8v

Application Key/Token

Scroll down to the bottom of the main page and select Create an Application/API Token

Fill out details as required and optional feature to upload an image to display on notification (72×72 pixel)

Once created copy the API Token

APP TOKEN: as4xmqvz44t75rjr6yb3cg6e984ag9

Testing API

Now with the API Tokens set up and copied, use the following command on the MikroTik to test:

/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=<APP TOKEN>&user=<USER TOKEN>&message=<MESSAGE>&title=<TITLE>&priority=1"
/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=as4xmqvz44t75rjr6yb3cg6e984ag9&user=u3cdzz34kwefi91wnxcrpcch19xi8v&message=Test Message&title=AWS CHR AU&priority=1"

Scripts

Basic Pushover Script

The below script is a simple example of how to send a notification using the fetch tool command and setting all the required details in variables.

#Define the Variables
:local appToken "";
:local userToken "";
:local message "";
:local title "";

/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=$appToken&user=$userToken&message=$message&title=$title&priority=1"

Populated example:

#Define the Variables
:local appToken "as4xmqvz44t75rjr6yb3cg6e984ag9";
:local userToken "u3cdzz34kwefi91wnxcrpcch19xi8v";
:local message "Test Message";
:local title "CHR AU";

/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=$appToken&user=$userToken&message=$message&title=$title&priority=1"

Using Script from another Script

This example uses Global Variables to be able to pass the info that might be different per application, e.g. the message and title.

#Define Global Variables
:global pushoverMessage;
:global pushoverTitle;

#Define the Variables
:local appToken "as4xmqvz44t75rjr6yb3cg6e984ag9";
:local userToken "u3cdzz34kwefi91wnxcrpcch19xi8v";
:local message "$pushoverMessage";
:local title "$pushoverTitle";

/tool fetch mode=https url="https://api.pushover.net/1/messages.json" http-method=post http-data="token=$appToken&user=$userToken&message=$message&title=$title&priority=1"

The script can then be ran

:global pushoverMessage "Test - New"; :global pushoverTitle "CHR AU"; sys script run pushover

Netwatch Example

/tool netwatch
add disabled=no down-script=":global pushoverMessage \"IPSec Tunnel to CHR UK DOWN\
    \"; :global pushoverTitle \"CHR AU::IPSEC MONITOR\"; sys script run pushover" \
    host=10.1.1.2 http-codes="" name=ipsec-check test-script="" type=simple \
    up-script=":global pushoverMessage \"IPSec Tunnel to CHR UK UP\"; :global push\
    overTitle \"CHR AU::IPSEC MONITOR\"; sys script run pushover"

Testing

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *