Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTOR-1220 : Plugin(database::informix::snmp) - Mode(log-file-usage) : consider log files with state backedUpButNeeded as free space #5352

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading