Added more debug to alerting capture (#4727)

This commit is contained in:
Neil Lathwood
2016-10-14 02:14:02 +01:00
committed by Tony Murray
parent d5ba013a8a
commit eab4ae5ab5
2 changed files with 26 additions and 2 deletions

View File

@@ -50,6 +50,28 @@ switch ($type) {
$output .= 'Alert rule: ' . $rule['rule'] . PHP_EOL;
$output .= 'Rule match: ' . $response . PHP_EOL . PHP_EOL;
}
if ($config['alert']['transports']['mail'] === true) {
$contacts = GetContacts($rules);
if (count($contacts) > 0) {
$output .= 'Found ' . count(contacts) . ' contacts to send alerts to.' . PHP_EOL;
}
foreach ($contacts as $email => $name) {
$output .= $name . '<' . $email . '>' . PHP_EOL;
}
$output .= PHP_EOL;
}
$transports = '';
$x = 0;
foreach ($config['alert']['transports'] as $name => $v) {
if ($config['alert']['transports'][$name] === true) {
$transports .= 'Transport: ' . $name . PHP_EOL;
$x++;
}
}
if (!empty($transports)) {
$output .= 'Found ' . $x . ' transports to send alerts to.' . PHP_EOL;
$output .= $transports;
}
break;
default:
echo 'You must specify a valid type';

View File

@@ -225,7 +225,7 @@ function GetContacts($results)
if (sizeof($results) == 0) {
return array();
}
if ($config['alert']['default_only'] == true || $config['alerts']['email']['default_only'] == true) {
if ($config['alert']['default_only'] === true || $config['alerts']['email']['default_only'] === true) {
return array(''.($config['alert']['default_mail'] ? $config['alert']['default_mail'] : $config['alerts']['email']['default']) => 'NOC');
}
$users = get_userlist();
@@ -252,7 +252,9 @@ function GetContacts($results)
} else {
$tmpa = dbFetchCell("SELECT sysContact FROM devices WHERE device_id = ?", array($result["device_id"]));
}
$contacts[$tmpa] = "NOC";
if (!empty($tmpa)) {
$contacts[$tmpa] = "NOC";
}
}
$tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"]));
foreach ($tmpa as $tmp) {