## External Data API Overview

Introduction

Ever since the first release of NetSaint, I've been asked if I had plans to support MySQL, PostgresQL, Oracle, or a slew of other data sources. In order to support alternate data stores for things like configuration data, status data, etc. I decided to change a lot of the underlying code in both the core program and CGIs to allow developers to add their own data I/O routines...

One of the major changes that was made in version 0.0.6 was a complete rewrite of the data I/O routines in both the core program and the CGIs. These revisions resulted in the creation of an abstraction layer that separated implementation-specific code for accessing data sources from the data processing routines present in the core and CGIs. The end result of this is a set of external data APIs that allows developers to easily write code to support different types of data sources in the core program and CGIs.

NetSaint 0.0.7 will make use of the new external data APIs to optionally provide native MySQL database support for status, retention, comment, extended, and object data. Developers should be able to write their own routines for providing support for other data sources (PostgresQL and Oracle databases, LDAP servers, etc.) fairly easily.

The reset of this documentation is provided to give developers an overview of how the APIs work and how to write their own code to support other data sources than those already natively provided by NetSaint.

External data types

With the exception of standard logging (to the log file or syslog facility), there are five different types of external data that the core program and/or the CGIs use:

1. Object data - This consists of object definitions (host, services, contact, contact groups, commands, etc) that are used by both the core program and CGIs. Basically everything that can be defined in the standard host config file(s)...
2. Comment data - This consists of host and service comments which are processed by the core program and available for display in the CGIs. By default, comments are stored in file specified by the comment_file directive.
3. Extended data - This consists of optional information that is used by the CGIs when displaying information about specific services and host. Currently, only extended data for hosts is supported. One example of extended data for a host is the graphics associated with it (i.e. icons). By default, extended information can be specified for particular hosts by using hostextinfo definitions in the CGI config file.
4. Status data - This consists of current program, host, and service status information which is made available by the core program and used by the CGIs. By default, status data is stored in the file specified by the status_file directive.
5. Retention data - This consists of saved program, host, and service status information that is used by the core program and should be retained across program restarts. By default, retention data is stored in the file specified by the state_retention_file directive.

Access to external data

The following table outlines what type of access the core program and CGIs have to each type of external data:

| Core Program | CGIs
Object data | Read | Read
Comment data | Read/Write | Read
Extended data | - | Read
Status data | Write | Read
Retention data | Read/Write | -

API details

For more information on how the various types of external data APIs work, as well as information on writing your own I/O routines for external data in the core program and CGIs, click on one of the links below...

- External object data (XOD) API
- External comment data (XCD) API
- External extended data (XED) API
- External status data (XSD) API
- External retention data (XRD) API