OpenWrt Forum Archive

Topic: Hostname instead of MAC-address

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
i was wondering if was possible to show the hostname instead of the MAC address on the first page (status) where it says "associated stations" at the bottom.
I always have to match the Hostname to the MAC-address on the DHCP Leases section, to see who's connected.

Thanks

yes it would be nice if these two were combined. I'd like to see BOTH mac address and hostname though.

^^^ That would be even better.

The file to modify is located at:   /usr/lib/lua/luci/view/admin_status/index.htm
Unfortunately i dont know Javascript.
Does anyone?

(Last edited by pirello on 24 Aug 2014, 02:39)

SOLUTION: Open /usr/lib/lua/luci/view/admin_status/index.htm

1.) Find this

<%+header%>

2.) And put this lua code snippet to a line before the code listed in 1.)

<%
local sys = require "luci.sys"
    local arpcache = { }
    
    -- collect MAC hints (mac is already upper, but be robust)
     -- this reads arp cache, /etc/ethers, dhcp leases, etc 
     sys.net.mac_hints(function(mac,name) arpcache[mac:upper()] = name end)
     -- add IP address, if entry is just a name (or name, if just an IP addr)
     sys.net.arptable(function(e)
         local m = e["HW address"]:upper()
         local s = arpcache[m]
         if s and not s:match("^[0-9.]+$") then
             arpcache[m] = "%s [%s]" %{ s, e["IP address"] }
         elseif not s then -- possibly if it just appeared in the arp cache
            arpcache[m] = "%s [%s]" %{ nixio.getnameinfo(e["IP address"]), e["IP address"] }
         end
     end)
    local system, model = luci.sys.sysinfo()
-%>

3.) find this portion of the html

<fieldset class="cbi-section">
    <legend><%:Associated Stations%></legend>

    <table class="cbi-section-table" id="wifi_assoc_table">
        <tr class="cbi-section-table-titles">
            <th class="cbi-section-table-cell">&#160;</th>

And insert this:

<th class="cbi-section-table-cell"><%:Hostname%></th>

4.) Find this javascript code

tr.insertCell(-1).innerHTML = assoclist[i].bssid;

5.) And put this javascript code snippet to a line before the javascript code listed in 4.)

tr.insertCell(-1).innerHTML = arptable[assoclist[i].bssid] ? arptable[assoclist[i].bssid] : '?';

Sample output screenshot: http://screencast.com/t/ItC2GAmnErE

(Last edited by digitalbinary on 6 Jul 2015, 01:20)

Thanks digitalbinary! It would be great if you submitted this as a patch so that it becomes an official part of Luci. Then all users will have this feature by default!

Thank you digitalbinary. I second drawz's proposal, this is definitely a keeper.

Cheers

wow works nicely
and would by great  if you can be mod to for Wifi -> Wireless Overview -> Associated Stations

you must submit this for openwrt!!

(Last edited by norman25 on 9 Jul 2015, 16:37)

yep. a very nice feature for openwrt!

Thanks digitalbinary, also happy to see my idea was good.

Guys on CC RC2 after putting solution from @digitalbinary i've got this:

/usr/lib/lua/luci/dispatcher.lua:360: Failed to execute template dispatcher target for entry '/admin/status/overview'.
The called action terminated with an exception:
/usr/lib/lua/luci/template.lua:39: Failed to load template 'admin_status/index'.
Error while parsing template '/usr/lib/lua/luci/view/admin_status/index.htm':
Syntax error in /usr/lib/lua/luci/view/admin_status/index.htm:121: unfinished string near '"'
stack traceback:
    [C]: in function 'assert'
    /usr/lib/lua/luci/dispatcher.lua:360: in function 'dispatch'
    /usr/lib/lua/luci/dispatcher.lua:135: in function </usr/lib/lua/luci/dispatcher.lua:134>

Now I revert index.htm to working my Luci.

I too am having an issue with CC 15.05 RC2

/usr/lib/lua/luci/dispatcher.lua:433: Failed to execute template dispatcher target for entry '/admin/status/overview'.
The called action terminated with an exception:
/usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_status/index'.
A runtime error occured: [string "/usr/lib/lua/luci/view/admin_status/index.h..."]:110: attempt to call field 'sysinfo' (a nil value)
stack traceback:
    [C]: in function 'assert'
    /usr/lib/lua/luci/dispatcher.lua:433: in function 'dispatch'
    /usr/lib/lua/luci/dispatcher.lua:168: in function </usr/lib/lua/luci/dispatcher.lua:167>

Are the numbers above line numbers in the code?

I tested under both bootstrap and openwrt themes.

Hey there.

May I recommend not to provide human readable adjustment descriptions but regular patch files instead?

https://en.wikipedia.org/wiki/Patch_%28 … e_examples
The whole thing was invented to avoid exactly this situation, and its 30 years old now.

According to OpenWRTs page on development and submitting coe, you need to send those patches to the mailing list anyway in order to get it merged to a official release.
https://dev.openwrt.org/wiki/SubmittingPatches

Regards,
Stephan.

(Last edited by golialive on 14 Jul 2015, 23:53)

After delete line with "local system, model = luci.sys.sysinfo()" (find solution on another forum) works on CC RC2 smile
I also use Notepad++ to edit index.htm not WinSCP to work. This should be build in firmware.

(Last edited by simono_pl on 15 Jul 2015, 07:47)

Guys now I'm on CC RC3 and on some devices on first column I see two ip addresses, one from my local network and second I don't known. My LAN network is 192.168.1.0, Example:
some-phone
[192.168.1.131]
[100.68.163.94]

(Last edited by simono_pl on 24 Jul 2015, 06:26)

Another plea to get this submitted as an official patch so that we can all use it! I doubt it would make the CC final release given that we are already at the RC stage, but it's worth a shot!

The discussion might have continued from here.