perfdata vm memory
This commit is contained in:
parent
34d3b704c3
commit
61340536e9
|
@ -47,7 +47,7 @@ sub custom_usage_perfdata {
|
||||||
my ($label, $nlabel) = ('used', $self->{nlabel});
|
my ($label, $nlabel) = ('used', $self->{nlabel});
|
||||||
my $value_perf = $self->{result_values}->{used};
|
my $value_perf = $self->{result_values}->{used};
|
||||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||||
($label, $nlabel) = ('free', 'vm.memory.free.bytes');
|
($label, $nlabel) = ('free', 'vm.memory.' . $self->{result_values}->{label_ref} . '.free.bytes');
|
||||||
$value_perf = $self->{result_values}->{free};
|
$value_perf = $self->{result_values}->{free};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ sub custom_usage_perfdata {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => $label, unit => 'B',
|
label => $self->{result_values}->{label_ref} . '_' . $label, unit => 'B',
|
||||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||||
nlabel => $nlabel,
|
nlabel => $nlabel,
|
||||||
value => $value_perf,
|
value => $value_perf,
|
||||||
|
@ -88,12 +88,13 @@ 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 %s Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
my $msg = sprintf(
|
||||||
|
'Memory %s Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
|
||||||
$self->{result_values}->{label_ref},
|
$self->{result_values}->{label_ref},
|
||||||
$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 {
|
||||||
|
@ -120,24 +121,21 @@ sub custom_overhead_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead_absolute});
|
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead_absolute});
|
||||||
my $msg = sprintf("Memory overhead: %s %s", $value, $unit);
|
return sprintf('Memory overhead: %s %s', $value, $unit);
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_ballooning_output {
|
sub custom_ballooning_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{vmmemctl_absolute});
|
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{vmmemctl_absolute});
|
||||||
my $msg = sprintf("Memory ballooning: %s %s", $value, $unit);
|
return sprintf('Memory ballooning: %s %s', $value, $unit);
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_shared_output {
|
sub custom_shared_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{shared_absolute});
|
my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{shared_absolute});
|
||||||
my $msg = sprintf("Memory shared: %s %s", $value, $unit);
|
return sprintf('Memory shared: %s %s', $value, $unit);
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
|
@ -162,30 +160,30 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
closure_custom_calc => $self->can('custom_status_calc'),
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global_consumed} = [
|
$self->{maps_counters}->{global_consumed} = [
|
||||||
{ label => 'consumed', nlabel => 'vm.memory.usage.bytes', set => {
|
{ label => 'consumed', nlabel => 'vm.memory.consumed.usage.bytes', set => {
|
||||||
key_values => [ { name => 'consumed' }, { name => 'total' } ],
|
key_values => [ { name => 'consumed' }, { name => 'total' } ],
|
||||||
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' },
|
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' },
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global_active} = [
|
$self->{maps_counters}->{global_active} = [
|
||||||
{ label => 'active', nlabel => 'vm.memory.active.bytes', set => {
|
{ label => 'active', nlabel => 'vm.memory.active.usage.bytes', set => {
|
||||||
key_values => [ { name => 'active' }, { name => 'total' } ],
|
key_values => [ { name => 'active' }, { name => 'total' } ],
|
||||||
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' },
|
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' },
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global_overhead} = [
|
$self->{maps_counters}->{global_overhead} = [
|
||||||
{ label => 'overhead', nlabel => 'vm.memory.overhead.bytes', set => {
|
{ label => 'overhead', nlabel => 'vm.memory.overhead.bytes', set => {
|
||||||
|
@ -193,10 +191,10 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_overhead_output'),
|
closure_custom_output => $self->can('custom_overhead_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'overhead', value => 'overhead_absolute', template => '%s', unit => 'B',
|
{ label => 'overhead', value => 'overhead_absolute', template => '%s', unit => 'B',
|
||||||
min => 0, label_extra_instance => 1 },
|
min => 0, label_extra_instance => 1 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global_vmmemctl} = [
|
$self->{maps_counters}->{global_vmmemctl} = [
|
||||||
{ label => 'ballooning', nlabel => 'vm.memory.ballooning.bytes', set => {
|
{ label => 'ballooning', nlabel => 'vm.memory.ballooning.bytes', set => {
|
||||||
|
@ -204,10 +202,10 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_ballooning_output'),
|
closure_custom_output => $self->can('custom_ballooning_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'ballooning', value => 'vmmemctl_absolute', template => '%s', unit => 'B',
|
{ label => 'ballooning', value => 'vmmemctl_absolute', template => '%s', unit => 'B',
|
||||||
min => 0, label_extra_instance => 1 },
|
min => 0, label_extra_instance => 1 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global_shared} = [
|
$self->{maps_counters}->{global_shared} = [
|
||||||
{ label => 'shared', nlabel => 'vm.memory.shared.bytes', set => {
|
{ label => 'shared', nlabel => 'vm.memory.shared.bytes', set => {
|
||||||
|
@ -215,10 +213,10 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_shared_output'),
|
closure_custom_output => $self->can('custom_shared_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'shared', value => 'shared_absolute', template => '%s', unit => 'B',
|
{ label => 'shared', value => 'shared_absolute', template => '%s', unit => 'B',
|
||||||
min => 0, label_extra_instance => 1 },
|
min => 0, label_extra_instance => 1 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,20 +249,20 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"vm-hostname:s" => { name => 'vm_hostname' },
|
'vm-hostname:s' => { name => 'vm_hostname' },
|
||||||
"filter" => { name => 'filter' },
|
'filter' => { name => 'filter' },
|
||||||
"scope-datacenter:s" => { name => 'scope_datacenter' },
|
'scope-datacenter:s' => { name => 'scope_datacenter' },
|
||||||
"scope-cluster:s" => { name => 'scope_cluster' },
|
'scope-cluster:s' => { name => 'scope_cluster' },
|
||||||
"scope-host:s" => { name => 'scope_host' },
|
'scope-host:s' => { name => 'scope_host' },
|
||||||
"filter-description:s" => { name => 'filter_description' },
|
'filter-description:s' => { name => 'filter_description' },
|
||||||
"filter-os:s" => { name => 'filter_os' },
|
'filter-os:s' => { name => 'filter_os' },
|
||||||
"filter-uuid:s" => { name => 'filter_uuid' },
|
'filter-uuid:s' => { name => 'filter_uuid' },
|
||||||
"display-description" => { name => 'display_description' },
|
'display-description' => { name => 'display_description' },
|
||||||
"units:s" => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '%' },
|
||||||
"free" => { name => 'free' },
|
'free' => { name => 'free' },
|
||||||
"unknown-status:s" => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/i or %{power_state} !~ /^poweredOn$/i' },
|
'unknown-status:s' => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/i or %{power_state} !~ /^poweredOn$/i' },
|
||||||
"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 => '' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -281,8 +279,10 @@ sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{vm} = {};
|
$self->{vm} = {};
|
||||||
my $response = $options{custom}->execute(params => $self->{option_results},
|
my $response = $options{custom}->execute(
|
||||||
command => 'memvm');
|
params => $self->{option_results},
|
||||||
|
command => 'memvm'
|
||||||
|
);
|
||||||
|
|
||||||
foreach my $vm_id (keys %{$response->{data}}) {
|
foreach my $vm_id (keys %{$response->{data}}) {
|
||||||
my $vm_name = $response->{data}->{$vm_id}->{name};
|
my $vm_name = $response->{data}->{$vm_id}->{name};
|
||||||
|
|
Loading…
Reference in New Issue