diff --git a/cloud/cadvisor/restapi/mode/containerusage.pm b/cloud/cadvisor/restapi/mode/containerusage.pm index eeaf7acb3..eca29ed64 100644 --- a/cloud/cadvisor/restapi/mode/containerusage.pm +++ b/cloud/cadvisor/restapi/mode/containerusage.pm @@ -31,10 +31,17 @@ sub custom_memory_output { my ($self, %options) = @_; my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_total}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_used}); - my $msg = sprintf("Memory Used: %s (%.2f%%) Total: %s" , - $total_used_value . " " . $total_used_unit, 100 * $self->{result_values}->{memory_used} / $self->{result_values}->{memory_total}, - $total_size_value . " " . $total_size_unit); - return $msg; + return sprintf( + "Memory Used: %s (%.2f%%) Total: %s" , + $total_used_value . " " . $total_used_unit, 100 * $self->{result_values}->{memory_used} / $self->{result_values}->{memory_total}, + $total_size_value . " " . $total_size_unit + ); +} + +sub prefix_containers_output { + my ($self, %options) = @_; + + return "Container '" . $options{instance_value}->{display} . "' "; } sub set_counters { @@ -45,86 +52,82 @@ sub set_counters { ]; $self->{maps_counters}->{containers} = [ - { label => 'cpu-number', set => { + { label => 'cpu-number', nlabel => 'container.cpu.count', set => { key_values => [ { name => 'cpu_number'}, { name => 'display' } ], output_template => 'CPU: %d core(s)', - output_use => 'cpu_number', perfdatas => [ - { label => 'cpu_number', value => 'cpu_number', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'cpu_number', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'cpu-total', set => { + { label => 'cpu-total', nlabel => 'container.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_total'}, { name => 'display' } ], output_template => 'CPU Usage: %.2f %%', - output_use => 'cpu_total', perfdatas => [ - { label => 'cpu_total', value => 'cpu_total', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'cpu_total', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'cpu-user', set => { + { label => 'cpu-user', nlabel => 'container.cpu.user.utilization.percentage', set => { key_values => [ { name => 'cpu_user'}, { name => 'display' } ], output_template => 'CPU User: %.2f %%', - output_use => 'cpu_user', perfdatas => [ - { label => 'cpu_user', value => 'cpu_user', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'cpu_user', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'cpu-system', set => { + { label => 'cpu-system', nlabel => 'container.cpu.system.utilization.percentage', set => { key_values => [ { name => 'cpu_system' }, { name => 'display' } ], output_template => 'CPU System: %.2f %%', - output_use => 'cpu_system', perfdatas => [ - { label => 'cpu_system', value => 'cpu_system', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'cpu_system', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'memory', set => { + { label => 'memory', nlabel => 'container.memory.usage.bytes', set => { key_values => [ { name => 'memory_used' }, { name => 'memory_total' }, { name => 'display' } ], - output_change_bytes => 1, closure_custom_output => $self->can('custom_memory_output'), + output_change_bytes => 1, perfdatas => [ - { label => 'memory_used', value => 'memory_used', template => '%s', - min => 0, max => 'memory_total',unit => 'B', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'memory_used', template => '%s', + min => 0, max => 'memory_total',unit => 'B', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'memory-cache', set => { + { label => 'memory-cache', nlabel => 'container.memory.cache.usage.bytes', set => { key_values => [ { name => 'memory_cache' }, { name => 'display' } ], - output_change_bytes => 1, output_template => 'Memory Cache: %s %s', + output_change_bytes => 1, perfdatas => [ - { label => 'memory_cache', value => 'memory_cache', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'memory_cache', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'memory-rss', set => { + { label => 'memory-rss', nlabel => 'container.memory.rss.usage.bytes', set => { key_values => [ { name => 'memory_rss' }, { name => 'display' } ], - output_change_bytes => 1, output_template => 'Memory RSS: %s %s', - perfdatas => [ - { label => 'memory_rss', value => 'memory_rss', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, - ], - } - }, - { label => 'swap', set => { - key_values => [ { name => 'swap' }, { name => 'display' } ], output_change_bytes => 1, - output_template => 'Swap: %s %s', perfdatas => [ - { label => 'swap', value => 'swap', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'memory_rss', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' } + ] } }, + { label => 'swap', nlabel => 'container.swap.usage.bytes', set => { + key_values => [ { name => 'swap' }, { name => 'display' } ], + output_template => 'Swap: %s %s', + output_change_bytes => 1, + perfdatas => [ + { label => 'swap', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' } + ] + } + } ]; } @@ -134,29 +137,15 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, - "warning-container-status:s" => { name => 'warning_container_status', default => '' }, - "critical-container-status:s" => { name => 'critical_container_status', default => '' }, + 'container-id:s' => { name => 'container_id' }, + 'container-name:s' => { name => 'container_name' }, + 'filter-name:s' => { name => 'filter_name' }, + 'use-name' => { name => 'use_name' } }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_container_status', 'critical_container_status']); -} - -sub prefix_containers_output { - my ($self, %options) = @_; - return "Container '" . $options{instance_value}->{display} . "' "; -} - sub manage_selection { my ($self, %options) = @_; @@ -265,7 +254,7 @@ Filter by container name (can be a regexp). =item B<--filter-counters> Only display some counters (regexp can be used). -Example: --filter-counters='^container-status$' +Example: --filter-counters='cpu' =item B<--warning-*> @@ -279,16 +268,6 @@ Threshold critical. Can be: 'read-iops', 'write-iops', 'traffic-in', 'traffic-out', 'cpu' (%), 'memory' (%). -=item B<--warning-container-status> - -Set warning threshold for status (Default: -) -Can used special variables like: %{name}, %{state}. - -=item B<--critical-container-status> - -Set critical threshold for status (Default: -). -Can used special variables like: %{name}, %{state}. - =back =cut diff --git a/cloud/cadvisor/restapi/mode/diskio.pm b/cloud/cadvisor/restapi/mode/diskio.pm index 568a57bf8..1d0bb533f 100644 --- a/cloud/cadvisor/restapi/mode/diskio.pm +++ b/cloud/cadvisor/restapi/mode/diskio.pm @@ -34,26 +34,26 @@ sub set_counters { ]; $self->{maps_counters}->{containers_diskio} = [ - { label => 'diskio-read', set => { + { label => 'diskio-read', nlabel => 'disk.io.read.bytespersecond', set => { key_values => [ { name => 'diskio_read' }, { name => 'display' } ], output_change_bytes => 1, output_template => 'Disk IO Read: %s %s/s', perfdatas => [ - { label => 'diskio_read', value => 'diskio_read', template => '%.2f', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'diskio_read', template => '%.2f', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'diskio-write', set => { + { label => 'diskio-write', nlabel => 'disk.io.write.bytespersecond', set => { key_values => [ { name => 'diskio_write' }, { name => 'display' } ], output_change_bytes => 1, output_template => 'Disk IO Write: %s %s/s', perfdatas => [ - { label => 'diskio_write', value => 'diskio_write', template => '%.2f', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'diskio_write', template => '%.2f', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -62,19 +62,19 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, - }); - + $options{options}->add_options(arguments => { + 'container-id:s' => { name => 'container_id' }, + 'container-name:s' => { name => 'container_name' }, + 'filter-name:s' => { name => 'filter_name' }, + 'use-name' => { name => 'use_name' } + }); + return $self; } sub prefix_containers_diskio_output { my ($self, %options) = @_; + return "Container '" . $options{instance_value}->{display} . "' "; } diff --git a/cloud/cadvisor/restapi/mode/nodestatus.pm b/cloud/cadvisor/restapi/mode/nodestatus.pm index 12d715bb9..6575d110f 100644 --- a/cloud/cadvisor/restapi/mode/nodestatus.pm +++ b/cloud/cadvisor/restapi/mode/nodestatus.pm @@ -25,60 +25,56 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_node_output { + my ($self, %options) = @_; + + return "Node '" . $options{instance_value}->{display} . "' "; +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All node informations are ok', skipped_code => { -11 => 1 } }, - ]; - - $self->{maps_counters}->{nodes} = [ - { label => 'node-status', threshold => 0, set => { - key_values => [ { name => 'status' }, { name => 'manager_status' }, { name => 'display' } ], - 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_status_threshold'), - } - }, + { name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All node informations are ok', skipped_code => { -11 => 1 } } ]; + $self->{maps_counters}->{node} = [ - { label => 'containers-running', set => { + { label => 'containers-running', nlabel => 'node.containers.running.count', set => { key_values => [ { name => 'containers_running' }, { name => 'display' } ], - output_template => 'Containers Running : %s', + output_template => 'Containers running: %s', perfdatas => [ - { label => 'containers_running', value => 'containers_running', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'containers_running', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'num-cores', set => { + { label => 'num-cores', nlabel => 'node.core.count', set => { key_values => [ { name => 'num_cores' }, { name => 'display' } ], output_template => 'CPU cores: %s', perfdatas => [ - { label => 'num_cores', value => 'num_cores', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'num_cores', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'memory-capacity', set => { + { label => 'memory-capacity', nlabel => 'node.memory.bytes', set => { key_values => [ { name => 'memory_capacity' }, { name => 'display' } ], output_template => 'Mem capacity %s %s', perfdatas => [ - { label => 'memory_capacity', value => 'memory_capacity', unit => 'B', output_change_bytes => 1, template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'memory_capacity', unit => 'B', output_change_bytes => 1, template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'cpu-frequency', set => { + { label => 'cpu-frequency', nlabel => 'node.cpu.frequency.hertz', set => { key_values => [ { name => 'cpu_frequency' }, { name => 'display' } ], output_template => 'CPU frequency %s %s', perfdatas => [ - { label => 'cpu_frequency', value => 'cpu_frequency', unit => 'Hz', output_change_bytes => 1, template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'cpu_frequency', unit => 'Hz', output_change_bytes => 1, template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -86,18 +82,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - - return $self; -} -sub prefix_node_output { - my ($self, %options) = @_; - - return "Node '" . $options{instance_value}->{display} . "' "; + $options{options}->add_options(arguments => { + }); + + return $self; } sub manage_selection { @@ -114,7 +103,7 @@ sub manage_selection { containers_running => scalar(@{$result->{$node_name}->{nodes}}), }; } - + if (scalar(keys %{$self->{node}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No node found."); $self->{output}->option_exit(); @@ -131,14 +120,9 @@ Check node status. =over 8 -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'containers-running', 'num-cores', 'memory-capacity', 'cpu-frequency'. - -=item B<--critical-*> - -Threshold critical. +Thresholds. Can be: 'containers-running', 'num-cores', 'memory-capacity', 'cpu-frequency'. =back diff --git a/cloud/cadvisor/restapi/mode/traffic.pm b/cloud/cadvisor/restapi/mode/traffic.pm index 603da6967..1a39fef5a 100644 --- a/cloud/cadvisor/restapi/mode/traffic.pm +++ b/cloud/cadvisor/restapi/mode/traffic.pm @@ -27,34 +27,40 @@ use warnings; use Digest::MD5 qw(md5_hex); use DateTime; +sub prefix_containers_traffic_output { + my ($self, %options) = @_; + + return "Container '" . $options{instance_value}->{display} . "' "; +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'containers_traffic', type => 1, cb_prefix_output => 'prefix_containers_traffic_output', message_multiple => 'All container traffics are ok', skipped_code => { -11 => 1 } }, + { name => 'containers_traffic', type => 1, cb_prefix_output => 'prefix_containers_traffic_output', message_multiple => 'All container traffics are ok', skipped_code => { -11 => 1 } } ]; $self->{maps_counters}->{containers_traffic} = [ - { label => 'traffic-in', set => { + { label => 'traffic-in', nlabel => 'container.traffic.in.bitspersecond', set => { key_values => [ { name => 'traffic_in' }, { name => 'display' } ], - output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', - perfdatas => [ - { label => 'traffic_in', value => 'traffic_in', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], - } - }, - { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out' }, { name => 'display' } ], output_change_bytes => 2, - output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, + { label => 'traffic-out', nlabel => 'container.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out' }, { 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' } + ] + } + } ]; } @@ -64,19 +70,13 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, + 'container-id:s' => { name => 'container_id' }, + 'container-name:s' => { name => 'container_name' }, + 'filter-name:s' => { name => 'filter_name' }, + 'use-name' => { name => 'use_name' } }); - - return $self; -} - -sub prefix_containers_traffic_output { - my ($self, %options) = @_; - return "Container '" . $options{instance_value}->{display} . "' "; + return $self; } sub manage_selection { diff --git a/cloud/cadvisor/restapi/plugin.pm b/cloud/cadvisor/restapi/plugin.pm index db0b95312..bbaa2e955 100644 --- a/cloud/cadvisor/restapi/plugin.pm +++ b/cloud/cadvisor/restapi/plugin.pm @@ -30,15 +30,15 @@ sub new { bless $self, $class; $self->{version} = '0.3'; - %{$self->{modes}} = ( + $self->{modes} = { 'container-usage' => 'cloud::cadvisor::restapi::mode::containerusage', 'disk-io' => 'cloud::cadvisor::restapi::mode::diskio', 'traffic' => 'cloud::cadvisor::restapi::mode::traffic', 'list-containers' => 'cloud::cadvisor::restapi::mode::listcontainers', - 'node-status' => 'cloud::cadvisor::restapi::mode::nodestatus', - ); + 'node-status' => 'cloud::cadvisor::restapi::mode::nodestatus' + }; - $self->{custom_modes}{api} = 'cloud::cadvisor::restapi::custom::api'; + $self->{custom_modes}->{api} = 'cloud::cadvisor::restapi::custom::api'; return $self; } diff --git a/cloud/cloudfoundry/restapi/mode/appsstate.pm b/cloud/cloudfoundry/restapi/mode/appsstate.pm index 3f02fdc0b..8fc0b2bef 100644 --- a/cloud/cloudfoundry/restapi/mode/appsstate.pm +++ b/cloud/cloudfoundry/restapi/mode/appsstate.pm @@ -24,22 +24,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_state_output { my ($self, %options) = @_; - my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); - return $msg; -} - -sub custom_state_calc { - my ($self, %options) = @_; - - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; - - return 0; + return sprintf("state is '%s'", $self->{result_values}->{state}); } sub prefix_output { @@ -53,39 +43,36 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'apps', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All apps state are ok' }, + { name => 'apps', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All apps state are ok' } ]; $self->{maps_counters}->{global} = [ - { label => 'started', set => { + { label => 'started', nlabel => 'applications.started.count', set => { key_values => [ { name => 'started' } ], output_template => 'Started : %d', perfdatas => [ - { label => 'started', value => 'started', template => '%d', - min => 0 }, - ], + { label => 'started', template => '%d', min => 0 } + ] } }, - { label => 'stopped', set => { + { label => 'stopped', nlabel => 'applications.stopped.count', set => { key_values => [ { name => 'stopped' } ], output_template => 'Stopped : %d', perfdatas => [ - { label => 'stopped', value => 'stopped', template => '%d', - min => 0 }, - ], + { label => 'stopped', template => '%d', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{apps} = [ - { label => 'state', set => { + { label => 'state', type => 2, critical_default => '%{state} !~ /STARTED/i', set => { key_values => [ { name => 'state' }, { name => 'name' } ], - closure_custom_calc => $self->can('custom_state_calc'), closure_custom_output => $self->can('custom_state_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -94,25 +81,15 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "organization-guid:s" => { name => 'organization_guid' }, - "space-guid:s" => { name => 'space_guid' }, - "filter-name:s" => { name => 'filter_name' }, - "warning-state:s" => { name => 'warning_state' }, - "critical-state:s" => { name => 'critical_state', default => '%{state} !~ /STARTED/i' }, - }); + $options{options}->add_options(arguments => { + 'organization-guid:s' => { name => 'organization_guid' }, + 'space-guid:s' => { name => 'space_guid' }, + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_state', 'critical_state']); -} - sub manage_selection { my ($self, %options) = @_; diff --git a/cloud/cloudfoundry/restapi/mode/instancesstate.pm b/cloud/cloudfoundry/restapi/mode/instancesstate.pm index 5091b6d93..bc3777d48 100644 --- a/cloud/cloudfoundry/restapi/mode/instancesstate.pm +++ b/cloud/cloudfoundry/restapi/mode/instancesstate.pm @@ -24,86 +24,21 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; - -sub custom_app_state_threshold { - my ($self, %options) = @_; - my $status = 'ok'; - my $message; - - eval { - local $SIG{__WARN__} = sub { $message = $_[0]; }; - local $SIG{__DIE__} = sub { $message = $_[0]; }; - - if (defined($self->{instance_mode}->{option_results}->{critical_app_state}) && $self->{instance_mode}->{option_results}->{critical_app_state} ne '' && - eval "$self->{instance_mode}->{option_results}->{critical_app_state}") { - $status = 'critical'; - } elsif (defined($self->{instance_mode}->{option_results}->{warning_app_state}) && $self->{instance_mode}->{option_results}->{warning_app_state} ne '' && - eval "$self->{instance_mode}->{option_results}->{warning_app_state}") { - $status = 'warning'; - } - }; - if (defined($message)) { - $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); - } - - return $status; -} +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_app_state_output { my ($self, %options) = @_; - my $msg = sprintf("App '%s' state is '%s'", - $self->{result_values}->{name}, $self->{result_values}->{state}); - return $msg; -} - -sub custom_app_state_calc { - my ($self, %options) = @_; - - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; - - return 0; -} - -sub custom_inst_state_threshold { - my ($self, %options) = @_; - my $status = 'ok'; - my $message; - - eval { - local $SIG{__WARN__} = sub { $message = $_[0]; }; - local $SIG{__DIE__} = sub { $message = $_[0]; }; - - if (defined($self->{instance_mode}->{option_results}->{critical_instance_state}) && $self->{instance_mode}->{option_results}->{critical_instance_state} ne '' && - eval "$self->{instance_mode}->{option_results}->{critical_instance_state}") { - $status = 'critical'; - } elsif (defined($self->{instance_mode}->{option_results}->{warning_instance_state}) && $self->{instance_mode}->{option_results}->{warning_instance_state} ne '' && - eval "$self->{instance_mode}->{option_results}->{warning_instance_state}") { - $status = 'warning'; - } - }; - if (defined($message)) { - $self->{output}->output_add(long_msg => 'filter status issue: ' . $message); - } - - return $status; + return sprintf( + "App '%s' state is '%s'", + $self->{result_values}->{name}, $self->{result_values}->{state} + ); } sub custom_inst_state_output { my ($self, %options) = @_; - my $msg = sprintf("state is '%s'", $self->{result_values}->{state}); - return $msg; -} - -sub custom_inst_state_calc { - my ($self, %options) = @_; - - $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; - $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; - - return 0; + return sprintf("state is '%s'", $self->{result_values}->{state}); } sub prefix_output { @@ -122,55 +57,50 @@ sub set_counters { ]; $self->{maps_counters}->{app} = [ - { label => 'state', set => { + { label => 'app-state', type => 2, critical_default => '%{state} !~ /STARTED/i', set => { key_values => [ { name => 'state' }, { name => 'name' } ], - closure_custom_calc => $self->can('custom_app_state_calc'), closure_custom_output => $self->can('custom_app_state_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_app_state_threshold'), + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; $self->{maps_counters}->{global} = [ - { label => 'running', set => { + { label => 'running', nlabel => 'instances.running.count', set => { key_values => [ { name => 'running' } ], output_template => 'Running : %d', perfdatas => [ - { label => 'running', value => 'running', template => '%d', - min => 0 }, - ], + { label => 'running', template => '%d', min => 0 } + ] } }, - { label => 'stopped', set => { + { label => 'stopped', nlabel => 'instances.stopped.count', set => { key_values => [ { name => 'stopped' } ], output_template => 'Stopped : %d', perfdatas => [ - { label => 'stopped', value => 'stopped', template => '%d', - min => 0 }, - ], + { label => 'stopped', template => '%d', min => 0 } + ] } }, - { label => 'crashed', set => { + { label => 'crashed', nlabel => 'instances.crashed.count', set => { key_values => [ { name => 'crashed' } ], output_template => 'Crashed : %d', perfdatas => [ - { label => 'crashed', value => 'crashed', template => '%d', - min => 0 }, - ], + { label => 'crashed', template => '%d', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{instances} = [ - { label => 'state', set => { + { label => 'instance-state', type => 2, critical_default => '%{state} !~ /RUNNING/i', set => { key_values => [ { name => 'state' }, { name => 'id' } ], - closure_custom_calc => $self->can('custom_inst_state_calc'), closure_custom_output => $self->can('custom_inst_state_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => $self->can('custom_inst_state_threshold'), } - }, + } ]; } @@ -180,11 +110,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "app-guid:s" => { name => 'app_guid' }, - "warning-app-state:s" => { name => 'warning_app_state' }, - "critical-app-state:s" => { name => 'critical_app_state', default => '%{state} !~ /STARTED/i' }, - "warning-instance-state:s" => { name => 'warning_instance_state' }, - "critical-instance-state:s" => { name => 'critical_instance_state', default => '%{state} !~ /RUNNING/i' }, + 'app-guid:s' => { name => 'app_guid' } }); return $self; @@ -198,8 +124,6 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Need to specify app-guid option."); $self->{output}->option_exit(); } - - $self->change_macros(macros => ['warning_app_state', 'critical_app_state', 'warning_instance_state', 'critical_instance_state']); } sub manage_selection { diff --git a/cloud/cloudfoundry/restapi/plugin.pm b/cloud/cloudfoundry/restapi/plugin.pm index ea1b47278..53b7c96b5 100644 --- a/cloud/cloudfoundry/restapi/plugin.pm +++ b/cloud/cloudfoundry/restapi/plugin.pm @@ -30,15 +30,15 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + $self->{modes} = { 'apps-state' => 'cloud::cloudfoundry::restapi::mode::appsstate', 'instances-state' => 'cloud::cloudfoundry::restapi::mode::instancesstate', 'list-apps' => 'cloud::cloudfoundry::restapi::mode::listapps', 'list-organizations' => 'cloud::cloudfoundry::restapi::mode::listorganizations', - 'list-spaces' => 'cloud::cloudfoundry::restapi::mode::listspaces', - ); + 'list-spaces' => 'cloud::cloudfoundry::restapi::mode::listspaces' + }; - $self->{custom_modes}{restapi} = 'cloud::cloudfoundry::restapi::custom::api'; + $self->{custom_modes}->{restapi} = 'cloud::cloudfoundry::restapi::custom::api'; return $self; } diff --git a/cloud/docker/restapi/mode/containerusage.pm b/cloud/docker/restapi/mode/containerusage.pm index 7f4c9260a..2d33c5236 100644 --- a/cloud/docker/restapi/mode/containerusage.pm +++ b/cloud/docker/restapi/mode/containerusage.pm @@ -25,24 +25,15 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); 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'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - - return 0; -} - sub custom_cpu_calc { my ($self, %options) = @_; @@ -57,15 +48,17 @@ sub custom_cpu_calc { sub custom_memory_perfdata { my ($self, %options) = @_; - my $extra_label = ''; - if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { - $extra_label .= '_' . $self->{result_values}->{display}; - } - $self->{output}->perfdata_add(label => 'memory_used' . $extra_label, unit => 'B', - value => $self->{result_values}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'memory_used', + nlabel => 'container.memory.usage.bytes', + unit => 'B', + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, + max => $self->{result_values}->{total} + ); } sub custom_memory_threshold { @@ -82,11 +75,12 @@ sub custom_memory_output { 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 $msg = sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; + return sprintf( + "Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); } sub custom_memory_calc { @@ -110,55 +104,54 @@ sub set_counters { ]; $self->{maps_counters}->{containers} = [ - { label => 'container-status', threshold => 0, set => { + { label => 'container-status', type => 2, set => { key_values => [ { name => 'state' }, { name => 'name' } ], - 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 => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } }, - { label => 'cpu', set => { + { label => 'cpu', nlabel => 'container.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_total_usage', diff => 1 }, { name => 'cpu_system_usage', diff => 1 }, { name => 'cpu_number' }, { name => 'display' } ], output_template => 'CPU Usage : %.2f %%', closure_custom_calc => $self->can('custom_cpu_calc'), output_use => 'prct_cpu', threshold_use => 'prct_cpu', perfdatas => [ { label => 'cpu', value => 'prct_cpu', 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 => 'memory', set => { + { label => 'memory', nlabel => 'container.memory.usage.bytes', set => { key_values => [ { name => 'memory_usage' }, { name => 'memory_total' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_memory_calc'), closure_custom_output => $self->can('custom_memory_output'), closure_custom_perfdata => $self->can('custom_memory_perfdata'), - closure_custom_threshold_check => $self->can('custom_memory_threshold'), + closure_custom_threshold_check => $self->can('custom_memory_threshold') } }, - { label => 'read-iops', set => { + { label => 'read-iops', nlabel => 'container.disk.io.read.usage.iops', set => { key_values => [ { name => 'read_io', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ { label => 'read_iops', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, - { label => 'write-iops', set => { + { label => 'write-iops', nlabel => 'container.disk.io.write.usage.iops', set => { key_values => [ { name => 'write_io', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ { label => 'write_iops', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; $self->{maps_counters}->{containers_traffic} = [ - { label => 'traffic-in', set => { + { label => 'traffic-in', nlabel => 'container.traffic.in.bitspersecond', set => { key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', @@ -168,16 +161,16 @@ sub set_counters { ], } }, - { label => 'traffic-out', set => { + { label => 'traffic-out', nlabel => 'container.traffic.out.bitspersecond', set => { key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', 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' } + ] } - }, + } ]; } @@ -187,12 +180,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'container-id:s' => { name => 'container_id' }, - 'container-name:s' => { name => 'container_name' }, - 'filter-name:s' => { name => 'filter_name' }, - 'use-name' => { name => 'use_name' }, - 'warning-container-status:s' => { name => 'warning_container_status', default => '' }, - 'critical-container-status:s' => { name => 'critical_container_status', default => '' }, + 'container-id:s' => { name => 'container_id' }, + 'container-name:s' => { name => 'container_name' }, + 'filter-name:s' => { name => 'filter_name' }, + 'use-name' => { name => 'use_name' } }); $self->{statefile_cache_containers} = centreon::plugins::statefile->new(%options); @@ -203,7 +194,6 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - $self->change_macros(macros => ['warning_container_status', 'critical_container_status']); $self->{statefile_cache_containers}->check_options(%options); } diff --git a/cloud/docker/restapi/mode/nodestatus.pm b/cloud/docker/restapi/mode/nodestatus.pm index 7141596bb..c2b27b7fe 100644 --- a/cloud/docker/restapi/mode/nodestatus.pm +++ b/cloud/docker/restapi/mode/nodestatus.pm @@ -37,7 +37,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All node informations are ok', skipped_code => { -11 => 1 } }, - { name => 'nodes', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All node status are ok', skipped_code => { -11 => 1 } }, + { name => 'nodes', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All node status are ok', skipped_code => { -11 => 1 } } ]; $self->{maps_counters}->{nodes} = [ @@ -50,7 +50,7 @@ sub set_counters { } ]; $self->{maps_counters}->{node} = [ - { label => 'containers-running', set => { + { label => 'containers-running', nlabel => 'node.containers.running.count', set => { key_values => [ { name => 'containers_running' }, { name => 'display' } ], output_template => 'Containers Running : %s', perfdatas => [ @@ -59,7 +59,7 @@ sub set_counters { ] } }, - { label => 'containers-stopped', set => { + { label => 'containers-stopped', nlabel => 'node.containers.stopped.count', set => { key_values => [ { name => 'containers_stopped' }, { name => 'display' } ], output_template => 'Containers Stopped : %s', perfdatas => [ @@ -68,7 +68,7 @@ sub set_counters { ] } }, - { label => 'containers-paused', set => { + { label => 'containers-paused', nlabel => 'node.containers.paused.count', set => { key_values => [ { name => 'containers_paused' }, { name => 'display' } ], output_template => 'Containers Paused : %s', perfdatas => [ diff --git a/cloud/ibm/softlayer/mode/events.pm b/cloud/ibm/softlayer/mode/events.pm index 4db7b457d..6b34cac9f 100644 --- a/cloud/ibm/softlayer/mode/events.pm +++ b/cloud/ibm/softlayer/mode/events.pm @@ -30,37 +30,24 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_event_output { my ($self, %options) = @_; - my $msg = sprintf("Status is '%s', Impacted items: %d, Start date: %s, End date: %s", + return sprintf( + "Status is '%s', Impacted items: %d, Start date: %s, End date: %s", $self->{result_values}->{status}, $self->{result_values}->{items}, ($self->{result_values}->{start_date} ne "-") ? $self->{result_values}->{start_date} . ' (' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since_start}) . ' ago)' : '-', - ($self->{result_values}->{end_date} ne "-") ? $self->{result_values}->{end_date} . ' (' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since_end}) . ' ago)' : '-'); - return $msg; -} - -sub custom_event_calc { - my ($self, %options) = @_; - - $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; - $self->{result_values}->{subject} = $options{new_datas}->{$self->{instance} . '_subject'}; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{items} = $options{new_datas}->{$self->{instance} . '_items'}; - $self->{result_values}->{start_date} = $options{new_datas}->{$self->{instance} . '_start_date'}; - $self->{result_values}->{since_start} = $options{new_datas}->{$self->{instance} . '_since_start'}; - $self->{result_values}->{end_date} = $options{new_datas}->{$self->{instance} . '_end_date'}; - $self->{result_values}->{since_end} = $options{new_datas}->{$self->{instance} . '_since_end'}; - return 0; + ($self->{result_values}->{end_date} ne "-") ? $self->{result_values}->{end_date} . ' (' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since_end}) . ' ago)' : '-' + ); } sub prefix_global_output { my ($self, %options) = @_; - + return "Number of events "; } sub prefix_events_output { my ($self, %options) = @_; - + return "Event '" . $options{instance_value}->{id} . "' with subject '" . $options{instance_value}->{subject} . "' "; } @@ -71,46 +58,43 @@ sub set_counters { { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, { name => 'events', type => 1, cb_prefix_output => 'prefix_events_output' }, ]; - + $self->{maps_counters}->{global} = [ - { label => 'active', set => { + { label => 'active', nlabel => 'events.active.count', set => { key_values => [ { name => 'active' } ], output_template => 'Active : %d', perfdatas => [ - { label => 'active_events', value => 'active', template => '%d', - min => 0 }, - ], + { label => 'active_events', template => '%d', min => 0 } + ] } }, - { label => 'completed', set => { + { label => 'completed', nlabel => 'events.completed.count', set => { key_values => [ { name => 'completed' } ], output_template => 'Completed : %d', perfdatas => [ - { label => 'completed_events', value => 'completed', template => '%d', - min => 0 }, - ], + { label => 'completed_events', template => '%d', min => 0 } + ] } }, - { label => 'published', set => { + { label => 'published',nlabel => 'events.published.count', set => { key_values => [ { name => 'published' } ], output_template => 'Published : %d', perfdatas => [ - { label => 'published_events', value => 'published', template => '%d', - min => 0 }, - ], + { label => 'published_events', template => '%d', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{events} = [ - { label => 'event', threshold => 0, set => { + { label => 'event', type => 2, critical_default => '%{status} =~ /Active/ && %{items} > 0', set => { key_values => [ { name => 'id' }, { name => 'subject' }, { name => 'status' }, { name => 'items' }, { name => 'start_date' }, { name => 'since_start' }, { name => 'end_date' }, { name => 'since_end' } ], - closure_custom_calc => $self->can('custom_event_calc'), closure_custom_output => $self->can('custom_event_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -119,23 +103,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-status:s" => { name => 'filter_status', default => 'Active' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Active/ && %{items} > 0' }, - }); + $options{options}->add_options(arguments => { + 'filter-status:s' => { name => 'filter_status', default => 'Active' } + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); -} - sub manage_selection { my ($self, %options) = @_; diff --git a/cloud/ibm/softlayer/mode/opentickets.pm b/cloud/ibm/softlayer/mode/opentickets.pm index 0119294b5..3db71cd69 100644 --- a/cloud/ibm/softlayer/mode/opentickets.pm +++ b/cloud/ibm/softlayer/mode/opentickets.pm @@ -25,35 +25,24 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use DateTime; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_ticket_output { my ($self, %options) = @_; - - my $msg = sprintf("Title: '%s', Group: '%s', Priority: %s, Create Date: %s (%s ago)", + + return sprintf( + "Title: '%s', Group: '%s', Priority: %s, Create Date: %s (%s ago)", $self->{result_values}->{title}, $self->{result_values}->{group}, $self->{result_values}->{priority}, $self->{result_values}->{create_date}, - centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since})); - return $msg; -} - -sub custom_ticket_calc { - my ($self, %options) = @_; - - $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; - $self->{result_values}->{title} = $options{new_datas}->{$self->{instance} . '_title'}; - $self->{result_values}->{priority} = $options{new_datas}->{$self->{instance} . '_priority'}; - $self->{result_values}->{create_date} = $options{new_datas}->{$self->{instance} . '_create_date'}; - $self->{result_values}->{group} = $options{new_datas}->{$self->{instance} . '_group'}; - $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; - return 0; + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since}) + ); } sub prefix_tickets_output { my ($self, %options) = @_; - + return "Ticket '" . $options{instance_value}->{id} . "' is open with "; } @@ -62,30 +51,29 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'tickets', type => 1, cb_prefix_output => 'prefix_tickets_output' }, + { name => 'tickets', type => 1, cb_prefix_output => 'prefix_tickets_output' } ]; - + $self->{maps_counters}->{global} = [ - { label => 'open', set => { + { label => 'open', nlabel => 'tickets.open.count', set => { key_values => [ { name => 'open' } ], output_template => 'Number of open tickets : %d', perfdatas => [ - { label => 'open_tickets', value => 'open', template => '%d', - min => 0 }, - ], + { label => 'open_tickets', template => '%d', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{tickets} = [ - { label => 'ticket', threshold => 0, set => { + { label => 'ticket', type => 2, set => { key_values => [ { name => 'id' }, { name => 'title' }, { name => 'priority' }, { name => 'create_date' }, { name => 'group' }, { name => 'since' } ], - closure_custom_calc => $self->can('custom_ticket_calc'), closure_custom_output => $self->can('custom_ticket_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -94,23 +82,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "ticket-group:s" => { name => 'ticket_group' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - }); + $options{options}->add_options(arguments => { + 'ticket-group:s' => { name => 'ticket_group' } + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); -} - sub manage_selection { my ($self, %options) = @_; diff --git a/cloud/ibm/softlayer/plugin.pm b/cloud/ibm/softlayer/plugin.pm index 8b6e8540d..12a185487 100644 --- a/cloud/ibm/softlayer/plugin.pm +++ b/cloud/ibm/softlayer/plugin.pm @@ -30,12 +30,12 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{modes} = { 'events' => 'cloud::ibm::softlayer::mode::events', - 'open-tickets' => 'cloud::ibm::softlayer::mode::opentickets', - ); + 'open-tickets' => 'cloud::ibm::softlayer::mode::opentickets' + }; - $self->{custom_modes}{xmlapi} = 'cloud::ibm::softlayer::custom::xmlapi'; + $self->{custom_modes}->{xmlapi} = 'cloud::ibm::softlayer::custom::xmlapi'; return $self; }