[Bug Report, closed & moved to feature request] Alert Notifications page: Sorts only by severity & timsetamp, regardless of column & direction selected

Bug report, not a request for help:

Alerts | Alert Notifications: click a sortable column heading & the result is always “sort by severity and then timestamp”. i.e. sort by timestamp, rule or hostname does not work.

Also, the ACK column it not sortable, so you can’t “view unacknowledged alerts first”, which seems a legitimate thing to want to do & for a sort function to provide.

[Centos 7 + Apache, fully patched]


Component Version
LibreNMS 1.48.1-60-g4f7a71c
DB Schema 2019_01_16_195644_add_vrf_id_and_bgpLocalAs (131)
PHP 7.2.14
MySQL 5.5.60-MariaDB
RRDTool 1.4.8


[OK] Composer Version: 1.8.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[FAIL] The poller (nemo.int.rnib.org.uk) has not completed within the last 5 minutes, check the cron job.
[FAIL] Some folders have incorrect file permissions, this may cause issues.
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

(The poller may be taking too long because of the number of subnets i need to scan.)
(the permissions error keeps coming up each day, no matter how many times i run the fix commands & verify that the problem is resolved straight after).



any news on this one please?

being able to sort alert notifications is pretty key to using this service in live operations (e,g, show me only alerts I haven’t acknowledged, show me alerts in priority order, in system order, in issue type order).

1 Like

I’m not a coder (if i was, i’d fix it), but on the basis that other UI tables do have working sorts (e.g. devices table), this feels like it should be an easy one to fix?

To recap:

  • clicking any clickable column heading on the alerts notification table results in a sort by priority and then time. repeated clicks do not alter the sorted list.
  • sorts by hostname, time of issue type do not work at all
  • the acknowledged column is not sortable, but should be, as “show me unacknowledged alerts first” is an entirely reasonable and normal request.


I have found the source of the problem:

clicking on a heading in the alert notifications table requests ajax_table.php, with the correct data, e.g. when sorting by hostname, the form data is:

current: 1
rowCount: 50
sort[hostname]: asc
id: alerts
device_id: -1

The /opt/librenms/html/ajax_table.php file shows the sort being performed:

if (isset($_REQUEST[‘sort’]) && is_array($_POST[‘sort’])) {
foreach ($_REQUEST[‘sort’] as $k => $v) {
$sort .= " $k $v";

Then the includes/table/alerts.inc.php file is called (by include_once “includes/table/$id.inc.php”;

in alerts.inc.php, the following stanza is responsible for the “no matter what heading the user clicks, ignore them and sort by severity and then timestamp behaviour”:

if (!isset($vars[‘sort’]) || empty($vars[‘sort’])) {
$sort = ‘timestamp DESC’;
} else {
$sort = ‘alert_rules.severity DESC, timestamp DESC’;

I’m not a PHP coder, so forgive my ignorance, but this looks to stamp all over the value of $sort, which was set in the ajax_table.php file.

Please could a dev take a look and resolve?

While you’re there, please could you make the table sortable by the ACK column too?

If this should logged as an issue on the github repo then please let me know (i did try logging it as such but was bounced here).


I’ve done some more digging (again not a PHP programmer:

In /opt/librenms/html/includes:

commenting out line 106 (// $sort = 'alert_rules.severity DESC, timestamp DESC;) in table/alerts.inc.php removed the “always sort by severity then timestamp, no matter what the user asks for” behaviour and gave me sort by time stamp or hostname.

I wasn’t able to sort by severity until i made the following change in common/alerts.inc.php:

line 232: was:

now: Pri

I did try removing the data-sortable=“false” tag from the ACK field, but that didn’t work (clicking on the column heading just brought back an empty table). We need a sortable field here.

Sorting the rule field is still not working as it should: clicking that column heading multiple times produces the same result, despite the POST request including the asc / desc directive.

Please can a dev take a look at this?



Component Version
LibreNMS 1.48.1-90-g3ad698f
DB Schema 2019_02_10_220000_add_dates_to_fdb (132)
PHP 7.2.14
MySQL 5.5.60-MariaDB
RRDTool 1.4.8


[OK] Composer Version: 1.8.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] Your local git contains modified files, this could prevent automatic updates.
You can fix this with ./scripts/github-remove
Modified Files:

I tried logging this as an issue on the github repo but it was closed :

kkrumm1 commented an hour ago
:wave:sorry but this is not the place to ask for help/request.

This issue has been closed as it isn’t classed as a new device request.

…it wasn’t a request for help either, it was a request to fix a bug.

How do you report a bug when there’s no response from the community & attempts to log an issue on github as normal are bounced?

That being said. This is all open and free software IF somebody wants to they will work on the “bug”.
You can’t keep demanding somebody fix this. Nobody works here as a job its all volunteer based.
Bugs are not reported in GitHub they are reported in community forums or discord and again if somebody wants to respond here they will.

I understand that please see above. thanks.

I would normally expect to see a system of capturing & tracking bugs, with feedback provided as they are scheduled for investigation, investigated, solutions / workarounds found, etc. From the GitHub tutorial: “Use issues to track ideas, enhancements, tasks, or bugs for work on GitHub.”. This makes more sense than peppering a help forum with such reports, but that’s down to the admins. It cannot be assumed that devs look at the help forum, or if it acts as a channel to one or more dev. Even a “bug report” forum would help, if there is some reason why the GitHub issues log can’t be used as above.

From Wikipedia: ‘software bug is an error, flaw, failure or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways.’ I would say that having clickable column headings in a table with ascending and descending indicators, clicking on which results in a sorted view, but not the sorted view requested, fulfils that definition.

I have demanded nothing, I have asked for this to be brought to the attention of a suitable dev to assist with what looks to be a simple issue for anyone familiar with the code-base & PHP. The code issues I have identified look like missed / overlooked QA issues rather than fundamental ones.

Why would a (non-person-specific) justifiably proud dev on this project want to walk past an obvious code error that looks to be easy to fix? Clearly you wouldn’t want to spend your life doing fixes, but wouldn’t you want a sensible place to record the issues and track progress?

Why is this functionality important? I want our ops team to use the alert notifications table to quickly identify and group issues flagged by LibreNMS. That’s a lot easier to do when you can sort by logical field names (the name of the thing that went wrong, when it went wrong, what the problem / problem type was, has someone already acknowledged it). I don’t see this as an unreasonable request for such a table, especially when it purports to contain this functionality.


1 Like

Back on topic:

Changing the table/alerts.inc.php as above does allow sorting in the alert notifications table BUT it breaks the alert dashboard widget (the table does not populate).

These two things should be decoupled (as they are currently not the same in terms of functionality and dependencies) OR, much better, they should both be made to work the same way, with (non-admin) user selectable filters for both (the widget has them only in widget edit mode, while the notifications table doesn’t have filters at all).

I’m now out of my depth on the coding side & don’t have the time or headspace to learn PHP & the relevant sections of the code base, so I’ll raise a feature request instead.

In the mean-time, a solution is possible with a full-dash alerts widget and allowing everyone to edit that widget, or getting everyone to create their own such widget. Editing the widget to change views isn’t ideal, but at least it offers the choice of views, unlike the alert notification table in the main web UI.
Doh, the widget doesn’t allow sort by hostname, so that’s not a great workaround after all :frowning: