Output for custom DFS backlog check differs in WebUI from agent output

Hello,

we use Version 1.6.0p23 Managed Services Edition. We have build the following custom check:

When we run this Powershell script manually we get this output:
$BacklogDC1ToDC2 = (Get-DfsrBacklog -GroupName “mygroup” -FolderName “myfolder” -SourceComputerName “DC1” -DestinationComputerName “DC2” -Verbose 4>&1).Message.ToString()
$BacklogDC2toDC1 = (Get-DfsrBacklog -GroupName “mygroup” -FolderName “myfolder” -SourceComputerName “DC2” -DestinationComputerName “DC1” -Verbose 4>&1).Message.ToString()
$CheckMKStatus = 0
$CheckMKMessage = “Backlog ok”
$WarnLimit = 25
$CritLimit = 50
$BacklogDC1ToDC2Count = 0
$BacklogDC2toDC1Count = 0
$BacklogCount = 0

if ($BacklogDC1ToDC2.ToLower().Contains(“count”)){
$BacklogDC1ToDC2Count = [int]$BacklogDC1ToDC2.Split(’:’)[2]
}

if ($BacklogDC2toDC1.ToLower().Contains(“count”)){
$BacklogDC2toDC1Count = [int]$BacklogDC2toDC1.Split(’:’)[2]
}

if ($BacklogDC1ToDC2Count -ge $WarnLimit -or $BacklogDC2toDC1Count -ge $WarnLimit){
$CheckMKStatus = 1
$CheckMKMessage = “Backlog higher than normal. Check Diagnostic Report.”

if ($BacklogDC1ToDC2Count -ge $CritLimit -or $BacklogDC2toDC1Count -ge $CritLimit){
    $CheckMKStatus = 2
    $CheckMKMessage = "Backlog too high. Check Diagnostic Report."
} 

}

if ($BacklogDC1ToDC2Count -ge $BacklogDC2toDC1Count){
$BacklogCount = $BacklogDC1ToDC2Count
}
else {
$BacklogCount = $BacklogDC2toDC1Count
}

“$CheckMKStatus DFS_Backlog_myfolder - Backlog file count is: $BacklogCount - $CheckMKMessage”
exit 0

When we check the output from Powershell-Script we get this output:
0 DFS_Backlog_myfolder - Backlog file count is: 3 - Backlog ok

When we check the output from the agent, we get this output:
0 DFS_Backlog_myfolder - Backlog file count is: 3 - Backlog ok

When we start this check from the CHECK_MK-Server we get this output:
0 DFS_Backlog_myfolder - Backlog file count is: 0 - Backlog ok

Changes to the backlog filecount are reflected on agent side, but not on server side.

Has anyone an idea what might be missing?

Regards,
Michael

Sorry, I’m not that good at PowerShell scripts, but often when I recognize this behavior, there are some environment variables, which are set for your script and the local agent, but not for the execution of the server.

Hi nvongeheur,

which environment variables do you mean?

Regards,
Michael

Like I said, I’m not quiet good at PowerShell. Maybe the “Get-DfsrBacklog” does need some environmentals, which are not set for the remote execution

Under which user account did the script run when testing? Is it the same as the checkmk agent uses?
I would assume, that there is no output from Get-DfsrBacklog at all.

Best regards
Daniel

Hi,

it was a user problem, beacsue only an user with admin rights could execute the Get-DfsrBacklog. We created a scheduled task and the output from this task will be monitored by the agent.

Michael

Did you try to run the checkmk service as another user? I encountered a similar problem with a powershell script and i tried to use my admin user for testing. the problem persists. in my case the output number is different and not 0. i am counting AD-Users in a OU.

But i thought about this way too to create some txt file with a number in it. the local system user could easily read the txt. but i wanted to keep things simple and not have running 2 scripts and a txt file for one number,