enh office 365 teams plugin

This commit is contained in:
Colin Gagnaire 2019-02-06 11:11:48 +01:00
parent 462b3a8c8f
commit 87c0447712
2 changed files with 27 additions and 5 deletions

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::microsoft::office365::teams::mode::devicesusage;
package cloud::microsoft::office365::teams::mode::deviceusage;
use base qw(centreon::plugins::templates::counter);
@ -169,6 +169,7 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-user:s" => { name => 'filter_user' },
"units:s" => { name => 'units', default => '%' },
"filter-counters:s" => { name => 'filter_counters' },
});
@ -191,9 +192,15 @@ sub manage_selection {
my $results = $options{custom}->office_get_teams_device_usage();
$self->{active}->{total} = scalar(@{$results});
foreach my $user (@{$results}) {
if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' &&
$user->{'User Principal Name'} !~ /$self->{option_results}->{filter_user}/) {
$self->{output}->output_add(long_msg => "skipping '" . $user->{'User Principal Name'} . "': no matching filter name.", debug => 1);
next;
}
$self->{active}->{total}++;
if (!defined($user->{'Last Activity Date'}) || $user->{'Last Activity Date'} eq '' ||
($user->{'Last Activity Date'} ne $user->{'Report Refresh Date'})) {
$self->{output}->output_add(long_msg => "skipping '" . $user->{'User Principal Name'} . "': no activity.", debug => 1);
@ -225,6 +232,10 @@ https://docs.microsoft.com/en-us/office365/admin/activity-reports/microsoft-team
=over 8
=item B<--filter-user>
Filter users.
=item B<--warning-*>
Threshold warning.

View File

@ -196,6 +196,7 @@ sub new {
$self->{version} = '1.0';
$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' },
});
@ -219,9 +220,15 @@ sub manage_selection {
my $results = $options{custom}->office_get_teams_activity();
$self->{active}->{total} = scalar(@{$results});
foreach my $user (@{$results}) {
if (defined($self->{option_results}->{filter_user}) && $self->{option_results}->{filter_user} ne '' &&
$user->{'User Principal Name'} !~ /$self->{option_results}->{filter_user}/) {
$self->{output}->output_add(long_msg => "skipping '" . $user->{'User Principal Name'} . "': no matching filter name.", debug => 1);
next;
}
$self->{active}->{total}++;
if (!defined($user->{'Last Activity Date'}) || $user->{'Last Activity Date'} eq '' ||
($user->{'Last Activity Date'} ne $user->{'Report Refresh Date'})) {
$self->{output}->output_add(long_msg => "skipping '" . $user->{'User Principal Name'} . "': no activity.", debug => 1);
@ -258,6 +265,10 @@ https://docs.microsoft.com/en-us/office365/admin/activity-reports/microsoft-team
=over 8
=item B<--filter-user>
Filter users.
=item B<--warning-*>
Threshold warning.