break change: option linux local

This commit is contained in:
garnier-quentin 2020-07-17 12:05:15 +02:00
parent 678f50fac2
commit dc2e572c7d
5 changed files with 35 additions and 95 deletions

View File

@ -140,12 +140,10 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'name:s' => { name => 'name' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'interrupt-frequency:s' => { name => 'interrupt_frequency', default => 1000 },
'bytes-per-sector:s' => { name => 'bytes_per_sector', default => 512 },
'skip' => { name => 'skip' }
'filter-partition-name:s' => { name => 'filter_partition_name' },
'interrupt-frequency:s' => { name => 'interrupt_frequency', default => 1000 },
'bytes-per-sector:s' => { name => 'bytes_per_sector', default => 512 },
'skip' => { name => 'skip' }
});
return $self;
@ -175,12 +173,8 @@ sub manage_selection {
while ($disk_parts =~ /^\s*\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s*/msg) {
my ($partition_name, $read_sector, $write_sector, $read_ms, $write_ms, $ms_ticks) = ($1, $2, $4, $3, $5, $6);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi})
&& $partition_name !~ /$self->{option_results}->{name}/i);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $partition_name !~ /$self->{option_results}->{name}/);
next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $partition_name ne $self->{option_results}->{name});
next if (defined($self->{option_results}->{filter_partition_name}) && $self->{option_results}->{filter_partition_name} ne '' &&
$partition_name !~ /$self->{option_results}->{filter_partition_name}/);
if (defined($self->{option_results}->{skip}) && $read_sector == 0 && $write_sector == 0) {
$self->{output}->output_add(long_msg => "skipping device '" . $partition_name . "': no read/write IO.", debug => 1);
@ -213,7 +207,7 @@ sub manage_selection {
$self->{cache_name} = 'cache_linux_local_' . $options{custom}->get_identifier() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{name}) ? md5_hex($self->{option_results}->{name}) : md5_hex('all'));
(defined($self->{option_results}->{filter_partition_name}) ? md5_hex($self->{option_results}->{filter_partition_name}) : md5_hex('all'));
}
1;
@ -276,17 +270,9 @@ Thresholds.
Can be: 'read-usage', 'write-usage', 'read-time', 'write-time',
'utils'.
=item B<--name>
=item B<--filter-partition-name>
Set the partition name (empty means 'check all partitions')
=item B<--regexp>
Allows to use regexp to filter partition name (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
Filter partition name (regexp can be used).
=item B<--bytes-per-sector>

View File

@ -123,7 +123,7 @@ Threshold critical in percent.
=item B<--filter-mountpoint>
Filter filesystem (regexp can be used).
Filter filesystem mount point (regexp can be used).
=item B<--filter-type>

View File

@ -128,14 +128,12 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-state:s' => { name => 'filter_state', },
'name:s' => { name => 'name' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'no-loopback' => { name => 'no_loopback', },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "RU"' }
'filter-state:s' => { name => 'filter_state', },
'filter-interface:s' => { name => 'filter_interface' },
'no-loopback' => { name => 'no_loopback', },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "RU"' }
});
return $self;
@ -197,14 +195,9 @@ sub do_selection {
next if (defined($self->{option_results}->{no_loopback}) && $values =~ /LOOPBACK/ms);
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&
$states !~ /$self->{option_results}->{filter_state}/);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi})
&& $interface_name !~ /$self->{option_results}->{name}/i);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $interface_name !~ /$self->{option_results}->{name}/);
next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $interface_name ne $self->{option_results}->{name});
$states !~ /$self->{option_results}->{filter_state}/);
next if (defined($self->{option_results}->{filter_interface}) && $self->{option_results}->{filter_interface} ne '' &&
$interface_name !~ /$self->{option_results}->{filter_interface}/);
$self->{interface}->{$interface_name} = {
display => $interface_name,
@ -300,17 +293,9 @@ in-error, out-error, in-discard, out-discard
Threshold critical in percent of total packets. Can be:
in-error, out-error, in-discard, out-discard
=item B<--name>
=item B<--filter-interface>
Set the interface name (empty means 'check all interfaces')
=item B<--regexp>
Allows to use regexp to filter storage mount point (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
Filter interface name (regexp can be used).
=item B<--filter-state>

View File

@ -129,12 +129,9 @@ sub new {
$options{options}->add_options(arguments => {
'filter-type:s' => { name => 'filter_type', },
'filter-fs:s' => { name => 'filter_fs', },
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
'name:s' => { name => 'name' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'space-reservation:s' => { name => 'space_reservation' }
'free' => { name => 'free' }
});
return $self;
@ -156,16 +153,11 @@ sub manage_selection {
my ($fs, $type, $size, $used, $available, $percent, $mount) = ($1, $2, $3, $4, $5, $6, $7);
next if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' &&
$fs !~ /$self->{option_results}->{filter_fs}/);
$fs !~ /$self->{option_results}->{filter_fs}/);
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
$type !~ /$self->{option_results}->{filter_type}/);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi})
&& $mount !~ /$self->{option_results}->{name}/i);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $mount !~ /$self->{option_results}->{name}/);
next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $mount ne $self->{option_results}->{name});
$type !~ /$self->{option_results}->{filter_type}/);
next if (defined($self->{option_results}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' &&
$mount !~ /$self->{option_results}->{filter_mountpoint}/);
$size *= 1024;
if (defined($self->{option_results}->{space_reservation})) {
@ -211,17 +203,9 @@ Units of thresholds (Default: '%') ('%', 'B').
Thresholds are on free space left.
=item B<--name>
=item B<--filter-mountpoint>
Set the storage mount point (empty means 'check all storages')
=item B<--regexp>
Allows to use regexp to filter storage mount point (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
Filter filesystem mount point (regexp can be used).
=item B<--filter-type>

View File

@ -137,10 +137,8 @@ sub new {
$options{options}->add_options(arguments => {
'filter-state:s' => { name => 'filter_state', },
'filter-interface:s' => { name => 'filter_interface' },
'units:s' => { name => 'units', default => 'b/s' },
'name:s' => { name => 'name' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'speed:s' => { name => 'speed' },
'no-loopback' => { name => 'no_loopback', },
'unknown-status:s' => { name => 'unknown_status', default => '' },
@ -205,14 +203,9 @@ sub do_selection {
next if (defined($self->{option_results}->{no_loopback}) && $values =~ /LOOPBACK/ms);
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&
$states !~ /$self->{option_results}->{filter_state}/);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi})
&& $interface_name !~ /$self->{option_results}->{name}/i);
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $interface_name !~ /$self->{option_results}->{name}/);
next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi})
&& $interface_name ne $self->{option_results}->{name});
$states !~ /$self->{option_results}->{filter_state}/);
next if (defined($self->{option_results}->{filter_interface}) && $self->{option_results}->{filter_interface} ne '' &&
$interface_name !~ /$self->{option_results}->{filter_interface}/);
$self->{interface}->{$interface_name} = {
display => $interface_name,
@ -294,17 +287,9 @@ Can used special variables like: %{status}, %{display}
Units of thresholds (Default: 'b/s') ('%', 'b/s').
Percent can be used only if --speed is set.
=item B<--name>
=item B<--filter-interface>
Set the interface name (empty means 'check all interfaces')
=item B<--regexp>
Allows to use regexp to filter intefaces (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
Filter interface name (regexp can be used).
=item B<--filter-state>