Monitor for mssql HA (always on)
Monitor for mssql HA (always on)
Hi,
May I know is there any monitoring plugin for mssql always on?
I have google but it seems like only this https://support.nagios.com/forum/viewto ... 07&p=75487.
May I know is the script safe to work?
Thanks
May I know is there any monitoring plugin for mssql always on?
I have google but it seems like only this https://support.nagios.com/forum/viewto ... 07&p=75487.
May I know is the script safe to work?
Thanks
-
bolson
Re: Monitor for mssql HA (always on)
Hello s.wiki,
Third party or user written scripts are beyond the purview and scope of us here at Nagios. I don't see anything in the script that appears to be unsafe. However, if your MSSQL installation is mission critical, you might consider setting up a test/dev environment to perform some testing before you deploy. Let me know if this answers your question and if we may close this thread.
Thank you!
Third party or user written scripts are beyond the purview and scope of us here at Nagios. I don't see anything in the script that appears to be unsafe. However, if your MSSQL installation is mission critical, you might consider setting up a test/dev environment to perform some testing before you deploy. Let me know if this answers your question and if we may close this thread.
Thank you!
Re: Monitor for mssql HA (always on)
Hi,
I am still trying to do the powershell script(form the link above) on the always-on server.
I am not familiar with any database at all.
But here is what i am trying to do, correct me if im wrong , or any ideas are welcome.
1. set up the checkexternalscript in the windows server, then add the powershell script.
3. check from nagios server, using nrpe -H ip -c customscript
From the link attached, other users commented on this : https://docs.microsoft.com/en-us/sql/da ... rTblshtAGs
nt authority\system| ,which i assume this is the user who will execute the powershell script.
The Database team has granted access to a specific database user 'nagios', but at the moment the credentials logged in to the windows / powershell is a different credential.
Thus running the script manually has no database access.
Is it possible to switch to user 'nagios' in the powershellscript?
Correct me if i am wrong from the beginning >.<
Thanks
I am still trying to do the powershell script(form the link above) on the always-on server.
I am not familiar with any database at all.
But here is what i am trying to do, correct me if im wrong , or any ideas are welcome.
1. set up the checkexternalscript in the windows server, then add the powershell script.
3. check from nagios server, using nrpe -H ip -c customscript
From the link attached, other users commented on this : https://docs.microsoft.com/en-us/sql/da ... rTblshtAGs
I have created a whoami script and by using my nagios server to check, the return output isImportant
You must have CONNECT, VIEW SERVER STATE, and VIEW ANY DEFINITION permissions to execute these cmdlets.
nt authority\system| ,which i assume this is the user who will execute the powershell script.
The Database team has granted access to a specific database user 'nagios', but at the moment the credentials logged in to the windows / powershell is a different credential.
Thus running the script manually has no database access.
Is it possible to switch to user 'nagios' in the powershellscript?
Correct me if i am wrong from the beginning >.<
Thanks
Re: Monitor for mssql HA (always on)
Have you taken any steps to verify that the script works first on the windows machine? It's always best to start with a script that works on the client machine before trying to run it with npre. Also, you can try running the commands manually. What happens on the windows machine when you run:
or
*replace the variables with your environment info*
from the command line? Are you prompted to login with sql credentials? It's not clear to me where/if you'd get prompted to use sql credentials.
Code: Select all
cd SQLSERVER:\SQL\"SERVERNAME"\"SQLINSTANCE"\AvailabilityGroups
Code: Select all
Test-SqlAvailabilityGroup "AVAILGROUPNAME"
from the command line? Are you prompted to login with sql credentials? It's not clear to me where/if you'd get prompted to use sql credentials.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Monitor for mssql HA (always on)
Hi, the script was not able to run properly on the local windows machine, i suspected it was the user permission thats why i tried to execute it using nrpe.cdienger wrote:Have you taken any steps to verify that the script works first on the windows machine? It's always best to start with a script that works on the client machine before trying to run it with npre. Also, you can try running the commands manually. What happens on the windows machine when you run:
orCode: Select all
cd SQLSERVER:\SQL\"SERVERNAME"\"SQLINSTANCE"\AvailabilityGroups
*replace the variables with your environment info*Code: Select all
Test-SqlAvailabilityGroup "AVAILGROUPNAME"
from the command line? Are you prompted to login with sql credentials? It's not clear to me where/if you'd get prompted to use sql credentials.
Anyway, there are 2 different error when i run the script.
first error( only appear on first run)
Code: Select all
PS C:\Program Files\NSClient++\scripts\custom> C:\Program Files\NSClient++\scripts\custom\Test_HAsql.ps1
cd : Cannot find drive. A drive with the name 'SQLSERVER' does not exist.
At C:\Program Files\NSClient++\scripts\custom\Test_HAsql.ps1:1 char:1
+ cd SQLSERVER:\SQL\"${Env:ComputerName}"\DEFAULT\AvailabilityGroups
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SQLSERVER:String) [Set-Location], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
Test-SqlAvailabilityGroup : Cannot find path 'SQLSERVER:\ITMSAGDatabaseTest' because it does not exist.
At C:\Program Files\NSClient++\scripts\custom\Test_HAsql.ps1:2 char:12
+ $Results = Test-SqlAvailabilityGroup "ITMSAGDatabaseTest" | Select HealthState
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ITMSAGDatabaseTest:String) [Test-SqlAvailabilityGroup], ItemNotFoundExceptio
n
+ FullyQualifiedErrorId : PathNotFound,Microsoft.SqlServer.Management.PowerShell.Hadr.TestSqlAvailabilityGroupCommand
- Error
after the first error, the default path change from C:\Program Files\NSClient++\scripts\custom> to SQLSERVER:\>, and then giving permission error.
Code: Select all
PS SQLSERVER:\> C:\Program Files\NSClient++\scripts\custom\Test_HAsql.ps1
Test-SqlAvailabilityGroup : Cannot find path 'SQLSERVER:\SQL\DCCDBFINDURTEST\DEFAULT\AvailabilityGroups\ITMSAGDatabaseTest'
because it does not exist.
At C:\Program Files\NSClient++\scripts\custom\Test_HAsql.ps1:2 char:12
+ $Results = Test-SqlAvailabilityGroup "ITMSAGDatabaseTest" | Select HealthState
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ITMSAGDatabaseTest:String) [Test-SqlAvailabilityGroup], ItemNotFoundExceptio
n
+ FullyQualifiedErrorId : PathNotFound,Microsoft.SqlServer.Management.PowerShell.Hadr.TestSqlAvailabilityGroupCommand
- ErrorRe: Monitor for mssql HA (always on)
It looks like you need to run the sqlps command first. Try running this and then the command within the script.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Monitor for mssql HA (always on)
Hi,cdienger wrote:It looks like you need to run the sqlps command first. Try running this and then the command within the script.
I have tested earlier ,adding sqlps at the line 1 of the script but it is not working.
my mistake on earlier post as I did it wrongly.
From the link , the op suggest to create 2 script.
1st script is : sqlps -Command "&{C:\Scripts\AvailableGroupStatus.ps1}"
2nd script is: C:\Scripts\AvailableGroupStatus.ps1
But it didnt work as expected, even when i run the 2nd script seperately.
Then I addedImport-Module "SQLPS" -DisableNameChecking at the line 1 of the 2nd script, and I think it is work as expected, however i am still not able to execute from 1st script.
Re: Monitor for mssql HA (always on)
Hi,
Thanks for your assistance earlier,
the issue i was facing has been solved.
however i have face another issue.
when I execute check_nrpe -H ipaddress -c check_availability,
i get my expected output but it looks like this, may i know how do i exclude the first output?
Thanks
Thanks for your assistance earlier,
the issue i was facing has been solved.
however i have face another issue.
when I execute check_nrpe -H ipaddress -c check_availability,
i get my expected output but it looks like this, may i know how do i exclude the first output?
Thanks
You do not have the required permissions to view the files attached to this post.
Re: Monitor for mssql HA (always on)
Glad to hear some progress has been made. Where exactly are you seeing that new message? What is returned when you run check_nrpe command from the command line?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Monitor for mssql HA (always on)
Hi, Kindly refer to the information below:cdienger wrote:Glad to hear some progress has been made. Where exactly are you seeing that new message? What is returned when you run check_nrpe command from the command line?
Code: Select all
# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c test-sqlavailabilitygroup
C:\Program Files\NSClient++>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& 'C:\Program Files\NSClient++\scripts\custom\Test-SqlAvailabilityGroup.ps1'"
OK: AvailabilityGroup Databases are Healthy|
Code: Select all
[/settings/external scripts/scripts]
test-sqlavailabilitygroup=scripts\custom\batch-Test-SqlAvailabilityGroup.batCode: Select all
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& 'C:\Program Files\NSClient++\scripts\custom\Test-SqlAvailabilityGroup.ps1'"