Hello, I created a powershell script to monitor a FTPS Server SSL Certificate. Openssl is installed on the probe server and running the script in powershell gives the correct output, however PRTG always gets the code 2 which I use for "Check Failed". I'd be thankful if anyone can point out the issue here.
Script:
param ($server, $port) $target = -join($server, ":", $port) $check = (Write-Output "Q" | openssl s_client -connect $target -CAfile c:\cacert.pem -starttls ftp -verify_quiet | openssl x509 -enddate -noout -checkend 2592000) $returncode = 2 if ($check -contains "Certificate will expire"){ $returncode = 1 } if ($check -contains "Certificate will not expire"){ $returncode = 0 } $returndescription = switch($returncode) { 2 {"Check Failed"} 1 {"Warning, will expire within 30 days or less"} 0 {"Success, will not expire soon"} } "<prtg>" "<result>" "<channel>Code</channel>" "<value>$returncode</value>" "</result>" "<text>$returndescription</text>" "<text>$check</text>" "</prtg>"
Powershell output:
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> ./ftpzertifikat.ps1 ftp.servername.de 21 220 SERVERNAME FTP Server DONE <prtg> <result> <channel>Code</channel> <value>0</value> </result> <text>Success, will not expire soon</text> <text>notAfter=Dec 30 23:59:59 2023 GMT Certificate will not expire</text> </prtg>
Add comment