Notify in details popup when critical issues happened in discovery task scan

This commit is contained in:
fbsanchez 2022-03-31 14:34:16 +02:00
parent 066ae12d43
commit 62172c19a2
3 changed files with 55 additions and 35 deletions

View File

@ -1192,7 +1192,7 @@ class DiscoveryTaskList extends HTML
*/
private function progressTaskGraph($task)
{
$result .= '<div class="flex">';
$result = '<div class="flex">';
$result .= '<div class="subtitle">';
$result .= '<span>'._('Overall Progress').'</span>';
@ -1317,6 +1317,9 @@ class DiscoveryTaskList extends HTML
if (is_array($task['stats']) === false) {
$task['stats'] = json_decode($task['summary'], true);
if (json_last_error() !== JSON_ERROR_NONE) {
return $task['summary'];
}
}
if (is_array($task['stats'])) {
@ -1379,31 +1382,35 @@ class DiscoveryTaskList extends HTML
$table->data[$i++][1] .= '</span>';
} else {
// Content.
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
$table->data[$i][1] = '<span id="discovered">';
$table->data[$i][1] .= $task['stats']['summary']['discovered'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
$table->data[$i][1] = '<span id="alive">';
$table->data[$i][1] .= $task['stats']['summary']['alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
$table->data[$i][1] = '<span id="not_alive">';
$table->data[$i][1] .= $task['stats']['summary']['not_alive'];
$table->data[$i++][1] .= '</span>';
if ($task['type'] == DISCOVERY_HOSTDEVICES) {
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
$table->data[$i][1] = '<span id="SNMP">';
$table->data[$i][1] .= $task['stats']['summary']['SNMP'];
if (is_array($task['stats']['summary']) === true) {
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
$table->data[$i][1] = '<span id="discovered">';
$table->data[$i][1] .= $task['stats']['summary']['discovered'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
$table->data[$i][1] = '<span id="WMI">';
$table->data[$i][1] .= $task['stats']['summary']['WMI'];
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
$table->data[$i][1] = '<span id="alive">';
$table->data[$i][1] .= $task['stats']['summary']['alive'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
$table->data[$i][1] = '<span id="not_alive">';
$table->data[$i][1] .= $task['stats']['summary']['not_alive'];
$table->data[$i++][1] .= '</span>';
if ($task['type'] == DISCOVERY_HOSTDEVICES) {
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
$table->data[$i][1] = '<span id="SNMP">';
$table->data[$i][1] .= $task['stats']['summary']['SNMP'];
$table->data[$i++][1] .= '</span>';
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
$table->data[$i][1] = '<span id="WMI">';
$table->data[$i][1] .= $task['stats']['summary']['WMI'];
$table->data[$i++][1] .= '</span>';
}
} else {
$table->data[$i][0] = $task['stats']['summary'];
}
}

View File

@ -228,13 +228,26 @@ function messages_process_read(
$utimestamp = time();
}
$already_read = db_get_value_filter(
'utimestamp_read',
'tnotification_user',
[
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
]
);
if (empty($already_read) === false) {
// Already read.
return true;
}
$ret = db_process_sql_update(
'tnotification_user',
['utimestamp_read' => $utimestamp],
[
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
'utimestamp_read' => null,
'id_mensaje' => $message_id,
'id_user' => $config['id_user'],
]
);
@ -585,13 +598,6 @@ function messages_get_overview_sent(
'tmensajes',
$filter
);
return db_get_all_rows_field_filter(
'tmensajes',
'id_usuario_origen',
$config['id_user'],
$order
);
}

View File

@ -1729,13 +1729,20 @@ sub PandoraFMS::Recon::Base::message($$$) {
my ($self, $message, $verbosity) = @_;
if ($verbosity <= 1) {
my $label = "[Discovery task " . $self->{'task_id'} . "]";
if (ref($self->{'task_data'}) eq 'HASH' && defined($self->{'task_data'}{'name'})) {
$label = "[Discovery task " . $self->{'task_data'}{'name'} . "]";
}
PandoraFMS::Core::send_console_notification(
$self->{'pa_config'},
$self->{'parent'}->getDBH(),
"[Recon task " . $self->{'task_id'} . "]",
$label,
$message,
['admin']
)
);
$self->{'summary'} = $message;
}
logger($self->{'pa_config'}, "[Recon task " . $self->{'task_id'} . "] $message", $verbosity);