Monitoring SQL Database - inside.

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.
kyang

Re: Monitoring SQL Database - inside.

Post by kyang »

Thanks @mcapra!
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

Thanks a lot mcapra, I have moved to the plugins proposed by you.

When I use the plugin "check_mssql_server.py" everything is good.

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_mssql_server.py -H x.x.x.x -U 'admin' -P 'pass' -p 1433 --time2connect
OK: Time to connect was 0.0201740264893s|time=0.0201740264893s;;;;
But now I have problem with plugin "check_mssql_database.py", typing the same data I get the error:

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_mssql_database.py -H x.x.x.x -U 'admin' -P 'pass' -p 1433 -T 'ah_Area'
(18456, "Login failed for user 'admin'.DB-Lib error message 20018, severity 14:
\nGeneral SQL Server error: Check messages from the SQL Server\
nDB-Lib error message 20002, severity 9:
\nAdaptive Server connection failed (x.x.x.x:1433)\n")
Any ideas?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitoring SQL Database - inside.

Post by scottwilkerson »

Melanie123 wrote:Thanks a lot mcapra, I have moved to the plugins proposed by you.

When I use the plugin "check_mssql_server.py" everything is good.

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_mssql_server.py -H x.x.x.x -U 'admin' -P 'pass' -p 1433 --time2connect
OK: Time to connect was 0.0201740264893s|time=0.0201740264893s;;;;
But now I have problem with plugin "check_mssql_database.py", typing the same data I get the error:

Code: Select all

root@ubuntu:/usr/local/nagios/libexec# ./check_mssql_database.py -H x.x.x.x -U 'admin' -P 'pass' -p 1433 -T 'ah_Area'
(18456, "Login failed for user 'admin'.DB-Lib error message 20018, severity 14:
\nGeneral SQL Server error: Check messages from the SQL Server\
nDB-Lib error message 20002, severity 9:
\nAdaptive Server connection failed (x.x.x.x:1433)\n")
Any ideas?
Are you sure the user that you are using has full rights for the database you are specifying?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Melanie123
Posts: 10
Joined: Wed Mar 07, 2018 7:19 am

Re: Monitoring SQL Database - inside.

Post by Melanie123 »

Thanks for reply, scottwilkerson.

Yes, I'm sure. I finally gave up with the check_mssql_database.py plugin and came back to check_mssql.
And there is progress. :)

Now, I have a question about formatting the results of sql queries.
When I use:

Code: Select all

./check_mssql -H x.x.x.x -U 'sa' -P xxx' -p 1433 -d database -q "SELECT ID_evt, name, evtTime, evtType, ID_tag FROM dbo.table WHERE name = 'alarm' AND ID_evt > 5157"
I have something like that:

Code: Select all

OK: Query duration=0.004576 seconds. Query result=5158 Query result=Condition.Alarm Query result=2018-03-22 11:42:37 Query result=3 Query result=299 Query result=5161 Query result=Condition.Alarm Query result=2018-03-22 11:42:48 Query result=2 Query result=299 Query result=5162 Query result=Condition.Alarm Query result=2018-03-22 11:43:38 Query result=3 Query result=298 Query result=5163 Query result=Condition.Alarm Query result=2018-03-22 11:45:22 Query result=3 Query result=331
Where and how can I change the formatting so that the result of the plugin would be like:

Code: Select all

OK: Query duration=0.004576 seconds. ID_evt =  5158, name = Condition.Alarm, evtTime = 2018-03-22 11:42:37, evtType = 3, ID_tag = 299
And "learn" for others: check x times if you are sure to enter good data from the SQL database. :)

Regards!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitoring SQL Database - inside.

Post by scottwilkerson »

when using the query function of this plugin, it expects you are going to just retuen a singe value, your query is returning many

example

Code: Select all

Example: check_mssql -H myserver -U myuser -P mypass -q "SELECT COUNT(*) FROM mytable" -W 2 -C 5
this would generate a warning if the count was more than 2 and critical if more than 5

There are no options for formatting the output with this plugin.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked