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.
Query sql Database
-
- Posts: 60
- Joined: Fri Feb 26, 2016 7:15 am
Re: Query sql Database
Ok
I need to execute a query like this
select top 1 from ... order by... DESC
using check_nrpe from my nagios server.
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
Here's a basic table:
If I wanted to get the pkey that is largest, I could execute the following query:
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.
Code: Select all
MariaDB [test]> SELECT * FROM mytable;
+------+----------------+
| pkey | value |
+------+----------------+
| 1 | welcome |
| 2 | hello |
| 3 | something else |
+------+----------------+
3 rows in set (0.00 sec)
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)
If the MySQL database has a user with remote access, you could check the query from your Nagios Core machine using the above plugin.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 60
- Joined: Fri Feb 26, 2016 7:15 am
Re: Query sql Database
Hi thanks for your answer
Is a MSSQL Database, not MySQL
Is a MSSQL Database, not MySQL
Re: Query sql Database
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
https://exchange.nagios.org/index.php?o ... word=mssql
Former Nagios Employee