diff --git a/html/forms/test-transport.inc.php b/html/forms/test-transport.inc.php new file mode 100644 index 0000000000..121961ee07 --- /dev/null +++ b/html/forms/test-transport.inc.php @@ -0,0 +1,53 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if (is_admin() === false) { + die('ERROR: You need to be admin'); +} + +$transport = mres($_POST['transport']); + +$obj = array( + 'contacts' => $config['alert']['default_mail'], + 'title' => 'Testing transport from ' . $config['project_name'], + 'msg' => 'This is a test alert', + 'severity' => 'critical', + 'state' => 'critical', + 'hostname' => 'testing', + 'name' => 'Testing rule', +); + +unset($obj); +$obj['contacts'] = 'test'; +$obj['title'] = 'test'; +$obj['msg'] = 'test'; +$obj['severity'] = 'test'; +$obj['state'] = 'test'; +$obj['hostname'] = 'test'; +$obj['name'] = 'test'; + +$status = 'error'; + +if (file_exists($config['install_dir']."/includes/alerts/transport.$transport.php")) { + $opts = $config['alert']['transports'][$transport]; + if ($opts) { + eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' };'); + $tmp = $tmp($obj,$opts); + if ($tmp) { + $status = 'ok'; + } + } +} + +echo _json_encode(array('status' => $status)); diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php index 9282284eea..74ed2be549 100644 --- a/html/pages/settings/alerting.inc.php +++ b/html/pages/settings/alerting.inc.php @@ -263,7 +263,7 @@ echo '