Closed mirei83 closed 3 years ago
Since Agent version 3 it is possible to define the shell the Agent should use for the execution.
I would recommend you to set shell = powershell
:
[check_exchange_DB]
command = "C:\scripts\oitc\check_exchange.ps1 -CheckType DBStatus"
# Maybe command = "C:\scripts\oitc\check_exchange.ps1" -CheckType DBStatus
shell = powershell
interval = 1800
timeout = 120
enabled = true
More examples can be found in the example config for custom checks: https://github.com/it-novum/openitcockpit-agent-go/blob/main/example/customchecks_example.ini
Hope this helps
Thank you for your answer. Unfortunatelly this did not solve my problem. After some testing I was able to make it work again, so I want to share the solution.
Somehow the script does not work when executed from the OITC agent. The solution was to simply remove the
begin {...} process{...} end{...}
bracets. Then it worked again.
I still cant tell if it was the version change from OITC or a Windows Update.
The docs of PowerShell 7.1 claims that this is still a thing: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_cmdletbindingattribute?view=powershell-7.1
How ever I have nearly zero experience with powershell soo - as long as it works :)
Agent Mode:
Versions
Operating system Please provide detailed operating system description (please do not just say "windows" or "linux"), installed antivirus, anything else that could be helpful information
Describe the bug I have an issue, that a script to check exchange values (https://github.com/yosbit/nagios-plugins/blob/master/README/README_check_exchange.md) does not work with the agent in version 3. It did work fine in version 2. Other powershell scripts do return values.
To Reproduce Steps to reproduce the behavior:
Download script https://github.com/yosbit/nagios-plugins/blob/master/README/README_check_exchange.md
Set as custom check with ' [check_exchange_DB] command = powershell.exe -file "C:\scripts\oitc\check_exchange.ps1" -CheckType DBStatus interval = 1800 timeout = 120 enabled = true '
Return in agent is ' "customchecks": { "check_exchange_db": { "stdout": "UNKNOWN: \n", "rc": 0, "execution_unix_timestamp_sec": 1632384259 '
Return in powershell is ' OK: All Exchange DB are mounted, Databases: Mailbox Database 0423674483 Total: 1 '