Plugin to monitor MSSQL DB Mirroring- not working
-
- Posts: 8
- Joined: Thu Jun 28, 2018 2:03 am
Plugin to monitor MSSQL DB Mirroring- not working
Hello all,
I am trying to monitor MSSQL mirroring status from nagios core. When the mirror status is diconnected or suspended, it should give an alert critical.
I tried this plugin (https://exchange.nagios.org/directory/P ... ng/details) with sa account, It always gives Critical and it seems that it is not able to fetch the row. I used Dumptrace to see the logs, and found nothing, attached the log for reference.
Could anyone please help if you come across this or any other method to monitor mirror status.
I am also using check_mssql_health plugin so i have installed dbd::sybase and other dependent modules.
Thanks in advance.!!
Regards,
Sannatar.
I am trying to monitor MSSQL mirroring status from nagios core. When the mirror status is diconnected or suspended, it should give an alert critical.
I tried this plugin (https://exchange.nagios.org/directory/P ... ng/details) with sa account, It always gives Critical and it seems that it is not able to fetch the row. I used Dumptrace to see the logs, and found nothing, attached the log for reference.
Could anyone please help if you come across this or any other method to monitor mirror status.
I am also using check_mssql_health plugin so i have installed dbd::sybase and other dependent modules.
Thanks in advance.!!
Regards,
Sannatar.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Plugin to monitor MSSQL DB Mirroring- not working
Can you show the command you are running and the error? (ok to obscure the username)
Also note if you have special chars in the username/password you will likely have to wort to escape them
Also note if you have special chars in the username/password you will likely have to wort to escape them
-
- Posts: 8
- Joined: Thu Jun 28, 2018 2:03 am
Re: Plugin to monitor MSSQL DB Mirroring- not working
Hi scott,
Thanks for replying.
I ran the query from Db and it is working fine, I ran Dumptrace also from the command line, it seems the query returns nothing. I always get Critical with no values.
In case if I give the wrong password I am getting "Adaptive server connection failed" So I think it is nothing to do with the special characters in password.
Regards,
sannatar
Thanks for replying.
I ran the query from Db and it is working fine, I ran Dumptrace also from the command line, it seems the query returns nothing. I always get Critical with no values.
In case if I give the wrong password I am getting "Adaptive server connection failed" So I think it is nothing to do with the special characters in password.
Regards,
sannatar
- Attachments
-
- dbmirroring_cmd.png (5.53 KiB) Viewed 6180 times
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Plugin to monitor MSSQL DB Mirroring- not working
So it works from the command line, can you also run it from the command line as the nagios user?
And if that works can you show the command config in nagios and the service definition (replacing any sensitive information)
Code: Select all
su nagios -c '/usr/local/nagios/libexec/check_dbmirroring.pl YOUR ARGS HERE'
-
- Posts: 8
- Joined: Thu Jun 28, 2018 2:03 am
Re: Plugin to monitor MSSQL DB Mirroring- not working
Hi,
Please find the output of the command. It returns command not found.
I haven't created the command,services for this yet, as it is not working in command line itself.
Please find the output of the command. It returns command not found.
I haven't created the command,services for this yet, as it is not working in command line itself.
- Attachments
-
- command output.PNG (5.19 KiB) Viewed 6163 times
Re: Plugin to monitor MSSQL DB Mirroring- not working
Double check the command you've copied from @scottwilkerson and try it again. You're missing the full path to the plugin (presumably, /usr/local/nagios/libexec/check_dbmirroring.pl).
When you su to the nagios user, you may be executing commands from the path of that user's home directory. I would wager check_dbmirroring.pl doesn't exist in that directory, so the full path must be provided to the -c argument.
When you su to the nagios user, you may be executing commands from the path of that user's home directory. I would wager check_dbmirroring.pl doesn't exist in that directory, so the full path must be provided to the -c argument.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Plugin to monitor MSSQL DB Mirroring- not working
Thanks for the assist, @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 8
- Joined: Thu Jun 28, 2018 2:03 am
Re: Plugin to monitor MSSQL DB Mirroring- not working
Sorry my bad. I have corrected the command using the full path.
Please find the command output. I ran the script on both Principal and mirrored servers using sa account. Initially i got util.pm error, I changed the lib path after that the output still says Critical.
[root@XXXXXX services]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.X -d XXXXXXX -u sa -p XXXXXXXXXX
Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
[root@XXXXXX services]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.Y -d XXXXXXX -u sa -p XXXXXXXXXX"
Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
After changing the lib path:
[root@XXXXXX libexec]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.X -d XXXXX -u sa -p XXXXXXXXX"
CRITICAL - Check your mirroring settings
[root@DXXXXXX libexec]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.Y -d XXXXX -u sa -p XXXXXXXXXX"
CRITICAL - Check your mirroring settings
Please find the command output. I ran the script on both Principal and mirrored servers using sa account. Initially i got util.pm error, I changed the lib path after that the output still says Critical.
[root@XXXXXX services]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.X -d XXXXXXX -u sa -p XXXXXXXXXX
Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
[root@XXXXXX services]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.Y -d XXXXXXX -u sa -p XXXXXXXXXX"
Can't locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
BEGIN failed--compilation aborted at /usr/local/nagios/libexec/check_dbmirroring.pl line 10.
After changing the lib path:
[root@XXXXXX libexec]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.X -d XXXXX -u sa -p XXXXXXXXX"
CRITICAL - Check your mirroring settings
[root@DXXXXXX libexec]# su nagios -c "/usr/local/nagios/libexec/check_dbmirroring.pl -H 10.X.X.Y -d XXXXX -u sa -p XXXXXXXXXX"
CRITICAL - Check your mirroring settings
Re: Plugin to monitor MSSQL DB Mirroring- not working
No one here wrote this plugin, so it's tough to say what the original intention of the plugin was. All of the below is based on my own knowledge of Perl and TSQL.
Though this plugin was written against SQL Server 2005, I don't think the underlying sys tables haven't changed much though so that shouldn't matter.
All that plugin does is run this query:
It then compares the role and state (m.mirroring_role_desc, m.mirroring_state_desc) of that query and checks to see if role is "PRINCIPAL" and state is "SYNCHRONIZED". If that query returns anything else, the plugin returns a CRITICAL state.
Troubleshooting probably starts with running that query yourself and seeing what it churns out.
Though this plugin was written against SQL Server 2005, I don't think the underlying sys tables haven't changed much though so that shouldn't matter.
All that plugin does is run this query:
Code: Select all
SELECT d.name, m.mirroring_role_desc, m.mirroring_state_desc
FROM sys.database_mirroring m
JOIN sys.databases d ON m.database_id = d.database_id
WHERE mirroring_state_desc IS NOT NULL AND name = '<the -d value>'
Troubleshooting probably starts with running that query yourself and seeing what it churns out.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Plugin to monitor MSSQL DB Mirroring- not working
Thanks for the input, @mcapra.
@sannatar16, run the query as suggested and let us know if there is anything further we can help with.
@sannatar16, run the query as suggested and let us know if there is anything further we can help with.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.