mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
test-template.php fixed after #8803 PR
Hello Following this post, ( https://community.librenms.org/t/bug-test-template-php-not-running-after-laravel-upgrade/4639/9 ), here is the PR. PipoCanaja DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [X] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
committed by
Neil Lathwood
parent
2f681a3df3
commit
2c26c08020
@@ -1,12 +1,14 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$init_modules = array('alerts');
|
||||
$init_modules = ['alerts', 'alerts-cli'];
|
||||
require __DIR__ . '/../includes/init.php';
|
||||
|
||||
use LibreNMS\Alert\Template;
|
||||
|
||||
$options = getopt('t:h:r:p:s:d::');
|
||||
|
||||
if ($options['t'] && $options['h'] && $options['r']) {
|
||||
if (isset($options['t']) && isset($options['h']) && isset($options['r'])) {
|
||||
set_debug(isset($options['d']));
|
||||
|
||||
$template_id = $options['t'];
|
||||
@@ -20,13 +22,14 @@ if ($options['t'] && $options['h'] && $options['r']) {
|
||||
}
|
||||
$alert['details'] = json_decode(gzuncompress($alert['details']), true);
|
||||
$obj = DescribeAlert($alert);
|
||||
$obj['template'] = dbFetchCell('SELECT `template` FROM `alert_templates` WHERE `id`=?', array($template_id));
|
||||
if (isset($options['p'])) {
|
||||
$obj['transport'] = $options['p'];
|
||||
}
|
||||
d_echo($obj);
|
||||
$ack = FormatAlertTpl($obj);
|
||||
print_r($ack);
|
||||
$type = new Template;
|
||||
$obj['title'] = $type->getTitle($obj);
|
||||
$obj['msg'] = $type->getBody($obj);
|
||||
unset($obj['template']);
|
||||
print_r($obj);
|
||||
} else {
|
||||
c_echo("
|
||||
Usage:
|
||||
@@ -37,7 +40,7 @@ Usage:
|
||||
-s Is the alert state <0|1|2|3|4> (optional - defaults to current state.)
|
||||
0 = ok, 1 = alert, 2 = acknowledged, 3 = got worse, 4 = got better
|
||||
-d Debug
|
||||
|
||||
|
||||
Example:
|
||||
./scripts/test-template.php -t 10 -d -h localhost -r 2 -p mail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user