enh(linux/local): add exclude options (#3249)
This commit is contained in:
parent
4261f049f8
commit
9e4cff0590
|
@ -56,6 +56,12 @@ sub custom_utils_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_device_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Device '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -128,22 +134,17 @@ sub set_counters {
|
|||
];
|
||||
}
|
||||
|
||||
sub prefix_device_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Device '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'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' }
|
||||
'filter-partition-name:s' => { name => 'filter_partition_name' },
|
||||
'exclude-partition-name:s' => { name => 'exclude_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,6 +176,8 @@ sub manage_selection {
|
|||
|
||||
next if (defined($self->{option_results}->{filter_partition_name}) && $self->{option_results}->{filter_partition_name} ne '' &&
|
||||
$partition_name !~ /$self->{option_results}->{filter_partition_name}/);
|
||||
next if (defined($self->{option_results}->{exclude_partition_name}) && $self->{option_results}->{exclude_partition_name} ne '' &&
|
||||
$partition_name =~ /$self->{option_results}->{exclude_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);
|
||||
|
@ -223,47 +226,6 @@ Command used: tail -n +1 /proc/stat /proc/diskstats 2>&1
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'tail').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-n +1 /proc/stat /proc/diskstats 2>&1').
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
|
@ -274,6 +236,10 @@ Can be: 'read-usage', 'write-usage', 'read-time', 'write-time',
|
|||
|
||||
Filter partition name (regexp can be used).
|
||||
|
||||
=item B<--exclude-partition-name>
|
||||
|
||||
Exclude partition name (regexp can be used).
|
||||
|
||||
=item B<--bytes-per-sector>
|
||||
|
||||
Bytes per sector (Default: 512)
|
||||
|
|
|
@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub prefix_inodes_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Inodes partition '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -45,21 +51,17 @@ sub set_counters {
|
|||
];
|
||||
}
|
||||
|
||||
sub prefix_inodes_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Inodes partition '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-type:s' => { name => 'filter_type', },
|
||||
'filter-fs:s' => { name => 'filter_fs', },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' }
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
'filter-fs:s' => { name => 'filter_fs' },
|
||||
'exclude-fs:s' => { name => 'exclude_fs' },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
|
||||
'exclude-mountpoint:s' => { name => 'exclude_mountpoint' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -82,10 +84,14 @@ sub manage_selection {
|
|||
|
||||
next if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' &&
|
||||
$fs !~ /$self->{option_results}->{filter_fs}/);
|
||||
next if (defined($self->{option_results}->{exclude_fs}) && $self->{option_results}->{exclude_fs} ne '' &&
|
||||
$fs =~ /$self->{option_results}->{exclude_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}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' &&
|
||||
$mount !~ /$self->{option_results}->{filter_mountpoint}/);
|
||||
next if (defined($self->{option_results}->{exclude_mountpoint}) && $self->{option_results}->{exclude_mountpoint} ne '' &&
|
||||
$mount =~ /$self->{option_results}->{exclude_mountpoint}/);
|
||||
|
||||
$percent =~ s/%//g;
|
||||
next if ($percent eq '-');
|
||||
|
@ -125,6 +131,10 @@ Threshold critical in percent.
|
|||
|
||||
Filter filesystem mount point (regexp can be used).
|
||||
|
||||
=item B<--exclude-mountpoint>
|
||||
|
||||
Exclude filesystem mount point (regexp can be used).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter filesystem type (regexp can be used).
|
||||
|
@ -133,6 +143,10 @@ Filter filesystem type (regexp can be used).
|
|||
|
||||
Filter filesystem (regexp can be used).
|
||||
|
||||
=item B<--exclude-fs>
|
||||
|
||||
Exclude filesystem (regexp can be used).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -40,11 +40,11 @@ sub prefix_output {
|
|||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'mountpoints', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All mount points options are ok' }
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{mountpoints} = [
|
||||
{
|
||||
label => 'status',
|
||||
|
@ -66,9 +66,11 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-device:s' => { name => 'filter_device' },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
|
||||
'filter-type:s' => { name => 'filter_type' }
|
||||
'filter-device:s' => { name => 'filter_device' },
|
||||
'exclude-device:s' => { name => 'exclude_device' },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
|
||||
'exclude-mountpoint:s' => { name => 'exclude_mountpoint' },
|
||||
'filter-type:s' => { name => 'filter_type' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -90,21 +92,16 @@ sub manage_selection {
|
|||
next if ($line !~ /^\s*(.*?)\s+on\s+(.*?)\s+type\s+(\S+)\s+\((.*)\)/);
|
||||
my ($device, $mountpoint, $type, $options) = ($1, $2, $3, $4);
|
||||
|
||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$type !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $mountpoint . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_device}) && $self->{option_results}->{filter_device} ne '' &&
|
||||
$device !~ /$self->{option_results}->{filter_device}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $mountpoint . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' &&
|
||||
$mountpoint !~ /$self->{option_results}->{filter_mountpoint}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $mountpoint . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
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}->{filter_device}) && $self->{option_results}->{filter_device} ne '' &&
|
||||
$device !~ /$self->{option_results}->{filter_device}/);
|
||||
next if (defined($self->{option_results}->{exclude_device}) && $self->{option_results}->{exclude_device} ne '' &&
|
||||
$device =~ /$self->{option_results}->{exclude_device}/);
|
||||
next if (defined($self->{option_results}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' &&
|
||||
$mountpoint !~ /$self->{option_results}->{filter_mountpoint}/);
|
||||
next if (defined($self->{option_results}->{exclude_mountpoint}) && $self->{option_results}->{exclude_mountpoint} ne '' &&
|
||||
$mountpoint =~ /$self->{option_results}->{exclude_mountpoint}/);
|
||||
|
||||
$self->{mountpoints}->{$mountpoint} = {
|
||||
display => $mountpoint,
|
||||
|
@ -112,7 +109,7 @@ sub manage_selection {
|
|||
options => $options
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{mountpoints}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => 'No mount points found');
|
||||
$self->{output}->option_exit();
|
||||
|
@ -135,10 +132,18 @@ Command used: mount 2>&1
|
|||
|
||||
Filter mount point name (Can use regexp).
|
||||
|
||||
=item B<--exclude-mountpoint>
|
||||
|
||||
Exclude mount point name (Can use regexp).
|
||||
|
||||
=item B<--filter-device>
|
||||
|
||||
Filter device name (Can use regexp).
|
||||
|
||||
=item B<--exclude-device>
|
||||
|
||||
Exclude device name (Can use regexp).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter mount point type (Can use regexp).
|
||||
|
|
|
@ -128,9 +128,10 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-state:s' => { name => 'filter_state', },
|
||||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
'filter-state:s' => { name => 'filter_state', },
|
||||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'exclude-interface:s' => { name => 'exclude_interface' },
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -188,6 +189,8 @@ sub do_selection {
|
|||
$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}/);
|
||||
next if (defined($self->{option_results}->{exclude_interface}) && $self->{option_results}->{exclude_interface} ne '' &&
|
||||
$interface_name =~ /$self->{option_results}->{exclude_interface}/);
|
||||
|
||||
$self->{interface}->{$interface_name} = {
|
||||
display => $interface_name,
|
||||
|
@ -232,47 +235,6 @@ Command used: /sbin/ip -s addr 2>&1
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'ip').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/sbin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-s addr 2>&1').
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning in percent of total packets. Can be:
|
||||
|
@ -287,6 +249,10 @@ in-error, out-error, in-discard, out-discard
|
|||
|
||||
Filter interface name (regexp can be used).
|
||||
|
||||
=item B<--exclude-interface>
|
||||
|
||||
Exclude interface name (regexp can be used).
|
||||
|
||||
=item B<--filter-state>
|
||||
|
||||
Filter filesystem type (regexp can be used).
|
||||
|
|
|
@ -167,15 +167,17 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-command:s' => { name => 'filter_command' },
|
||||
'filter-arg:s' => { name => 'filter_arg' },
|
||||
'filter-state:s' => { name => 'filter_state' },
|
||||
'filter-ppid:s' => { name => 'filter_ppid' },
|
||||
'add-cpu' => { name => 'add_cpu' },
|
||||
'add-memory' => { name => 'add_memory' },
|
||||
'add-disk-io' => { name => 'add_disk_io' },
|
||||
'page-size:s' => { name => 'page_size', default => 4096 },
|
||||
'clock-ticks:s' => { name => 'clock_ticks', default => 100 }
|
||||
'filter-command:s' => { name => 'filter_command' },
|
||||
'exclude-command:s' => { name => 'exclude_command' },
|
||||
'filter-arg:s' => { name => 'filter_arg' },
|
||||
'exclude-arg:s' => { name => 'exclude_arg' },
|
||||
'filter-state:s' => { name => 'filter_state' },
|
||||
'filter-ppid:s' => { name => 'filter_ppid' },
|
||||
'add-cpu' => { name => 'add_cpu' },
|
||||
'add-memory' => { name => 'add_memory' },
|
||||
'add-disk-io' => { name => 'add_disk_io' },
|
||||
'page-size:s' => { name => 'page_size', default => 4096 },
|
||||
'clock-ticks:s' => { name => 'clock_ticks', default => 100 }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -218,8 +220,12 @@ sub parse_output {
|
|||
|
||||
next if (defined($self->{option_results}->{filter_command}) && $self->{option_results}->{filter_command} ne '' &&
|
||||
$cmd !~ /$self->{option_results}->{filter_command}/);
|
||||
next if (defined($self->{option_results}->{exclude_command}) && $self->{option_results}->{exclude_command} ne '' &&
|
||||
$cmd =~ /$self->{option_results}->{exclude_command}/);
|
||||
next if (defined($self->{option_results}->{filter_arg}) && $self->{option_results}->{filter_arg} ne '' &&
|
||||
$args !~ /$self->{option_results}->{filter_arg}/);
|
||||
next if (defined($self->{option_results}->{exclude_arg}) && $self->{option_results}->{exclude_arg} ne '' &&
|
||||
$args =~ /$self->{option_results}->{exclude_arg}/);
|
||||
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&
|
||||
$state_map->{$state} !~ /$self->{option_results}->{filter_state}/i);
|
||||
next if (defined($self->{option_results}->{filter_ppid}) && $self->{option_results}->{filter_ppid} ne '' &&
|
||||
|
@ -390,10 +396,18 @@ Monitor disk I/O.
|
|||
|
||||
Filter process commands (regexp can be used).
|
||||
|
||||
=item B<--exclude-command>
|
||||
|
||||
Exclude process commands (regexp can be used).
|
||||
|
||||
=item B<--filter-arg>
|
||||
|
||||
Filter process arguments (regexp can be used).
|
||||
|
||||
=item B<--exclude-arg>
|
||||
|
||||
Exclude process arguments (regexp can be used).
|
||||
|
||||
=item B<--filter-ppid>
|
||||
|
||||
Filter process ppid (regexp can be used).
|
||||
|
|
|
@ -106,6 +106,12 @@ sub custom_usage_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_quota_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Quota '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -133,12 +139,6 @@ sub set_counters {
|
|||
];
|
||||
}
|
||||
|
||||
sub prefix_quota_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Quota '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -160,7 +160,7 @@ sub manage_selection {
|
|||
command_options => '-a -i 2>&1',
|
||||
no_quit => 1
|
||||
);
|
||||
|
||||
|
||||
#*** Report for user quotas on device /dev/xxxx
|
||||
#Block grace time: 7days; Inode grace time: 7days
|
||||
# Block limits File limits
|
||||
|
@ -168,18 +168,18 @@ sub manage_selection {
|
|||
#----------------------------------------------------------------------
|
||||
#root -- 20779412 0 0 5 0 0
|
||||
#apache -- 5721908 0 0 67076 0 0
|
||||
|
||||
|
||||
$self->{quota} = {};
|
||||
while ($stdout =~ /^\*\*\*.*?(\S+?)\n(.*?)(?=\*\*\*|\z)/msig) {
|
||||
my ($fs, $data) = ($1, $2);
|
||||
|
||||
|
||||
while ($data =~ /^(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.*?)\n/msig) {
|
||||
my ($user, $grace_on, $data_used, $data_soft, $data_hard, $usage) = ($1, $2, $3 * 1024, $4 * 1024, $5 * 1024, $6);
|
||||
my @values = split /\s+/, $usage;
|
||||
|
||||
|
||||
shift @values if ($usage =~ /^\+/);
|
||||
my ($inode_used, $inode_soft, $inode_hard) = (shift @values, shift @values, shift @values);
|
||||
|
||||
|
||||
my $name = $user . '.' . $fs;
|
||||
if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' &&
|
||||
$user !~ /$self->{option_results}->{filter_user}/) {
|
||||
|
@ -191,7 +191,9 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
next if (defined($self->{option_results}->{exclude_fs}) && $self->{option_results}->{exclude_fs} ne '' &&
|
||||
$fs =~ /$self->{option_results}->{exclude_fs}/);
|
||||
|
||||
$self->{quota}->{$name} = {
|
||||
display => $name,
|
||||
data_used => $data_used, data_soft => $data_soft, data_hard => $data_hard,
|
||||
|
@ -234,6 +236,10 @@ Filter username (regexp can be used).
|
|||
|
||||
Filter filesystem (regexp can be used).
|
||||
|
||||
=item B<--exclude-fs>
|
||||
|
||||
Exclude filesystem (regexp can be used).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -96,6 +96,12 @@ sub custom_usage_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_disks_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Storage '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -115,23 +121,19 @@ sub set_counters {
|
|||
];
|
||||
}
|
||||
|
||||
sub prefix_disks_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Storage '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$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' }
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
'filter-fs:s' => { name => 'filter_fs' },
|
||||
'exclude-fs:s' => { name => 'exclude_fs' },
|
||||
'filter-mountpoint:s' => { name => 'filter_mountpoint' },
|
||||
'exclude-mountpoint:s' => { name => 'exclude_mountpoint' },
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'free' => { name => 'free' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -154,10 +156,14 @@ sub manage_selection {
|
|||
|
||||
next if (defined($self->{option_results}->{filter_fs}) && $self->{option_results}->{filter_fs} ne '' &&
|
||||
$fs !~ /$self->{option_results}->{filter_fs}/);
|
||||
next if (defined($self->{option_results}->{exclude_fs}) && $self->{option_results}->{exclude_fs} ne '' &&
|
||||
$fs =~ /$self->{option_results}->{exclude_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}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' &&
|
||||
$mount !~ /$self->{option_results}->{filter_mountpoint}/);
|
||||
next if (defined($self->{option_results}->{exclude_mountpoint}) && $self->{option_results}->{exclude_mountpoint} ne '' &&
|
||||
$mount =~ /$self->{option_results}->{exclude_mountpoint}/);
|
||||
|
||||
$self->{disks}->{$mount} = {
|
||||
display => $mount,
|
||||
|
@ -210,6 +216,10 @@ Thresholds are on free space left.
|
|||
|
||||
Filter filesystem mount point (regexp can be used).
|
||||
|
||||
=item B<--exclude-mountpoint>
|
||||
|
||||
Exclude filesystem mount point (regexp can be used).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter filesystem type (regexp can be used).
|
||||
|
@ -218,6 +228,10 @@ Filter filesystem type (regexp can be used).
|
|||
|
||||
Filter filesystem (regexp can be used).
|
||||
|
||||
=item B<--exclude-fs>
|
||||
|
||||
Exclude filesystem (regexp can be used).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -39,14 +39,20 @@ sub custom_status_output {
|
|||
);
|
||||
}
|
||||
|
||||
sub prefix_sc_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Service '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'sc', type => 1, cb_prefix_output => 'prefix_sc_output', message_multiple => 'All services are ok' }
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total-running', nlabel => 'systemd.services.running.count', set => {
|
||||
key_values => [ { name => 'running' }, { name => 'total' } ],
|
||||
|
@ -81,6 +87,7 @@ sub set_counters {
|
|||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{sc} = [
|
||||
{ label => 'status', type => 2, critical_default => '%{active} =~ /failed/i', set => {
|
||||
key_values => [ { name => 'load' }, { name => 'active' }, { name => 'sub' }, { name => 'boot' }, { name => 'display' } ],
|
||||
|
@ -98,18 +105,13 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'exclude-name:s' => { name => 'exclude_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_sc_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Service '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -125,13 +127,12 @@ sub manage_selection {
|
|||
#brandbot.service loaded inactive dead Flexible Branding Service
|
||||
while ($stdout =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/msig) {
|
||||
my ($name, $load, $active, $sub) = ($1, $2, $3, lc($4));
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
next if (defined($self->{option_results}->{exclude_name}) && $self->{option_results}->{exclude_name} ne '' &&
|
||||
$name =~ /$self->{option_results}->{exclude_name}/);
|
||||
|
||||
$self->{sc}->{$name} = { display => $name, load => $load, active => $active, sub => $sub, boot => '-' };
|
||||
$self->{global}->{$sub} += 1 if (defined($self->{global}->{$sub}));
|
||||
$self->{global}->{total} += 1;
|
||||
|
@ -172,6 +173,10 @@ Command used: 'systemctl -a --no-pager --no-legend' and 'systemctl list-unit-fil
|
|||
|
||||
Filter service name (can be a regexp).
|
||||
|
||||
=item B<--exclude-name>
|
||||
|
||||
Exclude service name (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
|
|
|
@ -136,11 +136,12 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-state:s' => { name => 'filter_state', },
|
||||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'units:s' => { name => 'units', default => 'b/s' },
|
||||
'speed:s' => { name => 'speed' },
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
'filter-state:s' => { name => 'filter_state', },
|
||||
'filter-interface:s' => { name => 'filter_interface' },
|
||||
'exclude-interface:s' => { name => 'exclude_interface' },
|
||||
'units:s' => { name => 'units', default => 'b/s' },
|
||||
'speed:s' => { name => 'speed' },
|
||||
'no-loopback' => { name => 'no_loopback' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -201,6 +202,8 @@ sub do_selection {
|
|||
$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}/);
|
||||
next if (defined($self->{option_results}->{exclude_interface}) && $self->{option_results}->{exclude_interface} ne '' &&
|
||||
$interface_name =~ /$self->{option_results}->{exclude_interface}/);
|
||||
|
||||
$self->{interface}->{$interface_name} = {
|
||||
display => $interface_name,
|
||||
|
@ -286,6 +289,10 @@ Percent can be used only if --speed is set.
|
|||
|
||||
Filter interface name (regexp can be used).
|
||||
|
||||
=item B<--exclude-interface>
|
||||
|
||||
Exclude interface name (regexp can be used).
|
||||
|
||||
=item B<--filter-state>
|
||||
|
||||
Filter interfaces type (regexp can be used).
|
||||
|
|
Loading…
Reference in New Issue