Here's an SQL command that defines a "simple node view". Can be very handy to browse the nedi nodes database with an SQL client. The IP address is in dotted format, so you can directly filter on an address like 10.1.2.3 the firstseen/lastseen fields are in human readable format.
the view has the following columns:
name ip mac vlanid device ifname alias firstseen lastseen
alias is from the interfaces table, the other fields from the node table.
DROP VIEW IF EXISTS `nedi`.`nodes_simple`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nedi`@`pc.domain.tld` SQL SECURITY DEFINER VIEW `nedi`.`nodes_simple` AS select `nodes`.`name` AS `name`,inet_ntoa(`nodes`.`ip`) AS `ip`,
`nodes`.`mac` AS `mac`,`nodes`.`vlanid` AS `vlanid`,`nodes`.`device` AS `device`,
`nodes`.`ifname` AS `ifname`,`interfaces`.`alias` AS `alias`,
from_unixtime(`nodes`.`firstseen`) AS `firstseen`,from_unixtime(`nodes`.`lastseen`) AS `lastseen`
from `nodes` left join `interfaces` on ((`nodes`.`device` = `interfaces`.`device`) and (`nodes`.`ifname` = `interfaces`.`ifname`));
Example query
SELECT * FROM nodes_simple WHERE ip = '10.1.2.3';
Example result:
'host10123.test.ch', '10.1.2.3', '00319c7a54fc', 9, 'testsw', 'Fa0/11', 'blabla if description', '2008-12-03 11:40:01', '2009-01-08 15:40:01'
Greetings
Rufer