Added safe_output to server events
This commit is contained in:
parent
8fa33a2401
commit
f1cbaec98b
|
@ -525,7 +525,7 @@ Process an alert given the status returned by pandora_evaluate_alert.
|
|||
##########################################################################
|
||||
sub pandora_process_alert ($$$$$$$$;$) {
|
||||
my ($pa_config, $data, $agent, $module, $alert, $rc, $dbh, $timestamp, $extra_macros) = @_;
|
||||
|
||||
|
||||
if (defined ($agent)) {
|
||||
logger ($pa_config, "Processing alert '" . safe_output($alert->{'name'}) . "' for agent '" . safe_output($agent->{'nombre'}) . "': " . (defined ($AlertStatus[$rc]) ? $AlertStatus[$rc] : 'Unknown status') . ".", 10);
|
||||
}
|
||||
|
@ -565,12 +565,12 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||
# Generate an event
|
||||
if ($table eq 'tevent_alert') {
|
||||
pandora_event ($pa_config, "Alert ceased (" .
|
||||
$alert->{'name'} . ")", 0, 0, $alert->{'priority'}, $id,
|
||||
safe_output($alert->{'name'}) . ")", 0, 0, $alert->{'priority'}, $id,
|
||||
(defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0),
|
||||
"alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions);
|
||||
} else {
|
||||
pandora_event ($pa_config, "Alert ceased (" .
|
||||
$alert->{'name'} . ")", $agent->{'id_grupo'},
|
||||
safe_output($alert->{'name'}) . ")", $agent->{'id_grupo'},
|
||||
$agent->{'id_agente'}, $alert->{'priority'}, $id,
|
||||
(defined ($alert->{'id_agent_module'}) ? $alert->{'id_agent_module'} : 0),
|
||||
"alert_ceased", 0, $dbh, 'Pandora', '', '', '', '', $critical_instructions, $warning_instructions, $unknown_instructions);
|
||||
|
@ -1611,9 +1611,8 @@ sub pandora_planned_downtime_disabled_once_stop($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
|
||||
pandora_event ($pa_config,
|
||||
'(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . $downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
'(Created by ' . $downtime->{'id_user'} . ') Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
pandora_planned_downtime_unset_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
|
@ -1658,8 +1657,9 @@ sub pandora_planned_downtime_disabled_once_start($$) {
|
|||
SET executed = 1
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
|
||||
print"pandora_planned_downtime_disabled_once_start\n";
|
||||
pandora_event ($pa_config,
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
pandora_planned_downtime_set_disabled_elements($pa_config,
|
||||
$dbh, $downtime);
|
||||
|
@ -1849,7 +1849,7 @@ sub pandora_planned_downtime_quiet_once_stop($$) {
|
|||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
pandora_event ($pa_config,
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
|
@ -1890,8 +1890,9 @@ sub pandora_planned_downtime_quiet_once_start($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
print"pandora_planned_downtime_quiet_once_start\n";
|
||||
pandora_event ($pa_config,
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"(Created by " . $downtime->{'id_user'} . ") Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
pandora_planned_downtime_set_quiet_elements($pa_config,
|
||||
$dbh, $downtime->{'id'});
|
||||
|
@ -1944,8 +1945,9 @@ sub pandora_planned_downtime_monthly_start($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
print"pandora_planned_downtime_monthly_start\n";
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
|
@ -2020,8 +2022,9 @@ sub pandora_planned_downtime_monthly_stop($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
print"pandora_planned_downtime_monthly_stop\n";
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
|
@ -2129,8 +2132,9 @@ sub pandora_planned_downtime_weekly_start($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 1
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
print"pandora_planned_downtime_weekly_start\n";
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"Server ".$pa_config->{'servername'}." started planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_set_quiet_elements($pa_config,
|
||||
|
@ -2243,8 +2247,10 @@ sub pandora_planned_downtime_weekly_stop($$) {
|
|||
db_do($dbh, 'UPDATE tplanned_downtime
|
||||
SET executed = 0
|
||||
WHERE id = ?', $downtime->{'id'});
|
||||
|
||||
print"pandora_planned_downtime_weekly_stop\n";
|
||||
pandora_event ($pa_config,
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".$downtime->{'name'}, 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
"Server ".$pa_config->{'servername'}." stopped planned downtime: ".safe_output($downtime->{'name'}), 0, 0, 1, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
if ($downtime->{'type_downtime'} eq "quiet") {
|
||||
pandora_planned_downtime_unset_quiet_elements($pa_config,
|
||||
|
@ -2974,7 +2980,7 @@ sub pandora_create_agent ($$$$$$$$$$;$$$$$$$$$) {
|
|||
}
|
||||
|
||||
logger ($pa_config, "Server '$server_name' CREATED agent '$agent_name' address '$address'.", 10);
|
||||
pandora_event ($pa_config, "Agent [$alias] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
|
||||
pandora_event ($pa_config, "Agent [" . safe_output($alias) . "] created by $server_name", $group_id, $agent_id, 2, 0, 0, 'new_agent', 0, $dbh);
|
||||
return $agent_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -333,19 +333,22 @@ sub process_xml_data ($$$$$) {
|
|||
if (defined ($data->{'group_id'}) && $data->{'group_id'} ne '') {
|
||||
$group_id = $data->{'group_id'};
|
||||
if (! defined (get_group_name ($dbh, $group_id))) {
|
||||
pandora_event ($pa_config, "Unable to create agent '$agent_name': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
print "UNABLE GROUP ID\n";
|
||||
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group ID '" . $group_id . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
logger($pa_config, "Group ID " . $group_id . " does not exist.", 3);
|
||||
return;
|
||||
}
|
||||
} elsif (defined ($data->{'group'}) && $data->{'group'} ne '') {
|
||||
$group_id = get_group_id ($dbh, $data->{'group'});
|
||||
if (! defined (get_group_name ($dbh, $group_id))) {
|
||||
pandora_event ($pa_config, "Unable to create agent '$agent_name': group '" . $data->{'group'} . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
print "UNABLE GROUP\n";
|
||||
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': group '" . safe_output($data->{'group'}) . "' does not exist.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
logger($pa_config, "Group " . $data->{'group'} . " does not exist.", 3);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pandora_event ($pa_config, "Unable to create agent '$agent_name': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
print "UNABLE AUTOCREATE\n";
|
||||
pandora_event ($pa_config, "Unable to create agent '" . safe_output($agent_name) . "': autocreate_group $group_id does not exist. Edit the pandora_server.conf file and change it.", 0, 0, 0, 0, 0, 'error', 0, $dbh);
|
||||
logger($pa_config, "Group id $group_id does not exist (check autocreate_group config token).", 3);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
|
||||
$agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, $self->{'group_id'}, 0, $id_os, '', 300, $self->{'dbh'});
|
||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||
pandora_event($self->{'pa_config'}, "[RECON] New " . $self->get_device_type($device) . " found (" . join(',', $self->get_addresses($device)) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
|
||||
pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
|
||||
$agent_learning = 1;
|
||||
|
||||
# Create network profile modules for the agent
|
||||
|
|
Loading…
Reference in New Issue