BLOG
Checking the Progress of Beekeeper Execution Jobs
We have received requests to see more detail around what is happening while Beekeeper applies patches for devices. We have built a PowerShell script to query Beekeeper and the patched devices to display what is going on within Beekeeper and show the progress on individual patches.
To execute the script, you can run it on the Beekeeper server:
PS C:\_scripts> .\BK_CheckExecutionJobs.ps1
If you wish to run this script remotely, you will need to change the “localhost” references to your Beekeeper server name: (Ex: localhost to “JFHLABBK01”)
Before edit:
$ExecutionJobsRequestURI =
"http://localhost/BeekeeperApi/OPAS.svc/PatchRecords?`$filter=Status eq 'Running'"
$RunningJobsResults = Invoke-RestMethod -Uri $ExecutionJobsRequestURI -UseDefaultCredentials -Headers $URI_Headers
If($RunningJobsResults.value.Count -gt 0)
{
Write-Host "Current Beekeeper Execution Jobs:" -ForegroundColor Yellow
Write-Host " "
Foreach($Record in $RunningJobsResults.Value)
{
If($Record.'odata.type' -eq "OPASSvc.ClusterPatchRecord")
{
$Clustersrequesturi = "http://localhost/BeekeeperApi/OPAS.svc/Clusters?`$filter=ClusterId eq " + $Record.ClusterId
$Clusterresults = Invoke-RestMethod -Uri $ClustersrequestUri -UseDefaultCredentials -Headers $URI_Headers
Write-Host " Group currently Executing: " $Clusterresults.value.ClusterName " Node count: " $Record.NodeCount -ForegroundColor Cyan
}
If($Record.'odata.type' -eq "OPASSvc.NodePatchRecord")
{
$NodeRequestURI = "http://localhost/BeekeeperApi/OPAS.svc/ClusterNodes?`$filter=NodeId eq $($Record.NodeId)"
$NodeResults = Invoke-RestMethod -Uri $NodeRequestURI -UseDefaultCredentials -Headers $URI_Headers
Write-Host " On Node: " $NodeResults.value.NodeName -ForegroundColor Green
$EventRequestURI = "http://localhost/BeekeeperApi/OPAS.svc/Events?`$filter=(NodePatchRecordId eq $($Record.RecordId))"
After edit:
$ExecutionJobsRequestURI =
"http://JFHLABBK01/BeekeeperApi/OPAS.svc/PatchRecords?`$filter=Status eq 'Running'"
$RunningJobsResults = Invoke-RestMethod -Uri $ExecutionJobsRequestURI -UseDefaultCredentials -Headers $URI_Headers
If($RunningJobsResults.value.Count -gt 0)
{
Write-Host "Current Beekeeper Execution Jobs:" -ForegroundColor Yellow
Write-Host " "
Foreach($Record in $RunningJobsResults.Value)
{
If($Record.'odata.type' -eq "OPASSvc.ClusterPatchRecord")
{
$Clustersrequesturi = "http://JFHLABBK01/BeekeeperApi/OPAS.svc/Clusters?`$filter=ClusterId eq " + $Record.ClusterId
$Clusterresults = Invoke-RestMethod -Uri $ClustersrequestUri -UseDefaultCredentials -Headers $URI_Headers
Write-Host " Group currently Executing: " $Clusterresults.value.ClusterName " Node count: " $Record.NodeCount -ForegroundColor Cyan
}
If($Record.'odata.type' -eq "OPASSvc.NodePatchRecord")
{
$NodeRequestURI = "http://JFHLABBK01/BeekeeperApi/OPAS.svc/ClusterNodes?`$filter=NodeId eq $($Record.NodeId)"
$NodeResults = Invoke-RestMethod -Uri $NodeRequestURI -UseDefaultCredentials -Headers $URI_Headers
Write-Host " On Node: " $NodeResults.value.NodeName -ForegroundColor Green
$EventRequestURI = "http://JFHLABBK01/BeekeeperApi/OPAS.svc/Events?`$filter=(NodePatchRecordId eq $($Record.RecordId))"
Once you execute the script, it will show you Beekeeper’s progress:
Another example demonstrates more detail and actual status of individual patches.
Within the detail of a device’s patches, Evaluationstate is the progress phase and Compliancestate is the installed state.
This script is in our Github repository:
https://github.com/green-house-data/BeekeeperScripts/blob/master/BK_CheckExecutionJobs.ps1