Oracle Query

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Oracle Query

Post by Chite »

Hey all, I'm running the latest version of Nagios XI 5.3.0. I want to run an Oracle Query to return a specific value (1 or 0). I've used the Configuration wizard to go through and setup the oracle db info along with SID, username, password, and query. the query I'm running is below. The problem I'm running into is nagios add's a --warning <value> --critical <value> at the end of the query. I would like to see nagios alarm on if the value returned is "1"....

check_xi_oraclequery!--connect '<servername>:1521/<instance name>' --username '<username>' --password '<password>' --mode sql --name="SELECT count(*) FROM <table name>.ETL_RUN_INFO WHERE STATUS ='RUNNING' AND ETL_NO = ( SELECT MAX(ETL_NO) FROM <table name>.ETL_RUN_INFO )" --critical 1

Maybe I'm not running the proper monitoring plugin (if anyone has any ideas on what I could use for this that'd be great) I did see this one (https://labs.consol.de/nagios/check_oracle_health/) but I wanted to try the integrated sql query first before I tried installing another plugin.

thanks for your help!
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Oracle Query

Post by Chite »

Sorry I pulled that query directly from the "configure Service" area: here's the original query:

SELECT count(*) FROM <table name>.ETL_RUN_INFO WHERE STATUS ='RUNNING' AND ETL_NO = ( SELECT MAX(ETL_NO) FROM <table name>.ETL_RUN_INFO )
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Oracle Query

Post by Box293 »

This plugin uses the development guidelines:

https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

Try:

Code: Select all

--critical @1
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Oracle Query

Post by Chite »

so here's my query now . check_xi_oraclequery!--connect '<server name:1521/instance name>' --username <username> --password <password> --mode sql --name="SELECT count(*) FROM <table name>.ETL_RUN_INFO WHERE STATUS ='RUNNING' AND ETL_NO = ( SELECT MAX(ETL_NO) FROM <table name>.ETL_RUN_INFO )" --critical @1

the query and that critical value is working!!!! thank you!!

One last question. is there anyway I can set this to ONLY run once a day? the DBA only wants the check done at 8am every morning. I see in the core config manager I can set it to only monitor every <#> minutes. would I just put it to <1440> min indicating every 24 hours? just not sure how to set it to only run at 8am daily.

thanks for you help!!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Oracle Query

Post by rkennedy »

Chite wrote:so here's my query now . check_xi_oraclequery!--connect '<server name:1521/instance name>' --username <username> --password <password> --mode sql --name="SELECT count(*) FROM <table name>.ETL_RUN_INFO WHERE STATUS ='RUNNING' AND ETL_NO = ( SELECT MAX(ETL_NO) FROM <table name>.ETL_RUN_INFO )" --critical @1

the query and that critical value is working!!!! thank you!!

One last question. is there anyway I can set this to ONLY run once a day? the DBA only wants the check done at 8am every morning. I see in the core config manager I can set it to only monitor every <#> minutes. would I just put it to <1440> min indicating every 24 hours? just not sure how to set it to only run at 8am daily.

thanks for you help!!
There are two routes you could go.

A. Set the check to run every 1440. (this would not explicitly specify at 8AM though)
B. Set the check to run every x minutes, and assign a specific time period to the check_period (that is between say 7:58 and 8:02). This would cause it to get scheduled within that time span.
Former Nagios Employee
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Oracle Query

Post by Chite »

yeah that's a great idea to set a check_period. the only question I have is, do I have to add a check_period called timeperiod_8am or something like that, and set the value 7:58 - 8:02 to it? I've never done that before, where do I create that?

thanks, sorry for all the questions but this has been very helpful!

Chaden
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Oracle Query

Post by Box293 »

Yes, create a timeperiod with the time when you want to be allowed to run.

CCM > Alerting > Time Periods
Add
Give it a name and Description
Add each of these definitions:

sunday 07:58-08:02
monday 07:58-08:02
tuesday 07:58-08:02
wednesday 07:58-08:02
thursday 07:58-08:02
friday 07:58-08:02
saturday 07:58-08:02

Save

Now go to the service and on the Check Settings tab select the time period in the "Check Period" drop down list
Save and apply config
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Oracle Query

Post by Chite »

worked perfectly!! thank you!
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Oracle Query

Post by jomann »

Awesome! Anything else we can help with? Or is it okay to close this?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked