Fix alert and template test scripts (#10464)

This commit is contained in:
Tony Murray
2019-07-26 20:31:47 -05:00
committed by GitHub
parent 6394c35ce6
commit 9c8782a7da
2 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
use LibreNMS\Alert\RunAlerts;
$init_modules = ['alerts', 'laravel'];
require __DIR__ . '/../includes/init.php';
@@ -8,11 +10,12 @@ $options = getopt('t:h:r:p:s:d::');
if (isset($options['r']) && isset($options['h'])) {
set_debug(isset($options['d']));
$runAlerts = new RunAlerts();
$rule_id = (int)$options['r'];
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
$where = "alerts.device_id = $device_id && alerts.rule_id = $rule_id";
$alerts = loadAlerts($where);
$alerts = $runAlerts->loadAlerts($where);
if (empty($alerts)) {
echo "No active alert found, please check that you have the correct ids";
exit(2);
@@ -21,7 +24,7 @@ if (isset($options['r']) && isset($options['h'])) {
$alert['details']['delay'] = 0;
$alert['note'] = 'Testing';
IssueAlert($alert);
$runAlerts->issueAlert($alert);
} else {
c_echo("
Info: