fix indent

This commit is contained in:
garnier-quentin 2020-02-03 15:19:28 +01:00
parent 093ecd88e4
commit bd94ae30eb
11 changed files with 228 additions and 197 deletions

View File

@ -32,8 +32,7 @@ my $cluster_name = '';
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status}; return 'status : ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub custom_status_calc {
@ -59,11 +58,13 @@ sub custom_usage_perfdata {
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label, unit => 'B', $self->{output}->perfdata_add(
label => $label, unit => 'B',
value => $value_perf, value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total}); min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -86,11 +87,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit, $total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
return $msg; );
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -102,7 +104,6 @@ sub custom_usage_calc {
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0; return 0;
} }
@ -156,12 +157,11 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'warning-status:s' => { name => 'warning_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' }, 'critical-status:s' => { name => 'critical_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '' }, 'units:s' => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, 'free' => { name => 'free' },
"free" => { name => 'free' },
}); });
return $self; return $self;
@ -198,9 +198,11 @@ sub manage_selection {
$self->{output}->option_exit(); $self->{output}->option_exit();
} }
my $snmp_result = $options{snmp}->get_table(oid => $oid_nutanix, my $snmp_result = $options{snmp}->get_table(
oid => $oid_nutanix,
start => $mapping->{clusterName}->{oid}, end => $mapping->{clusterLatency}->{oid}, start => $mapping->{clusterName}->{oid}, end => $mapping->{clusterLatency}->{oid},
nothing_quit => 1); nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
$self->{cluster} = { %$result }; $self->{cluster} = { %$result };
$cluster_name = centreon::plugins::misc::trim($result->{clusterName}); $cluster_name = centreon::plugins::misc::trim($result->{clusterName});

View File

@ -43,11 +43,13 @@ sub custom_usage_perfdata {
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
label => $label . $extra_label, unit => 'B',
value => $value_perf, value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total}); min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -70,11 +72,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit, $total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
return $msg; );
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -86,7 +89,6 @@ sub custom_usage_calc {
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0; return 0;
} }
@ -133,9 +135,9 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' }, 'units:s' => { name => 'units', default => '%' },
"free" => { name => 'free' }, 'free' => { name => 'free' },
}); });
return $self; return $self;
@ -166,8 +168,10 @@ sub manage_selection {
} }
$self->{container} = {}; $self->{container} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_citEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_citEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{citContainerName}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{citContainerName}->{oid}\.(.*)$/);

View File

@ -30,8 +30,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = 'state : ' . $self->{result_values}->{state}; return 'state : ' . $self->{result_values}->{state};
return $msg;
} }
sub custom_status_calc { sub custom_status_calc {
@ -59,11 +58,13 @@ sub custom_usage_perfdata {
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
label => $label . $extra_label, unit => 'B',
value => $value_perf, value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total}); min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -86,11 +87,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit, $total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
return $msg; );
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -102,7 +104,6 @@ sub custom_usage_calc {
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free}; $self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0; return 0;
} }
@ -165,13 +166,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' }, 'warning-status:s' => { name => 'warning_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' }, 'critical-status:s' => { name => 'critical_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '' }, 'units:s' => { name => 'units', default => '%' },
"units:s" => { name => 'units', default => '%' }, 'free' => { name => 'free' },
"free" => { name => 'free' },
}); });
return $self; return $self;
@ -214,8 +214,10 @@ sub manage_selection {
} }
$self->{disk} = {}; $self->{disk} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_dstEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_dstEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{dstDiskId}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{dstDiskId}->{oid}\.(.*)$/);
@ -231,8 +233,10 @@ sub manage_selection {
my $inodes_used; my $inodes_used;
$inodes_used = 100 - ($result->{dstNumFreeInodes} * 100 / $result->{dstNumTotalInodes}) if ($result->{dstNumTotalInodes} > 0); $inodes_used = 100 - ($result->{dstNumFreeInodes} * 100 / $result->{dstNumTotalInodes}) if ($result->{dstNumTotalInodes} > 0);
$self->{disk}->{$instance} = { display => $result->{dstDiskId}, $self->{disk}->{$instance} = {
%$result, inodes_used => $inodes_used, display => $result->{dstDiskId},
%$result,
inodes_used => $inodes_used
}; };
} }

View File

@ -35,11 +35,13 @@ sub custom_usage_perfdata {
$extra_label = '_' . $self->{result_values}->{display} 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 = (total => $self->{result_values}->{total}, cast_int => 1); my %total_options = (total => $self->{result_values}->{total}, cast_int => 1);
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
label => $label . $extra_label, unit => 'B',
value => $value_perf, value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total}); min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_output { sub custom_usage_output {
@ -48,11 +50,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Memory Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
'Memory Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit, $total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
return $msg; );
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -64,7 +67,6 @@ sub custom_usage_calc {
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
$self->{result_values}->{used} = $self->{result_values}->{prct_used} * $self->{result_values}->{total} / 100; $self->{result_values}->{used} = $self->{result_values}->{prct_used} * $self->{result_values}->{total} / 100;
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
return 0; return 0;
} }
@ -138,7 +140,7 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' },
}); });
return $self; return $self;
@ -172,8 +174,10 @@ sub manage_selection {
} }
$self->{hypervisor} = {}; $self->{hypervisor} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_hypervisorEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_hypervisorEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{hypervisorName}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{hypervisorName}->{oid}\.(.*)$/);
@ -187,7 +191,8 @@ sub manage_selection {
next; next;
} }
$self->{hypervisor}->{$instance} = { display => $result->{hypervisorName}, $self->{hypervisor}->{$instance} = {
display => $result->{hypervisorName},
%$result, %$result,
}; };
} }

View File

@ -33,9 +33,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
@ -71,8 +70,10 @@ sub run {
$self->{output}->output_add(long_msg => "'" . $name . "'"); $self->{output}->output_add(long_msg => "'" . $name . "'");
} }
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => 'List Containers:'); severity => 'OK',
short_msg => 'List containers:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit(); $self->{output}->exit();
} }
@ -110,4 +111,3 @@ Filter by container name.
=back =back
=cut =cut

View File

@ -41,9 +41,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
@ -56,10 +55,14 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ my $snmp_result = $self->{snmp}->get_multiple_table(
oids => [
{ oid => $mapping->{dstDiskId}->{oid} }, { oid => $mapping->{dstDiskId}->{oid} },
{ oid => $mapping->{dstState}->{oid} }, { oid => $mapping->{dstState}->{oid} },
], return_type => 1, nothing_quit => 1); ],
return_type => 1,
nothing_quit => 1
);
$self->{disk} = {}; $self->{disk} = {};
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{dstState}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{dstState}->{oid}\.(.*)$/);
@ -85,8 +88,10 @@ sub run {
$self->{output}->output_add(long_msg => "[disk_id = " . $self->{disk}->{$name}->{dstDiskId} . "] [state = " . $self->{disk}->{$name}->{dstState} . "]"); $self->{output}->output_add(long_msg => "[disk_id = " . $self->{disk}->{$name}->{dstDiskId} . "] [state = " . $self->{disk}->{$name}->{dstState} . "]");
} }
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => 'List Disks:'); severity => 'OK',
short_msg => 'List disks:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit(); $self->{output}->exit();
} }
@ -103,8 +108,10 @@ sub disco_show {
$self->manage_selection(); $self->manage_selection();
foreach my $name (sort keys %{$self->{disk}}) { foreach my $name (sort keys %{$self->{disk}}) {
$self->{output}->add_disco_entry(disk_id => $self->{disk}->{$name}->{dstDiskId}, $self->{output}->add_disco_entry(
state => $self->{disk}->{$name}->{dstState}); disk_id => $self->{disk}->{$name}->{dstDiskId},
state => $self->{disk}->{$name}->{dstState}
);
} }
} }
@ -125,4 +132,3 @@ Filter by disk id.
=back =back
=cut =cut

View File

