fix(office365): mode site-usage - add --use-pseudonymize option (#3390)
This commit is contained in:
parent
8f1021295d
commit
4e969a5b78
|
@ -30,12 +30,12 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'filter-url:s' => { name => 'filter_url' },
|
||||||
"filter-url:s" => { name => 'filter_url' },
|
'filter-id:s' => { name => 'filter_id' },
|
||||||
"filter-id:s" => { name => 'filter_id' },
|
'use-pseudonymize:s' => { name => 'use_pseudonymize' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,12 @@ sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $results = $options{custom}->office_get_sharepoint_site_usage(param => "period='D7'");
|
my $results = $options{custom}->office_get_sharepoint_site_usage(param => "period='D7'");
|
||||||
|
foreach my $site (@$results) {
|
||||||
|
if ($site->{'Site URL'} !~ /^(https|http):/ && !defined($self->{option_results}->{use_pseudonymize})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "reports pseudonymize user-level information is enabled. use option --use-pseudonymize or disable it");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $site (@{$results}) {
|
|
||||||
if (defined($self->{option_results}->{filter_url}) && $self->{option_results}->{filter_url} ne '' &&
|
if (defined($self->{option_results}->{filter_url}) && $self->{option_results}->{filter_url} ne '' &&
|
||||||
$site->{'Site URL'} !~ /$self->{option_results}->{filter_url}/) {
|
$site->{'Site URL'} !~ /$self->{option_results}->{filter_url}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $site->{'Site URL'} . "': no matching filter name.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping '" . $site->{'Site URL'} . "': no matching filter name.", debug => 1);
|
||||||
|
@ -61,9 +65,9 @@ sub manage_selection {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{sites}->{$site->{'Site Id'}} = {
|
$self->{sites}->{ $site->{'Site Id'} } = {
|
||||||
id => $site->{'Site Id'},
|
id => $site->{'Site Id'},
|
||||||
url => $site->{'Site URL'},
|
url => $site->{'Site URL'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +77,19 @@ sub run {
|
||||||
|
|
||||||
$self->manage_selection(%options);
|
$self->manage_selection(%options);
|
||||||
foreach my $site (sort keys %{$self->{sites}}) {
|
foreach my $site (sort keys %{$self->{sites}}) {
|
||||||
$self->{output}->output_add(long_msg => sprintf("[id = %s] [url = %s]",
|
$self->{output}->output_add(
|
||||||
$self->{sites}->{$site}->{id},
|
long_msg => sprintf(
|
||||||
$self->{sites}->{$site}->{url}));
|
"[id: %s] [url: %s]",
|
||||||
|
$self->{sites}->{$site}->{id},
|
||||||
|
$self->{sites}->{$site}->{url}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(
|
||||||
short_msg => 'List sites:');
|
severity => 'OK',
|
||||||
|
short_msg => 'List sites:'
|
||||||
|
);
|
||||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
@ -97,7 +107,7 @@ sub disco_show {
|
||||||
foreach my $site (sort keys %{$self->{sites}}) {
|
foreach my $site (sort keys %{$self->{sites}}) {
|
||||||
$self->{output}->add_disco_entry(
|
$self->{output}->add_disco_entry(
|
||||||
id => $self->{sites}->{$site}->{id},
|
id => $self->{sites}->{$site}->{id},
|
||||||
url => $self->{sites}->{$site}->{url},
|
url => $self->{sites}->{$site}->{url}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +127,10 @@ List sites.
|
||||||
Filter sites.
|
Filter sites.
|
||||||
Can be: 'url', 'id' (can be a regexp).
|
Can be: 'url', 'id' (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--use-pseudonymize>
|
||||||
|
|
||||||
|
Use pseudonymize user-level information.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
|
@ -306,11 +306,12 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-url:s' => { name => 'filter_url' },
|
'filter-url:s' => { name => 'filter_url' },
|
||||||
'filter-id:s' => { name => 'filter_id' },
|
'filter-id:s' => { name => 'filter_id' },
|
||||||
'units:s' => { name => 'units', default => '%' },
|
'use-pseudonymize:s' => { name => 'use_pseudonymize' }
|
||||||
'free' => { name => 'free' },
|
'units:s' => { name => 'units', default => '%' },
|
||||||
'filter-counters:s' => { name => 'filter_counters', default => 'active-sites|total' }
|
'free' => { name => 'free' },
|
||||||
|
'filter-counters:s' => { name => 'filter_counters', default => 'active-sites|total' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -318,7 +319,7 @@ sub new {
|
||||||
|
|
||||||
sub manage_selection {
|
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} = {
|
$self->{global} = {
|
||||||
storage_used_active => 0, storage_used_inactive => 0,
|
storage_used_active => 0, storage_used_inactive => 0,
|
||||||
|
@ -335,6 +336,11 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $site (@{$results}, @{$results_daily}) {
|
foreach my $site (@{$results}, @{$results_daily}) {
|
||||||
|
if ($site->{'Site URL'} !~ /^(https|http):/ && !defined($self->{option_results}->{use_pseudonymize})) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "reports pseudonymize user-level information is enabled. use option --use-pseudonymize or disable it");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
if (defined($self->{option_results}->{filter_url}) && $self->{option_results}->{filter_url} ne '' &&
|
if (defined($self->{option_results}->{filter_url}) && $self->{option_results}->{filter_url} ne '' &&
|
||||||
$site->{'Site URL'} !~ /$self->{option_results}->{filter_url}/) {
|
$site->{'Site URL'} !~ /$self->{option_results}->{filter_url}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $site->{'Site URL'} . "': no matching filter name.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping '" . $site->{'Site URL'} . "': no matching filter name.", debug => 1);
|
||||||
|
@ -389,39 +395,32 @@ https://docs.microsoft.com/en-us/microsoft-365/admin/activity-reports/sharepoint
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--filter-*>
|
|
||||||
|
|
||||||
Filter sites.
|
|
||||||
Can be: 'url', 'id' (can be a regexp).
|
|
||||||
|
|
||||||
=item B<--warning-*>
|
|
||||||
|
|
||||||
Threshold warning.
|
|
||||||
Can be: 'active-sites',
|
|
||||||
'total-usage-active' (count), 'total-usage-inactive' (count),
|
|
||||||
'total-file-count-active' (count), 'total-file-count-inactive' (count),
|
|
||||||
'total-active-file-count' (count), 'total-visited-page-count' (count),
|
|
||||||
'total-page-view-count' (count),
|
|
||||||
'usage' (count), 'file-count' (count), 'active-file-count' (count),
|
|
||||||
'visited-page-count' (count), 'page-view-count' (count).
|
|
||||||
|
|
||||||
=item B<--critical-*>
|
|
||||||
|
|
||||||
Threshold critical.
|
|
||||||
Can be: 'active-sites',
|
|
||||||
'total-usage-active' (count), 'total-usage-inactive' (count),
|
|
||||||
'total-file-count-active' (count), 'total-file-count-inactive' (count),
|
|
||||||
'total-active-file-count' (count), 'total-visited-page-count' (count),
|
|
||||||
'total-page-view-count' (count),
|
|
||||||
'usage' (count), 'file-count' (count), 'active-file-count' (count),
|
|
||||||
'visited-page-count' (count), 'page-view-count' (count).
|
|
||||||
|
|
||||||
=item B<--filter-counters>
|
=item B<--filter-counters>
|
||||||
|
|
||||||
Only display some counters (regexp can be used).
|
Only display some counters (regexp can be used).
|
||||||
Example to hide per user counters: --filter-counters='active-sites|total'
|
Example to hide per user counters: --filter-counters='active-sites|total'
|
||||||
(Default: 'active-sites|total')
|
(Default: 'active-sites|total')
|
||||||
|
|
||||||
|
=item B<--filter-*>
|
||||||
|
|
||||||
|
Filter sites.
|
||||||
|
Can be: 'url', 'id' (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--use-pseudonymize>
|
||||||
|
|
||||||
|
Use pseudonymize user-level information.
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'active-sites',
|
||||||
|
'total-usage-active' (count), 'total-usage-inactive' (count),
|
||||||
|
'total-file-count-active' (count), 'total-file-count-inactive' (count),
|
||||||
|
'total-active-file-count' (count), 'total-visited-page-count' (count),
|
||||||
|
'total-page-view-count' (count),
|
||||||
|
'usage' (count), 'file-count' (count), 'active-file-count' (count),
|
||||||
|
'visited-page-count' (count), 'page-view-count' (count).
|
||||||
|
|
||||||
=item B<--units>
|
=item B<--units>
|
||||||
|
|
||||||
Unit of thresholds (Default: '%') ('%', 'count').
|
Unit of thresholds (Default: '%') ('%', 'count').
|
||||||
|
|
Loading…
Reference in New Issue