If you're going to fetch lease info from linux box via ssh, then you can easily do filtering with some simple commands on linux box itself.
One-liner that does the trick:
WANTED=my-host-name; LEASES=$( ssh user@routerboard.my.domain '/ip dhcp-server lease { :foreach i in=[find (!dynamic && status="bound")] do={ :local activeAddress [get $i active-address]; :local activeMacAddress [get $i active-mac-address]; :local hostname [get $i host-name]; :put ($outputContent . "\n" . $activeAddress . "," . $activeMacAddress . "," . $hostname) } }' ) ; echo ${LEASES} | grep ${WANTED} | cut -d, -f1
or, to make a script that takes hostname as argument:
#!/usr/bin/env bash
WANTED=$1
if [ -z "${WANTED}" ]; then
echo 'Error! You have to specify host name as single argument.' >&2
exit 1
fi
RB=user@routerboard.my.domain
LEASES=$( ssh ${RB} '/ip dhcp-server lease { :foreach i in=[find (!dynamic && status="bound")] do={ :local activeAddress [get $i active-address]; :local activeMacAddress [get $i active-mac-address]; :local hostname [get $i host-name]; :put ($outputContent . "\n" . $activeAddress . "," . $activeMacAddress . "," . $hostname) } }' )
echo ${LEASES} | grep ${WANTED} | cut -d, -f1
save it as a file and then run it, giving it host name, for which you want to get IP address from lease. Adjust whatever is assigned to variable RB, to correct value for your case (user might be admin, host name might be IP address if your RB doesn't have FQDN available from your DNS service.
If you want to fetch leased IP address for more than one host, you can replace the last line with a loop, looping through host names of interest. No need for multiple ssh lease fetches.