Skip to content

Commit

Permalink
fix(informix-snmp): consider log files in backedUpButNeeded state as …
Browse files Browse the repository at this point in the history
…free space in log-file-usage mode (#5352) (#4943)

Co-authored-by: gmolina <[email protected]>

Refs: CTOR-1220
  • Loading branch information
sfarouq-ext authored Jan 10, 2025
1 parent f5f2103 commit 54c92ee
Show file tree
Hide file tree
Showing 4 changed files with 418 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/database/informix/snmp/mode/logfileusage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ sub new {

my $mapping = {
onLogicalLogDbspace => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.3' },
onLogicalLogStatus => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.4' },
onLogicalLogPagesAllocated => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.7' },
onLogicalLogPagesUsed => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.8' },
};
Expand All @@ -76,6 +77,7 @@ sub manage_selection {
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $mapping->{onLogicalLogDbspace}->{oid} },
{ oid => $mapping->{onLogicalLogStatus}->{oid} },
{ oid => $mapping->{onLogicalLogPagesAllocated}->{oid} },
{ oid => $mapping->{onLogicalLogPagesUsed}->{oid} },
], return_type => 1, nothing_quit => 1
Expand Down Expand Up @@ -103,7 +105,17 @@ sub manage_selection {
}

$self->{global}->{$name}->{allocated} += $result->{onLogicalLogPagesAllocated};
$self->{global}->{$name}->{used} += $result->{onLogicalLogPagesUsed};

# Status of the logical-log file:
# newlyAdded (1)
# free (2)
# current (3)
# used (4)
# backedUpButNeeded (5)
# consider log files with state backedUpButNeeded as free space
if ($result->{onLogicalLogStatus} != 5) {
$self->{global}->{$name}->{used} += $result->{onLogicalLogPagesUsed};
}
}

foreach (keys %{$self->{global}}) {
Expand All @@ -128,7 +140,8 @@ Check log files usage.
=item B<--filter-name>
Filter dbspace name (can be a regexp).
Define which C<dbspace> should be monitored based on their names.
This option will be treated as a regular expression.
=item B<--warning-usage>
Expand Down
28 changes: 28 additions & 0 deletions tests/database/informix/snmp/list-instances.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*** Settings ***
Documentation List informix instances.
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource

Test Timeout 120s

*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=database::informix::snmp::plugin

*** Test Cases ***
list-instances ${tc}
[Tags] database informix
${command} Catenate
... ${CMD}
... --mode=list-instances
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=database/informix/snmp/slim_informix-log
... --snmp-timeout=1
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 --verbose List instances: [instance = default]
... 2 --filter-instance='instance' List instances: [instance = default]
30 changes: 30 additions & 0 deletions tests/database/informix/snmp/logfile-usage.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
*** Settings ***
Documentation Check log files usage.
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource

Test Timeout 120s

*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=database::informix::snmp::plugin

*** Test Cases ***
logfile-usage ${tc}
[Tags] database informix
${command} Catenate
... ${CMD}
... --mode=logfile-usage
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=database/informix/snmp/slim_informix-log
... --snmp-timeout=1
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 --verbose OK: All dbspace log files usage are ok | 'used_default.linies'=0.00%;;;0;100 'used_default.logical_log'=0.73%;;;0;100 'used_default.rootdbs'=0.00%;;;0;100 Dbspace 'default.linies' Log Files Used: 0.00% Dbspace 'default.logical_log' Log Files Used: 0.73% Dbspace 'default.rootdbs' Log Files Used: 0.00%
... 2 --filter-name='default.linies' OK: Dbspace 'default.linies' Log Files Used: 0.00% | 'used'=0.00%;;;0;100
... 3 --warning-usage=80:90 WARNING: Dbspace 'default.linies' Log Files Used: 0.00% - Dbspace 'default.logical_log' Log Files Used: 0.73% - Dbspace 'default.rootdbs' Log Files Used: 0.00% | 'used_default.linies'=0.00%;80:90;;0;100 'used_default.logical_log'=0.73%;80:90;;0;100 'used_default.rootdbs'=0.00%;80:90;;0;100
... 4 --critical-usage=80:90 CRITICAL: Dbspace 'default.linies' Log Files Used: 0.00% - Dbspace 'default.logical_log' Log Files Used: 0.73% - Dbspace 'default.rootdbs' Log Files Used: 0.00% | 'used_default.linies'=0.00%;;80:90;0;100 'used_default.logical_log'=0.73%;;80:90;0;100 'used_default.rootdbs'=0.00%;;80:90;0;100
Loading

0 comments on commit 54c92ee

Please sign in to comment.