(plugin) apps::monitoring::nodeexporter::linux - enhancements on options (#3803)
* adding option to filter on partition name * enhancement on options
This commit is contained in:
parent
e3040adf03
commit
2430712636
|
@ -190,9 +190,7 @@ sub manage_selection {
|
|||
|
||||
my $raw_metrics = centreon::common::monitoring::openmetrics::scrape::parse(%options, strip_chars => "[\"']");
|
||||
|
||||
$self->{cache_name} = 'linux_nodeexporter' . $options{custom}->get_uuid() . '_' . $self->{mode} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_channel}) ? md5_hex($self->{option_results}->{filter_channel}) : md5_hex('all'));
|
||||
$self->{cache_name} = 'linux_nodeexporter' . $options{custom}->get_uuid() . '_' . $self->{mode} . '_' . md5_hex('all');
|
||||
|
||||
$self->{node_cpu} = {};
|
||||
my $cpu_number;
|
||||
|
@ -212,6 +210,11 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{node_cpu}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$cpu_number = keys %{$self->{node_cpu}};
|
||||
$avg_cpu_idle = $cpu_idle / $cpu_number;
|
||||
|
||||
|
|
|
@ -94,6 +94,11 @@ sub manage_selection {
|
|||
|
||||
$self->{load}->{$metric} = $raw_metrics->{$metric}->{data}[0]->{value};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{load}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -155,6 +155,10 @@ sub manage_selection {
|
|||
|
||||
$self->{node_memory}->{$metric} = $raw_metrics->{$metric}->{data}[0]->{value};
|
||||
}
|
||||
if (scalar(keys %{$self->{node_memory}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -127,8 +127,9 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
'fstype:s' => { name => 'fstype', default => 'linuxfs|rootfs|tmpfs' },
|
||||
"storage:s" => { name => 'storage' },
|
||||
"units:s" => { name => 'units', default => '%' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -156,7 +157,7 @@ sub manage_selection {
|
|||
next if ($metric !~ /node_filesystem_free_bytes|node_filesystem_size_bytes/i );
|
||||
|
||||
foreach my $data (@{$raw_metrics->{$metric}->{data}}) {
|
||||
next if ( $data->{dimensions}->{fstype} !~ /$self->{option_results}->{fstype}/i );
|
||||
next if ((defined($self->{option_results}->{fstype}) && $data->{dimensions}->{fstype} !~ /$self->{option_results}->{fstype}/i ) || (defined($self->{option_results}->{storage}) && $data->{dimensions}->{mountpoint} !~ /$self->{option_results}->{storage}/i));
|
||||
|
||||
foreach my $mountpoint ($data->{dimensions}->{mountpoint}) {
|
||||
$self->{node_storage}->{$mountpoint}->{$metric} = $data->{value};
|
||||
|
@ -164,6 +165,11 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{node_storage}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No partition found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -182,6 +188,12 @@ Inclusion filter on fstype.
|
|||
|
||||
Can be used to exclude fstypes. Example : --fstype='^(?!(tmpfs))'
|
||||
|
||||
=item B<--storage>
|
||||
|
||||
Specify which disk to monitor. Can be a regex.
|
||||
|
||||
Default: all disks are monitored.
|
||||
|
||||
=item B<--units>
|
||||
|
||||
Units of thresholds. Can be : '%', 'B'
|
||||
|
|
|
@ -133,7 +133,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter:s" => { name => 'filter', default => 'lo' },
|
||||
"interface:s" => { name => 'interface', default => '^(?!(lo$))' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -145,8 +145,7 @@ sub manage_selection {
|
|||
my $raw_metrics = centreon::common::monitoring::openmetrics::scrape::parse(%options, strip_chars => "[\"']");
|
||||
|
||||
$self->{cache_name} = 'linux_nodeexporter' . $options{custom}->get_uuid() . '_' . $self->{mode} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_channel}) ? md5_hex($self->{option_results}->{filter_channel}) : md5_hex('all'));
|
||||
(defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all'));
|
||||
|
||||
|
||||
my $traffic_metrics;
|
||||
|
@ -156,7 +155,7 @@ sub manage_selection {
|
|||
next if ($metric !~ /node_network_receive_packets_total|node_network_transmit_packets_total|node_network_receive_bytes_total|node_network_transmit_bytes_total|node_network_up/i );
|
||||
|
||||
foreach my $data (@{$raw_metrics->{$metric}->{data}}) {
|
||||
next if (defined($self->{option_results}->{filter}) && $data->{dimensions}->{device} =~ $self->{option_results}->{filter});
|
||||
next if (defined($self->{option_results}->{interface}) && $data->{dimensions}->{device} !~ /$self->{option_results}->{interface}/i);
|
||||
$self->{interface}->{$data->{dimensions}->{device}}->{traffic}->{$metric} = $data->{value} if ($metric ne 'node_network_up');
|
||||
$self->{interface}->{$data->{dimensions}->{device}}->{traffic}->{display} = $data->{dimensions}->{device} if ($metric ne 'node_network_up');
|
||||
|
||||
|
@ -166,6 +165,11 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{interface}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No interface found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -174,9 +178,11 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
=item B<--filter>
|
||||
=item B<--interface>
|
||||
|
||||
Filter to exclude interfaces. Is a regex.
|
||||
Specify which interface to monitor. Can be a regex.
|
||||
|
||||
Default: all interfaces are monitored except 'lo' interface.
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
|
|
Loading…
Reference in New Issue