I used check-windows-disk.ps1 powershell script from asset samroy92/sensu-plugins-windows.
When I execute manually the script on my Windows Server environment, it detects a 99% full disk and as expected the exit code is 2
PS C:\ProgramData\Sensu\cache\sensu-agent\7606a43a1fb5bcfb8b13d29293fae26f83239ae96f089c3930f5d46dc72ffb7101478e5c023aa2c384b582e574d04a6a433c5e1f65f708f0f67afa5d173859c3\bin> .\check-windows-disk.ps1
cmdlet check-windows-disk.ps1 at command pipeline position 1
Supply values for the following parameters:
WARNING: 75
CRITICAL: 90
CheckDisk CRITICAL: 1 disks in critical state
(D:) 99.67%, FREE: 0 GB, SIZE: 31 GB
PS C:\ProgramData\Sensu\cache\sensu-agent\7606a43a1fb5bcfb8b13d29293fae26f83239ae96f089c3930f5d46dc72ffb7101478e5c023aa2c384b582e574d04a6a433c5e1f65f708f0f67afa5d173859c3\bin> $LASTEXITCODE
2
However the status which is retrieved by Sensu is 1 (not 2 as expected).
tribvn@sensu:~$ sudo sensuctl event info CalopixIntegrat windows-check-disk-usage
=== CalopixIntegrat - windows-check-disk-usage
Entity: CalopixIntegrat
Check: windows-check-disk-usage
Output: CheckDisk CRITICAL: 1 disks in critical state
(D:) 99.67%, FREE: 0 GB, SIZE: 31 GB
Status: 1
History: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Silenced: false
Timestamp: 2023-06-14 18:23:08 +0200 CEST
UUID: 4742815a-5116-4d5a-add9-83f9426089ce
Why the exit code of the powershell code and the status of the matching check is not the same?
Sensu version is 5.21.0
Thanks by advance for your help.