(plugin) apps::microsoft::wsus - add downstream servers (#3989)
* wip * wip * wip
This commit is contained in:
parent
bea66af713
commit
d4fe70dac6
|
@ -100,7 +100,7 @@ sub new {
|
||||||
'ps-display' => { name => 'ps_display' },
|
'ps-display' => { name => 'ps_display' },
|
||||||
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
|
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
|
||||||
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
|
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
|
||||||
'not-updated-since:s' => { name => 'not_updated_since', default => 10 },
|
'not-updated-since:s' => { name => 'not_updated_since', default => 30 },
|
||||||
'use-ssl' => { name => 'use_ssl' }
|
'use-ssl' => { name => 'use_ssl' }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -210,21 +210,15 @@ Set WSUS port.
|
||||||
|
|
||||||
=item B<--not-updated-since>
|
=item B<--not-updated-since>
|
||||||
|
|
||||||
Time in minutes to count computers not updated since.
|
Time in days to count computers not updated since (Default: 30).
|
||||||
|
|
||||||
=item B<--use-ssl>
|
=item B<--use-ssl>
|
||||||
|
|
||||||
Set if WSUS use ssl.
|
Set if WSUS use ssl.
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Warning thresholds.
|
Thresholds.
|
||||||
Can be: 'needing-updates', 'with-update-errors',
|
|
||||||
'up-to-date', 'not-contacted', 'unassigned'
|
|
||||||
|
|
||||||
=item B<--critical-*>
|
|
||||||
|
|
||||||
Critical thresholds.
|
|
||||||
Can be: 'needing-updates', 'with-update-errors',
|
Can be: 'needing-updates', 'with-update-errors',
|
||||||
'up-to-date', 'not-contacted', 'unassigned'
|
'up-to-date', 'not-contacted', 'unassigned'
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ use DateTime;
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf("status is '%s'", $self->{result_values}->{status});
|
return sprintf("status is '%s'", $self->{result_values}->{status});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_status_calc {
|
sub custom_status_calc {
|
||||||
|
@ -47,8 +46,7 @@ sub custom_status_calc {
|
||||||
sub custom_last_status_output {
|
sub custom_last_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf("status is '%s'", $self->{result_values}->{status});
|
return sprintf("status is '%s'", $self->{result_values}->{status});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_last_status_calc {
|
sub custom_last_status_calc {
|
||||||
|
@ -73,9 +71,13 @@ sub custom_progress_perfdata {
|
||||||
sub custom_progress_threshold {
|
sub custom_progress_threshold {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{progress},
|
my $exit = $self->{perfdata}->threshold_check(
|
||||||
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
|
value => $self->{result_values}->{progress},
|
||||||
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
threshold => [
|
||||||
|
{ label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' }
|
||||||
|
]
|
||||||
|
);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +119,13 @@ sub custom_duration_perfdata {
|
||||||
sub custom_duration_threshold {
|
sub custom_duration_threshold {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{duration},
|
my $exit = $self->{perfdata}->threshold_check(
|
||||||
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
|
value => $self->{result_values}->{duration},
|
||||||
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
threshold => [
|
||||||
|
{ label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{label}, exit_litteral => 'warning' }
|
||||||
|
]
|
||||||
|
);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,12 +152,24 @@ sub custom_duration_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_output_current {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Current Synchronisation ";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_output_last {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Last Synchronisation ";
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'current', type => 0, cb_prefix_output => 'prefix_output_current' },
|
{ name => 'current', type => 0, cb_prefix_output => 'prefix_output_current' },
|
||||||
{ name => 'last', type => 0, cb_prefix_output => 'prefix_output_last' },
|
{ name => 'last', type => 0, cb_prefix_output => 'prefix_output_last' }
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{current} = [
|
$self->{maps_counters}->{current} = [
|
||||||
|
@ -160,7 +178,7 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
closure_custom_calc => $self->can('custom_status_calc'),
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'synchronisation-progress', set => {
|
{ label => 'synchronisation-progress', set => {
|
||||||
|
@ -168,10 +186,11 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_progress_calc'),
|
closure_custom_calc => $self->can('custom_progress_calc'),
|
||||||
closure_custom_output => $self->can('custom_progress_output'),
|
closure_custom_output => $self->can('custom_progress_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_progress_perfdata'),
|
closure_custom_perfdata => $self->can('custom_progress_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_progress_threshold'),
|
closure_custom_threshold_check => $self->can('custom_progress_threshold')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{last} = [
|
$self->{maps_counters}->{last} = [
|
||||||
{ label => 'last-synchronisation-status', threshold => 0, set => {
|
{ label => 'last-synchronisation-status', threshold => 0, set => {
|
||||||
key_values => [ { name => 'LastSynchronizationResult' } ],
|
key_values => [ { name => 'LastSynchronizationResult' } ],
|
||||||
|
@ -186,24 +205,12 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_duration_calc'),
|
closure_custom_calc => $self->can('custom_duration_calc'),
|
||||||
closure_custom_output => $self->can('custom_duration_output'),
|
closure_custom_output => $self->can('custom_duration_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_duration_perfdata'),
|
closure_custom_perfdata => $self->can('custom_duration_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_duration_threshold'),
|
closure_custom_threshold_check => $self->can('custom_duration_threshold')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_output_current {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Current Synchronisation ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub prefix_output_last {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Last Synchronisation ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
|
|
@ -55,13 +55,22 @@ Try {
|
||||||
|
|
||||||
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
||||||
|
|
||||||
$wsusStatus = $wsusObject.GetStatus()
|
$computerTargetScope = New-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||||
|
$computerTargetScope.IncludeDownstreamComputerTargets = $true
|
||||||
|
$updateSource = "All"
|
||||||
|
$wsusStatus = $wsusObject.GetComputerStatus($computerTargetScope, $updateSource)
|
||||||
|
|
||||||
$notUpdatedSinceTimespan = new-object TimeSpan($notUpdatedSince, 0, 0, 0)
|
$notUpdatedSinceTimespan = new-object TimeSpan($notUpdatedSince, 0, 0, 0)
|
||||||
$computersNotContactedSinceCount = $wsusObject.GetComputersNotContactedSinceCount([DateTime]::UtcNow.Subtract($notUpdatedSinceTimespan))
|
$computerTargetScopeNotContactedSince = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||||
|
$computerTargetScopeNotContactedSince.ToLastReportedStatusTime = [DateTime]::UtcNow.Subtract($notUpdatedSinceTimespan)
|
||||||
|
$computerTargetScopeNotContactedSince.IncludeDownstreamComputerTargets = $true
|
||||||
|
$computersNotContactedSinceCount = $wsusObject.GetComputerTargetCount($computerTargetScopeNotContactedSince)
|
||||||
|
|
||||||
$computerTargetScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
$computerTargetScopeUnassigned = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||||
$unassignedComputersCount = $wsusObject.GetComputerTargetGroup([Microsoft.UpdateServices.Administration.ComputerTargetGroupId]::UnassignedComputers).GetComputerTargets().Count
|
$computerTargetScopeUnassigned.IncludeDownstreamComputerTargets = $true
|
||||||
|
$group = $wsusObject.GetComputerTargetGroups() | ? {$_.Name -like "Unassigned Computers"}
|
||||||
|
$computerTargetScopeUnassigned.ComputerTargetGroups.Add($group)
|
||||||
|
$unassignedComputersCount = $wsusObject.GetComputerTargetCount($computerTargetScopeUnassigned)
|
||||||
|
|
||||||
$item = @{
|
$item = @{
|
||||||
ComputerTargetsNeedingUpdatesCount = $wsusStatus.ComputerTargetsNeedingUpdatesCount;
|
ComputerTargetsNeedingUpdatesCount = $wsusStatus.ComputerTargetsNeedingUpdatesCount;
|
||||||
|
|
|
@ -54,17 +54,22 @@ Try {
|
||||||
|
|
||||||
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
||||||
|
|
||||||
$wsusStatus = $wsusObject.GetStatus()
|
$computerTargetScope = New-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||||
|
$computerTargetScope.IncludeDownstreamComputerTargets = $true
|
||||||
|
$updateSource = "All"
|
||||||
|
$wsusStatus = $wsusObject.GetComputerStatus($computerTargetScope, $updateSource)
|
||||||
|
|
||||||
|
$wsusUpdateStatus = $wsusObject.GetStatus()
|
||||||
|
|
||||||
$item = @{
|
$item = @{
|
||||||
ComputerTargetCount = $wsusStatus.ComputerTargetCount;
|
ComputerTargetCount = $wsusStatus.ComputerTargetCount;
|
||||||
CustomComputerTargetGroupCount = $wsusStatus.CustomComputerTargetGroupCount;
|
CustomComputerTargetGroupCount = $wsusStatus.CustomComputerTargetGroupCount;
|
||||||
UpdateCount = $wsusStatus.UpdateCount;
|
UpdateCount = $wsusUpdateStatus.UpdateCount;
|
||||||
ApprovedUpdateCount = $wsusStatus.ApprovedUpdateCount;
|
ApprovedUpdateCount = $wsusUpdateStatus.ApprovedUpdateCount;
|
||||||
DeclinedUpdateCount = $wsusStatus.DeclinedUpdateCount;
|
DeclinedUpdateCount = $wsusUpdateStatus.DeclinedUpdateCount;
|
||||||
NotApprovedUpdateCount = $wsusStatus.NotApprovedUpdateCount;
|
NotApprovedUpdateCount = $wsusUpdateStatus.NotApprovedUpdateCount;
|
||||||
UpdatesWithStaleUpdateApprovalsCount = $wsusStatus.UpdatesWithStaleUpdateApprovalsCount;
|
UpdatesWithStaleUpdateApprovalsCount = $wsusUpdateStatus.UpdatesWithStaleUpdateApprovalsCount;
|
||||||
ExpiredUpdateCount = $wsusStatus.ExpiredUpdateCount
|
ExpiredUpdateCount = $wsusUpdateStatus.ExpiredUpdateCount
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonString = $item | ConvertTo-JSON-20
|
$jsonString = $item | ConvertTo-JSON-20
|
||||||
|
|
|
@ -54,7 +54,8 @@ Try {
|
||||||
|
|
||||||
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
$wsusObject = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusServer, $useSsl, $wsusPort)
|
||||||
|
|
||||||
$wsusStatus = $wsusObject.GetStatus()
|
$updateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope
|
||||||
|
$wsusStatus = $wsusObject.GetUpdateStatus($UpdateScope, $True)
|
||||||
|
|
||||||
$item = @{
|
$item = @{
|
||||||
UpdatesWithClientErrorsCount = $wsusStatus.UpdatesWithClientErrorsCount;
|
UpdatesWithClientErrorsCount = $wsusStatus.UpdatesWithClientErrorsCount;
|
||||||
|
|
Loading…
Reference in New Issue