check_mssql_database.py gives exceptions.TypeError

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

check_mssql_database.py gives exceptions.TypeError

Post by sgargano »

Hello,

after we have upgraded Nagios to the latest version by following this guide,

https://assets.nagios.com/downloads/nag ... ctions.pdf

the upgrade was successfully installed by yum.

One of the checks that are running is failing:

Code: Select all

/usr/local/nagios/libexec/check_mssql_database.py -H [IP] -U report_user -P [PASSWORD] -T [TABLE]

<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.
I've seen there is already a post for this error, so I followed this guide and seen that I have all the components required

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Code: Select all

[root@chlugmw1 libexec]# yum info freetds
Loaded plugins: fastestmirror, rhnplugin
This system is receiving updates from RHN Classic or Red Hat Satellite.
Loading mirror speeds from cached hostfile
 * base: mirror.spreitzer.ch
 * extras: mirror.spreitzer.ch
 * updates: mirror.spreitzer.ch
Installed Packages
Name        : freetds
Arch        : x86_64
Version     : 0.95.81
Release     : 1.el7
Size        : 2.7 M
Repo        : installed
From repo   : nagiosxi-deps
Summary     : Implementation of the TDS (Tabular DataStream) protocol
URL         : http://www.freetds.org/
License     : LGPLv2+ and GPLv2+
Description : FreeTDS is a project to document and implement the TDS (Tabular
            : DataStream) protocol. TDS is used by Sybase(TM) and Microsoft(TM) for
            : client to database server communications. FreeTDS includes call
            : level interfaces for DB-Lib, CT-Lib, and ODBC.

Code: Select all

yum list installed | grep pymssql
python-pymssql.x86_64          2.1.1-1.el7              @nagiosxi-deps
The only different thing is that pymssql has been installed by yum, I currently don't see pip...but in any case is there.

This check was working correctly before the upgrade, with "check_mssql_database.py" version 1.1.0, and now we have 2.1.1.
So I tried to use the older version but the error is there again.

Any idea to fix it?

Thanks
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_mssql_database.py gives exceptions.TypeError

Post by npolovenko »

Hello, @sgargano. I noticed that you're are using the python-pymssql.x86_64 2.1.1 package from the @nagiosxi-deps, while on my server I have python2-pymssql.x86_64 2.1.3 version from the epel repo.
yum list installed | grep pymssql
python-pymssql.x86_64 2.1.1-1.el7 @nagiosxi-deps

[root@centos7x64 libexec]# yum list installed | grep pymssql
python2-pymssql.x86_64 2.1.3-2.el7 @epel

Do you have acess to the epel repo on the server? Can you show me the output of:
yum repolist
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: check_mssql_database.py gives exceptions.TypeError

Post by sgargano »

Code: Select all


Loaded plugins: fastestmirror, rhnplugin
This system is receiving updates from RHN Classic or Red Hat Satellite.
Loading mirror speeds from cached hostfile
 * base: mirror.spreitzer.ch
 * extras: mirror.spreitzer.ch
 * updates: mirror.spreitzer.ch
repo id                                                                               repo name                                                                             status
!base/7/x86_64                                                                        CentOS-7 - Base                                                                       10,019
centos-7-base-x86_64                                                                  CentOS 7 Base x86_64                                                                  26,877
centos-7-updates-x86_64                                                               CentOS 7 Updates x86_64                                                               10,336
!extras/7/x86_64                                                                      CentOS-7 - Extras                                                                        364
!nagios-base                                                                          Nagios                                                                                    91
!nagiosxi-deps                                                                        Nagios XI Dependencies                                                                    29
!spacewalk-client/x86_64                                                              Spacewalk Client Tools                                                                    98
!spacewalktools7_x86_64                                                               Spacewalk Tools 7 x86_64                                                                 179
!updates/7/x86_64                                                                     CentOS-7 - Updates                                                                     1,067
repolist: 49,060

npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_mssql_database.py gives exceptions.TypeError

Post by npolovenko »

@sgargano, Looks like you don't have the epel repo:
!epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64
You can use this tutorial to install the missing repo:
https://www.cyberciti.biz/faq/installin ... edhat-7-x/

After that run:
yum remove python-pymssql.x86_64
yum update
yum install python2-pymssql
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: check_mssql_database.py gives exceptions.TypeError

Post by sgargano »

as suggested we enabled the epel repo,

we had to run this command rather than the one suggested,

Code: Select all

rpm -e --nodeps python-pymssql.x86_64
not to delete nagiosxi as dependcy package.

Now the result is:

Code: Select all

[root@chlug]# yum list installed | grep pymssql
python2-pymssql.x86_64         2.1.3-2.el7              @epel
but even with this right version of pymssql we still have the error reported above.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_mssql_database.py gives exceptions.TypeError

Post by lmiltchev »

I did some digging in to this, and found out that the new plugin requires warning/critical values to be added. Can you try running something like this:

Code: Select all

/usr/local/nagios/libexec/check_mssql_database.py -H [IP] -U report_user -P [PASSWORD] -T [TABLE] --warning 1 --critical 5
Did this work?
Be sure to check out our Knowledgebase for helpful articles and solutions!
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: check_mssql_database.py gives exceptions.TypeError

Post by sgargano »

No, didn't work.

Our full string we used so far is this:

Code: Select all

./check_mssql_database_1.1.0.py -H [server] -U [user] -P [password] -T [table ]-I [instance] --time2connect -c 0.0001:120
We also tried adding warning and critical but we got the same issue.

Code: Select all

./check_mssql_database.py -H [server]  -U [user]-P [password] -T [table ] -I [instance]--time2connect -c 0.0001:120 --warning 1 --critical 2
<class 'pymssql.InterfaceError'>
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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_mssql_database.py gives exceptions.TypeError

Post by scottwilkerson »

you are specifying critical twice

Try

Code: Select all

./check_mssql_database.py -H [server]  -U [user]-P [password] -T [table ] -I [instance] --time2connect -w 0.0001:119 -c 0.0001:120
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: check_mssql_database.py gives exceptions.TypeError

Post by sgargano »

I got the same error:

Code: Select all

[root@chlugmw1 libexec]# ./check_mssql_database.py -H SERVERNAME -U USER -P PASSWORD -T TABLE -I INSTANCE --time2connect  --warning 1 --critical 2
<class 'pymssql.InterfaceError'>
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.
[root@chlugmw1 libexec]#
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_mssql_database.py gives exceptions.TypeError

Post by lmiltchev »

Are you running the check against a Windows Server 2016?

Let's check the version of your plugin - run the following command and show the output:

Code: Select all

grep Version /usr/local/nagios/libexec/check_mssql_database.py
What kind of permissions does your user have? Can you log in the MSSQL server as your user, run the following query, and show the output?

Code: Select all

SELECT * FROM fn_my_permissions(null, 'DATABASE')
SELECT * FROM fn_my_permissions(null, 'SERVER')
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked