Page 1 of 1
Oracle Query
Posted: Mon Oct 03, 2016 4:00 pm
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!
Re: Oracle Query
Posted: Mon Oct 03, 2016 4:13 pm
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 )
Re: Oracle Query
Posted: Mon Oct 03, 2016 4:57 pm
by Box293
Re: Oracle Query
Posted: Tue Oct 04, 2016 3:42 pm
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!!
Re: Oracle Query
Posted: Tue Oct 04, 2016 4:26 pm
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.
Re: Oracle Query
Posted: Tue Oct 04, 2016 5:57 pm
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
Re: Oracle Query
Posted: Tue Oct 04, 2016 7:26 pm
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
Re: Oracle Query
Posted: Wed Oct 05, 2016 12:49 pm
by Chite
worked perfectly!! thank you!
Re: Oracle Query
Posted: Wed Oct 05, 2016 1:52 pm
by jomann
Awesome! Anything else we can help with? Or is it okay to close this?