forked from massimo-filippi/mikrotik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dhcp-notify-slack.rsc
37 lines (28 loc) · 1.08 KB
/
dhcp-notify-slack.rsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
##
## 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 "#my-channel"
:global SlackMessage "New guest connected to *My wifi name*"
:global SlackMessageAttachements "[{\"fields\": [{\"title\": \"Host name\",\"value\": \"$hostName\",\"short\": false},{\"title\": \"IP\",\"value\": \"$leaseActIP\",\"short\": false},{\"title\": \"MAC\",\"value\": \"$leaseActMAC\",\"short\": false}],\"color\": \"#F35A00\",\"mrkdwn_in\":[\"text\",\"pretext\"]}]";
/system script run "Message To Slack";
}
}
}