Towards that end, I modified an existing script (very proud of myself) to email me the details of all new DHCP lease assignments:
Code: Select all
/system
:local cdate [clock get date]
:local yyyy [:pick $cdate 0 4]
:local MM [:pick $cdate 5 7]
:local dd [:pick $cdate 8 10]
:local thistime [/system clock get time]
:local thishour [:pick $thistime 0 2]
:local thisminute [:pick $thistime 3 5]
:local thissecond [:pick $thistime 6 8]
:local identitydatetime "$[identity get name]_$yyyy-$MM-$dd_$thishour:$thisminute:$thissecond"
:local datetime "$yyyy-$MM-$dd_$thishour:$thisminute:$thissecond"
:local systemname "$[identity get name]"
:if ($leaseBound=1) do={
:log info "testing after condition BOUND" }
:if ([/ip dhcp-server lease find where dynamic mac-address=$leaseActMAC]!="") do={
:log info "testing after condition DYNAMIC"}
:local recipient "joseph@xxxxx.com"
:if (($leaseBound=1) && ([/ip dhcp-server lease find where dynamic mac-address=$leaseActMAC]!="")) do={
:log info "testing after conditions BOUND and DYNAMIC"
:tool e-mail send to=$recipient subject="$systemname DHCP Lease Assigned to $leaseActMAC" body="MAC address $leaseActMAC received IP address $leaseActIP with a hostname of $[/ip/dhcp-server/lease/get value-name=host-name [find where mac-address=$leaseActMAC]] from DHCP Server $leaseServerName on $datetime from $systemname"
:log info "Sent DHCP alert for MAC $leaseActMAC"
}
But, the bigger problem is that the host-name doesn't exist and I want to know more about the newly connected device.
Has anyone figured out a way to run a scan on the new device (it will have an IP address) to get at least basic info about it (host name, DNS name, OS, services, etc.)?
Also, I would really like the data to be stored somewhere more easily saved and manipulated (email doesn't cut it for that).
I run a Home Assistant server with MQTT (Mosquitto) broker, but haven't been able to get the RouterOS<->HA-MQTT working. I went down the HA road because once new device info is in HA, I can utilize HA's other features such as letting me know when someone arrives, etc.
Thank you!