check_mssql_database.py - Type Error/DivisonZero Error

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Marcusg562
Posts: 7
Joined: Thu Aug 03, 2017 3:28 am

check_mssql_database.py - Type Error/DivisonZero Error

Post by Marcusg562 »

Hey all,

when I'm trying to run on bash

Code: Select all

./check_mssql_database.py -H MYHOST:MYPORT -U USER -P SECRET -T CHECKTABLE --loggrowths
I got the following error:
<type 'exceptions.TypeError'>
Caught unexpected error. This could be caused by your sysperfinfo not containing the proper entries for this query, and you may delete this service check.
When I'm running instead the following SQL Command (I'm only connected to the SQL Server not to an insatance):

Code: Select all

SELECT cntr_value,counter_name,instance_name FROM Vudyog.sys.sysperfinfo WHERE instance_name='CHECKTABLE ';
I got a list with many information inside. Therefore I tried

Code: Select all

SELECT cntr_value FROM sysperfinfo WHERE counter_name='Log Cache Hit Ratio' AND instance_name='CHECKTABLE ';
Last one works great and I also got a Value as you can see in the attachment:
2017-08-04 07_59_06-DBeaver - General - [ _MS SQL Server - 10.18.45.98_ Script-13 ].png
2017-08-04 07_59_06-DBeaver - General - [ _MS SQL Server - 10.18.45.98_ Script-13 ].png (3.71 KiB) Viewed 5273 times
So I didn't understand where there is my problem and how I can solve it. I got a connection with the check_mssql_database.py script but it seems that the script doesn't connect to the right DB/TABLE.

Has anyone a glue here?

Regards
Marcus
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by tgriep »

What version of MSSQL are you running on that server?
Can you post the check_mssql_database.py script here or the link to the where you downloaded it from?
A possible cause could be that the user permissions may not be sufficient so make sure they are set correctly.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Marcusg562
Posts: 7
Joined: Thu Aug 03, 2017 3:28 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by Marcusg562 »

tgriep wrote:What version of MSSQL are you running on that server?
I'm not pretty sure at this moment but it should be MSSQL 2012 or 2014. I will verify this.
tgriep wrote:Can you post the check_mssql_database.py script here or the link to the where you downloaded it from?
Yes, see atachment for my used script:
check_mssql_database.py
(14.22 KiB) Downloaded 565 times
Files downloaded from https://github.com/NagiosEnterprises/ch ... collection
tgriep wrote:A possible cause could be that the user permissions may not be sufficient so make sure they are set correctly.
I'm pretty sure, that this isn't the problem because I'm MSSQL SA on this SQL Cluster. I'm also able to run the SQL select statement in an SQL Client (I'm using DBeaver) and got a response (with values which seems good with me) when I replace the variables in the statement with values.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by tgriep »

In your example command

Code: Select all

./check_mssql_database.py -H MYHOST:MYPORT -U USER -P SECRET -T CHECKTABLE --loggrowths
You are specifying loggrowths as the option.

When that is used, this is the query that is generated, so see if you can run this in your MSSQL server without any errors.

Code: Select all

BASE_QUERY = "SELECT cntr_value FROM sysperfinfo WHERE counter_name='Log Growths' AND instance_name='CHECKTABLE';"
Also, from what I heard, in MSSQL 2012 and newer, some tables were removed so you cannot check for them as they do not exist and will cause errors running the plugin.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Marcusg562
Posts: 7
Joined: Thu Aug 03, 2017 3:28 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by Marcusg562 »

tgriep wrote:In your example command

Code: Select all

./check_mssql_database.py -H MYHOST:MYPORT -U USER -P SECRET -T CHECKTABLE --loggrowths
You are specifying loggrowths as the option.

When that is used, this is the query that is generated, so see if you can run this in your MSSQL server without any errors.

Code: Select all

BASE_QUERY = "SELECT cntr_value FROM sysperfinfo WHERE counter_name='Log Growths' AND instance_name='CHECKTABLE';"
Also, from what I heard, in MSSQL 2012 and newer, some tables were removed so you cannot check for them as they do not exist and will cause errors running the plugin.
^

Hi, I've already verified that the Tables are there:
2017-08-08 08_23_08-DBeaver - General - [ _MS SQL Server - 10.18.45.98_ Script-13 ].png
And also by loggrowths works fine within the SQL client as you can see in the pic below:
2017-08-08 08_21_34-DBeaver - General - [ _MS SQL Server - 10.18.45.98_ Script-13 ].png
Just for Information we use MSSQL Server 2012 SP1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by tgriep »

I am thing that the version of that plugin you are using is not working right and I suggest downgrading to an older version to see if that fixes the issue.
I have posted an older version to this post, try it and see if that fixes the issue.
Attachments
check_mssql_database.py
(14.11 KiB) Downloaded 509 times
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by tgriep »

I did some comparing of the old plugin to the new one and the error is caused by not specifying a warning and critical threshold on the command line.
Add those and it should work for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Marcusg562
Posts: 7
Joined: Thu Aug 03, 2017 3:28 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by Marcusg562 »

Thanks, that's works great for me!
bolson

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by bolson »

May we close this topic?
Marcusg562
Posts: 7
Joined: Thu Aug 03, 2017 3:28 am

Re: check_mssql_database.py - Type Error/DivisonZero Error

Post by Marcusg562 »

Absolutely agree with this!
Locked