fix(multiple): thresholds and new perfdata (#2865)

This commit is contained in:
qgarnier 2021-06-10 11:52:44 +02:00 committed by GitHub
parent e3ba7ae7eb
commit 2620ce8a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 415 additions and 326 deletions

View File

@ -33,8 +33,8 @@ sub custom_usage_perfdata {
label => 'usage', nlabel => 'memory.usage.bytes', label => 'usage', nlabel => 'memory.usage.bytes',
unit => 'B', unit => 'B',
value => $self->{result_values}->{used}, value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $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->{label}, 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}); min => 0, max => $self->{result_values}->{total});
} }
@ -43,8 +43,11 @@ sub custom_usage_threshold {
my $exit = $self->{perfdata}->threshold_check( my $exit = $self->{perfdata}->threshold_check(
value => $self->{result_values}->{prct_used}, value => $self->{result_values}->{prct_used},
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -78,7 +81,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'memory', type => 1, cb_prefix_output => 'prefix_output', { 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} = [ $self->{maps_counters}->{memory} = [
@ -87,9 +90,9 @@ sub set_counters {
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'), closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold')
} }
}, }
]; ];
} }
@ -168,4 +171,4 @@ Threshold critical in percent.
=back =back
=cut =cut

View File

@ -33,8 +33,8 @@ sub custom_usage_perfdata {
label => 'usage', nlabel => 'storage.usage.bytes', label => 'usage', nlabel => 'storage.usage.bytes',
unit => 'B', unit => 'B',
value => $self->{result_values}->{used}, value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $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->{label}, 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}); min => 0, max => $self->{result_values}->{total});
} }
@ -43,8 +43,11 @@ sub custom_usage_threshold {
my $exit = $self->{perfdata}->threshold_check( my $exit = $self->{perfdata}->threshold_check(
value => $self->{result_values}->{prct_used}, value => $self->{result_values}->{prct_used},
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, threshold => [
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -88,9 +91,9 @@ sub set_counters {
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'), closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold')
} }
}, }
]; ];
} }
@ -106,8 +109,8 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' }, 'filter-name:s' => { name => 'filter_name' },
"filter-type:s" => { name => 'filter_type' }, 'filter-type:s' => { name => 'filter_type' }
}); });
return $self; 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 }, 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 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 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 { sub manage_selection {

View File

@ -54,8 +54,8 @@ sub custom_memory_perfdata {
unit => 'B', unit => 'B',
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
value => $self->{result_values}->{used}, value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $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->{label}, 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, min => 0,
max => $self->{result_values}->{total} max => $self->{result_values}->{total}
); );
@ -64,7 +64,12 @@ sub custom_memory_perfdata {
sub custom_memory_threshold { sub custom_memory_threshold {
my ($self, %options) = @_; 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; return $exit;
} }
@ -157,8 +162,8 @@ sub set_counters {
output_template => 'Traffic In : %s %s/s', output_template => 'Traffic In : %s %s/s',
perfdatas => [ perfdatas => [
{ label => 'traffic_in', template => '%.2f', { 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 => { { label => 'traffic-out', nlabel => 'container.traffic.out.bitspersecond', set => {

View File

@ -38,11 +38,14 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_users', nlabel => 'exchange.users.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_users',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), nlabel => 'exchange.users.active.count',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
unit => 'users', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,9 +55,13 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -62,12 +69,13 @@ sub custom_active_threshold {
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active users on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -99,7 +107,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -112,63 +120,65 @@ sub set_counters {
} }
}, },
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-send-count', nlabel => 'exchange.users.emails.sent.total.count', set => { { label => 'total-send-count', nlabel => 'exchange.users.emails.sent.total.count', set => {
key_values => [ { name => 'send_count' } ], key_values => [ { name => 'send_count' } ],
output_template => 'Send Count: %d', output_template => 'Send Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_send_count', value => 'send_count', template => '%d', { label => 'total_send_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-receive-count', nlabel => 'exchange.users.emails.received.total.count', set => { { label => 'total-receive-count', nlabel => 'exchange.users.emails.received.total.count', set => {
key_values => [ { name => 'receive_count' } ], key_values => [ { name => 'receive_count' } ],
output_template => 'Receive Count: %d', output_template => 'Receive Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_receive_count', value => 'receive_count', template => '%d', { label => 'total_receive_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-read-count', nlabel => 'exchange.users.emails.read.total.count', set => { { label => 'total-read-count', nlabel => 'exchange.users.emails.read.total.count', set => {
key_values => [ { name => 'read_count' } ], key_values => [ { name => 'read_count' } ],
output_template => 'Read Count: %d', output_template => 'Read Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_read_count', value => 'read_count', template => '%d', { label => 'total_read_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{users} = [ $self->{maps_counters}->{users} = [
{ label => 'send-count', nlabel => 'exchange.users.emails.sent.count', set => { { label => 'send-count', nlabel => 'exchange.users.emails.sent.count', set => {
key_values => [ { name => 'send_count' }, { name => 'name' } ], key_values => [ { name => 'send_count' }, { name => 'name' } ],
output_template => 'Send Count: %d', output_template => 'Send Count: %d',
perfdatas => [ perfdatas => [
{ label => 'send_count', value => 'send_count', template => '%d', { label => 'send_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'receive-count', nlabel => 'exchange.users.emails.received.count', set => { { label => 'receive-count', nlabel => 'exchange.users.emails.received.count', set => {
key_values => [ { name => 'receive_count' }, { name => 'name' } ], key_values => [ { name => 'receive_count' }, { name => 'name' } ],
output_template => 'Receive Count: %d', output_template => 'Receive Count: %d',
perfdatas => [ perfdatas => [
{ label => 'receive_count', value => 'receive_count', template => '%d', { label => 'receive_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'read-count', nlabel => 'exchange.users.emails.read.count', set => { { label => 'read-count', nlabel => 'exchange.users.emails.read.count', set => {
key_values => [ { name => 'read_count' }, { name => 'name' } ], key_values => [ { name => 'read_count' }, { name => 'name' } ],
output_template => 'Read Count: %d', output_template => 'Read Count: %d',
perfdatas => [ perfdatas => [
{ label => 'read_count', value => 'read_count', template => '%d', { label => 'read_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, }
]; ];
} }
@ -180,7 +190,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, "filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, "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; return $self;

View File

@ -38,11 +38,13 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_sites', nlabel => 'onedrive.sites.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_sites', nlabel => 'onedrive.sites.active.count',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
unit => 'sites', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,9 +54,13 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -62,12 +68,13 @@ sub custom_active_threshold {
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active sites on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active sites on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -87,12 +94,15 @@ sub custom_usage_perfdata {
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
$self->{output}->perfdata_add(label => 'used' . $extra_label, nlabel => $self->{result_values}->{display} . '#onedrive.sites.usage.bytes', $self->{output}->perfdata_add(
unit => 'B', label => 'used' . $extra_label,
value => $self->{result_values}->{used}, nlabel => $self->{result_values}->{display} . '#onedrive.sites.usage.bytes',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), unit => 'B',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), value => $self->{result_values}->{used},
min => 0, max => $self->{result_values}->{total}); 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 { 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_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
} }
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; 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 ($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 ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", return sprintf(
$total_value . " " . $total_unit, "Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$used_value . " " . $used_unit, $self->{result_values}->{prct_used}, $total_value . " " . $total_unit,
$free_value . " " . $free_unit, $self->{result_values}->{prct_free}); $used_value . " " . $used_unit, $self->{result_values}->{prct_used},
return $msg; $free_value . " " . $free_unit, $self->{result_values}->{prct_free}
);
} }
sub custom_usage_calc { sub custom_usage_calc {
@ -163,7 +178,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -174,17 +189,18 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_threshold_check => $self->can('custom_active_threshold'),
closure_custom_perfdata => $self->can('custom_active_perfdata') closure_custom_perfdata => $self->can('custom_active_perfdata')
} }
}, }
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-usage-active', nlabel => 'onedrive.sites.active.usage.total.bytes', set => { { label => 'total-usage-active', nlabel => 'onedrive.sites.active.usage.total.bytes', set => {
key_values => [ { name => 'storage_used_active' } ], key_values => [ { name => 'storage_used_active' } ],
output_template => 'Usage (active sites): %s %s', output_template => 'Usage (active sites): %s %s',
output_change_bytes => 1, output_change_bytes => 1,
perfdatas => [ perfdatas => [
{ label => 'total_usage_active', value => 'storage_used_active', template => '%d', { label => 'total_usage_active', template => '%d',
min => 0, unit => 'B' }, min => 0, unit => 'B' }
], ]
} }
}, },
{ label => 'total-usage-inactive', nlabel => 'onedrive.sites.inactive.usage.total.bytes', set => { { 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_template => 'Usage (inactive sites): %s %s',
output_change_bytes => 1, output_change_bytes => 1,
perfdatas => [ perfdatas => [
{ label => 'total_usage_inactive', value => 'storage_used_inactive', template => '%d', { label => 'total_usage_inactive', template => '%d',
min => 0, unit => 'B' }, min => 0, unit => 'B' }
], ]
} }
}, },
{ label => 'total-file-count-active', nlabel => 'onedrive.sites.active.files.total.count', set => { { label => 'total-file-count-active', nlabel => 'onedrive.sites.active.files.total.count', set => {
key_values => [ { name => 'file_count_active' } ], key_values => [ { name => 'file_count_active' } ],
output_template => 'File Count (active sites): %d', output_template => 'File Count (active sites): %d',
perfdatas => [ perfdatas => [
{ label => 'total_file_count_active', value => 'file_count_active', template => '%d', { label => 'total_file_count_active', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-file-count-inactive', nlabel => 'onedrive.sites.inactive.files.total.count', set => { { label => 'total-file-count-inactive', nlabel => 'onedrive.sites.inactive.files.total.count', set => {
key_values => [ { name => 'file_count_inactive' } ], key_values => [ { name => 'file_count_inactive' } ],
output_template => 'File Count (inactive sites): %d', output_template => 'File Count (inactive sites): %d',
perfdatas => [ perfdatas => [
{ label => 'total_file_count_inactive', value => 'file_count_inactive', template => '%d', { label => 'total_file_count_inactive', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-active-file-count', nlabel => 'onedrive.sites.files.active.total.count', set => { { label => 'total-active-file-count', nlabel => 'onedrive.sites.files.active.total.count', set => {
key_values => [ { name => 'active_file_count' } ], key_values => [ { name => 'active_file_count' } ],
output_template => 'Active File Count (active sites): %d', output_template => 'Active File Count (active sites): %d',
perfdatas => [ perfdatas => [
{ label => 'total_active_file_count', value => 'active_file_count', template => '%d', { label => 'total_active_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{sites} = [ $self->{maps_counters}->{sites} = [
{ label => 'usage', set => { { label => 'usage', set => {
key_values => [ { name => 'storage_used' }, { name => 'storage_allocated' }, { name => 'url' }, { name => 'owner' } ], key_values => [ { name => 'storage_used' }, { name => 'storage_allocated' }, { name => 'url' }, { name => 'owner' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'), closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold')
} }
}, },
{ label => 'file-count', nlabel => 'onedrive.sites.files.count', set => { { label => 'file-count', nlabel => 'onedrive.sites.files.count', set => {
key_values => [ { name => 'file_count' }, { name => 'url' }, { name => 'owner' } ], key_values => [ { name => 'file_count' }, { name => 'url' }, { name => 'owner' } ],
output_template => 'File Count: %d', output_template => 'File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'file_count', value => 'file_count', template => '%d', { label => 'file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'url' }, min => 0, label_extra_instance => 1, instance_use => 'url' }
], ]
} }
}, },
{ label => 'active-file-count', nlabel => 'onedrive.sites.files.active.count', set => { { label => 'active-file-count', nlabel => 'onedrive.sites.files.active.count', set => {
key_values => [ { name => 'active_file_count' }, { name => 'url' }, { name => 'owner' } ], key_values => [ { name => 'active_file_count' }, { name => 'url' }, { name => 'owner' } ],
output_template => 'Active File Count: %d', output_template => 'Active File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'active_file_count', value => 'active_file_count', template => '%d', { label => 'active_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'url' }, min => 0, label_extra_instance => 1, instance_use => 'url' }
], ]
} }
}, }
]; ];
} }
@ -265,7 +282,7 @@ sub new {
"filter-owner:s" => { name => 'filter_owner' }, "filter-owner:s" => { name => 'filter_owner' },
"units:s" => { name => 'units', default => '%' }, "units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' }, "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; return $self;
@ -275,8 +292,10 @@ sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{active} = { active => 0, total => 0, report_date => '' }; $self->{active} = { active => 0, total => 0, report_date => '' };
$self->{global} = { storage_used_active => 0, storage_used_inactive => 0, $self->{global} = {
file_count_active => 0, file_count_inactive => 0, active_file_count => 0 }; storage_used_active => 0, storage_used_inactive => 0,
file_count_active => 0, file_count_inactive => 0, active_file_count => 0
};
$self->{sites} = {}; $self->{sites} = {};
my $results = $options{custom}->office_get_onedrive_usage(param => "period='D7'"); my $results = $options{custom}->office_get_onedrive_usage(param => "period='D7'");

View File

@ -38,11 +38,14 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_users', nlabel => 'onedrive.users.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_users',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), nlabel => 'onedrive.users.active.count',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
unit => 'users', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,9 +55,13 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -62,12 +69,13 @@ sub custom_active_threshold {
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active users on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -99,7 +107,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -110,83 +118,85 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_threshold_check => $self->can('custom_active_threshold'),
closure_custom_perfdata => $self->can('custom_active_perfdata') closure_custom_perfdata => $self->can('custom_active_perfdata')
} }
}, }
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.total.count', set => { { label => 'total-viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.total.count', set => {
key_values => [ { name => 'viewed_edited_file_count' } ], key_values => [ { name => 'viewed_edited_file_count' } ],
output_template => 'Viewed or Edited File Count: %d', output_template => 'Viewed or Edited File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', { label => 'total_viewed_edited_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-synced-file-count', nlabel => 'onedrive.users.files.synced.total.count', set => { { label => 'total-synced-file-count', nlabel => 'onedrive.users.files.synced.total.count', set => {
key_values => [ { name => 'synced_file_count' } ], key_values => [ { name => 'synced_file_count' } ],
output_template => 'Synced File Count: %d', output_template => 'Synced File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_synced_file_count', value => 'synced_file_count', template => '%d', { label => 'total_synced_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.total.count', set => { { label => 'total-shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.total.count', set => {
key_values => [ { name => 'shared_int_file_count' } ], key_values => [ { name => 'shared_int_file_count' } ],
output_template => 'Shared Internally File Count: %d', output_template => 'Shared Internally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_shared_int_file_count', value => 'shared_int_file_count', template => '%d', { label => 'total_shared_int_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.total.count', set => { { label => 'total-shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.total.count', set => {
key_values => [ { name => 'shared_ext_file_count' } ], key_values => [ { name => 'shared_ext_file_count' } ],
output_template => 'Shared Externally File Count: %d', output_template => 'Shared Externally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', { label => 'total_shared_ext_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{users} = [ $self->{maps_counters}->{users} = [
{ label => 'viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.count', set => { { label => 'viewed-edited-file-count', nlabel => 'onedrive.users.files.viewed.count', set => {
key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ], key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ],
output_template => 'Viewed or Edited File Count: %d', output_template => 'Viewed or Edited File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', { label => 'viewed_edited_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'synced-file-count', nlabel => 'onedrive.users.files.synced.count', set => { { label => 'synced-file-count', nlabel => 'onedrive.users.files.synced.count', set => {
key_values => [ { name => 'synced_file_count' }, { name => 'name' } ], key_values => [ { name => 'synced_file_count' }, { name => 'name' } ],
output_template => 'Synced File Count: %d', output_template => 'Synced File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'synced_file_count', value => 'synced_file_count', template => '%d', { label => 'synced_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.count', set => { { label => 'shared-int-file-count', nlabel => 'onedrive.users.files.shared.internally.count', set => {
key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ], key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ],
output_template => 'Shared Internally File Count: %d', output_template => 'Shared Internally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'shared_int_file_count', value => 'shared_int_file_count', template => '%d', { label => 'shared_int_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.count', set => { { label => 'shared-ext-file-count', nlabel => 'onedrive.users.files.shared.externally.count', set => {
key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ], key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ],
output_template => 'Shared Externally File Count: %d', output_template => 'Shared Externally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', { label => 'shared_ext_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, }
]; ];
} }
@ -198,7 +208,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, "filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, "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; return $self;
@ -208,8 +218,10 @@ sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{active} = { active => 0, total => 0, report_date => '' }; $self->{active} = { active => 0, total => 0, report_date => '' };
$self->{global} = { viewed_edited_file_count => 0, synced_file_count => 0, $self->{global} = {
shared_int_file_count => 0, shared_ext_file_count => 0 }; viewed_edited_file_count => 0, synced_file_count => 0,
shared_int_file_count => 0, shared_ext_file_count => 0
};
$self->{users} = {}; $self->{users} = {};
my $results = $options{custom}->office_get_onedrive_activity(param => "period='D7'"); my $results = $options{custom}->office_get_onedrive_activity(param => "period='D7'");

View File

@ -38,11 +38,13 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_users', nlabel => 'sharepoint.users.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_users', nlabel => 'sharepoint.users.active.count',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
unit => 'users', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,22 +54,26 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active users on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -99,7 +105,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -110,101 +116,103 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_threshold_check => $self->can('custom_active_threshold'),
closure_custom_perfdata => $self->can('custom_active_perfdata') closure_custom_perfdata => $self->can('custom_active_perfdata')
} }
}, }
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.total.count', set => { { label => 'total-viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.total.count', set => {
key_values => [ { name => 'viewed_edited_file_count' } ], key_values => [ { name => 'viewed_edited_file_count' } ],
output_template => 'Viewed or Edited File Count: %d', output_template => 'Viewed or Edited File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', { label => 'total_viewed_edited_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-synced-file-count', nlabel => 'sharepoint.users.files.synced.total.count', set => { { label => 'total-synced-file-count', nlabel => 'sharepoint.users.files.synced.total.count', set => {
key_values => [ { name => 'synced_file_count' } ], key_values => [ { name => 'synced_file_count' } ],
output_template => 'Synced File Count: %d', output_template => 'Synced File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_synced_file_count', value => 'synced_file_count', template => '%d', { label => 'total_synced_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.total.count', set => { { label => 'total-shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.total.count', set => {
key_values => [ { name => 'shared_int_file_count' } ], key_values => [ { name => 'shared_int_file_count' } ],
output_template => 'Shared Internally File Count: %d', output_template => 'Shared Internally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_shared_int_file_count', value => 'shared_int_file_count', template => '%d', { label => 'total_shared_int_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.total.count', set => { { label => 'total-shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.total.count', set => {
key_values => [ { name => 'shared_ext_file_count' } ], key_values => [ { name => 'shared_ext_file_count' } ],
output_template => 'Shared Externally File Count: %d', output_template => 'Shared Externally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', { label => 'total_shared_ext_file_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-visited-page-count', nlabel => 'sharepoint.users.pages.visited.total.count', set => { { label => 'total-visited-page-count', nlabel => 'sharepoint.users.pages.visited.total.count', set => {
key_values => [ { name => 'visited_page_count' } ], key_values => [ { name => 'visited_page_count' } ],
output_template => 'Visited Page Count (active sites): %d', output_template => 'Visited Page Count (active sites): %d',
perfdatas => [ perfdatas => [
{ label => 'total_visited_page_count', value => 'visited_page_count', template => '%d', { label => 'total_visited_page_count', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{users} = [ $self->{maps_counters}->{users} = [
{ label => 'viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.count', set => { { label => 'viewed-edited-file-count', nlabel => 'sharepoint.users.files.viewed.count', set => {
key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ], key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ],
output_template => 'Viewed or Edited File Count: %d', output_template => 'Viewed or Edited File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', { label => 'viewed_edited_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'synced-file-count', nlabel => 'sharepoint.users.files.synced.count', set => { { label => 'synced-file-count', nlabel => 'sharepoint.users.files.synced.count', set => {
key_values => [ { name => 'synced_file_count' }, { name => 'name' } ], key_values => [ { name => 'synced_file_count' }, { name => 'name' } ],
output_template => 'Synced File Count: %d', output_template => 'Synced File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'synced_file_count', value => 'synced_file_count', template => '%d', { label => 'synced_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.count', set => { { label => 'shared-int-file-count', nlabel => 'sharepoint.users.files.shared.internally.count', set => {
key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ], key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ],
output_template => 'Shared Internally File Count: %d', output_template => 'Shared Internally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'shared_int_file_count', value => 'shared_int_file_count', template => '%d', { label => 'shared_int_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.count', set => { { label => 'shared-ext-file-count', nlabel => 'sharepoint.users.files.shared.externally.count', set => {
key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ], key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ],
output_template => 'Shared Externally File Count: %d', output_template => 'Shared Externally File Count: %d',
perfdatas => [ perfdatas => [
{ label => 'shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', { label => 'shared_ext_file_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'visited-page-count', nlabel => 'sharepoint.users.pages.visited.count', set => { { label => 'visited-page-count', nlabel => 'sharepoint.users.pages.visited.count', set => {
key_values => [ { name => 'visited_page_count' }, { name => 'name' } ], key_values => [ { name => 'visited_page_count' }, { name => 'name' } ],
output_template => 'Visited Page Count: %d', output_template => 'Visited Page Count: %d',
perfdatas => [ perfdatas => [
{ label => 'visited_page_count', value => 'visited_page_count', template => '%d', { label => 'visited_page_count', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, }
]; ];
} }
@ -216,7 +224,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, "filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, "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; return $self;
@ -226,9 +234,11 @@ sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{active} = { active => 0, total => 0, report_date => '' }; $self->{active} = { active => 0, total => 0, report_date => '' };
$self->{global} = { viewed_edited_file_count => 0, synced_file_count => 0, $self->{global} = {
shared_int_file_count => 0, shared_ext_file_count => 0, viewed_edited_file_count => 0, synced_file_count => 0,
visited_page_count => 0 }; shared_int_file_count => 0, shared_ext_file_count => 0,
visited_page_count => 0
};
$self->{users} = {}; $self->{users} = {};
my $results = $options{custom}->office_get_sharepoint_activity(param => "period='D7'"); my $results = $options{custom}->office_get_sharepoint_activity(param => "period='D7'");

View File

@ -38,11 +38,14 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_devices', nlabel => 'skype.devices.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_devices',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), nlabel => 'skype.devices.active.count',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
unit => 'devices', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,9 +55,13 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
@ -62,12 +69,13 @@ sub custom_active_threshold {
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active devices on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active devices on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -105,52 +113,53 @@ sub set_counters {
} }
}, },
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'windows', nlabel => 'skype.devices.windows.count', set => { { label => 'windows', nlabel => 'skype.devices.windows.count', set => {
key_values => [ { name => 'windows' } ], key_values => [ { name => 'windows' } ],
output_template => 'Windows: %d', output_template => 'Windows: %d',
perfdatas => [ perfdatas => [
{ label => 'windows', value => 'windows', template => '%d', { label => 'windows', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'ipad', nlabel => 'skype.devices.ipad.count', set => { { label => 'ipad', nlabel => 'skype.devices.ipad.count', set => {
key_values => [ { name => 'ipad' } ], key_values => [ { name => 'ipad' } ],
output_template => 'iPad: %d', output_template => 'iPad: %d',
perfdatas => [ perfdatas => [
{ label => 'ipad', value => 'ipad', template => '%d', { label => 'ipad', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'iphone', nlabel => 'skype.devices.iphone.count', set => { { label => 'iphone', nlabel => 'skype.devices.iphone.count', set => {
key_values => [ { name => 'iphone' } ], key_values => [ { name => 'iphone' } ],
output_template => 'iPhone: %d', output_template => 'iPhone: %d',
perfdatas => [ perfdatas => [
{ label => 'iphone', value => 'iphone', template => '%d', { label => 'iphone', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'android-phone', nlabel => 'skype.devices.android.count', set => { { label => 'android-phone', nlabel => 'skype.devices.android.count', set => {
key_values => [ { name => 'android_phone' } ], key_values => [ { name => 'android_phone' } ],
output_template => 'Android Phone: %d', output_template => 'Android Phone: %d',
perfdatas => [ perfdatas => [
{ label => 'android_phone', value => 'android_phone', template => '%d', { label => 'android_phone', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'windows-phone', nlabel => 'skype.devices.windowsphone.count', set => { { label => 'windows-phone', nlabel => 'skype.devices.windowsphone.count', set => {
key_values => [ { name => 'windows_phone' } ], key_values => [ { name => 'windows_phone' } ],
output_template => 'Windows Phone: %d', output_template => 'Windows Phone: %d',
perfdatas => [ perfdatas => [
{ label => 'windows_phone', value => 'windows_phone', template => '%d', { label => 'windows_phone', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
} }
@ -160,8 +169,8 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, 'filter-user:s' => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, 'units:s' => { name => 'units', default => '%' }
}); });
return $self; return $self;

View File

@ -38,11 +38,14 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_users', nlabel => 'skype.users.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_users',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), nlabel => 'skype.users.active.count',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
unit => 'users', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,22 +55,26 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active users on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -99,7 +106,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -112,63 +119,65 @@ sub set_counters {
} }
}, },
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.total.count', set => { { label => 'total-peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.total.count', set => {
key_values => [ { name => 'peer_to_peer_sessions' } ], key_values => [ { name => 'peer_to_peer_sessions' } ],
output_template => 'Peer-to-peer Sessions Count: %d', output_template => 'Peer-to-peer Sessions Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', { label => 'total_peer_to_peer_sessions', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-organized-conference', nlabel => 'skype.users.conferences.organized.total.count', set => { { label => 'total-organized-conference', nlabel => 'skype.users.conferences.organized.total.count', set => {
key_values => [ { name => 'organized_conference' } ], key_values => [ { name => 'organized_conference' } ],
output_template => 'Organized Conference Count: %d', output_template => 'Organized Conference Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_organized_conference', value => 'organized_conference', template => '%d', { label => 'total_organized_conference', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-participated-conference', nlabel => 'skype.users.conferences.participated.total.count', set => { { label => 'total-participated-conference', nlabel => 'skype.users.conferences.participated.total.count', set => {
key_values => [ { name => 'participated_conference' } ], key_values => [ { name => 'participated_conference' } ],
output_template => 'Participated Conference Count: %d', output_template => 'Participated Conference Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_participated_conference', value => 'participated_conference', template => '%d', { label => 'total_participated_conference', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{users} = [ $self->{maps_counters}->{users} = [
{ label => 'peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.count', set => { { label => 'peer-to-peer-sessions', nlabel => 'skype.users.sessions.p2p.count', set => {
key_values => [ { name => 'peer_to_peer_sessions' }, { name => 'name' } ], key_values => [ { name => 'peer_to_peer_sessions' }, { name => 'name' } ],
output_template => 'Peer-to-peer Sessions Count: %d', output_template => 'Peer-to-peer Sessions Count: %d',
perfdatas => [ perfdatas => [
{ label => 'peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', { label => 'peer_to_peer_sessions', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'organized-conference', nlabel => 'skype.users.conferences.organized.count', set => { { label => 'organized-conference', nlabel => 'skype.users.conferences.organized.count', set => {
key_values => [ { name => 'organized_conference' }, { name => 'name' } ], key_values => [ { name => 'organized_conference' }, { name => 'name' } ],
output_template => 'Organized Conference Count: %d', output_template => 'Organized Conference Count: %d',
perfdatas => [ perfdatas => [
{ label => 'organized_conference', value => 'organized_conference', template => '%d', { label => 'organized_conference', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'participated-conference', nlabel => 'skype.users.conferences.participated.count', set => { { label => 'participated-conference', nlabel => 'skype.users.conferences.participated.count', set => {
key_values => [ { name => 'participated_conference' }, { name => 'name' } ], key_values => [ { name => 'participated_conference' }, { name => 'name' } ],
output_template => 'Participated Conference Count: %d', output_template => 'Participated Conference Count: %d',
perfdatas => [ perfdatas => [
{ label => 'participated_conference', value => 'participated_conference', template => '%d', { label => 'participated_conference', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, }
]; ];
} }
@ -180,7 +189,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, "filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, "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; return $self;

View File

@ -38,11 +38,14 @@ sub custom_active_perfdata {
$self->{result_values}->{report_date} =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/; $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 => 'perfdate', value => timelocal(0,0,12,$3,$2-1,$1-1900));
$self->{output}->perfdata_add(label => 'active_users', nlabel => 'teams.users.active.count', $self->{output}->perfdata_add(
value => $self->{result_values}->{active}, label => 'active_users',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), nlabel => 'teams.users.active.count',
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), value => $self->{result_values}->{active},
unit => 'users', min => 0, max => $self->{result_values}->{total}); 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 { sub custom_active_threshold {
@ -52,22 +55,26 @@ sub custom_active_threshold {
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_active}; $threshold_value = $self->{result_values}->{prct_active};
} }
my $exit = $self->{perfdata}->threshold_check(value => $threshold_value, my $exit = $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $threshold_value,
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit; return $exit;
} }
sub custom_active_output { sub custom_active_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Active users on %s : %d/%d (%.2f%%)", return sprintf(
$self->{result_values}->{report_date}, "Active users on %s : %d/%d (%.2f%%)",
$self->{result_values}->{active}, $self->{result_values}->{report_date},
$self->{result_values}->{total}, $self->{result_values}->{active},
$self->{result_values}->{prct_active}); $self->{result_values}->{total},
return $msg; $self->{result_values}->{prct_active}
);
} }
sub custom_active_calc { sub custom_active_calc {
@ -99,7 +106,7 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'active', type => 0 }, { name => 'active', type => 0 },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { 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} = [ $self->{maps_counters}->{active} = [
@ -110,83 +117,85 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_active_threshold'), closure_custom_threshold_check => $self->can('custom_active_threshold'),
closure_custom_perfdata => $self->can('custom_active_perfdata') closure_custom_perfdata => $self->can('custom_active_perfdata')
} }
}, }
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-team-chat', nlabel => 'teams.users.messages.team.total.count', set => { { label => 'total-team-chat', nlabel => 'teams.users.messages.team.total.count', set => {
key_values => [ { name => 'team_chat' } ], key_values => [ { name => 'team_chat' } ],
output_template => 'Team Chat Message Count: %d', output_template => 'Team Chat Message Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_team_chat', value => 'team_chat', template => '%d', { label => 'total_team_chat', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-private-chat', nlabel => 'teams.users.messages.private.total.count', set => { { label => 'total-private-chat', nlabel => 'teams.users.messages.private.total.count', set => {
key_values => [ { name => 'private_chat' } ], key_values => [ { name => 'private_chat' } ],
output_template => 'Private Chat Message Count: %d', output_template => 'Private Chat Message Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_private_chat', value => 'private_chat', template => '%d', { label => 'total_private_chat', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-call', nlabel => 'teams.users.call.total.count', set => { { label => 'total-call', nlabel => 'teams.users.call.total.count', set => {
key_values => [ { name => 'call' } ], key_values => [ { name => 'call' } ],
output_template => 'Call Count: %d', output_template => 'Call Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_call', value => 'call', template => '%d', { label => 'total_call', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, },
{ label => 'total-meeting', nlabel => 'teams.users.meeting.total.count', set => { { label => 'total-meeting', nlabel => 'teams.users.meeting.total.count', set => {
key_values => [ { name => 'meeting' } ], key_values => [ { name => 'meeting' } ],
output_template => 'Meeting Count: %d', output_template => 'Meeting Count: %d',
perfdatas => [ perfdatas => [
{ label => 'total_meeting', value => 'meeting', template => '%d', { label => 'total_meeting', template => '%d',
min => 0 }, min => 0 }
], ]
} }
}, }
]; ];
$self->{maps_counters}->{users} = [ $self->{maps_counters}->{users} = [
{ label => 'team-chat', nlabel => 'teams.users.messages.team.count', set => { { label => 'team-chat', nlabel => 'teams.users.messages.team.count', set => {
key_values => [ { name => 'team_chat' }, { name => 'name' } ], key_values => [ { name => 'team_chat' }, { name => 'name' } ],
output_template => 'Team Chat Message Count: %d', output_template => 'Team Chat Message Count: %d',
perfdatas => [ perfdatas => [
{ label => 'team_chat', value => 'team_chat', template => '%d', { label => 'team_chat', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'private-chat', nlabel => 'teams.users.messages.private.count', set => { { label => 'private-chat', nlabel => 'teams.users.messages.private.count', set => {
key_values => [ { name => 'private_chat' }, { name => 'name' } ], key_values => [ { name => 'private_chat' }, { name => 'name' } ],
output_template => 'Private Chat Message Count: %d', output_template => 'Private Chat Message Count: %d',
perfdatas => [ perfdatas => [
{ label => 'private_chat', value => 'private_chat', template => '%d', { label => 'private_chat', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'call', nlabel => 'teams.users.call.count', set => { { label => 'call', nlabel => 'teams.users.call.count', set => {
key_values => [ { name => 'call' }, { name => 'name' } ], key_values => [ { name => 'call' }, { name => 'name' } ],
output_template => 'Call Count: %d', output_template => 'Call Count: %d',
perfdatas => [ perfdatas => [
{ label => 'call', value => 'call', template => '%d', { label => 'call', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, },
{ label => 'meeting', nlabel => 'teams.users.meeting.count', set => { { label => 'meeting', nlabel => 'teams.users.meeting.count', set => {
key_values => [ { name => 'meeting' }, { name => 'name' } ], key_values => [ { name => 'meeting' }, { name => 'name' } ],
output_template => 'Meeting Count: %d', output_template => 'Meeting Count: %d',
perfdatas => [ perfdatas => [
{ label => 'meeting', value => 'meeting', template => '%d', { label => 'meeting', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'name' }, min => 0, label_extra_instance => 1, instance_use => 'name' }
], ]
} }
}, }
]; ];
} }
@ -198,7 +207,7 @@ sub new {
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"filter-user:s" => { name => 'filter_user' }, "filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' }, "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; return $self;