I recently upgraded to NetXMS 5.0.6 (from 4.5.6) and it seems there is a problem with "ExternalMetricProvider" on the agent: I'm calling a few PowerShell-scripts with different execution intervals. After restart of the agent service everything seems fine and the scripts are executed as expected, but on the second call it is behaving strange: PowerShell stops executing in the middle of the script and in the agent log I find that the external command is killed because of ExternalMetricProviderTimeout, but actually the PowerShell process is still running in the background. The external command is not exected again after that.
I downgraded the agent to 4.5.6 and it is working as expected again.
Can you please enable
DebugLevel = 7
in agent configuration file and set it to log to file
LogFile = /path/to/log/file
let it run until it finishes second call of the script and share the log (you can sent it to me as private message if needed)
I created a minimal test-setup and it still happens. It seems the agent crashes on stopping the Windows service.
I see you have two external metric providers configured. Does the problem still happen if you remove the second one?
Can you also check with Windows Task manager, if between this line
2024.08.14 16:18:01.182 *D* [procexec.2 ] ProcessExecutor::executeWithOutput(): process "CMD.EXE /C pwsh.exe -NoProfile C:\\NetXMS\\var\\test1.ps1" started (PID=2020)
and that line
2024.08.14 16:18:31.185 *D* [ext.provider ] ExternalDataProvider::poll(): command "pwsh.exe -NoProfile C:\\NetXMS\\var\\test1.ps1" execution timeout (30000 milliseconds)
pwsh.exe -NoProfile C:\\NetXMS\\var\\test1.ps1
process is actually running, or it has already terminated? I'd try to add say 10 second delay inside test1.ps1, then it would be seen in Task Manager that this process starts and when it ends.
Yes, the problem still happens with one script (second ExternalMetricProvider removed).
No, the process pwsh.exe is not running after the script is finished in this test-setup. The PowerShell-file was empty before and I added 10 seconds of delay, but it does not change the behavior.
Can you actually share your powershell script (or some version of it with which gives same results).
Also, what's the version of powershell itself - it might make some difference.
Sure, but the script does almost nothing.
Start-Transcript -Path "$($PSScriptRoot)\$(Split-Path $PSCommandPath -Leaf).log" | Out-Null
Start-Sleep -Seconds 15
Stop-Transcript | Out-Null
On the system is the most recent version of PowerShell installed, currently 7.4.4 (I'm not using Windows PowerShell).
https://github.com/PowerShell/PowerShell
So which exactly powershell you use and on what OS this is?
Windows Server 2022 and PowerShell-7.4.4-win-x64.msi
Just upgraded to 5.0.8 and everything looks fine again, thank you!