feature: Notify about failed updates, block detectable bad updates (#7188)

* Feature: Notify about failed updates, block detectable bad updates
Ability to post notifications when the update fails.
Detect and roll back updates that will cause broken installs. (Needs testing)
Add severity to notifications, critical (2) notifications will display a toast.

This will be used for removing in-tree dependencies and raising the minimum php version.

* Improve naming a bit add phpdoc to new_notification
In case multiple notifications are created, remove them all.

* Remove notifications when update is disabled.

* update travis to use db testing

* added missing index
This commit is contained in:
Tony Murray
2017-08-26 15:35:39 -05:00
committed by Neil Lathwood
parent 932b05c38c
commit 0def643e09
8 changed files with 194 additions and 43 deletions

View File

@@ -8,8 +8,9 @@
$init_modules = array('alerts');
require __DIR__ . '/includes/init.php';
include_once __DIR__ . '/includes/notifications.php';
$options = getopt('f:d:o:');
$options = getopt('f:d:o:t:r:');
if (isset($options['d'])) {
echo "DEBUG\n";
@@ -97,8 +98,26 @@ if ($options['f'] === 'device_perf') {
}
}
if ($options['f'] === 'set_notification') {
if ($options['t'] === 'update') {
$title = 'Error: Daily update failed';
if ($options['r']) {
remove_notification($title);
} else {
new_notification(
$title,
'The daily update script (daily.sh) has failed. Please check output by hand. If you need assistance, '
. 'visit the <a href="https://www.librenms.org/#support">LibreNMS Website</a> to find out how.',
2,
'daily.sh'
);
}
}
}
if ($options['f'] === 'notifications') {
include_once 'includes/notifications.php';
post_notifications();
}
if ($options['f'] === 'bill_data') {