I would like to export or capture current host name and ip address from active leases.
The problem export does not include that info and all the prints I have tried that are reasonably easy to import into sql or spreadsheet shorten the host name.
any thoughts or recommendations?
Yeah… Script it. Just tell me what format you want the output in and I can modify one of my scripts to do it.
Sent from my SCH-I545 using Tapatalk
Thanks!
what I need to end up with is a CSV with the following:
ip-address,mac-address,“host-name”
Your help greatly appreciated!
Greg Clemmons
Statics, dynamics, only bound? Or exactly which are you looking for. I’ll write it tonight once my son goes to bed.
Sent from my SCH-I545 using Tapatalk
static using:
Active Address, Active Mac Address, Active Host Name
Thanks again
Ok. I’ll modify one of my scripts and post it tonight
Sent from my SCH-I545 using Tapatalk
DHCPtoCVS
:local outputFileName “DHCPLeases.csv”
#:if (![:len [/file find name=$outputFileName]] > 0) do={
/file print file=$outputFileName
#}
:local outputContent “”
/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]
:set outputContent ($outputContent . "\n" . $activeAddress . "," . $activeMacAddress . "," . $hostname)
}
}
#:put $outputContent
#/file {
set [find name=$outputFileName] contents=$outputContent
#}Currently it just puts it to the screen but you can modify it to put to a file… I haven’t fully tested it… but thats the basic idea.
Thank you very much!
Appears I have 2 problems:
#1
When I uncomment the file open / test part of the script I get: “Script Error: cannot logically negate time interval”
#2
When I uncomment the file write portion I get: “failure: new contents too long”
Very close. Any thought?
Then your file exceeds the maximum size… I’d let it use put and run it via SSH and dump to a file.
Thanks Again that did work with using file capture with ssh. The file size limit is a pain but no biggie.
I do see the power of scripting.
Yeah… No problem. The file limit does cause some issues. If you want to use put instead I would actually modify the script to use put inside the loop instead of set. It will be more efficient.
Sent from my SCH-I545 using Tapatalk
I’d just do..
/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)
}
}
Hi there sir efaden
I am planing to make a coin operated wifi HotSpot,
And I have done it by auto generating user name and uptime limit, using nodemcu esp8266, & I want to upgrade it to, auto login without typing user name, just insert coin & login button on my portal, here is what I want to happen,
If someone access portal & tap insert coin button, my esp8266 generate uptime limit and auto login if login button is tap, can u help me about this?