Skip to content

Commit

Permalink
test-template.php fixed after librenms#8803 PR
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
PipoCanaja authored and laf committed Jul 16, 2018
1 parent 2f681a3 commit 2c26c08
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/test-template.php
@@ -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'];
Expand All @@ -20,13 +22,14 @@
}
$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:
Expand All @@ -37,7 +40,7 @@
-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
Expand Down

0 comments on commit 2c26c08

Please sign in to comment.