Skip to content

Instantly share code, notes, and snippets.

@colorwebdesigner
Last active May 23, 2020 10:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colorwebdesigner/bf48470397c0d02759c4f3dcdd010169 to your computer and use it in GitHub Desktop.
Save colorwebdesigner/bf48470397c0d02759c4f3dcdd010169 to your computer and use it in GitHub Desktop.
Mikrotik script for send message to Slack on IP change
: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