From 2620ce8a9560d09f963f7a8ab474777faa2cd88d Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 10 Jun 2021 11:52:44 +0200 Subject: [PATCH] fix(multiple): thresholds and new perfdata (#2865) --- centreon/common/aruba/snmp/mode/memory.pm | 19 +-- centreon/common/aruba/snmp/mode/storage.pm | 21 +-- cloud/docker/restapi/mode/containerusage.pm | 15 +- .../office365/exchange/mode/emailactivity.pm | 82 ++++++----- .../office365/onedrive/mode/siteusage.pm | 133 ++++++++++-------- .../office365/onedrive/mode/usersactivity.pm | 102 ++++++++------ .../sharepoint/mode/usersactivity.pm | 116 ++++++++------- .../office365/skype/mode/devicesusage.pm | 73 +++++----- .../office365/skype/mode/usersactivity.pm | 83 ++++++----- .../office365/teams/mode/usersactivity.pm | 97 +++++++------ 10 files changed, 415 insertions(+), 326 deletions(-) diff --git a/centreon/common/aruba/snmp/mode/memory.pm b/centreon/common/aruba/snmp/mode/memory.pm index 83987a0ee..f36d812e0 100644 --- a/centreon/common/aruba/snmp/mode/memory.pm +++ b/centreon/common/aruba/snmp/mode/memory.pm @@ -33,8 +33,8 @@ sub custom_usage_perfdata { label => 'usage', nlabel => 'memory.usage.bytes', 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), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), min => 0, max => $self->{result_values}->{total}); } @@ -43,8 +43,11 @@ sub custom_usage_threshold { my $exit = $self->{perfdata}->threshold_check( value => $self->{result_values}->{prct_used}, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -78,7 +81,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'memory', type => 1, cb_prefix_output => 'prefix_output', - message_multiple => 'All memory pools are ok' }, + message_multiple => 'All memory pools are ok' } ]; $self->{maps_counters}->{memory} = [ @@ -87,9 +90,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') } - }, + } ]; } @@ -168,4 +171,4 @@ Threshold critical in percent. =back =cut - \ No newline at end of file + diff --git a/centreon/common/aruba/snmp/mode/storage.pm b/centreon/common/aruba/snmp/mode/storage.pm index ea7a5167c..e387f855a 100644 --- a/centreon/common/aruba/snmp/mode/storage.pm +++ b/centreon/common/aruba/snmp/mode/storage.pm @@ -33,8 +33,8 @@ sub custom_usage_perfdata { label => 'usage', nlabel => 'storage.usage.bytes', 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), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), min => 0, max => $self->{result_values}->{total}); } @@ -43,8 +43,11 @@ sub custom_usage_threshold { my $exit = $self->{perfdata}->threshold_check( value => $self->{result_values}->{prct_used}, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -88,9 +91,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') } - }, + } ]; } @@ -106,8 +109,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "filter-type:s" => { name => 'filter_type' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-type:s' => { name => 'filter_type' } }); return $self; @@ -123,7 +126,7 @@ my $mapping = { sysExtStorageType => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.2', map => \%map_storage_type }, sysExtStorageSize => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.3' }, # MB sysExtStorageUsed => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.4' }, # MB - sysExtStorageName => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.5' }, + sysExtStorageName => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.14.1.5' } }; sub manage_selection { diff --git a/cloud/docker/restapi/mode/containerusage.pm b/cloud/docker/restapi/mode/containerusage.pm index 96510589a..cf0338d57 100644 --- a/cloud/docker/restapi/mode/containerusage.pm +++ b/cloud/docker/restapi/mode/containerusage.pm @@ -54,8 +54,8 @@ sub custom_memory_perfdata { 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), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), min => 0, max => $self->{result_values}->{total} ); @@ -64,7 +64,12 @@ sub custom_memory_perfdata { sub custom_memory_threshold { my ($self, %options) = @_; - my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $self->{result_values}->{prct_used}, threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -157,8 +162,8 @@ sub set_counters { output_template => 'Traffic In : %s %s/s', 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 => 'traffic-out', nlabel => 'container.traffic.out.bitspersecond', set => { diff --git a/cloud/microsoft/office365/exchange/mode/emailactivity.pm b/cloud/microsoft/office365/exchange/mode/emailactivity.pm index aa0c21400..d1a6535d4 100644 --- a/cloud/microsoft/office365/exchange/mode/emailactivity.pm +++ b/cloud/microsoft/office365/exchange/mode/emailactivity.pm @@ -38,11 +38,14 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_users', nlabel => 'exchange.users.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'users', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_users', + nlabel => 'exchange.users.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'users', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,9 +55,13 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -62,12 +69,13 @@ sub custom_active_threshold { sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active users on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -99,7 +107,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'users', type => 1, cb_prefix_output => 'prefix_mailbox_output', message_multiple => 'All email activity are ok' }, + { name => 'users', type => 1, cb_prefix_output => 'prefix_mailbox_output', message_multiple => 'All email activity are ok' } ]; $self->{maps_counters}->{active} = [ @@ -112,63 +120,65 @@ sub set_counters { } }, ]; + $self->{maps_counters}->{global} = [ { label => 'total-send-count', nlabel => 'exchange.users.emails.sent.total.count', set => { key_values => [ { name => 'send_count' } ], output_template => 'Send Count: %d', perfdatas => [ - { label => 'total_send_count', value => 'send_count', template => '%d', - min => 0 }, - ], + { label => 'total_send_count', template => '%d', + min => 0 } + ] } }, { label => 'total-receive-count', nlabel => 'exchange.users.emails.received.total.count', set => { key_values => [ { name => 'receive_count' } ], output_template => 'Receive Count: %d', perfdatas => [ - { label => 'total_receive_count', value => 'receive_count', template => '%d', - min => 0 }, - ], + { label => 'total_receive_count', template => '%d', + min => 0 } + ] } }, { label => 'total-read-count', nlabel => 'exchange.users.emails.read.total.count', set => { key_values => [ { name => 'read_count' } ], output_template => 'Read Count: %d', perfdatas => [ - { label => 'total_read_count', value => 'read_count', template => '%d', - min => 0 }, - ], + { label => 'total_read_count', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{users} = [ { label => 'send-count', nlabel => 'exchange.users.emails.sent.count', set => { key_values => [ { name => 'send_count' }, { name => 'name' } ], output_template => 'Send Count: %d', perfdatas => [ - { label => 'send_count', value => 'send_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'send_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'receive-count', nlabel => 'exchange.users.emails.received.count', set => { key_values => [ { name => 'receive_count' }, { name => 'name' } ], output_template => 'Receive Count: %d', perfdatas => [ - { label => 'receive_count', value => 'receive_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'receive_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'read-count', nlabel => 'exchange.users.emails.read.count', set => { key_values => [ { name => 'read_count' }, { name => 'name' } ], output_template => 'Read Count: %d', perfdatas => [ - { label => 'read_count', value => 'read_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'read_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -180,7 +190,7 @@ sub new { $options{options}->add_options(arguments => { "filter-user:s" => { name => 'filter_user' }, "units:s" => { name => 'units', default => '%' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active|total' } }); return $self; diff --git a/cloud/microsoft/office365/onedrive/mode/siteusage.pm b/cloud/microsoft/office365/onedrive/mode/siteusage.pm index ff5e8b49b..46bc34923 100644 --- a/cloud/microsoft/office365/onedrive/mode/siteusage.pm +++ b/cloud/microsoft/office365/onedrive/mode/siteusage.pm @@ -38,11 +38,13 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_sites', nlabel => 'onedrive.sites.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'sites', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_sites', nlabel => 'onedrive.sites.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'sites', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,9 +54,13 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -62,12 +68,13 @@ sub custom_active_threshold { sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active sites on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active sites on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -87,12 +94,15 @@ sub custom_usage_perfdata { my $extra_label = ''; $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); - $self->{output}->perfdata_add(label => 'used' . $extra_label, nlabel => $self->{result_values}->{display} . '#onedrive.sites.usage.bytes', - 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 => 'used' . $extra_label, + nlabel => $self->{result_values}->{display} . '#onedrive.sites.usage.bytes', + unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total} + ); } sub custom_usage_threshold { @@ -105,9 +115,13 @@ sub custom_usage_threshold { $threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -118,11 +132,12 @@ sub custom_usage_output { my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); - my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $self->{result_values}->{prct_used}, - $free_value . " " . $free_unit, $self->{result_values}->{prct_free}); - return $msg; + return sprintf( + "Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_value . " " . $total_unit, + $used_value . " " . $used_unit, $self->{result_values}->{prct_used}, + $free_value . " " . $free_unit, $self->{result_values}->{prct_free} + ); } sub custom_usage_calc { @@ -163,7 +178,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'sites', type => 1, cb_prefix_output => 'prefix_site_output', message_multiple => 'All sites usage are ok' }, + { name => 'sites', type => 1, cb_prefix_output => 'prefix_site_output', message_multiple => 'All sites usage are ok' } ]; $self->{maps_counters}->{active} = [ @@ -174,17 +189,18 @@ sub set_counters { closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_perfdata => $self->can('custom_active_perfdata') } - }, + } ]; + $self->{maps_counters}->{global} = [ { label => 'total-usage-active', nlabel => 'onedrive.sites.active.usage.total.bytes', set => { key_values => [ { name => 'storage_used_active' } ], output_template => 'Usage (active sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'total_usage_active', value => 'storage_used_active', template => '%d', - min => 0, unit => 'B' }, - ], + { label => 'total_usage_active', template => '%d', + min => 0, unit => 'B' } + ] } }, { label => 'total-usage-inactive', nlabel => 'onedrive.sites.inactive.usage.total.bytes', set => { @@ -192,66 +208,67 @@ sub set_counters { output_template => 'Usage (inactive sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'total_usage_inactive', value => 'storage_used_inactive', template => '%d', - min => 0, unit => 'B' }, - ], + { label => 'total_usage_inactive', template => '%d', + min => 0, unit => 'B' } + ] } }, { label => 'total-file-count-active', nlabel => 'onedrive.sites.active.files.total.count', set => { key_values => [ { name => 'file_count_active' } ], output_template => 'File Count (active sites): %d', perfdatas => [ - { label => 'total_file_count_active', value => 'file_count_active', template => '%d', - min => 0 }, - ], + { label => 'total_file_count_active', template => '%d', + min => 0 } + ] } }, { label => 'total-file-count-inactive', nlabel => 'onedrive.sites.inactive.files.total.count', set => { key_values => [ { name => 'file_count_inactive' } ], output_template => 'File Count (inactive sites): %d', perfdatas => [ - { label => 'total_file_count_inactive', value => 'file_count_inactive', template => '%d', - min => 0 }, - ], + { label => 'total_file_count_inactive', template => '%d', + min => 0 } + ] } }, { label => 'total-active-file-count', nlabel => 'onedrive.sites.files.active.total.count', set => { key_values => [ { name => 'active_file_count' } ], output_template => 'Active File Count (active sites): %d', perfdatas => [ - { label => 'total_active_file_count', value => 'active_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_active_file_count', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{sites} = [ { label => 'usage', set => { key_values => [ { name => 'storage_used' }, { name => 'storage_allocated' }, { name => 'url' }, { name => 'owner' } ], 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') } }, { label => 'file-count', nlabel => 'onedrive.sites.files.count', set => { key_values => [ { name => 'file_count' }, { name => 'url' }, { name => 'owner' } ], output_template => 'File Count: %d', perfdatas => [ - { label => 'file_count', value => 'file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'url' }, - ], + { label => 'file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'url' } + ] } }, { label => 'active-file-count', nlabel => 'onedrive.sites.files.active.count', set => { key_values => [ { name => 'active_file_count' }, { name => 'url' }, { name => 'owner' } ], output_template => 'Active File Count: %d', perfdatas => [ - { label => 'active_file_count', value => 'active_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'url' }, - ], + { label => 'active_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'url' } + ] } - }, + } ]; } @@ -265,7 +282,7 @@ sub new { "filter-owner:s" => { name => 'filter_owner' }, "units:s" => { name => 'units', default => '%' }, "free" => { name => 'free' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active-sites|total' } }); return $self; @@ -275,8 +292,10 @@ sub manage_selection { my ($self, %options) = @_; $self->{active} = { active => 0, total => 0, report_date => '' }; - $self->{global} = { storage_used_active => 0, storage_used_inactive => 0, - file_count_active => 0, file_count_inactive => 0, active_file_count => 0 }; + $self->{global} = { + storage_used_active => 0, storage_used_inactive => 0, + file_count_active => 0, file_count_inactive => 0, active_file_count => 0 + }; $self->{sites} = {}; my $results = $options{custom}->office_get_onedrive_usage(param => "period='D7'"); diff --git a/cloud/microsoft/office365/onedrive/mode/usersactivity.pm b/cloud/microsoft/office365/onedrive/mode/usersactivity.pm index b8a3b0645..92cab1c17 100644 --- a/cloud/microsoft/office365/onedrive/mode/usersactivity.pm +++ b/cloud/microsoft/office365/onedrive/mode/usersactivity.pm @@ -38,11 +38,14 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_users', nlabel => 'onedrive.users.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'users', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_users', + nlabel => 'onedrive.users.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'users', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,9 +55,13 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -62,12 +69,13 @@ sub custom_active_threshold { sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active users on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -99,7 +107,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' }, + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' } ]; $self->{maps_counters}->{active} = [ @@ -110,83 +118,85 @@ sub set_counters { closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_perfdata => $self->can('custom_active_perfdata') } - }, + } ]; + $self->{maps_counters}->{global} = [ { label => 'total-viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.total.count', set => { key_values => [ { name => 'viewed_edited_file_count' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_viewed_edited_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-synced-file-count', nlabel => 'onedrive.users.files.synced.total.count', set => { key_values => [ { name => 'synced_file_count' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'total_synced_file_count', value => 'synced_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_synced_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.total.count', set => { key_values => [ { name => 'shared_int_file_count' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'total_shared_int_file_count', value => 'shared_int_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_shared_int_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.total.count', set => { key_values => [ { name => 'shared_ext_file_count' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'total_shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_shared_ext_file_count', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{users} = [ { label => 'viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.count', set => { key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'viewed_edited_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'synced-file-count', nlabel => 'onedrive.users.files.synced.count', set => { key_values => [ { name => 'synced_file_count' }, { name => 'name' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'synced_file_count', value => 'synced_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'synced_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.count', set => { key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'shared_int_file_count', value => 'shared_int_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'shared_int_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.count', set => { key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'shared_ext_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -198,7 +208,7 @@ sub new { $options{options}->add_options(arguments => { "filter-user:s" => { name => 'filter_user' }, "units:s" => { name => 'units', default => '%' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active|total' } }); return $self; @@ -208,8 +218,10 @@ sub manage_selection { my ($self, %options) = @_; $self->{active} = { active => 0, total => 0, report_date => '' }; - $self->{global} = { viewed_edited_file_count => 0, synced_file_count => 0, - shared_int_file_count => 0, shared_ext_file_count => 0 }; + $self->{global} = { + viewed_edited_file_count => 0, synced_file_count => 0, + shared_int_file_count => 0, shared_ext_file_count => 0 + }; $self->{users} = {}; my $results = $options{custom}->office_get_onedrive_activity(param => "period='D7'"); diff --git a/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm b/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm index 642fb8411..f63338377 100644 --- a/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm +++ b/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm @@ -38,11 +38,13 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_users', nlabel => 'sharepoint.users.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'users', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_users', nlabel => 'sharepoint.users.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'users', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,22 +54,26 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; - } sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active users on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -99,7 +105,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' }, + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' } ]; $self->{maps_counters}->{active} = [ @@ -110,101 +116,103 @@ sub set_counters { closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_perfdata => $self->can('custom_active_perfdata') } - }, + } ]; + $self->{maps_counters}->{global} = [ { label => 'total-viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.total.count', set => { key_values => [ { name => 'viewed_edited_file_count' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_viewed_edited_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-synced-file-count', nlabel => 'sharepoint.users.files.synced.total.count', set => { key_values => [ { name => 'synced_file_count' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'total_synced_file_count', value => 'synced_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_synced_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.total.count', set => { key_values => [ { name => 'shared_int_file_count' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'total_shared_int_file_count', value => 'shared_int_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_shared_int_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.total.count', set => { key_values => [ { name => 'shared_ext_file_count' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'total_shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', - min => 0 }, - ], + { label => 'total_shared_ext_file_count', template => '%d', + min => 0 } + ] } }, { label => 'total-visited-page-count', nlabel => 'sharepoint.users.pages.visited.total.count', set => { key_values => [ { name => 'visited_page_count' } ], output_template => 'Visited Page Count (active sites): %d', perfdatas => [ - { label => 'total_visited_page_count', value => 'visited_page_count', template => '%d', - min => 0 }, - ], + { label => 'total_visited_page_count', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{users} = [ { label => 'viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.count', set => { key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'viewed_edited_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'synced-file-count', nlabel => 'sharepoint.users.files.synced.count', set => { key_values => [ { name => 'synced_file_count' }, { name => 'name' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'synced_file_count', value => 'synced_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'synced_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.count', set => { key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'shared_int_file_count', value => 'shared_int_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'shared_int_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.count', set => { key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'shared_ext_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'visited-page-count', nlabel => 'sharepoint.users.pages.visited.count', set => { key_values => [ { name => 'visited_page_count' }, { name => 'name' } ], output_template => 'Visited Page Count: %d', perfdatas => [ - { label => 'visited_page_count', value => 'visited_page_count', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'visited_page_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -216,7 +224,7 @@ sub new { $options{options}->add_options(arguments => { "filter-user:s" => { name => 'filter_user' }, "units:s" => { name => 'units', default => '%' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active|total' } }); return $self; @@ -226,9 +234,11 @@ sub manage_selection { my ($self, %options) = @_; $self->{active} = { active => 0, total => 0, report_date => '' }; - $self->{global} = { viewed_edited_file_count => 0, synced_file_count => 0, - shared_int_file_count => 0, shared_ext_file_count => 0, - visited_page_count => 0 }; + $self->{global} = { + viewed_edited_file_count => 0, synced_file_count => 0, + shared_int_file_count => 0, shared_ext_file_count => 0, + visited_page_count => 0 + }; $self->{users} = {}; my $results = $options{custom}->office_get_sharepoint_activity(param => "period='D7'"); diff --git a/cloud/microsoft/office365/skype/mode/devicesusage.pm b/cloud/microsoft/office365/skype/mode/devicesusage.pm index 64edf0516..f2bd55a16 100644 --- a/cloud/microsoft/office365/skype/mode/devicesusage.pm +++ b/cloud/microsoft/office365/skype/mode/devicesusage.pm @@ -38,11 +38,14 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_devices', nlabel => 'skype.devices.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'devices', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_devices', + nlabel => 'skype.devices.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'devices', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,9 +55,13 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -62,12 +69,13 @@ sub custom_active_threshold { sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active devices on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active devices on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -105,52 +113,53 @@ sub set_counters { } }, ]; + $self->{maps_counters}->{global} = [ { label => 'windows', nlabel => 'skype.devices.windows.count', set => { key_values => [ { name => 'windows' } ], output_template => 'Windows: %d', perfdatas => [ - { label => 'windows', value => 'windows', template => '%d', - min => 0 }, - ], + { label => 'windows', template => '%d', + min => 0 } + ] } }, { label => 'ipad', nlabel => 'skype.devices.ipad.count', set => { key_values => [ { name => 'ipad' } ], output_template => 'iPad: %d', perfdatas => [ - { label => 'ipad', value => 'ipad', template => '%d', - min => 0 }, - ], + { label => 'ipad', template => '%d', + min => 0 } + ] } }, { label => 'iphone', nlabel => 'skype.devices.iphone.count', set => { key_values => [ { name => 'iphone' } ], output_template => 'iPhone: %d', perfdatas => [ - { label => 'iphone', value => 'iphone', template => '%d', - min => 0 }, - ], + { label => 'iphone', template => '%d', + min => 0 } + ] } }, { label => 'android-phone', nlabel => 'skype.devices.android.count', set => { key_values => [ { name => 'android_phone' } ], output_template => 'Android Phone: %d', perfdatas => [ - { label => 'android_phone', value => 'android_phone', template => '%d', - min => 0 }, - ], + { label => 'android_phone', template => '%d', + min => 0 } + ] } }, { label => 'windows-phone', nlabel => 'skype.devices.windowsphone.count', set => { key_values => [ { name => 'windows_phone' } ], output_template => 'Windows Phone: %d', perfdatas => [ - { label => 'windows_phone', value => 'windows_phone', template => '%d', - min => 0 }, - ], + { label => 'windows_phone', template => '%d', + min => 0 } + ] } - }, + } ]; } @@ -160,8 +169,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-user:s" => { name => 'filter_user' }, - "units:s" => { name => 'units', default => '%' }, + 'filter-user:s' => { name => 'filter_user' }, + 'units:s' => { name => 'units', default => '%' } }); return $self; diff --git a/cloud/microsoft/office365/skype/mode/usersactivity.pm b/cloud/microsoft/office365/skype/mode/usersactivity.pm index 390796172..9cc57a230 100644 --- a/cloud/microsoft/office365/skype/mode/usersactivity.pm +++ b/cloud/microsoft/office365/skype/mode/usersactivity.pm @@ -38,11 +38,14 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_users', nlabel => 'skype.users.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'users', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_users', + nlabel => 'skype.users.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'users', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,22 +55,26 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; - } sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active users on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -99,7 +106,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' }, + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' } ]; $self->{maps_counters}->{active} = [ @@ -112,63 +119,65 @@ sub set_counters { } }, ]; + $self->{maps_counters}->{global} = [ { label => 'total-peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.total.count', set => { key_values => [ { name => 'peer_to_peer_sessions' } ], output_template => 'Peer-to-peer Sessions Count: %d', perfdatas => [ - { label => 'total_peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', - min => 0 }, - ], + { label => 'total_peer_to_peer_sessions', template => '%d', + min => 0 } + ] } }, { label => 'total-organized-conference', nlabel => 'skype.users.conferences.organized.total.count', set => { key_values => [ { name => 'organized_conference' } ], output_template => 'Organized Conference Count: %d', perfdatas => [ - { label => 'total_organized_conference', value => 'organized_conference', template => '%d', - min => 0 }, - ], + { label => 'total_organized_conference', template => '%d', + min => 0 } + ] } }, { label => 'total-participated-conference', nlabel => 'skype.users.conferences.participated.total.count', set => { key_values => [ { name => 'participated_conference' } ], output_template => 'Participated Conference Count: %d', perfdatas => [ - { label => 'total_participated_conference', value => 'participated_conference', template => '%d', - min => 0 }, - ], + { label => 'total_participated_conference', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{users} = [ { label => 'peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.count', set => { key_values => [ { name => 'peer_to_peer_sessions' }, { name => 'name' } ], output_template => 'Peer-to-peer Sessions Count: %d', perfdatas => [ - { label => 'peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'peer_to_peer_sessions', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'organized-conference', nlabel => 'skype.users.conferences.organized.count', set => { key_values => [ { name => 'organized_conference' }, { name => 'name' } ], output_template => 'Organized Conference Count: %d', perfdatas => [ - { label => 'organized_conference', value => 'organized_conference', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'organized_conference', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'participated-conference', nlabel => 'skype.users.conferences.participated.count', set => { key_values => [ { name => 'participated_conference' }, { name => 'name' } ], output_template => 'Participated Conference Count: %d', perfdatas => [ - { label => 'participated_conference', value => 'participated_conference', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'participated_conference', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -180,7 +189,7 @@ sub new { $options{options}->add_options(arguments => { "filter-user:s" => { name => 'filter_user' }, "units:s" => { name => 'units', default => '%' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active|total' } }); return $self; diff --git a/cloud/microsoft/office365/teams/mode/usersactivity.pm b/cloud/microsoft/office365/teams/mode/usersactivity.pm index 63aa09f74..8f86d90b1 100644 --- a/cloud/microsoft/office365/teams/mode/usersactivity.pm +++ b/cloud/microsoft/office365/teams/mode/usersactivity.pm @@ -38,11 +38,14 @@ sub custom_active_perfdata { $self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $self->{output}->perfdata_add(label => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900)); - $self->{output}->perfdata_add(label => 'active_users', nlabel => 'teams.users.active.count', - value => $self->{result_values}->{active}, - 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), - unit => 'users', min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => 'active_users', + nlabel => 'teams.users.active.count', + value => $self->{result_values}->{active}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options), + unit => 'users', min => 0, max => $self->{result_values}->{total} + ); } sub custom_active_threshold { @@ -52,22 +55,26 @@ sub custom_active_threshold { if ($self->{instance_mode}->{option_results}->{units} eq '%') { $threshold_value = $self->{result_values}->{prct_active}; } - my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; - } sub custom_active_output { my ($self, %options) = @_; - my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", - $self->{result_values}->{report_date}, - $self->{result_values}->{active}, - $self->{result_values}->{total}, - $self->{result_values}->{prct_active}); - return $msg; + return sprintf( + "Active users on %s : %d/%d (%.2f%%)", + $self->{result_values}->{report_date}, + $self->{result_values}->{active}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_active} + ); } sub custom_active_calc { @@ -99,7 +106,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'active', type => 0 }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' }, + { name => 'users', type => 1, cb_prefix_output => 'prefix_user_output', message_multiple => 'All users activity are ok' } ]; $self->{maps_counters}->{active} = [ @@ -110,83 +117,85 @@ sub set_counters { closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_perfdata => $self->can('custom_active_perfdata') } - }, + } ]; + $self->{maps_counters}->{global} = [ { label => 'total-team-chat', nlabel => 'teams.users.messages.team.total.count', set => { key_values => [ { name => 'team_chat' } ], output_template => 'Team Chat Message Count: %d', perfdatas => [ - { label => 'total_team_chat', value => 'team_chat', template => '%d', - min => 0 }, - ], + { label => 'total_team_chat', template => '%d', + min => 0 } + ] } }, { label => 'total-private-chat', nlabel => 'teams.users.messages.private.total.count', set => { key_values => [ { name => 'private_chat' } ], output_template => 'Private Chat Message Count: %d', perfdatas => [ - { label => 'total_private_chat', value => 'private_chat', template => '%d', - min => 0 }, - ], + { label => 'total_private_chat', template => '%d', + min => 0 } + ] } }, { label => 'total-call', nlabel => 'teams.users.call.total.count', set => { key_values => [ { name => 'call' } ], output_template => 'Call Count: %d', perfdatas => [ - { label => 'total_call', value => 'call', template => '%d', - min => 0 }, - ], + { label => 'total_call', template => '%d', + min => 0 } + ] } }, { label => 'total-meeting', nlabel => 'teams.users.meeting.total.count', set => { key_values => [ { name => 'meeting' } ], output_template => 'Meeting Count: %d', perfdatas => [ - { label => 'total_meeting', value => 'meeting', template => '%d', - min => 0 }, - ], + { label => 'total_meeting', template => '%d', + min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{users} = [ { label => 'team-chat', nlabel => 'teams.users.messages.team.count', set => { key_values => [ { name => 'team_chat' }, { name => 'name' } ], output_template => 'Team Chat Message Count: %d', perfdatas => [ - { label => 'team_chat', value => 'team_chat', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'team_chat', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'private-chat', nlabel => 'teams.users.messages.private.count', set => { key_values => [ { name => 'private_chat' }, { name => 'name' } ], output_template => 'Private Chat Message Count: %d', perfdatas => [ - { label => 'private_chat', value => 'private_chat', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'private_chat', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'call', nlabel => 'teams.users.call.count', set => { key_values => [ { name => 'call' }, { name => 'name' } ], output_template => 'Call Count: %d', perfdatas => [ - { label => 'call', value => 'call', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'call', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'meeting', nlabel => 'teams.users.meeting.count', set => { key_values => [ { name => 'meeting' }, { name => 'name' } ], output_template => 'Meeting Count: %d', perfdatas => [ - { label => 'meeting', value => 'meeting', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name' }, - ], + { label => 'meeting', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -198,7 +207,7 @@ sub new { $options{options}->add_options(arguments => { "filter-user:s" => { name => 'filter_user' }, "units:s" => { name => 'units', default => '%' }, - "filter-counters:s" => { name => 'filter_counters', default => 'active|total' }, + "filter-counters:s" => { name => 'filter_counters', default => 'active|total' } }); return $self;