Merge branch 'ent-7527-problemas-pandora_revent' into 'develop'
Fixed issues with https calls Closes pandora_enterprise#7527 See merge request artica/pandorafms!4128
This commit is contained in:
commit
22fa755fc3
|
@ -3,7 +3,7 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
# Pandora FMS - Remote Event Tool (via WEB API)
|
# Pandora FMS - Remote Event Tool (via WEB API)
|
||||||
########################################################################
|
########################################################################
|
||||||
# Copyright (c) 2013 Artica Soluciones Tecnologicas S.L
|
# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License version 2
|
# modify it under the terms of the GNU General Public License version 2
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
# Includes list
|
# Includes list
|
||||||
use strict;
|
use strict;
|
||||||
use LWP::Simple;
|
use LWP::Simple;
|
||||||
|
use LWP::UserAgent;
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
use lib '/usr/lib/perl5';
|
use lib '/usr/lib/perl5';
|
||||||
use PandoraFMS::Tools;
|
use PandoraFMS::Tools;
|
||||||
|
@ -32,40 +33,41 @@ sub help_screen{
|
||||||
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
|
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
|
||||||
|
|
||||||
Where options:\n
|
Where options:\n
|
||||||
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
|
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
|
||||||
-name <event_name> : Free text
|
-name <event_name> : Free text (surrounded by single-quotes, for security reasons)
|
||||||
-group <id_group> : Group ID (use 0 for 'all')
|
-group <id_group> : Group ID (use 0 for 'all')
|
||||||
-agent : Agent ID
|
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
|
|
||||||
[-status <status>] : 0 New, 1 Validated, 2 In process
|
[-agent <id_agent] : Agent ID
|
||||||
[-user <id_user>] : User comment (use in combination with -comment option)
|
[-status <status>] : 0 New, 1 Validated, 2 In process
|
||||||
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
|
[-user <id_user>] : User comment (use in combination with -comment option)
|
||||||
|
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
|
||||||
alert_manual_validation, system, error, new_agent
|
alert_manual_validation, system, error, new_agent
|
||||||
configuration_change, going_unknown, going_down_critical,
|
configuration_change, going_unknown, going_down_critical,
|
||||||
going_down_warning, going_up_normal
|
going_down_warning, going_up_normal
|
||||||
[-severity <severity>] : 0 Maintance,
|
[-severity <severity>] : 0 Maintance,
|
||||||
1 Informative,
|
1 Informative,
|
||||||
2 Normal,
|
2 Normal,
|
||||||
3 Warning,
|
3 Warning,
|
||||||
4 Crit,
|
4 Crit,
|
||||||
5 Minor,
|
5 Minor,
|
||||||
6 Major
|
6 Major
|
||||||
[-am <id_agent_module>] : ID Agent Module linked to event
|
[-am <id_agent_module>] : ID Agent Module linked to event
|
||||||
[-alert <id_alert_am>] : ID Alert Module linked to event
|
[-alert <id_alert_am>] : ID Alert Module linked to event
|
||||||
[-c_instructions <critical_instructions>]
|
[-c_instructions <critical_instructions>]
|
||||||
[-w_instructions <warning_instructions>]
|
[-w_instructions <warning_instructions>]
|
||||||
[-u_instructions <unknown_instructions>]
|
[-u_instructions <unknown_instructions>]
|
||||||
[-user_comment <comment>]
|
[-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
|
||||||
[-owner_user <owner event>] : Use the login name, not the descriptive
|
[-owner_user <owner event>] : Use the login name, not the descriptive
|
||||||
[-source <source>] : (By default 'Pandora')
|
[-source <source>] : (By default 'Pandora')
|
||||||
[-tag <tags>] : Tag (must exist in the system to be imported)
|
[-tag <tags>] : Tag (must exist in the system to be imported)
|
||||||
[-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
|
[-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
|
||||||
[-id_extra <id extra>] : Id extra
|
[-id_extra <id extra>] : Id extra
|
||||||
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
|
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
|
||||||
[-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1.
|
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
|
||||||
[-server_id <server_id>] : The pandora node server_id\n\n";
|
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
|
||||||
|
[-server_id <server_id>] : The pandora node server_id\n\n";
|
||||||
|
|
||||||
print "Example of event generation:\n\n";
|
print "Example of event generation:\n\n";
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ Optional parameters:
|
||||||
##############################################################################
|
##############################################################################
|
||||||
sub tool_api_init () {
|
sub tool_api_init () {
|
||||||
|
|
||||||
print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2015 Artica ST\n";
|
print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2021 Artica ST\n";
|
||||||
print "This program is Free Software, licensed under the terms of GPL License v2\n";
|
print "This program is Free Software, licensed under the terms of GPL License v2\n";
|
||||||
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
|
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ sub tool_api_main () {
|
||||||
my $db_user;
|
my $db_user;
|
||||||
my $db_pass;
|
my $db_pass;
|
||||||
my @db_info;
|
my @db_info;
|
||||||
my $id_agent;
|
my $id_agent = '0';
|
||||||
my $id_user = '';
|
my $id_user = '';
|
||||||
my $status = '';
|
my $status = '';
|
||||||
my $id_agent_module = '';
|
my $id_agent_module = '';
|
||||||
|
@ -141,6 +143,7 @@ sub tool_api_main () {
|
||||||
my $call_api;
|
my $call_api;
|
||||||
my $custom_data = "";
|
my $custom_data = "";
|
||||||
my $server_id = 0;
|
my $server_id = 0;
|
||||||
|
my $separator = '|';
|
||||||
|
|
||||||
#~ help or api path (required)
|
#~ help or api path (required)
|
||||||
if ($ARGV[0] eq '-h') {
|
if ($ARGV[0] eq '-h') {
|
||||||
|
@ -185,12 +188,18 @@ sub tool_api_main () {
|
||||||
|
|
||||||
if ($line eq '-agent') {
|
if ($line eq '-agent') {
|
||||||
$id_agent = $ARGV[$i + 1];
|
$id_agent = $ARGV[$i + 1];
|
||||||
|
# If not defined, send 0 for API.
|
||||||
|
if ($id_agent eq undef) {
|
||||||
|
$id_agent = '0';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($line eq '-group') {
|
if ($line eq '-group') {
|
||||||
$id_group = $ARGV[$i + 1];
|
$id_group = $ARGV[$i + 1];
|
||||||
}
|
}
|
||||||
if ($line eq '-name') {
|
if ($line eq '-name') {
|
||||||
$event_name = $ARGV[$i + 1];
|
$event_name = $ARGV[$i + 1];
|
||||||
|
$event_name =~ s/#/%23/g;
|
||||||
}
|
}
|
||||||
if ($line eq '-type') {
|
if ($line eq '-type') {
|
||||||
$event_type = $ARGV[$i + 1];
|
$event_type = $ARGV[$i + 1];
|
||||||
|
@ -250,50 +259,49 @@ sub tool_api_main () {
|
||||||
if ($line eq '-server_id') {
|
if ($line eq '-server_id') {
|
||||||
$server_id = $ARGV[$i + 1];
|
$server_id = $ARGV[$i + 1];
|
||||||
}
|
}
|
||||||
|
if ($line eq '-separator') {
|
||||||
|
$separator = $ARGV[$i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_name eq "") {
|
if ($event_name eq "") {
|
||||||
print "[ERROR] Missing id agent! Read help info:\n\n";
|
print "[ERROR] Missing event name! Read help info:\n\n";
|
||||||
help_screen ();
|
help_screen ();
|
||||||
}
|
}
|
||||||
if ($id_group eq "") {
|
if ($id_group eq "") {
|
||||||
print "[ERROR] Missing event group! Read help info:\n\n";
|
print "[ERROR] Missing event group! Read help info:\n\n";
|
||||||
help_screen ();
|
help_screen ();
|
||||||
}
|
}
|
||||||
if ($id_agent eq "" && $agent_name eq "") {
|
|
||||||
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
|
|
||||||
help_screen ();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_event = $event_name .
|
$data_event = $event_name .
|
||||||
"|" . $id_group .
|
$separator . $id_group .
|
||||||
"|" . $id_agent .
|
$separator . $id_agent .
|
||||||
"|" . $status .
|
$separator . $status .
|
||||||
"|" . $id_user .
|
$separator . $id_user .
|
||||||
"|" . $event_type .
|
$separator . $event_type .
|
||||||
"|" . $severity .
|
$separator . $severity .
|
||||||
"|" . $id_agent_module .
|
$separator . $id_agent_module .
|
||||||
"|" . $id_alert_am .
|
$separator . $id_alert_am .
|
||||||
"|" . $critical_instructions .
|
$separator . $critical_instructions .
|
||||||
"|" . $warning_instructions .
|
$separator . $warning_instructions .
|
||||||
"|" . $unknown_instructions .
|
$separator . $unknown_instructions .
|
||||||
"|" . $user_comment .
|
$separator . $user_comment .
|
||||||
"|" . $owner_user .
|
$separator . $owner_user .
|
||||||
"|" . $source .
|
$separator . $source .
|
||||||
"|" . $tags .
|
$separator . $tags .
|
||||||
"|" . $custom_data .
|
$separator . $custom_data .
|
||||||
"|" . $server_id .
|
$separator . $server_id .
|
||||||
"|" . $id_extra .
|
$separator . $id_extra .
|
||||||
"|" . $agent_name .
|
$separator . $agent_name .
|
||||||
"|" . $force_create_agent;
|
$separator . $force_create_agent;
|
||||||
|
|
||||||
$call_api = $api_path . '?' .
|
$call_api = $api_path . '?' .
|
||||||
'op=set&' .
|
'op=set&' .
|
||||||
'op2=create_event&' .
|
'op2=create_event&' .
|
||||||
'other=' . $data_event .'&' .
|
'other=' . $data_event .'&' .
|
||||||
'other_mode=url_encode_separator_|&' .
|
'other_mode=url_encode_separator_'.$separator.'&' .
|
||||||
'apipass=' . $api_pass . '&' .
|
'apipass=' . $api_pass . '&' .
|
||||||
'user=' . $db_user . '&' .
|
'user=' . $db_user . '&' .
|
||||||
'pass=' . $db_pass;
|
'pass=' . $db_pass;
|
||||||
|
@ -321,7 +329,8 @@ sub tool_api_main () {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $content = get($call_api);
|
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
|
||||||
|
my $content = $ua->get($call_api);
|
||||||
|
|
||||||
if ($option eq '-create_event') {
|
if ($option eq '-create_event') {
|
||||||
if ($content eq undef) {
|
if ($content eq undef) {
|
||||||
|
@ -329,7 +338,7 @@ sub tool_api_main () {
|
||||||
help_screen();
|
help_screen();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Event ID: $content";
|
print "Event ID: $content->{'_content'}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($option eq '-validate_event') {
|
elsif ($option eq '-validate_event') {
|
||||||
|
|
|
@ -12818,8 +12818,10 @@ function api_set_create_event($id, $trash1, $other, $returnType)
|
||||||
|
|
||||||
$error_msg = '';
|
$error_msg = '';
|
||||||
if ($other['data'][2] != '') {
|
if ($other['data'][2] != '') {
|
||||||
|
// Id agent assignment. If come from pandora_revent, id_agent can be 0.
|
||||||
$id_agent = $other['data'][2];
|
$id_agent = $other['data'][2];
|
||||||
if (is_metaconsole()) {
|
// To the next if is metaconsole and id_agent is not none.
|
||||||
|
if (is_metaconsole() === true && $id_agent > 0) {
|
||||||
// On metaconsole, connect with the node to check the permissions
|
// On metaconsole, connect with the node to check the permissions
|
||||||
if (empty($values['server_id'])) {
|
if (empty($values['server_id'])) {
|
||||||
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
|
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
|
||||||
|
@ -12842,7 +12844,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
|
||||||
|
|
||||||
$values['id_agente'] = $id_agent;
|
$values['id_agente'] = $id_agent;
|
||||||
|
|
||||||
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) {
|
if ((int) $id_agent > 0 && util_api_check_agent_and_print_error($id_agent, 'string', 'AR') === false) {
|
||||||
if (is_metaconsole()) {
|
if (is_metaconsole()) {
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
# Pandora FMS - Remote Event Tool (via WEB API)
|
# Pandora FMS - Remote Event Tool (via WEB API)
|
||||||
########################################################################
|
########################################################################
|
||||||
# Copyright (c) 2013-2021 Artica Soluciones Tecnologicas S.L
|
# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License version 2
|
# modify it under the terms of the GNU General Public License version 2
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
# Includes list
|
# Includes list
|
||||||
use strict;
|
use strict;
|
||||||
use LWP::Simple;
|
use LWP::Simple;
|
||||||
|
use LWP::UserAgent;
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
use lib '/usr/lib/perl5';
|
use lib '/usr/lib/perl5';
|
||||||
use PandoraFMS::Tools;
|
use PandoraFMS::Tools;
|
||||||
|
@ -32,40 +33,41 @@ sub help_screen{
|
||||||
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
|
\t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options>
|
||||||
|
|
||||||
Where options:\n
|
Where options:\n
|
||||||
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
|
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
|
||||||
-name <event_name> : Free text
|
-name <event_name> : Free text (surrounded by single-quotes, for security reasons)
|
||||||
-group <id_group> : Group ID (use 0 for 'all')
|
-group <id_group> : Group ID (use 0 for 'all')
|
||||||
-agent : Agent ID
|
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
|
|
||||||
[-status <status>] : 0 New, 1 Validated, 2 In process
|
[-agent <id_agent] : Agent ID
|
||||||
[-user <id_user>] : User comment (use in combination with -comment option)
|
[-status <status>] : 0 New, 1 Validated, 2 In process
|
||||||
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
|
[-user <id_user>] : User comment (use in combination with -comment option)
|
||||||
|
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
|
||||||
alert_manual_validation, system, error, new_agent
|
alert_manual_validation, system, error, new_agent
|
||||||
configuration_change, going_unknown, going_down_critical,
|
configuration_change, going_unknown, going_down_critical,
|
||||||
going_down_warning, going_up_normal
|
going_down_warning, going_up_normal
|
||||||
[-severity <severity>] : 0 Maintance,
|
[-severity <severity>] : 0 Maintance,
|
||||||
1 Informative,
|
1 Informative,
|
||||||
2 Normal,
|
2 Normal,
|
||||||
3 Warning,
|
3 Warning,
|
||||||
4 Crit,
|
4 Crit,
|
||||||
5 Minor,
|
5 Minor,
|
||||||
6 Major
|
6 Major
|
||||||
[-am <id_agent_module>] : ID Agent Module linked to event
|
[-am <id_agent_module>] : ID Agent Module linked to event
|
||||||
[-alert <id_alert_am>] : ID Alert Module linked to event
|
[-alert <id_alert_am>] : ID Alert Module linked to event
|
||||||
[-c_instructions <critical_instructions>]
|
[-c_instructions <critical_instructions>]
|
||||||
[-w_instructions <warning_instructions>]
|
[-w_instructions <warning_instructions>]
|
||||||
[-u_instructions <unknown_instructions>]
|
[-u_instructions <unknown_instructions>]
|
||||||
[-user_comment <comment>]
|
[-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
|
||||||
[-owner_user <owner event>] : Use the login name, not the descriptive
|
[-owner_user <owner event>] : Use the login name, not the descriptive
|
||||||
[-source <source>] : (By default 'Pandora')
|
[-source <source>] : (By default 'Pandora')
|
||||||
[-tag <tags>] : Tag (must exist in the system to be imported)
|
[-tag <tags>] : Tag (must exist in the system to be imported)
|
||||||
[-custom_data <custom_data>]: Custom data should be a base 64 encoded JSON document example -custom_data \'{\"test1\" : 1, \"test2\": 2}\'
|
[-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
|
||||||
[-id_extra <id extra>] : Id extra
|
[-id_extra <id extra>] : Id extra
|
||||||
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
|
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
|
||||||
[-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1.
|
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
|
||||||
[-server_id <server_id>] : The pandora node server_id\n\n";
|
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
|
||||||
|
[-server_id <server_id>] : The pandora node server_id\n\n";
|
||||||
|
|
||||||
print "Example of event generation:\n\n";
|
print "Example of event generation:\n\n";
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ sub tool_api_main () {
|
||||||
my $db_user;
|
my $db_user;
|
||||||
my $db_pass;
|
my $db_pass;
|
||||||
my @db_info;
|
my @db_info;
|
||||||
my $id_agent;
|
my $id_agent = '0';
|
||||||
my $id_user = '';
|
my $id_user = '';
|
||||||
my $status = '';
|
my $status = '';
|
||||||
my $id_agent_module = '';
|
my $id_agent_module = '';
|
||||||
|
@ -141,6 +143,7 @@ sub tool_api_main () {
|
||||||
my $call_api;
|
my $call_api;
|
||||||
my $custom_data = "";
|
my $custom_data = "";
|
||||||
my $server_id = 0;
|
my $server_id = 0;
|
||||||
|
my $separator = '|';
|
||||||
|
|
||||||
#~ help or api path (required)
|
#~ help or api path (required)
|
||||||
if ($ARGV[0] eq '-h') {
|
if ($ARGV[0] eq '-h') {
|
||||||
|
@ -185,12 +188,18 @@ sub tool_api_main () {
|
||||||
|
|
||||||
if ($line eq '-agent') {
|
if ($line eq '-agent') {
|
||||||
$id_agent = $ARGV[$i + 1];
|
$id_agent = $ARGV[$i + 1];
|
||||||
|
# If not defined, send 0 for API.
|
||||||
|
if ($id_agent eq undef) {
|
||||||
|
$id_agent = '0';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($line eq '-group') {
|
if ($line eq '-group') {
|
||||||
$id_group = $ARGV[$i + 1];
|
$id_group = $ARGV[$i + 1];
|
||||||
}
|
}
|
||||||
if ($line eq '-name') {
|
if ($line eq '-name') {
|
||||||
$event_name = $ARGV[$i + 1];
|
$event_name = $ARGV[$i + 1];
|
||||||
|
$event_name =~ s/#/%23/g;
|
||||||
}
|
}
|
||||||
if ($line eq '-type') {
|
if ($line eq '-type') {
|
||||||
$event_type = $ARGV[$i + 1];
|
$event_type = $ARGV[$i + 1];
|
||||||
|
@ -250,50 +259,49 @@ sub tool_api_main () {
|
||||||
if ($line eq '-server_id') {
|
if ($line eq '-server_id') {
|
||||||
$server_id = $ARGV[$i + 1];
|
$server_id = $ARGV[$i + 1];
|
||||||
}
|
}
|
||||||
|
if ($line eq '-separator') {
|
||||||
|
$separator = $ARGV[$i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event_name eq "") {
|
if ($event_name eq "") {
|
||||||
print "[ERROR] Missing id agent! Read help info:\n\n";
|
print "[ERROR] Missing event name! Read help info:\n\n";
|
||||||
help_screen ();
|
help_screen ();
|
||||||
}
|
}
|
||||||
if ($id_group eq "") {
|
if ($id_group eq "") {
|
||||||
print "[ERROR] Missing event group! Read help info:\n\n";
|
print "[ERROR] Missing event group! Read help info:\n\n";
|
||||||
help_screen ();
|
help_screen ();
|
||||||
}
|
}
|
||||||
if ($id_agent eq "" && $agent_name eq "") {
|
|
||||||
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
|
|
||||||
help_screen ();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_event = $event_name .
|
$data_event = $event_name .
|
||||||
"|" . $id_group .
|
$separator . $id_group .
|
||||||
"|" . $id_agent .
|
$separator . $id_agent .
|
||||||
"|" . $status .
|
$separator . $status .
|
||||||
"|" . $id_user .
|
$separator . $id_user .
|
||||||
"|" . $event_type .
|
$separator . $event_type .
|
||||||
"|" . $severity .
|
$separator . $severity .
|
||||||
"|" . $id_agent_module .
|
$separator . $id_agent_module .
|
||||||
"|" . $id_alert_am .
|
$separator . $id_alert_am .
|
||||||
"|" . $critical_instructions .
|
$separator . $critical_instructions .
|
||||||
"|" . $warning_instructions .
|
$separator . $warning_instructions .
|
||||||
"|" . $unknown_instructions .
|
$separator . $unknown_instructions .
|
||||||
"|" . $user_comment .
|
$separator . $user_comment .
|
||||||
"|" . $owner_user .
|
$separator . $owner_user .
|
||||||
"|" . $source .
|
$separator . $source .
|
||||||
"|" . $tags .
|
$separator . $tags .
|
||||||
"|" . $custom_data .
|
$separator . $custom_data .
|
||||||
"|" . $server_id .
|
$separator . $server_id .
|
||||||
"|" . $id_extra .
|
$separator . $id_extra .
|
||||||
"|" . $agent_name .
|
$separator . $agent_name .
|
||||||
"|" . $force_create_agent;
|
$separator . $force_create_agent;
|
||||||
|
|
||||||
$call_api = $api_path . '?' .
|
$call_api = $api_path . '?' .
|
||||||
'op=set&' .
|
'op=set&' .
|
||||||
'op2=create_event&' .
|
'op2=create_event&' .
|
||||||
'other=' . $data_event .'&' .
|
'other=' . $data_event .'&' .
|
||||||
'other_mode=url_encode_separator_|&' .
|
'other_mode=url_encode_separator_'.$separator.'&' .
|
||||||
'apipass=' . $api_pass . '&' .
|
'apipass=' . $api_pass . '&' .
|
||||||
'user=' . $db_user . '&' .
|
'user=' . $db_user . '&' .
|
||||||
'pass=' . $db_pass;
|
'pass=' . $db_pass;
|
||||||
|
@ -321,13 +329,8 @@ sub tool_api_main () {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#-----------DEBUG----------------------------
|
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
|
||||||
#print($call_api . "\n\n\n");
|
my $content = $ua->get($call_api);
|
||||||
|
|
||||||
my $content = get($call_api);
|
|
||||||
|
|
||||||
#-----------DEBUG----------------------------
|
|
||||||
#print($content . "\n\n\n");
|
|
||||||
|
|
||||||
if ($option eq '-create_event') {
|
if ($option eq '-create_event') {
|
||||||
if ($content eq undef) {
|
if ($content eq undef) {
|
||||||
|
@ -335,7 +338,7 @@ sub tool_api_main () {
|
||||||
help_screen();
|
help_screen();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Event ID: $content";
|
print "Event ID: $content->{'_content'}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($option eq '-validate_event') {
|
elsif ($option eq '-validate_event') {
|
||||||
|
|
Loading…
Reference in New Issue