Hi, I had the exact same message in the librenms.log when going to the LibreNMS ‘Ports’ - ‘Customers’ page.
2022-03-17T12:53:43.028767+00:00] production.ERROR: Trying to get property ‘os’ of non-object {“userId”:4,“exception”:"[object] (ErrorException(code: 0): Trying to get property ‘os’ of non-object at /opt/librenms/app/Models/Port.php:64)"}
With the suspected cause being a deleted device’s ports still present in the ports table.
In my case device id 3 has been deleted and I assume because the os is NULL the exception is caused.
MariaDB [librenms]> select `port_descr_descr`, port_id, ports.device_id, ifAlias, devices.os from `ports` left join `devices` on `ports`.`device_id` = `devices`.`device_id` where `port_descr_type` in ('cust') order by `port_descr_descr`;
+-----------------------------------------+---------+-----------+------------+
| port_descr_descr | port_id | device_id | ifAlias | os
+-----------------------------------------+---------+-----------+------------
| Acme | 1539 | 6 | Cust: Acme | iosxr
| Acme | 776 | 3 | Cust: Acme | NULL <-----------
I think I have fixed the problem by deleting the ports associated with the deleted devices.
I identified the port id’s with deleted devices with the following query
MariaDB [librenms]> select port_id from ports where device_id not in (select device_id from devices);
±--------+
| port_id |
±--------+
| 101 |
| 776 |
etc
Then added the port id’s to a file then bulk deleted with the purge-ports.php script.
./scripts/purge-port.php -f purge-ports.txt
The LibreNMS ‘Ports’ - ‘Customers’ page now loads as expected, with no further exceptions in the librenms.log
I am not aware of any other problems these actions might cause and I am not sure how I got into this state. Also what the process is to remove these ports in an automated way so this does not happen in the future.
The cleanup ‘Ports older than (days)’ is set to 10 days.