I need to query the dhcp-server lease status and display all IP’s/macs/names that are STATUS=waiting AND do not have a comment.
I started out with this code:
:foreach i in=[/ip dhcp-server lease find status=waiting] do={
:put [/ip dhcp-server lease get $i status]
:put [/ip dhcp-server lease get $i address]
:put [/ip dhcp-server lease get $i mac-address];
}
and it only shows BOUND ip’s.
What can I do to only display STATUS=waiting or STATUS!=bound and have no comments?
Thank you for your time.
“waiting” status do not exist, or better, on winbox the lease is on waiting status when do not have the other status possible: authorizing bound busy offered testing
You can obtain what you want, simply using full right syntax.
:foreach i in=[/ip dhcp-server lease find where !status and !comment] do={
:put message="waiting";
:put message=[/ip dhcp-server lease get $i value-name=address];
:put message=[/ip dhcp-server lease get $i value-name=mac-address];
};
This line are removed because on “waiting” state do not generate any output.
:put message=[/ip dhcp-server lease get $i value-name=status];