Is there a way to access notification & escalation information for hosts and services through the API?
Some or our application servers have multiple tiers, with some variance in services, which has made for a cluster of varying escalations.
Since escalations will only match host that have services specified, we have separate escalations steps for each. (some of which have 5-6 separate steps)
Example.
4 Web Servers
- 10 services each, 3 of which are not shared on all servers, 5 escalation steps
- Requires 15 escalation steps
10 App servers
- 18 services, two servers are non standard in checks, 5 escalation steps
- Requires 10 escalation steps
3 DB servers
- 40+ services, identical checks, 5 escalation steps each
- Requires 5 escalation steps
This is just one application stack, and we are currently monitoring around 15 similarly structured stacks.
All servers have different escalations during non-business hours.
So for this example, we have 60 escalation steps to meet the business needs for notifications.
I am trying to visually present notifications to our admins, to allow them to click on a host/service, and see all escalation steps and notification information related to this check without having to drill through what could be many escalations display with the info button.
While I believe I saw default notification information for the host/service in the backend API, it does not appear that it contains any information about escalations, nor notifications defined in templates.
I have managed to get some of this by direct DB queries, but I would like to find out if there is a better way to do that.
So...
1. Is there a way to access notification information for host/services, templates & escalations through the API.
if not
1. What is the best way to make DB queries in a component?
2. Is there a schema definition that would help to discover the mappings and table relationships in the DB?
Component Development: Escalations
Re: Component Development: Escalations
Currently most of our API's are built around status information, so the notification information that you would access from any of the viewing pages in XI is there, but for the configuration information you'd have to work with direct SQL queries.
Primer on XI Component Development and Existing API's
http://assets.nagios.com/downloads/nagi ... opment.pdf
Configuration information is stored in the MySQL->nagiosql database. Unfortunately there isn't a DB schema available for it. However, I can give some basic pointers and we'll be happy to give more detail as you may need it.
- All tables are either related to a specific type of object, or they're a simply relationship table with the ID's from each object type that are related.
//object tables
tbl_host
tbl_service
tbl_contact
tbl_contactgroup
tbl_serviceescalation
//escalation link tables
tbl_lnkServiceescalationToContact
tbl_lnkServiceescalationToContactgroup
tbl_lnkServiceescalationToHost
tbl_lnkServiceescalationToHostgroup
tbl_lnkServiceescalationToService
For making queries in a component, if you use the standard set of functions at the top of your page you'll have access to the XI session, and all DB connections:
For doing sql queries, you can use the following wrapper functions:
Primer on XI Component Development and Existing API's
http://assets.nagios.com/downloads/nagi ... opment.pdf
Configuration information is stored in the MySQL->nagiosql database. Unfortunately there isn't a DB schema available for it. However, I can give some basic pointers and we'll be happy to give more detail as you may need it.
- All tables are either related to a specific type of object, or they're a simply relationship table with the ID's from each object type that are related.
//object tables
tbl_host
tbl_service
tbl_contact
tbl_contactgroup
tbl_serviceescalation
//escalation link tables
tbl_lnkServiceescalationToContact
tbl_lnkServiceescalationToContactgroup
tbl_lnkServiceescalationToHost
tbl_lnkServiceescalationToHostgroup
tbl_lnkServiceescalationToService
For making queries in a component, if you use the standard set of functions at the top of your page you'll have access to the XI session, and all DB connections:
Code: Select all
require_once(dirname(__FILE__).'/../../common.inc.php');
// initialization stuff
pre_init();
// start session
init_session();
// grab GET or POST variables
grab_request_vars();
// check prereqs
check_prereqs();
// check authentication
check_authentication(false);For doing sql queries, you can use the following wrapper functions:
Code: Select all
$query = "SELECT * FROM tbl_host";
$show_debug = true; //display sql errors while in development
$resource = exec_sql_query($query,DB_NAGIOSQL,$show_debug); //pulls from config DB
$query="SELECT * FROM nagios_hosts";
$show_debug = true; //display sql errors while in development
$resource = exec_sql_query($query,DB_NDOUTILSL,$show_debug); //pulls from status DB