Page 1 of 1

Nagios & SQL 2013 Monitoring

Posted: Wed Oct 16, 2013 11:11 am
by jhagedorn
This might help out anyone tring to monitor "SQL 2013 Always-On".. :)

Setup Nagios to call local command: sqlps -Command "&{C:\Scripts\AvailableGroupStatus.ps1}"

Replace "SERVERNAME" with your SQL ServerName
Replace "SQLINSTANCE" with your SQL InstanceName
Replace "AVAILGROUPNAME" with your SQL AvailableGroup Name to check
-------
AvailableGroupStatus.ps1
-------
cd SQLSERVER:\SQL\"SERVERNAME"\"SQLINSTANCE"\AvailabilityGroups
$Results = Test-SqlAvailabilityGroup "AVAILGROUPNAME" | Select HealthState
if($Results.HealthState -eq "Healthy"){
$Output = "OK: AvailabilityGroup Databases are Healthy"
}else{

$Output = $Results.HealthState + " - Error"
$statFlag = 1
}
Write-Host $Output

if($statFlag -eq 1){
exit 2
}else{
exit 0
}
exit

If you have any questions.. Just YELL.. :)

Re: Nagios & SQL 2013 Monitoring

Posted: Wed Oct 16, 2013 11:13 am
by slansing
Thank you for the contribution jhagedorn! :)

Re: Nagios & SQL 2013 Monitoring

Posted: Wed Oct 16, 2013 11:20 am
by jhagedorn
It is not FULLY documented.. But if you have setup remote powershell scripts, it should be ok.. There are other PSSQL commands.. :) http://technet.microsoft.com/en-us/libr ... 78391.aspx

Re: Nagios & SQL 2013 Monitoring

Posted: Wed Oct 16, 2013 4:15 pm
by sreinhardt
HAHA M$ fully documenting things? :D Nice script though!!

Re: Nagios & SQL 2013 Monitoring

Posted: Thu Oct 17, 2013 1:01 pm
by jhagedorn
Im going to modify this to pass 3 parameters HostName/Instance/AvailabityGroup... Ill update it, when I get it working.. LOL Unless someone was to do my task.. :)

Re: Nagios & SQL 2013 Monitoring

Posted: Thu Oct 17, 2013 2:24 pm
by sreinhardt
Have at it man! Params at the beginning of the script should handle most of that looking at your current code.