Send an email when a (new) device connects over wlanx

Hi,

I’m looking for a way to send me an email when a device connects to “wlanx”. It would be great if the output lists the MAC, device name and IP address. As long as the device is connected there is no need to send me an other email.

So, I tried creating it myself but because I have 0,0 experience with scripting for microtik I’m not getting very far.

I assume I can use the “/interface wireless registration” command. Then i should filter only devices connected through interface “wlanx”. This will give me the MAC-Address (and other info I don’t care about).

With this MAC-Address I can look into the “/ip pool lease” that lists the MAC, IP and hostname.

Now the big question: how do I ‘fetch’ the data from those commands?

I’ve tried this:

:put [/interface wireless registration get [find interface=wlan2]];

But my output is a huge amount of data:

.id=*43;802.1x-port-enabled=true;ap=false;bridge=false;bytes=35215676,2099371;frame-bytes=35038250,1981429;frames=29575,19657;hw-frame-bytes=38370479,2489592;hw-frames=31811,20955;interface=wlan2
;last-activity=00:00:00.070;last-ip=192.168.13.100;mac-address=00:21:6B:22:F1:3C;management-protection=false;p-throughput=82638;packets=29575,19657;rx-rate=65.0Mbps;signal-strength=-56dBm@1Mbps;s
ignal-strength-ch0=-59;signal-strength-ch1=-60;signal-to-noise=50;strength-at-rates=-56dBm@1Mbps 70ms;-61dBm@2Mbps 3s350ms;-57dBm@5.5Mbps 2m18s330ms;-59dBm@6Mbps 5s330ms;-62dBm@9Mbps 4m30s960ms;-
62dBm@12Mbps 6m19s680ms;-64dBm@18Mbps 4m34s340ms;-62dBm@24Mbps 4m53s430ms;-59dBm@36Mbps 3s30ms;-63dBm@48Mbps 8s220ms;-66dBm@54Mbps 24m35s920ms;-60dBm@HT20-1 4m46s120ms;-60dBm@HT20-2 4m39s570ms;-6
3dBm@HT20-3 4m19s640ms;-66dBm@HT20-4 3m46s870ms;-59dBm@HT20-5 2s820ms;-59dBm@HT20-6 2s820ms;-60dBm@HT20-7 3s220ms;tx-ccq=90;tx-frames-timed-out=0;tx-rate=104.0Mbps;uptime=00:24:36;wds=false;wmm-e
nabled=true

How do I extract the MAC address from all this data?

It would be great if anyone could point me in the right direction. Note that I’m not asking for a ready-to use script. I prefer it to be more “pointers” so I can learn from it!