Page 1 of 1
Query sql Database
Posted: Mon Jun 06, 2016 7:53 am
by rambertnala
Hi everybody.
I need help to do this.
I need to do a query to sql table and get value at las row and third column. That value is not integer. It's a nvchar value
So i need to get that value stored at that position, using plugin nagios from nrpe.
I have installed Nsclient 0.4.3 at conmputer where i wanna get value.
I don't know if i have explained very well which i need.
Thanks and regards.
Re: Query sql Database
Posted: Mon Jun 06, 2016 9:52 am
by rambertnala
Ok
I need to execute a query like this
select top 1 from ... order by... DESC
using check_nrpe from my nagios server.
Re: Query sql Database
Posted: Mon Jun 06, 2016 4:44 pm
by mcapra
Here's a basic table:
Code: Select all
MariaDB [test]> SELECT * FROM mytable;
+------+----------------+
| pkey | value |
+------+----------------+
| 1 | welcome |
| 2 | hello |
| 3 | something else |
+------+----------------+
3 rows in set (0.00 sec)
If I wanted to get the pkey that is largest, I could execute the following query:
Code: Select all
MariaDB [test]> SELECT * FROM mytable ORDER BY pkey DESC LIMIT 1;
+------+----------------+
| pkey | value |
+------+----------------+
| 3 | something else |
+------+----------------+
1 row in set (0.00 sec)
On your machine that is using NSClient++, your first step would be acquiring a plugin that allows you to execute MySQL queries. I don't see any on the exchange currently that work with the windows command line, so you'd either have to write one yourself or get perl on the NSClient++ machine and leverage a plugin like this:
https://exchange.nagios.org/directory/P ... n)/details
If the MySQL database has a user with remote access, you could check the query from your Nagios Core machine using the above plugin.
Re: Query sql Database
Posted: Wed Jun 08, 2016 9:11 am
by rambertnala
Hi thanks for your answer
Is a MSSQL Database, not MySQL
Re: Query sql Database
Posted: Wed Jun 08, 2016 11:32 am
by rkennedy
See if any of the plugins will work for you on our Exchange as @mcapra mentioned. This is regardless of MySQL or MSSQL. Here's a quick link -
https://exchange.nagios.org/index.php?o ... word=mssql