@ -33,9 +33,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
@ -110,4 +109,3 @@ Filter by hypervisor name.
=back =back
=cut =cut

View File

@ -33,9 +33,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
@ -110,4 +109,3 @@ Filter by storage pool name.
=back =back
=cut =cut

View File

@ -36,9 +36,8 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
@ -51,10 +50,14 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ my $snmp_result = $self->{snmp}->get_multiple_table(
oids => [
{ oid => $mapping->{vmName}->{oid} }, { oid => $mapping->{vmName}->{oid} },
{ oid => $mapping->{vmPowerState}->{oid} }, { oid => $mapping->{vmPowerState}->{oid} },
], return_type => 1, nothing_quit => 1); ],
return_type => 1,
nothing_quit => 1
);
$self->{vm} = {}; $self->{vm} = {};
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{vmPowerState}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{vmPowerState}->{oid}\.(.*)$/);
@ -80,8 +83,10 @@ sub run {
$self->{output}->output_add(long_msg => "[name = " . $self->{vm}->{$name}->{vmName} . "] [state = " . $self->{vm}->{$name}->{vmPowerState} . "]"); $self->{output}->output_add(long_msg => "[name = " . $self->{vm}->{$name}->{vmName} . "] [state = " . $self->{vm}->{$name}->{vmPowerState} . "]");
} }
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => 'List Virtual Machines:'); severity => 'OK',
short_msg => 'List Virtual Machines:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit(); $self->{output}->exit();
} }
@ -98,8 +103,10 @@ sub disco_show {
$self->manage_selection(); $self->manage_selection();
foreach my $name (sort keys %{$self->{vm}}) { foreach my $name (sort keys %{$self->{vm}}) {
$self->{output}->add_disco_entry(name => $self->{vm}->{$name}->{vmName}, $self->{output}->add_disco_entry(
state => $self->{vm}->{$name}->{vmPowerState}); name => $self->{vm}->{$name}->{vmName},
state => $self->{vm}->{$name}->{vmPowerState}
);
} }
} }
@ -120,4 +127,3 @@ Filter by virtual machine name.
=back =back
=cut =cut

View File

@ -43,11 +43,13 @@ sub custom_usage_perfdata {
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
label => $label . $extra_label, unit => 'B',
value => $value_perf, value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), 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), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total}); min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -70,11 +72,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit, $total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
return $msg; );
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -86,7 +89,6 @@ sub custom_usage_calc {
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0; return 0;
} }
@ -133,9 +135,9 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' }, 'units:s' => { name => 'units', default => '%' },
"free" => { name => 'free' }, 'free' => { name => 'free' },
}); });
return $self; return $self;
@ -166,8 +168,10 @@ sub manage_selection {
} }
$self->{sp} = {}; $self->{sp} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_spitEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_spitEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{spitStoragePoolName}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{spitStoragePoolName}->{oid}\.(.*)$/);
@ -181,8 +185,9 @@ sub manage_selection {
next; next;
} }
$self->{sp}->{$instance} = { display => $result->{spitStoragePoolName}, $self->{sp}->{$instance} = {
%$result, display => $result->{spitStoragePoolName},
%$result
}; };
} }

View File

@ -100,7 +100,7 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' },
}); });
return $self; return $self;
@ -135,8 +135,10 @@ sub manage_selection {
} }
$self->{vm} = {}; $self->{vm} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_vmEntry, my $snmp_result = $options{snmp}->get_table(
nothing_quit => 1); oid => $oid_vmEntry,
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{vmName}->{oid}\.(.*)$/); next if ($oid !~ /^$mapping->{vmName}->{oid}\.(.*)$/);
@ -152,8 +154,9 @@ sub manage_selection {
$result->{vmRxBytes} *= 8; $result->{vmRxBytes} *= 8;
$result->{vmTxBytes} *= 8; $result->{vmTxBytes} *= 8;
$self->{vm}->{$instance} = { display => $result->{vmName}, $self->{vm}->{$instance} = {
%$result, display => $result->{vmName},
%$result
}; };
} }