Last active
May 23, 2020 10:36
-
-
Save colorwebdesigner/bf48470397c0d02759c4f3dcdd010169 to your computer and use it in GitHub Desktop.
Mikrotik script for send message to Slack on IP change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:global ipCurrent "$ipCurrent"; | |
{ | |
# Change to your settings | |
# ----------------------- | |
:local wanInterface "eth1"; | |
:local slackHookUrl "https://hooks.slack.com/services/YOUR/APP/SECRET"; | |
# ----------------------- | |
:local ipNew [/ip address get [find interface=$wanInterface] address]; | |
:local ipNewF [:pick $ipNew 0 ([:len $ipNew]-3)]; | |
:local ipCurrentF [:pick $ipCurrent 0 ([:len $ipCurrent]-3)]; | |
:local dataForMsg "{\"text\":\"IP change detected.\n$ipCurrentF --> $ipNewF\"}"; | |
:if ($ipNew != $ipCurrent) do={ | |
:set ipCurrent $ipNew; | |
/tool fetch http-data=$dataForMsg url=$slackHookUrl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment