2011-07-07 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm: Added support for warning/critical status
	  regexp (works with both numeric and string data types). Added
	  support for alert-only planned downtimes.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4523 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2011-07-07 11:09:23 +00:00
parent d281058ef2
commit 1d9cb4b24a
2 changed files with 44 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2011-07-07 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Added support for warning/critical status
regexp (works with both numeric and string data types). Added
support for alert-only planned downtimes.
2011-07-07 Sergio Martin <sergio.martin@artica.es>
* Makefile.PL

View File

@ -926,7 +926,11 @@ sub pandora_planned_downtime ($$) {
my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents WHERE id_downtime = ' . $downtime->{'id'});
foreach my $downtime_agent (@downtime_agents) {
if ($downtime_agent->{'only_alerts'} == 0) {
db_do ($dbh, 'UPDATE tagente SET disabled = 1 WHERE id_agente = ?', $downtime_agent->{'id_agent'});
} else {
db_do ($dbh, 'UPDATE talert_template_modules SET disabled = 1 WHERE id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ?)', $downtime_agent->{'id_agent'});
}
}
}
@ -943,7 +947,12 @@ sub pandora_planned_downtime ($$) {
my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents WHERE id_downtime = ' . $downtime->{'id'});
foreach my $downtime_agent (@downtime_agents) {
if ($downtime_agent->{'only_alerts'} == 0) {
db_do ($dbh, 'UPDATE tagente SET disabled = 0 WHERE id_agente = ?', $downtime_agent->{'id_agent'});
} else {
db_do ($dbh, 'UPDATE talert_template_modules SET disabled = 0 WHERE id_agent_module IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ?)', $downtime_agent->{'id_agent'});
}
}
}
}
@ -1823,6 +1832,7 @@ sub get_module_status ($$$) {
my ($data, $module, $module_type) = @_;
my ($critical_min, $critical_max, $warning_min, $warning_max) =
($module->{'min_critical'}, $module->{'max_critical'}, $module->{'min_warning'}, $module->{'max_warning'});
my ($critical_str, $warning_str) = ($module->{'str_critical'}, $module->{'str_warning'});
# Was the module status set in the XML data file?
if (defined ($module->{'status'})) {
@ -1831,16 +1841,17 @@ sub get_module_status ($$$) {
return 0 if (uc ($module->{'status'}) eq 'NORMAL');
}
# Set default critical max/min for *proc modules
# Set default critical max/min/str values
$critical_str = '' unless defined ($critical_str);
$warning_str = '' unless defined ($warning_str);
if ($module_type =~ m/_proc$/ && ($critical_min eq $critical_max)) {
($critical_min, $critical_max) = (0, 1);
}
if ($module_type =~ m/keep_alive/ && ($critical_min eq $critical_max)) {
elsif ($module_type =~ m/keep_alive/ && ($critical_min eq $critical_max)) {
($critical_min, $critical_max) = (0, 1);
}
if ($module_type eq "log4x") {
elsif ($module_type eq "log4x") {
if ($critical_min eq $critical_max) {
($critical_min, $critical_max) = (50, 61); # ERROR - FATAL
}
@ -1849,6 +1860,9 @@ sub get_module_status ($$$) {
}
}
# Numeric
if ($module_type !~ m/_string/) {
# Critical
if ($critical_min ne $critical_max) {
return 1 if ($data >= $critical_min && $data < $critical_max);
@ -1860,6 +1874,13 @@ sub get_module_status ($$$) {
return 2 if ($data >= $warning_min && $data < $warning_max);
return 2 if ($data >= $warning_min && $warning_max < $warning_min);
}
}
# Critical
return 1 if ($critical_str ne '' && $data =~ /$critical_str/);
# Warning
return 2 if ($warning_str ne '' && $data =~ /$warning_str/);
# Normal
return 0;