Skip to main content

Posts

Showing posts from July, 2019

getty to test URLs, send email alert when URL fail

This is the Powershell script: #This script monitor DS critical URLs, send email alert if URL is not "0% fail" $ErrorActionPreference = 'SilentlyContinue' c: cd C:\DBA\bin\getty $URLSource="c:\dba\bin\getty\URLsource.txt" $LOG="c:\dba\bin\getty\DSMonitoringURLsPS.log" $GETTYDIR="C:\DBA\bin\getty" $GETTY="C:\DBA\bin\getty\getty_NO_Save_Log.bat" remove-item -Path $LOG -ErrorAction Ignore #foreach($ThisURL in Get-Content $URLSource| Where {$_ -notmatch '^#.*'}) foreach($ThisURL in Get-Content $URLSource)  { if ($ThisURL -notmatch '^#.*') { $ThisURL=$ThisURL.trim() cd $GETTYDIR & $GETTY $ThisURL 3 >> $LOG } else { "skipped checking this URL :"+$ThisURL >> $LOG }  } if (!(Test-Path $LOG)) {   Write-Warning "outputfile absent, exiting"   exit } $SEL = get-content $LOG|select-string " fail"|select-string -notMatch -simplematch "