Community discussions

MikroTik App
 
Jorbu
just joined
Topic Author
Posts: 23
Joined: Sun Apr 01, 2012 4:23 am

CAPsMAN Registration Table Device IP or Hostname

Fri Feb 17, 2017 3:05 am

Hi,

Has anyone built or seen a script that will pull all registered CAPsMAN devices, and tie them together (via MAC address) to the IP and "Active Host Name" from the DHCP server leases table? I find myself frequently checking both in order to identify what devices are hanging off certain APs within my networks. This would just make the job a bit quicker.

Thanks!
 
gramels
just joined
Posts: 16
Joined: Thu Aug 14, 2014 11:28 am

Re: CAPsMAN Registration Table Device IP or Hostname

Mon Mar 13, 2017 6:40 am

sorry, dont, but would love to see this as well...
 
Retral
just joined
Posts: 22
Joined: Wed Jul 25, 2018 9:10 pm

Re: CAPsMAN Registration Table Device IP or Hostname

Fri Apr 19, 2019 10:08 pm

I wanted this functionality myself so I took a half hour and cobbled together some dirty code myself. The code below will match entries from CapsMan then display the following:
Host Name, CapsMan Interface, IP Address, IP Address Expiry Time and the Mac Address of the Client.
[:foreach i in=[/caps-man registration-table find] do={([:local M [/caps-man registration-table get $i mac-address]]\
.[:put [/ip dhcp-server lease get [find where mac-address=$M] host-name]].\
[:put [/caps-man registration-table get $i interface]].\
[:put [/ip dhcp-server lease get [find where mac-address=$M] address]].\
[:put [/ip dhcp-server lease get [find where mac-address=$M] expires-after]].[:put $M].[:put ""])}]
Feel free to criticise (please do criticise it because I find my main weakness is in understanding syntax and I'd love to fix that) and or improve it. I'm sure it can be added to and condensed a lot,
however I'm not a very good at coding so this is what I can provide atm.
 
chriscolden
just joined
Posts: 10
Joined: Fri May 04, 2018 3:41 pm

Re: CAPsMAN Registration Table Device IP or Hostname

Wed Aug 05, 2020 4:00 pm

Just my take on it. not too different, but I try and make the output a bit easier to read and also pull the comment as not everything i have sets a hostname.
:foreach i in=[/caps-man registration-table find] do={
	:local varM [/caps-man registration-table get $i mac-address]
	:local varH [/ip dhcp-server lease get [find where mac-address=$varM] host-name]
	:local varI [/caps-man registration-table get $i interface]
	:local varIP [/ip dhcp-server lease get [find where mac-address=$varM] address]
	:local varC [/ip dhcp-server lease get [find where mac-address=$varM] comment]
	:put ("$varI\t$varM\t$varIP\t$varH\t$varC")
}

Who is online

Users browsing this forum: Google [Bot] and 25 guests