Created
May 23, 2020 11:04
-
-
Save g3rhard/60815e340a9abda06ef9d6970bcea1be to your computer and use it in GitHub Desktop.
This file contains 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
## | |
## Send a message to Slack on DHCP Bound | |
## https://github.com/massimo-filippi/mikrotik | |
## | |
## script by Maxim Krusina, maxim@mfcc.cz | |
## based on: http://jeremyhall.com.au/mikrotik-routeros-slack-messaging-hack/ | |
## created: 2018-09-23 | |
## updated: 2018-09-23 | |
## | |
## usage: | |
## use this script as DHCP Lease Script | |
## | |
:global leaseBound | |
:global leaseServerName | |
:global leaseActMAC | |
:global leaseActIP | |
# Do the stuff on Bind | |
:if ($leaseBound = 1) do={ | |
/ip dhcp-server lease { | |
:foreach i in [find dynamic address=$leaseActIP] do={ | |
:local hostName [/ip dhcp-server lease get $i host-name]; | |
:global SlackChannel "#mindless-administrating" | |
:global SlackMessage "New guest connected to *Wi-Fi*" | |
:global SlackMessageAttachements "*Host name*: $hostName\n *IP*: $leaseActIP\n *MAC*: $leaseActMAC" | |
/system script run "Message To Slack"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment