This commit is contained in:
garnier-quentin 2020-06-23 13:51:44 +02:00
parent e397594631
commit d63c1e898b
4 changed files with 56 additions and 65 deletions

View File

@ -33,33 +33,30 @@ sub set_counters {
];
$self->{maps_counters}->{global} = [
{ label => 'active', set => {
{ label => 'active', nlabel => 'connections.server.active.count', set => {
key_values => [ { name => 'active' } ],
output_template => 'Active Server TCP connections: %s',
perfdatas => [
{ label => 'active_server', value => 'active', template => '%s',
unit => 'con', min => 0 },
],
{ label => 'active_server', template => '%s', unit => 'con', min => 0 }
]
}
},
{ label => 'server', set => {
{ label => 'server', nlabel => 'connections.server.count', set => {
key_values => [ { name => 'server' } ],
output_template => 'Server TCP connections: %s',
perfdatas => [
{ label => 'server', value => 'server', template => '%s',
unit => 'con', min => 0 },
],
{ label => 'server', template => '%s', unit => 'con', min => 0 }
]
}
},
{ label => 'client', set => {
{ label => 'client', nlabel => 'connections.client.count', set => {
key_values => [ { name => 'client' } ],
output_template => 'Client TCP connections: %s',
perfdatas => [
{ label => 'client', value => 'client', template => '%s',
unit => 'con', min => 0 },
],
{ label => 'client', template => '%s', unit => 'con', min => 0 }
]
}
}
},
];
}
@ -68,8 +65,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
$options{options}->add_options(arguments => {
});
return $self;

View File

@ -32,7 +32,7 @@ sub new {
$options{options}->add_options(arguments => {
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' },
'critical:s' => { name => 'critical' }
});
return $self;
@ -64,8 +64,10 @@ sub run {
my $used = $result->{$oid_resMemUsage} * $total_size / 100;
my $free = $total_size - $used;
my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_resMemUsage},
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit = $self->{perfdata}->threshold_check(
value => $result->{$oid_resMemUsage},
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
);
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size);
my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used);
@ -82,7 +84,9 @@ sub run {
);
$self->{output}->perfdata_add(
label => "used", unit => 'B',
label => 'used',
nlabel => 'memory.usage.bytes',
unit => 'B',
value => int($used),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),

View File

@ -38,9 +38,9 @@ sub set_counters {
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'),
closure_custom_threshold_check => $self->can('custom_usage_threshold')
}
}
},
];
}
@ -124,7 +124,7 @@ sub new {
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
'free' => { name => 'free' }
});
return $self;
@ -167,7 +167,7 @@ sub manage_selection {
}
if (scalar(keys %{$self->{storage}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No storage found.");
$self->{output}->add_option_msg(short_msg => 'No storage found.');
$self->{output}->option_exit();
}
}

View File

@ -36,59 +36,58 @@ sub set_counters {
$self->{maps_counters}->{vservers} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'state' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
closure_custom_threshold_check => $self->can('custom_threshold_output')
}
},
{ label => 'health', set => {
{ label => 'health', nlabel => 'vserver.health.percentage', set => {
key_values => [ { name => 'health' }, { name => 'display' } ],
output_template => 'Health: %.2f %%', output_error_template => 'Health: %s',
perfdatas => [
{ label => 'health', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'in-traffic', set => {
{ label => 'in-traffic', nlabel => 'vserver.traffic.in.bitspersecond', set => {
key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ],
output_template => 'Traffic In: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'traffic_in', template => '%.2f',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' },
],
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'out-traffic', set => {
{ label => 'out-traffic', nlabel => 'vserver.traffic.out.bitspersecond', set => {
key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ],
output_template => 'Traffic Out: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'traffic_out', template => '%.2f',
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' },
],
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'clients', set => {
{ label => 'clients', nlabel => 'vserver.connections.client.count', set => {
key_values => [ { name => 'clients', diff => 1 }, { name => 'display' } ],
output_template => 'Total Client Connections : %s',
perfdatas => [
{ label => 'clients', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display' },
],
min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'servers', set => {
{ label => 'servers', nlabel => 'vserver.connections.server.count', set => {
key_values => [ { name => 'servers', diff => 1 }, { name => 'display' } ],
output_template => 'Total Server Connections : %s',
perfdatas => [
{ label => 'servers', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display' },
],
min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
}
},
];
}
@ -138,16 +137,8 @@ sub custom_threshold_output {
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'State : ' . $self->{result_values}->{state};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
return 0;
return 'State : ' . $self->{result_values}->{state};
}
sub new {
@ -158,7 +149,7 @@ sub new {
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' },
'threshold-overload:s@' => { name => 'threshold_overload' },
'threshold-overload:s@' => { name => 'threshold_overload' }
});
return $self;
@ -226,7 +217,7 @@ sub manage_selection {
oids => [
{ oid => $mapping->{vsvrFullName}->{oid} },
{ oid => $mapping->{vsvrState}->{oid} },
{ oid => $mapping->{vsvrEntityType}->{oid} },
{ oid => $mapping->{vsvrEntityType}->{oid} }
],
return_type => 1,
nothing_quit => 1