BUG: Problem with eventlog when port was removed after event


Let us assume you have some events in the eventlog regarding a port on a specific device.
If you go and remove that port completely from the device it then completely breaks eventlog page with the following error in the librenms.log

production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getShortLabel() on null in /opt/librenms/app/Http/Controllers/Table/EventlogController.php:83

This is because the port doesn’t exist it cannot get the label for it.

Adding the lines “if (isset($port)) {” effectively solves the problem in file /opt/librenms/app/Http/Controllers/Table/EventlogController.php

    if ($eventlog->type == 'interface') {
        if (is_numeric($eventlog->reference)) {
            $port = $eventlog->related;
            if (isset($port)) {
                    return '<b>' . Url::portLink($port, $port->getShortLabel()) . '</b>';

Please send a patch on GitHub. Your fix is correct.

pull request #9778

1 Like