From a88b222db2138a1be77c10cf84f505d0e2b2320f Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 20 Apr 2011 15:55:28 +0000 Subject: [PATCH] 2011-04-20 Ramon Novoa * lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Module status can be set from the XML data file. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4271 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 6 ++++++ pandora_server/lib/PandoraFMS/Core.pm | 7 +++++++ pandora_server/lib/PandoraFMS/DataServer.pm | 3 +++ 3 files changed, 16 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index d440b457f9..8b702be097 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,9 @@ +2011-04-20 Ramon Novoa + + * lib/PandoraFMS/Core.pm, + lib/PandoraFMS/DataServer.pm: Module status can be set from the XML + data file. + 2011-04-20 Ramon Novoa * lib/PandoraFMS/Core.pm: Added _policy_ macro to alerts (Enterprise). diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index c6e28af847..eec830a6ab 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1634,6 +1634,13 @@ sub get_module_status ($$$) { my ($critical_min, $critical_max, $warning_min, $warning_max) = ($module->{'min_critical'}, $module->{'max_critical'}, $module->{'min_warning'}, $module->{'max_warning'}); + # Was the module status set in the XML data file? + if (defined ($module->{'status'})) { + return 1 if (uc ($module->{'status'}) eq 'CRITICAL'); + return 2 if (uc ($module->{'status'}) eq 'WARNING'); + return 0 if (uc ($module->{'status'}) eq 'NORMAL'); + } + # Set default critical max/min for *proc modules if ($module_type =~ m/_proc$/ && ($critical_min eq $critical_max)) { ($critical_min, $critical_max) = (0, 1); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index bb84994a59..ab2f2fa2ca 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -548,6 +548,9 @@ sub process_module_data ($$$$$$$$$) { my $data_object = get_module_data($data, $module_type); my $extra_macros = get_macros_for_data($data, $module_type); + # Get module status from XML data file if available + $module->{'status'} = get_tag_value ($data, 'status', undef); + pandora_process_module ($pa_config, $data_object, $agent, $module, $module_type, $timestamp, $utimestamp, $server_id, $dbh, $extra_macros); }