diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 5441cbdada..37aabe8f3e 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -439,7 +439,8 @@ if (! empty($modules)) { if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) { $interface_traffic_modules_aux = array('in' => '', 'out' => ''); foreach ($interface_traffic_modules as $interface_traffic_module) { - if (preg_match ("/if(.+)Octets_$interface_name$/i", (string)$interface_traffic_module['nombre'], $matches)) { + $interface_name_escaped = str_replace("/", "\/", $interface_name); + if (preg_match ("/if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) { if (strtolower($matches[1]) == 'in') { $interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo']; } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 7a238c91ac..7405274f9e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1146,15 +1146,10 @@ sub pandora_process_module ($$$$$$$$$;$) { $min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2); } - # replace $new_status with $last_known_status when recovering from 'unknown' - if ($status == 3) { - $new_status = $last_known_status; - } - if ($last_status == $new_status) { # Avoid overflows - $status_changes = $min_ff_event if ($status_changes > $module->{'min_ff_event'}); + $status_changes = $min_ff_event if ($status_changes > $min_ff_event); $status_changes++; if ($module_type =~ m/async/ && $min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) { @@ -1173,9 +1168,10 @@ sub pandora_process_module ($$$$$$$$$;$) { } # Change status - if ($status_changes == $min_ff_event && $status != $new_status) { + if ($status_changes >= $min_ff_event && $status != $new_status) { generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $last_known_status, $dbh); $status = $new_status; + $last_status = $new_status; # Update module status count pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'}); @@ -1185,20 +1181,23 @@ sub pandora_process_module ($$$$$$$$$;$) { elsif ($status == 4) { generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $last_known_status, $dbh); $status = 0; + $last_status = $new_status; # Update module status count pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'}); } # If unknown modules receive data, restore status even if min_ff_event is not matched. elsif ($status == 3) { + $last_status = $new_status; # Set last_status before forcing the module's new status to its last known status. + $new_status = $last_known_status; # Set the module to its last known status. generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $last_known_status, $dbh); $status = $new_status; # Update module status count pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'}); + } else { + $last_status = $new_status; } - - $last_status = $new_status; # tagente_estado.last_try defaults to NULL, should default to '1970-01-01 00:00:00' $agent_status->{'last_try'} = '1970-01-01 00:00:00' unless defined ($agent_status->{'last_try'}); @@ -3563,18 +3562,15 @@ sub generate_status_event ($$$$$$$$) { # Warning } elsif ($status == 2) { - # From normal - if ($last_known_status == 0 || $last_known_status == 4) { - ($event_type, $severity) = ('going_up_warning', 3); - $description = $pa_config->{"text_going_up_warning"}; - # From critical - } elsif ($last_known_status == 1) { + if ($last_known_status == 1) { ($event_type, $severity) = ('going_down_warning', 3); $description = $pa_config->{"text_going_down_warning"}; - } else { - # Unknown last_status - return; + } + # From normal or warning (after becoming unknown) + else { + ($event_type, $severity) = ('going_up_warning', 3); + $description = $pa_config->{"text_going_up_warning"}; } } else { # Unknown status diff --git a/pandora_server/lib/PandoraFMS/SNMPServer.pm b/pandora_server/lib/PandoraFMS/SNMPServer.pm index f1f9064e17..f874fc3d42 100644 --- a/pandora_server/lib/PandoraFMS/SNMPServer.pm +++ b/pandora_server/lib/PandoraFMS/SNMPServer.pm @@ -219,7 +219,7 @@ sub pandora_snmptrapd { if (!defined($oid)) { logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv2 trap?)", 1); - next; + return; } $oid =~ s/.* = OID: //; $data = join("\t", @data); diff --git a/pandora_server/util/integrity_check b/pandora_server/util/integrity_check index 0d89a80f51..eb52c949f7 100755 --- a/pandora_server/util/integrity_check +++ b/pandora_server/util/integrity_check @@ -19,9 +19,9 @@ if [ $# -lt 2 ] then echo "Syntax:" echo " " - echo "integrity_chech new|check [" + echo "integrity_chech new|check|compare [] [] []" echo " " - echo " If mode 'check' is selected, it will require a integrity file (generated by this tool) to check it against current setup" + echo " If mode 'check' is selected, it will require a integrity file (generated by this tool) to check it against current setup. If mode 'compare' is selected, it wil require two integrity files, and will report differences between them" echo " " exit -1 fi @@ -32,12 +32,70 @@ INTEGRITY_REPORT=$INTEGRITY_FILE.report MODE=$1 ERROR=0 -if [ ! -d "$CONSOLE_PATH" ] +if [ ! -d "$CONSOLE_PATH" ] && [ "$MODE" != "compare" ] then echo "Error: Console path doesn't exist" exit -1 fi +if [ "$MODE" == "compare" ] +then + FILE1=$2 + FILE2=$3 + + if [ ! -f "$FILE1" ] || [ ! -f "$FILE2" ] + then + echo "Error, at least one of the integrity files provided not found" + exit -1 + fi + + IFS=" +" + COUNTER=0 + for a in `cat $FILE1 | grep -v "^#"` + do + if [ $COUNTER -eq 0 ] + then + echo -ne "\b|" + fi + + if [ $COUNTER -eq 1 ] + then + echo -ne "\b/" + fi + + if [ $COUNTER -eq 2 ] + then + echo -ne "\b-" + fi + if [ $COUNTER -eq 3 ] + then + echo -ne "\b\\" + COUNTER=-1 + fi + + COUNTER=`expr $COUNTER + 1` + + F1=`echo $a | awk '{ print $2 }'` + M1=`echo $a | awk '{ print $1 }'` + + BUF=`cat $FILE2 | grep "$F1\$"` + if [ -z "$BUF" ] + then + echo " " + echo "[MISS] $F1 is not present in $FILE2" + else + M2=`echo $BUF | awk '{ print $1 }'` + if [ "$M2" != "$M1" ] + then + echo " " + echo "[DIFF] $F1 has changed" + fi + fi + done + +fi + if [ "$MODE" == "check" ] then if [ ! -f "$INTEGRITY_FILE" ]