Merge branch '38-no-funciona-event-alerts-sobre-alertas-de-snmp-traps-integria-4383-6' into 'pandora_6.0'

Alert in sound console with snmp alert events / 6 - #39

See merge request !292
This commit is contained in:
vgilc 2017-03-27 10:22:09 +02:00
commit 4bc04caa72
2 changed files with 54 additions and 35 deletions

View File

@ -132,7 +132,7 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
*
* @return mixed Return id if the group have any alert is fired or false is not.
*/
function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1=1') {
function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1=1', $agents = null) {
global $config;
$return = false;
@ -145,19 +145,38 @@ function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query =
else {
$temp = array();
foreach ($type as $item) {
$temp[] = '"' . $item . '"';
array_push ( $temp , $item );
}
$typeWhere = ' AND event_type IN (' . implode(',', $temp) . ')';
$typeWhere = ' AND event_type IN (';
foreach ($temp as $ele) {
$typeWhere .= "'".$ele."'";
if($ele != end($temp)){
$typeWhere .= ",";
}
}
$typeWhere .= ')';
}
if ($agents == null) {
$agents = agents_get_group_agents($idGroup, false, "lower", false);
$idAgents = array_keys($agents);
}
else {
$idAgents = array_values($agents);
}
$result = db_get_all_rows_sql('SELECT id_evento
FROM tevento
WHERE estado = 0 AND id_agente IN (' . implode(',', $idAgents) . ') ' . $typeWhere . $query . '
WHERE estado = 0 AND id_agente IN (0,' . implode(',', $idAgents) . ') ' . $typeWhere . $query . '
ORDER BY id_evento DESC LIMIT 1');
if ($result === false) {
@ -165,7 +184,7 @@ function alerts_get_event_status_group($idGroup, $type = "alert_fired", $query =
}
return $result[0]['id_evento'];
}
}
/**
* Insert in talert_commands a new command.

View File

@ -138,7 +138,7 @@ if (is_ajax ()) {
$alert = get_parameter('alert_fired');
if ($alert == 'true') {
$resultAlert = alerts_get_event_status_group($idGroup,
'alert_fired', $query);
array('alert_fired','alert_ceased'), $query);
}
$critical = get_parameter('critical');
if ($critical == 'true') {