From 3ffab90a421548ff25d17f9c98c6bc30351cfaa9 Mon Sep 17 00:00:00 2001 From: vgilc Date: Fri, 10 Feb 2012 09:30:21 +0000 Subject: [PATCH] 2012-02-10 Vanessa Gil * util/pandora_manage.pl: Added new Event validate given id. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5545 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 4 +++ pandora_server/util/pandora_manage.pl | 35 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index b5215c0f80..39e19c1ba3 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2012-02-10 Vanessa Gil + + * util/pandora_manage.pl: Added new Event validate given id. + 2012-02-07 Ramon Novoa * lib/PandoraFMS/Core.pm: Added new SNMP alert fields and macros. diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b3ba4c310a..cc93115def 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -131,6 +131,7 @@ sub help_screen{ print "EVENTS:\n\n" unless $param ne ''; help_screen_line('--create_event', ' [ ]', 'Add event'); help_screen_line('--validate_event', ' ', 'Validate events'); + help_screen_line('--validate_event_id', '', 'Validate event given a event id'); print "INCIDENTS:\n\n" unless $param ne ''; help_screen_line('--create_incident', ' <description> <origin> <status> <priority 0 for Informative, 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance> <group> [<owner>]', 'Create incidents'); print "POLICIES:\n\n" unless $param ne ''; @@ -424,6 +425,21 @@ sub pandora_validate_event_filter ($$$$$$$$$) { db_do ($dbh, "UPDATE tevento SET estado = 1 WHERE estado = 0".$filter); } +########################################################################## +# Validate event given a event id +########################################################################## +sub pandora_validate_event_id ($$$) { + my ($pa_config, $id_event, $dbh) = @_; + my $filter = ''; + + if ($id_event ne ''){ + $filter .= " AND id_evento = $id_event"; + } + + logger($pa_config, "Validating events", 10); + db_do ($dbh, "UPDATE tevento SET estado = 1 WHERE estado = 0".$filter); +} + ########################################################################## ## Update a user from hash ########################################################################## @@ -2334,6 +2350,21 @@ sub cli_validate_event() { print "[INFO] Validating event for agent '$agent_name'\n\n"; } +############################################################################## +# Validate event. +# Related option: --validate_event_id +############################################################################## + +sub cli_validate_event_id() { + my $id_event = @ARGV[2]; + + print "[INFO] Validating event '$id_event'\n\n"; + + my $result = pandora_validate_event_id ($conf, $id_event, $dbh); + exist_check($result,'event',$id_event); + +} + ############################################################################## # Create incident. # Related option: --create_incident @@ -3149,6 +3180,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 7, 6); cli_validate_event(); } + elsif ($param eq '--validate_event_id') { + param_check($ltotal, 1); + cli_validate_event_id(); + } elsif ($param eq '--create_incident') { param_check($ltotal, 7, 1); cli_create_incident();