commit
dae81192af
|
@ -44,8 +44,10 @@ sub new {
|
|||
"display-description" => { name => 'display_description' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"datastore-name:s" => { name => 'datastore_name' },
|
||||
"filter-datastore:s" => { name => 'filter_datastore' },
|
||||
"warning-max-total-latency:s" => { name => 'warning_max_total_latency' },
|
||||
"critical-max-total-latency:s" => { name => 'critical_max_total_latency' },
|
||||
"datastore-name:s" => { name => 'datastore_name' },
|
||||
"filter-datastore:s" => { name => 'filter_datastore' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $label (('warning', 'critical')) {
|
||||
foreach my $label (('warning', 'critical', 'warning_max_total_latency', 'critical_max_total_latency')) {
|
||||
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
|
||||
my ($label_opt) = $label;
|
||||
$label_opt =~ tr/_/-/;
|
||||
|
@ -146,6 +148,14 @@ Threshold warning in IOPs.
|
|||
|
||||
Threshold critical in IOPs.
|
||||
|
||||
=item B<--warning-max-total-latency>
|
||||
|
||||
Threshold warning in ms.
|
||||
|
||||
=item B<--critical-max-total-latency>
|
||||
|
||||
Threshold critical in ms.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -30,7 +30,8 @@ sub set_counters {
|
|||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' }
|
||||
{ name => 'ssid', type => 1, cb_prefix_output => 'prefix_ssid_output', message_multiple => 'All users by SSID are ok' },
|
||||
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' },
|
||||
];
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total', set => {
|
||||
|
@ -136,6 +137,18 @@ sub set_counters {
|
|||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{ap} = [
|
||||
{ label => 'ap', set => {
|
||||
key_values => [ { name => 'total' }, { name => 'display' } ],
|
||||
output_template => 'users : %s',
|
||||
perfdatas => [
|
||||
{ label => 'ap', value => 'total_absolute', template => '%s',
|
||||
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_ssid_output {
|
||||
|
@ -144,6 +157,12 @@ sub prefix_ssid_output {
|
|||
return "SSID '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_ap_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "AP '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -152,7 +171,8 @@ sub new {
|
|||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-ssid:s" => { name => 'filter_ssid' },
|
||||
"filter-ssid:s" => { name => 'filter_ssid' },
|
||||
"filter-ap:s" => { name => 'filter_ap' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -181,6 +201,8 @@ my $mapping3 = {
|
|||
|
||||
my $oid_agentInventoryMachineModel = '.1.3.6.1.4.1.14179.1.1.1.3';
|
||||
my $oid_bsnDot11EssSsid = '.1.3.6.1.4.1.14179.2.1.1.1.2';
|
||||
my $oid_bsnAPName = '.1.3.6.1.4.1.14179.2.2.1.1.3';
|
||||
my $oid_bsnAPIfLoadNumOfClients = '.1.3.6.1.4.1.14179.2.2.13.1.4';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -193,6 +215,8 @@ sub manage_selection {
|
|||
{ oid => $mapping2->{bsnMobileStationSsid}->{oid} },
|
||||
{ oid => $oid_bsnDot11EssSsid },
|
||||
{ oid => $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} },
|
||||
{ oid => $oid_bsnAPName },
|
||||
{ oid => $oid_bsnAPIfLoadNumOfClients },
|
||||
],
|
||||
nothing_quit => 1);
|
||||
$self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'});
|
||||
|
@ -219,13 +243,32 @@ sub manage_selection {
|
|||
my $result = $options{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{ $mapping3->{bsnDot11EssNumberOfMobileStations}->{oid} }, instance => $instance);
|
||||
if (defined($self->{option_results}->{filter_ssid}) && $self->{option_results}->{filter_ssid} ne '' &&
|
||||
$ssid_name !~ /$self->{option_results}->{filter_ssid}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping '" . $ssid_name . "': no matching filter.", debug => 1);
|
||||
$self->{output}->output_add(long_msg => "skipping ssid '" . $ssid_name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{ssid}->{$ssid_name} = { display => $ssid_name, total => 0 } if (!defined($self->{ssid}->{$ssid_name}));
|
||||
$self->{ssid}->{$ssid_name}->{total} += $result->{bsnDot11EssNumberOfMobileStations};
|
||||
}
|
||||
|
||||
# check by ap
|
||||
$self->{ap} = {};
|
||||
foreach my $oid (keys %{$self->{results}->{ $oid_bsnAPName }}) {
|
||||
$oid =~ /^$oid_bsnAPName\.(.*)/;
|
||||
my $instance = $1;
|
||||
my $ap_name = $self->{results}->{$oid_bsnAPName}->{$oid};
|
||||
if (defined($self->{option_results}->{filter_ap}) && $self->{option_results}->{filter_ap} ne '' &&
|
||||
$ap_name !~ /$self->{option_results}->{filter_ap}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping ap '" . $ap_name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
foreach my $oid2 (keys %{$self->{results}->{ $oid_bsnAPIfLoadNumOfClients }}) {
|
||||
next if ($oid2 !~ /^$oid_bsnAPIfLoadNumOfClients\.$instance\./);
|
||||
$self->{ap}->{$instance} = { display => $ap_name, total => 0 } if (!defined($self->{ap}->{$instance}));
|
||||
$self->{ap}->{$instance}->{total} += $self->{results}->{$oid_bsnAPIfLoadNumOfClients}->{$oid2};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -234,7 +277,7 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check total users connected and status on AP.
|
||||
Check users connected (total, by SSID, by AP).
|
||||
|
||||
=over 8
|
||||
|
||||
|
@ -248,19 +291,23 @@ Example: --filter-counters='^total|total-idle$'
|
|||
Threshold warning.
|
||||
Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated',
|
||||
'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted',
|
||||
'total-probing', 'total-blacklisted', 'ssid'.
|
||||
'total-probing', 'total-blacklisted', 'ssid', 'ap'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'total', 'total-idle', 'total-aaapending', 'total-authenticated',
|
||||
'total-associated', 'total-powersave', 'total-disassociated', 'total-tobedeleted',
|
||||
'total-probing', 'total-blacklisted', 'ssid'.
|
||||
'total-probing', 'total-blacklisted', 'ssid', 'ap'.
|
||||
|
||||
=item B<--filter-ssid>
|
||||
|
||||
Filter by SSID (can be a regexp).
|
||||
|
||||
=item B<--filter-ap>
|
||||
|
||||
Filter by AP (can be a regexp).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -20,11 +20,110 @@
|
|||
|
||||
package centreon::common::jvm::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'heap', type => 0 },
|
||||
{ name => 'nonheap', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{heap} = [
|
||||
{ label => 'heap', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'max' }, { name => 'label' } ],
|
||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
}
|
||||
},
|
||||
];
|
||||
$self->{maps_counters}->{nonheap} = [
|
||||
{ label => 'nonheap', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'max' }, { name => 'label' } ],
|
||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
sub custom_usage_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $use_th = 1;
|
||||
$use_th = 0 if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0);
|
||||
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
my %total_options = ();
|
||||
if ($instance_mode->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) {
|
||||
$total_options{total} = $self->{result_values}->{max};
|
||||
$total_options{cast_int} = 1;
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{result_values}->{label}, unit => 'B',
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
# Cannot use percent without total
|
||||
return 'ok' if ($self->{result_values}->{max} <= 0 && $instance_mode->{option_results}->{units} eq '%');
|
||||
my ($exit, $threshold_value);
|
||||
$threshold_value = $self->{result_values}->{used};
|
||||
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
||||
return $exit;
|
||||
}
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg;
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||
if ($self->{result_values}->{max} > 0) {
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{max});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{max} - $self->{result_values}->{used});
|
||||
$msg = sprintf("%s Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $self->{result_values}->{label},
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used});
|
||||
} else {
|
||||
$msg = sprintf("%s Used: %s", $self->{result_values}->{label},
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used});
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_usage_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{label} = $options{new_datas}->{$self->{label} . '_label'};
|
||||
$self->{result_values}->{max} = $options{new_datas}->{$self->{instance} . '_max'};
|
||||
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
|
||||
|
||||
if ($self->{result_values}->{max} > 0) {
|
||||
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{max};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -32,75 +131,30 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-heap:s" => { name => 'warning_heap' },
|
||||
"critical-heap:s" => { name => 'critical_heap' },
|
||||
"warning-nonheap:s" => { name => 'warning_nonheap' },
|
||||
"critical-nonheap:s" => { name => 'critical_nonheap' },
|
||||
{
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-heap', value => $self->{option_results}->{warning_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-heap threshold '" . $self->{option_results}->{warning_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-heap', value => $self->{option_results}->{critical_heap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-heap threshold '" . $self->{option_results}->{critical_heap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-nonheap', value => $self->{option_results}->{warning_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-nonheap threshold '" . $self->{option_results}->{warning_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-nonheap', value => $self->{option_results}->{critical_nonheap})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-nonheap threshold '" . $self->{option_results}->{critical_nonheap} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$instance_mode = $self;
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "java.lang:type=Memory" }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
my $result = $options{custom}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $prct_heap = $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max} * 100;
|
||||
my $prct_nonheap = $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used} / $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max} * 100;
|
||||
|
||||
my $exit1 = $self->{perfdata}->threshold_check(value => $prct_heap,
|
||||
threshold => [ { label => 'critical-heap', exit_litteral => 'critical' }, { label => 'warning-heap', exit_litteral => 'warning' } ]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $prct_nonheap,
|
||||
threshold => [ { label => 'critical-nonheap', exit_litteral => 'critical' }, { label => 'warning-nonheap', exit_litteral => 'warning'} ]);
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("HeapMemory Usage: %.2f%% - NonHeapMemoryUsage : %.2f%%",
|
||||
$prct_heap, $prct_nonheap));
|
||||
|
||||
$self->{output}->perfdata_add(label => 'HeapMemoryUsage', unit => 'B',
|
||||
value => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-heap', total => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-heap', total => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, cast_int => 1),
|
||||
min => 0, max => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max});
|
||||
|
||||
$self->{output}->perfdata_add(label => 'NonHeapMemoryUsage', unit => 'B',
|
||||
value => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-nonheap', total => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-nonheap', total => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, cast_int => 1),
|
||||
min => 0, max => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max});
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
$self->{heap} = { label => 'HeapMemory', used => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{used}, max => $result->{"java.lang:type=Memory"}->{HeapMemoryUsage}->{max} };
|
||||
$self->{nonheap} = { label => 'NonHeapMemoryUsage', used => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{used}, max => $result->{"java.lang:type=Memory"}->{NonHeapMemoryUsage}->{max} };
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -132,6 +186,10 @@ Threshold warning of NonHeap memory usage
|
|||
|
||||
Threshold critical of NonHeap memory usage
|
||||
|
||||
=item B<--units>
|
||||
|
||||
Units of thresholds (Default: '%') ('%', 'B').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::powershell::dell::compellent::hbausage;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub get_powershell {
|
||||
my (%options) = @_;
|
||||
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
|
||||
|
||||
return '' if ($no_ps == 1);
|
||||
|
||||
my $ps = '
|
||||
$culture = new-object "System.Globalization.CultureInfo" "en-us"
|
||||
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$scuser = "' . $options{cem_user} . '"
|
||||
$scpass = ConvertTo-SecureString "' . $options{cem_password} . '" -AsPlainText -Force
|
||||
$schost = "' . $options{cem_host} . '"
|
||||
$scport = "' . $options{cem_port} . '"
|
||||
$connName = "EMDefault"
|
||||
|
||||
Function display_hba_information {
|
||||
$conn = Connect-DellApiConnection -HostName $schost -Port $scport -User $scuser -password $scpass -Save $connName
|
||||
';
|
||||
if (defined($options{filter_sc}) && $options{filter_sc} ne '') {
|
||||
$ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName -Name "' . $options{filter_sc} . '"
|
||||
';
|
||||
} else {
|
||||
$ps .= '$storageCenters = Get-DellStorageCenter -ConnectionName $connName
|
||||
';
|
||||
}
|
||||
|
||||
$ps .= '
|
||||
$historical = New-DellHistoricalFilter -FilterTime "Other" -StartTime "' . $options{start_time} . '" -EndTime "' . $options{end_time} . '"
|
||||
foreach ($sc in $storageCenters) {
|
||||
$hbaList = Get-DellScServerHba -ConnectionName $connName -StorageCenter $sc
|
||||
|
||||
foreach ($hba in $hbaList) {
|
||||
$usageList = Get-DellScServerHbaHistoricalIoUsage -ConnectionName $connName -Instance $hba -HistoricalFilter $historical
|
||||
|
||||
write-host ("[sc={0}]" -f $hba.ScName) -NoNewline
|
||||
write-host ("[name={0}]" -f $hba.Name) -NoNewline
|
||||
|
||||
$attrs = @{ReadKbPerSecond = 0; WriteKbPerSecond = 0; ReadIops = 0; WriteIops = 0; ReadLatency = 0; WriteLatency = 0; }
|
||||
$count = 0
|
||||
foreach ($usage in $usageList) {
|
||||
foreach ($item in $($attrs.GetEnumerator() | sort -Property Key)) {
|
||||
$attrs[$item.Key] += ($usage | Select -ExpandProperty $item.Key)
|
||||
}
|
||||
$count++
|
||||
}
|
||||
|
||||
foreach ($item in $attrs.GetEnumerator() | sort -Property Key) {
|
||||
write-host ("[{0}={1}]" -f $item.Key, ($item.Value / $count)) -NoNewline
|
||||
}
|
||||
write-host
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Try {
|
||||
Import-Module "' . $options{sdk_path_dll} . '"
|
||||
display_hba_information
|
||||
} Catch {
|
||||
Write-Host $Error[0].Exception
|
||||
$ret = Remove-DellSavedApiConnection -Name $connName
|
||||
exit 1
|
||||
}
|
||||
|
||||
$ret = Remove-DellSavedApiConnection -Name $connName
|
||||
exit 0
|
||||
';
|
||||
|
||||
return centreon::plugins::misc::powershell_encoded($ps);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Method to get compellent hba informations.
|
||||
|
||||
=cut
|
|
@ -30,7 +30,7 @@ use Pod::Find qw(pod_where);
|
|||
|
||||
my %handlers = (DIE => {});
|
||||
|
||||
my $global_version = 20160324;
|
||||
my $global_version = 20160524;
|
||||
my $alternative_fatpacker = 0;
|
||||
|
||||
sub new {
|
||||
|
|
|
@ -22,9 +22,9 @@ package centreon::plugins::values;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# le label de perfdata: on peut le surcharger (au lieu du label)
|
||||
# le warning/critical: on peut surcharger
|
||||
# Warning message with sprintf and too much arguments.
|
||||
# Really annoying. Need to disable that warning
|
||||
no if ($^V gt v5.22.0), 'warnings' => 'redundant';
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -139,7 +139,7 @@ sub output {
|
|||
return $self->{closure_custom_output}->($self);
|
||||
}
|
||||
my $first = ${${$self->{key_values}}[0]}{name};
|
||||
my ($value, $unit) = ($self->{result_values}->{$first . '_absolute'}, $self->{result_values}->{output_absolute_unit});
|
||||
my ($value, $unit) = ($self->{result_values}->{$first . '_absolute'}, $self->{output_absolute_unit});
|
||||
|
||||
if (!defined($self->{output_use})) {
|
||||
if ($self->{per_second} == 1) {
|
||||
|
|
16
changelog
16
changelog
|
@ -1,3 +1,19 @@
|
|||
2016-05-24 Quentin Garnier <qgarnier@centreon.com>
|
||||
* Can use '/' instead '::' for plugin option (#380)
|
||||
* Mode added: [pacemaker] 'constraints'
|
||||
* Mode added: [netbackup] 'tape-usage'
|
||||
* Mode added: [oracle] 'data-files-status'
|
||||
* Mode added: [netasq] 'connections'
|
||||
* Enhancement: [cisco wlc]{ap-users} get users by AP (#375)
|
||||
* Enhancement: [oracle]{tablespace} can use free size left
|
||||
* Fix: [pdu apc]{load} incorrect values (#408)
|
||||
* Fix: [mscs] Issue with old versions
|
||||
* Fix: [postgres]{timesync} threshold issue
|
||||
* Fix: [ntp]{offset} time formula issue
|
||||
* Fix: [github]{issues} Get only issue
|
||||
* Fix: [netasq]{memory} Use BSD memory check
|
||||
* Fix: [tomcat]{applications} Issue on Windows (#356)
|
||||
|
||||
2016-03-24 Quentin Garnier <qgarnier@centreon.com>
|
||||
* Plugin added: to check AKCP SensorProbe
|
||||
* Plugin added: to check Juniper ISG
|
||||
|
|
|
@ -158,6 +158,7 @@ sub run {
|
|||
}
|
||||
|
||||
if (defined($result->{rPDULoadStatusLoad}) && $result->{rPDULoadStatusLoad} =~ /[0-9]/) {
|
||||
$result->{rPDULoadStatusLoad} /= 10;
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'load', instance => $instance, value => $result->{rPDULoadStatusLoad});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
|
|
|
@ -96,9 +96,9 @@ sub set_counters {
|
|||
},
|
||||
{ label => 'time', set => {
|
||||
key_values => [ { name => 'upsAdvBatteryRunTimeRemaining' } ],
|
||||
output_template => 'Remaining time : %s minutes',
|
||||
output_template => 'Remaining time : %.2f minutes',
|
||||
perfdatas => [
|
||||
{ label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining_absolute', template => '%s',
|
||||
{ label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining_absolute', template => '%.2f',
|
||||
min => 0, unit => 'm' },
|
||||
],
|
||||
}
|
||||
|
|
|
@ -125,12 +125,13 @@ sub check_options {
|
|||
$self->{extra_oids} = {};
|
||||
foreach (@{$self->{option_results}->{add_extra_oid}}) {
|
||||
next if ($_ eq '');
|
||||
my ($name, $oid) = split /,/;
|
||||
my ($name, $oid, $matching) = split /,/;
|
||||
$matching = '%{instance}' if (!defined($matching));
|
||||
if (!defined($oid) || $oid !~ /^(\.\d+){1,}$/ || $name eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong syntax for add-extra-oid '" . $_ . "' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{extra_oids}->{$name} = $oid;
|
||||
$self->{extra_oids}->{$name} = { oid => $oid, matching => $matching };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,11 +169,11 @@ sub run {
|
|||
$self->{output}->output_add(long_msg => "Skipping interface '" . $display_value . "': adminstatus is not 'up' and option --use-adminstatus is set");
|
||||
next;
|
||||
}
|
||||
|
||||
my $extra_values = $self->get_extra_values_by_instance(instance => $_);
|
||||
my $extra_display = '';
|
||||
my $extra_display_append = ' ';
|
||||
foreach my $name (keys %{$self->{extra_oids}}) {
|
||||
$extra_display .= $extra_display_append . $name . ' = ' . (defined($result->{$self->{extra_oids}->{$name} . "." . $_}) ? $result->{$self->{extra_oids}->{$name} . "." . $_} : '');
|
||||
$extra_display_append = ', ';
|
||||
foreach my $name (keys %{$extra_values}) {
|
||||
$extra_display .= ', ' . $name . ' = ' . $extra_values->{$name};
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "'" . $display_value . "' [speed = $interface_speed, status = " .
|
||||
|
@ -194,9 +195,6 @@ sub get_additional_information {
|
|||
push @$oids, $self->{oid_opstatus} if (defined($self->{oid_opstatus}));
|
||||
push @$oids, $oid_speed32 if ($self->{no_speed} == 0);
|
||||
push @$oids, $oid_speed64 if (!$self->{snmp}->is_snmpv1() && $self->{no_speed} == 0);
|
||||
if (scalar(keys %{$self->{extra_oids}}) > 0) {
|
||||
push @$oids, values %{$self->{extra_oids}};
|
||||
}
|
||||
|
||||
$self->{snmp}->load(oids => $oids, instances => $self->{interface_id_selected});
|
||||
return $self->{snmp}->get_leef();
|
||||
|
@ -216,12 +214,22 @@ sub get_display_value {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oids = [{ oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}} }];
|
||||
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) {
|
||||
push @$oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} };
|
||||
}
|
||||
if (scalar(keys %{$self->{extra_oids}}) > 0) {
|
||||
foreach (keys %{$self->{extra_oids}}) {
|
||||
push @$oids, { oid => $self->{extra_oids}->{$_}->{oid} };
|
||||
}
|
||||
}
|
||||
|
||||
$self->{datas} = {};
|
||||
my $result = $self->{snmp}->get_table(oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}});
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $oids);
|
||||
$self->{datas}->{all_ids} = [];
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_filter}} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_filter}}\.(.*)$/);
|
||||
$self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
|
||||
$self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_filter}} }->{$key});
|
||||
push @{$self->{datas}->{all_ids}}, $1;
|
||||
}
|
||||
|
||||
|
@ -231,11 +239,10 @@ sub manage_selection {
|
|||
}
|
||||
|
||||
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) {
|
||||
$result = $self->{snmp}->get_table(oid => $self->{oids_label}->{$self->{option_results}->{oid_display}});
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_display}} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_display}}\.(.*)$/);
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
|
||||
}
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_display}} }->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{interface})) {
|
||||
|
@ -265,6 +272,27 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
|
||||
sub get_extra_values_by_instance {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $extra_values = {};
|
||||
foreach my $name (keys %{$self->{extra_oids}}) {
|
||||
my $matching = $self->{extra_oids}->{$name}->{matching};
|
||||
$matching =~ s/%\{instance\}/$options{instance}/g;
|
||||
next if (!defined($self->{results}->{ $self->{extra_oids}->{$name}->{oid} }));
|
||||
|
||||
my $append = '';
|
||||
foreach (keys %{$self->{results}->{ $self->{extra_oids}->{$name}->{oid} }}) {
|
||||
if (/^$self->{extra_oids}->{$name}->{oid}\.$matching/) {
|
||||
$extra_values->{$name} = '' if (!defined($extra_values->{$name}));
|
||||
$extra_values->{$name} .= $append . $self->{results}->{$self->{extra_oids}->{$name}->{oid}}->{$_};
|
||||
$append = ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $extra_values;
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -299,18 +327,13 @@ sub disco_show {
|
|||
next if (defined($self->{option_results}->{filter_status}) && defined($result->{$self->{oid_opstatus} . "." . $_}) &&
|
||||
$self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} !~ /$self->{option_results}->{filter_status}/i);
|
||||
next if ($self->is_admin_status_down(admin_status => $result->{$self->{oid_adminstatus} . "." . $_}));
|
||||
|
||||
my %extra_values = ();
|
||||
foreach my $name (keys %{$self->{extra_oids}}) {
|
||||
$extra_values{$name} = defined($result->{$self->{extra_oids}->{$name} . "." . $_}) ?
|
||||
$result->{$self->{extra_oids}->{$name} . "." . $_} : '';
|
||||
}
|
||||
|
||||
|
||||
my $extra_values = $self->get_extra_values_by_instance(instance => $_);
|
||||
$self->{output}->add_disco_entry(name => $display_value,
|
||||
total => $interface_speed,
|
||||
status => defined($result->{$self->{oid_opstatus} . "." . $_}) ? $self->{oid_opstatus_mapping}->{$result->{$self->{oid_opstatus} . "." . $_}} : '',
|
||||
interfaceid => $_,
|
||||
%extra_values);
|
||||
%$extra_values);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +387,10 @@ Regexp dst to transform display value. (security risk!!!)
|
|||
|
||||
=item B<--add-extra-oid>
|
||||
|
||||
Display an OID. Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18'
|
||||
Display an OID.
|
||||
Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18'
|
||||
or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*'
|
||||
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -0,0 +1,318 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::dell::compellent::local::mode::hbausage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::dell::compellent::hbausage;
|
||||
use DateTime;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'hba', type => 1, cb_prefix_output => 'prefix_hba_output', message_multiple => 'All HBA are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{hba} = [
|
||||
{ label => 'read-iops', set => {
|
||||
key_values => [ { name => 'read_iops' }, { name => 'display' } ],
|
||||
output_template => 'Read IOPs : %s',
|
||||
perfdatas => [
|
||||
{ label => 'read_iops', value => 'read_iops_absolute', template => '%d',
|
||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'read-usage', set => {
|
||||
key_values => [ { name => 'read_bps' }, { name => 'display' } ],
|
||||
output_template => 'Read usage : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'read_usage', value => 'read_bps_absolute', template => '%d',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'read-latency', set => {
|
||||
key_values => [ { name => 'read_latency' }, { name => 'display' } ],
|
||||
output_template => 'Read latency : %s ms',
|
||||
perfdatas => [
|
||||
{ label => 'read_latency', value => 'read_latency_absolute', template => '%d',
|
||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'write-iops', set => {
|
||||
key_values => [ { name => 'write_iops' }, { name => 'display' } ],
|
||||
output_template => 'Write IOPs : %s',
|
||||
perfdatas => [
|
||||
{ label => 'write_iops', value => 'write_iops_absolute', template => '%d',
|
||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'write-usage', set => {
|
||||
key_values => [ { name => 'write_bps' }, { name => 'display' } ],
|
||||
output_template => 'Write Usage : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'write_usage', value => 'write_bps_absolute', template => '%d',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'write-latency', set => {
|
||||
key_values => [ { name => 'write_latency' }, { name => 'display' } ],
|
||||
output_template => 'Write Latency : %s ms',
|
||||
perfdatas => [
|
||||
{ label => 'write_latency', value => 'write_latency_absolute', template => '%d',
|
||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_hba_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "HBA '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"cem-host:s" => { name => 'cem_host' },
|
||||
"cem-user:s" => { name => 'cem_user' },
|
||||
"cem-password:s" => { name => 'cem_password' },
|
||||
"cem-port:s" => { name => 'cem_port', default => 3033 },
|
||||
"sdk-path-dll:s" => { name => 'sdk_path_dll' },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"command:s" => { name => 'command', default => 'powershell.exe' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"no-ps" => { name => 'no_ps' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only' },
|
||||
"ps-sc-filter:s" => { name => 'ps_sc_filter' },
|
||||
"start-time:s" => { name => 'start_time' },
|
||||
"end-time:s" => { name => 'end_time' },
|
||||
"timezone:s" => { name => 'timezone' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub get_iso8601 {
|
||||
my ($self, %options) = @_;
|
||||
my $value = $options{date}->datetime . '.' . sprintf("%03d", $options{date}->millisecond());
|
||||
my $offset = $options{date}->offset();
|
||||
|
||||
$value .= "-" if ($offset < 0);
|
||||
$value .= "+" if ($offset >= 0);
|
||||
$offset = abs($offset);
|
||||
$value .= sprintf("%02d:%02d", $offset / 3600, $offset % 3600);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub parse_date {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if ($options{date} !~ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong time option '" . $options{date} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $dt = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6,
|
||||
time_zone => $self->{option_results}->{timezone});
|
||||
return $dt;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq '');
|
||||
foreach my $label (('cem_host', 'cem_user', 'cem_password', 'cem_port', 'sdk_path_dll')) {
|
||||
if (!defined($self->{option_results}->{$label}) || $self->{option_results}->{$label} eq '') {
|
||||
my ($label_opt) = $label;
|
||||
$label_opt =~ tr/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
my ($dt_start, $dt_end);
|
||||
if (defined($self->{option_results}->{end_time}) && $self->{option_results}->{end_time} ne '') {
|
||||
$dt_end = $self->parse_date(date => $self->{option_results}->{end_time});
|
||||
} else {
|
||||
$dt_end = DateTime->now(time_zone => $self->{option_results}->{timezone});
|
||||
}
|
||||
$self->{end_time} = $self->get_iso8601(date => $dt_end);
|
||||
|
||||
if (defined($self->{option_results}->{start_time}) && $self->{option_results}->{start_time} ne '') {
|
||||
$dt_start = $self->parse_date(date => $self->{option_results}->{start_time});
|
||||
} else {
|
||||
$dt_start = $dt_end->subtract(minutes => 30);
|
||||
}
|
||||
$self->{start_time} = $self->get_iso8601(date => $dt_start);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $ps = centreon::common::powershell::dell::compellent::hbausage::get_powershell(cem_host => $self->{option_results}->{cem_host},
|
||||
cem_user => $self->{option_results}->{cem_user},
|
||||
cem_password => $self->{option_results}->{cem_password},
|
||||
cem_port => $self->{option_results}->{cem_port},
|
||||
sdk_path_dll => $self->{option_results}->{sdk_path_dll},
|
||||
no_ps => $self->{option_results}->{no_ps},
|
||||
filter_sc => $self->{option_results}->{ps_sc_filter},
|
||||
end_time => $self->{end_time}, start_time => $self->{start_time});
|
||||
|
||||
$self->{option_results}->{command_options} .= " " . $ps;
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $stdout);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
# microseconds for latencies
|
||||
#[sc=PRD-SAN-01][name=xxxx][ReadIops=39,5][ReadKbPerSecond=1220,75][ReadLatency=3997][WriteIops=95,75][WriteKbPerSecond=1217][WriteLatency=3903,25]
|
||||
$self->{hba} = {};
|
||||
$stdout =~ s/,/\./msg;
|
||||
while ($stdout =~ /^\[sc=(.*?)\]\[name=(.*?)\]\[ReadIops=(.*?)\]\[ReadKbPerSecond=(.*?)\]\[ReadLatency=(.*?)\]\[WriteIops=(.*?)\]\[WriteKbPerSecond=(.*?)\]\[WriteLatency=(.*?)\]/mig) {
|
||||
my ($sc, $name, $read_iops, $read_kbps, $read_latency, $write_iops, $write_kbps, $write_latency) =
|
||||
($1, $2, $3, $4, $5, $6, $7, $8);
|
||||
my $display = $sc . '/' . $name;
|
||||
|
||||
$self->{hba}->{$name} = { display => $display, read_iops => $read_iops, read_bps => $read_kbps * 1000, read_latency => $read_latency / 1000,
|
||||
write_iops => $write_iops, write_bps => $write_kbps * 1000, write_latency => $write_latency / 1000 };
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hba usages.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--cem-host>
|
||||
|
||||
Compellent Entreprise Manager hostname (Required).
|
||||
|
||||
=item B<--cem-user>
|
||||
|
||||
Compellent Entreprise Manager username (Required).
|
||||
|
||||
=item B<--cem-password>
|
||||
|
||||
Compellent Entreprise Manager password (Required).
|
||||
|
||||
=item B<--cem-port>
|
||||
|
||||
Compellent Entreprise Manager port (Default: 3033).
|
||||
|
||||
=item B<--sdk-path-dll>
|
||||
|
||||
Path to 'DellStorage.ApiCommandSet.dll' (Required).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout time for command execution (Default: 50 sec)
|
||||
|
||||
=item B<--no-ps>
|
||||
|
||||
Don't encode powershell. To be used with --command and 'type' command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'powershell.exe').
|
||||
Can be changed if you have output in a file. To be used with --no-ps option!!!
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
|
||||
|
||||
=item B<--ps-exec-only>
|
||||
|
||||
Print powershell output.
|
||||
|
||||
=item B<--ps-sc-filter>
|
||||
|
||||
Filter Storage Center (only wilcard '*' can be used. In Powershell).
|
||||
|
||||
=item B<--start-time>
|
||||
|
||||
Begin time for counters sampling. If not set, 30 minutes before the end-time option or current time
|
||||
Format: 2016-05-25T10:30:00
|
||||
|
||||
=item B<--end-time>
|
||||
|
||||
End time for counters sampling. If not set, the current execution time.
|
||||
Format: 2016-05-25T15:30:00
|
||||
|
||||
=item B<--timezone>
|
||||
|
||||
Timezone of time options. Default is 'GMT'.
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^read-iops$'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'read-iops', 'read-usage', 'read-latency',
|
||||
'write-iops', 'write-usage', 'write-latency'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'read-iops', 'read-usage', 'read-latency',
|
||||
'write-iops', 'write-usage', 'write-latency'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -31,6 +31,7 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'hba-usage' => 'storage::dell::compellent::local::mode::hbausage',
|
||||
'volume-usage' => 'storage::dell::compellent::local::mode::volumeusage',
|
||||
);
|
||||
|
||||
|
|
|
@ -20,32 +20,56 @@
|
|||
|
||||
package storage::netapp::snmp::mode::filesys;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $maps_counters = {
|
||||
'000_usage' => { set => {
|
||||
key_values => [ { name => 'name' }, { name => 'used' }, { name => 'total' },
|
||||
{ name => 'dfCompressSavedPercent' }, { name => 'dfDedupeSavedPercent' } ],
|
||||
closure_custom_calc => \&custom_usage_calc,
|
||||
closure_custom_output => \&custom_usage_output,
|
||||
closure_custom_perfdata => \&custom_usage_perfdata,
|
||||
closure_custom_threshold_check => \&custom_usage_threshold,
|
||||
}
|
||||
},
|
||||
'001_inodes' => { set => {
|
||||
key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'name' } ],
|
||||
output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s",
|
||||
perfdatas => [
|
||||
{ label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'name_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'fs', type => 1, cb_prefix_output => 'prefix_fs_output', message_multiple => 'All filesystems are ok.' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{fs} = [
|
||||
{ label => 'usage', set => {
|
||||
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ],
|
||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
}
|
||||
},
|
||||
{ label => 'inodes', set => {
|
||||
key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'display' } ],
|
||||
output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s",
|
||||
perfdatas => [
|
||||
{ label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'compresssaved', set => {
|
||||
key_values => [ { name => 'dfCompressSavedPercent' }, { name => 'display' } ],
|
||||
output_template => 'Compress Saved : %s %%', output_error_template => "Compress Saved : %s",
|
||||
perfdatas => [
|
||||
{ label => 'compresssaved', value => 'dfCompressSavedPercent_absolute', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'dedupsaved', set => {
|
||||
key_values => [ { name => 'dfDedupeSavedPercent' }, { name => 'display' } ],
|
||||
output_template => 'Dedupe Saved : %s %%', output_error_template => "Dedupe Saved : %s",
|
||||
perfdatas => [
|
||||
{ label => 'dedupsaved', value => 'dfDedupeSavedPercent_absolute', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
|
@ -60,7 +84,7 @@ sub custom_usage_perfdata {
|
|||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{name} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
my %total_options = ();
|
||||
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
|
@ -72,18 +96,6 @@ sub custom_usage_perfdata {
|
|||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
||||
min => 0, max => $self->{result_values}->{total});
|
||||
if (defined($self->{result_values}->{dfCompressSavedPercent}) && $self->{result_values}->{dfCompressSavedPercent} ne '' &&
|
||||
$self->{result_values}->{dfCompressSavedPercent} >= 0) {
|
||||
$self->{output}->perfdata_add(label => 'compresssaved' . $extra_label, unit => '%',
|
||||
value => $self->{result_values}->{dfCompressSavedPercent},
|
||||
min => 0, max => 100);
|
||||
}
|
||||
if (defined($self->{result_values}->{dfDedupeSavedPercent}) && $self->{result_values}->{dfDedupeSavedPercent} ne '' &&
|
||||
$self->{result_values}->{dfDedupeSavedPercent} >= 0) {
|
||||
$self->{output}->perfdata_add(label => 'dedupsaved' . $extra_label, unit => '%',
|
||||
value => $self->{result_values}->{dfDedupeSavedPercent},
|
||||
min => 0, max => 100);
|
||||
}
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -124,11 +136,9 @@ sub custom_usage_output {
|
|||
sub custom_usage_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'};
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
|
||||
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
|
||||
$self->{result_values}->{dfCompressSavedPercent} = $options{new_datas}->{$self->{instance} . '_dfCompressSavedPercent'};
|
||||
$self->{result_values}->{dfDedupeSavedPercent} = $options{new_datas}->{$self->{instance} . '_dfDedupeSavedPercent'};
|
||||
|
||||
return 0 if ($options{new_datas}->{$self->{instance} . '_total'} == 0);
|
||||
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||
|
@ -144,6 +154,12 @@ sub custom_usage_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_fs_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Filesys '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -156,96 +172,17 @@ sub new {
|
|||
"free" => { name => 'free' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
});
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
my ($id, $name) = split /_/;
|
||||
if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$maps_counters->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $name);
|
||||
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
|
||||
}
|
||||
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$instance_mode = $self;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{filesys_selected}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All filesys usages are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{filesys_selected}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits;
|
||||
foreach (sort keys %{$maps_counters}) {
|
||||
$maps_counters->{$_}->{obj}->set(instance => $id);
|
||||
|
||||
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{filesys_selected}->{$id});
|
||||
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
|
||||
$long_msg_append = ', ';
|
||||
next;
|
||||
}
|
||||
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $maps_counters->{$_}->{obj}->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = ', ';
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $long_msg");
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "Filesys '" . $self->{filesys_selected}->{$id}->{name} . "' $long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
my %map_types = (
|
||||
1 => 'traditionalVolume',
|
||||
2 => 'flexibleVolume',
|
||||
|
@ -279,45 +216,45 @@ sub manage_selection {
|
|||
{ oid => $mapping2->{dfCompressSavedPercent}->{oid} },
|
||||
{ oid => $mapping2->{dfDedupeSavedPercent}->{oid} },
|
||||
];
|
||||
if (!$self->{snmp}->is_snmpv1()) {
|
||||
if (!$options{snmp}->is_snmpv1()) {
|
||||
push @{$oids}, { oid => $mapping2->{df64TotalKBytes}->{oid} }, { oid => $mapping2->{df64UsedKBytes}->{oid} };
|
||||
}
|
||||
|
||||
my $results = $self->{snmp}->get_multiple_table(oids => $oids, return_type => 1, nothing_quit => 1);
|
||||
$self->{filesys_selected} = {};
|
||||
my $results = $options{snmp}->get_multiple_table(oids => $oids, return_type => 1, nothing_quit => 1);
|
||||
$self->{fs} = {};
|
||||
foreach my $oid (keys %{$results}) {
|
||||
next if ($oid !~ /^$mapping2->{dfFileSys}->{oid}\.(\d+)/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance);
|
||||
|
||||
my $name = $result2->{dfFileSys};
|
||||
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 name.");
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter name.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$result->{dfType} !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping '" . $result->{dfType} . "': no matching filter type.");
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{dfType} . "': no matching filter type.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{filesys_selected}->{$instance} = { name => $name };
|
||||
$self->{filesys_selected}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024;
|
||||
$self->{filesys_selected}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024;
|
||||
$self->{fs}->{$instance} = { display => $name };
|
||||
$self->{fs}->{$instance}->{total} = $result2->{dfKBytesTotal} * 1024;
|
||||
$self->{fs}->{$instance}->{used} = $result2->{dfKBytesUsed} * 1024;
|
||||
if (defined($result2->{df64TotalKBytes}) && $result2->{df64TotalKBytes} > 0) {
|
||||
$self->{filesys_selected}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024;
|
||||
$self->{filesys_selected}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024;
|
||||
$self->{fs}->{$instance}->{total} = $result2->{df64TotalKBytes} * 1024;
|
||||
$self->{fs}->{$instance}->{used} = $result2->{df64UsedKBytes} * 1024;
|
||||
}
|
||||
$self->{filesys_selected}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent};
|
||||
$self->{filesys_selected}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent};
|
||||
if ($self->{filesys_selected}->{$instance}->{total} > 0) {
|
||||
$self->{filesys_selected}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity};
|
||||
$self->{fs}->{$instance}->{dfCompressSavedPercent} = $result2->{dfCompressSavedPercent};
|
||||
$self->{fs}->{$instance}->{dfDedupeSavedPercent} = $result2->{dfDedupeSavedPercent};
|
||||
if ($self->{fs}->{$instance}->{total} > 0) {
|
||||
$self->{fs}->{$instance}->{dfPerCentInodeCapacity} = $result2->{dfPerCentInodeCapacity};
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{filesys_selected}}) <= 0) {
|
||||
if (scalar(keys %{$self->{fs}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -336,12 +273,12 @@ Check filesystem usage (volumes, snapshots and aggregates also).
|
|||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: usage, inodes (%).
|
||||
Can be: usage, inodes (%), compresssaved (%), dedupsaved (%).
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: usage, inodes (%).
|
||||
Can be: usage, inodes (%), compresssaved (%), dedupsaved (%).
|
||||
|
||||
=item B<--units>
|
||||
|
||||
|
|
Loading…
Reference in New Issue