2017-07-23 19:56:22 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
2018-07-14 22:15:43 +01:00
|
|
|
$init_modules = ['alerts', 'alerts-cli'];
|
2017-07-23 19:56:22 +01:00
|
|
|
require __DIR__ . '/../includes/init.php';
|
|
|
|
|
|
|
|
$options = getopt('t:h:r:p:s:d::');
|
|
|
|
|
|
|
|
if ($options['r'] && $options['h']) {
|
2018-07-13 17:08:00 -05:00
|
|
|
set_debug(isset($options['d']));
|
|
|
|
|
2018-05-08 15:35:21 -05:00
|
|
|
$rule_id = (int)$options['r'];
|
2017-07-23 19:56:22 +01:00
|
|
|
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
2018-05-08 15:35:21 -05:00
|
|
|
$where = "alerts.device_id = $device_id && alerts.rule_id = $rule_id";
|
|
|
|
$alerts = loadAlerts($where);
|
|
|
|
if (empty($alerts)) {
|
2017-07-23 19:56:22 +01:00
|
|
|
echo "No active alert found, please check that you have the correct ids";
|
|
|
|
exit(2);
|
|
|
|
}
|
2018-05-08 15:35:21 -05:00
|
|
|
$alert = $alerts[0];
|
|
|
|
|
2017-07-23 19:56:22 +01:00
|
|
|
$alert['details']['delay'] = 0;
|
2018-07-14 22:15:43 +01:00
|
|
|
$alert['note'] = 'Testing';
|
2017-07-23 19:56:22 +01:00
|
|
|
IssueAlert($alert);
|
|
|
|
} else {
|
|
|
|
c_echo("
|
|
|
|
Info:
|
|
|
|
Use this to send an actual alert via transports that is currently active.
|
|
|
|
Usage:
|
|
|
|
-r Is the Rule ID.
|
|
|
|
-h Is the device ID or hostname
|
|
|
|
-d Debug
|
|
|
|
|
|
|
|
Example:
|
|
|
|
./scripts/test-alert.php -r 4 -d -h localhost
|
|
|
|
|
|
|
|
");
|
|
|
|
exit(1);
|
|
|
|
}
|