Database Ndoutils
Database Ndoutils
Copyright (c) 2006-2007 Ethan Galstad Last Updated: August 29, 2007
Page 1 / 57
NDOUtils DB Model
Section Introduction ........................................................................................ Central Tables ....................................................................................
instances ................................................................................ objects .................................................................................... 5 7 8 9 11 13 16 17 18 19 20 22 24 25 26 28 29 31 32 34 36 37 38 41 42 43 46 48
Copyright (c) 2006-2007 Ethan Galstad
Page
Page 3 / 57
Introduction
This documentation is still in flux, and there are undoubtably errors presents, so take everything you find here with a grain of salt. If you have suggestions, changes, etc. for the documentation, please let me know. Table Names The NDOUtils addon allows users to specify a custom prefix to each table name in the database. By default, this prefix is "nagios_". The tables documented here are listed without any prefix, so the "instances" table as referenced in this documentation may actually be called "nagios_instances" in the database. Configuration Tables I have not yet documented the tables that contain configuration data. A few changes are being made in the Nagios 3 code that will alter the table structures, so I don't want to have to redo a ton of work updating the documentation. The configuration tables represent a read-only output view of the configuration that Nagios is using. Nagios doesn't read the tables to determine its configuration the tables are just provided so you know how Nagios was last configured.
Page 4 / 57
Central Tables
Page 5 / 57
Central Tables
There are two core or central tables, described below, that are referenced by nearly other table in the database. Read below for more information. Table List instances objects Relationship Diagram
Page 6 / 57
instances Table Description: This table is needed to ensure that multiple instances of Nagios can store their configuration and status information in the same database. Each instance represents a different Nagios installation/process. A new instance will automatically be created when the user specifies a new instance name (when running one of the NDOUtils components) that does not already exist in the database. Structure: Field instance_id instance_name instance_description
Notes Unique number identifying a distinct instance of Nagios. Instance name, as passed to and used by NDOUtils components. Optional text describing the instance in more detail.
Page 7 / 57
objects Table Description: This table is used to store all current (and past) objects that are (and have been) defined in your Nagios configuration files. Why are the names of the objects stored in this table and not elsewhere? Well, when you delete an object definition from you Nagios configuration, that object will no longer appear in the object tables of the database. Since you're still going to want to be able to run reports for old hosts, service, etc., we store the name of the object here so you're not completely baffled by the reports you get. :-) Structure: Field object_id instance_id objecttype_id
Notes A unique number identifying the object. A number indicating the instance of Nagios to which the object belongs. A number indicating what type of object this is.
Values
1 = Host 2 = Service 3 = Host group 4 = Service group 5 = Host escalation 6 = Service escalation 7 = Host dependency 8 = Service dependency 9 = Timeperiod 10 = Contact 11 = Contact group 12 = Command 13 = Extended host info (deprecated) 14 = Extended service info (deprecated)
name1 name2
VARCHAR(128) VARCHAR(128)
The first name associated with the object definition, as used in your Nagios configuration files. The second name (if any) associated with the object definition, as used in your Nagios configuration files. This field is only used for service definitions which have a host name (name1 field) and service description (name2 field). A number indicating whether or not the object is currently defined in your 0 = Inactive Nagios configuration files. If an object definition is removed from your Nagios 1 = Active configuration files, it will remain in this table, but will be marked as inactive.
is_active
SMALLINT
Page 8 / 57
Debugging Tables
Page 9 / 57
Debugging Tables
There is currently only one table in the database that is used to hold information that might be useful for debugging purposes. Read below for more information. Table List conninfo Relationship Diagram
Page 10 / 57
conninfo Table Description: This table is used to store debugging information regarding the NDO2DB daemon and the user agents (e.g. LOG2DB, NDOMOD NEB module, etc.) that connect to it. This information is probably only interesting if you are attempting to debug connection problems. Structure: Field conninfo_id instance_id agent_name agent_version disposition
Notes Unique number identifying the connection info record. Unique number identifying the distinct instance of Nagios for which data is being transmitted/processed. Text string identifying the user agent that is sending data to the NDO2DB daemon. Text string identifying the version of the user agent that is sending data. Text string identifying the disposition or type of data that is being sent to the NDO2DB daemon.
Values
"REALTIME" if being sent directly from a running Nagios process or "ARCHIVED" if being sent from a flat file. "TCPSOCKET" or "UNIXSOCKET". "INITIAL" or "RECONNECT".
connect_source connect_type
VARCHAR(16) VARCHAR(16)
Text string identifying the method that the user agent is using to connect to the NDO2DB daemon. Text string indentifying whether this connect was a new connection, or if it was a reconnect due to an earlier communications failure between the user agent and the NDO2DB daemon. The initial time the user agent connected to the daemon. The time (if any) the user agent disconnect from the daemon. The time that the user agent last checked in with the daemon to indicate that it was still alive and sending data. The timestamp of the first data that the user agent sent to the daemon. The timestamp of the last (or latest) data that the user agent sent to the daemon. The number of bytes of data that have been sent by the user agent and processed by the daemon. The number of lines of data that have been sent by the user agent and processed by the daemon. The number of data entries that have been sent by the user agent and processed by the daemon.
Relationships: Page 11 / 57 NDOUtils Database Model www.nagios.org Copyright (c) 2006-2007 Ethan Galstad
Field instance_id
Page 12 / 57
Page 13 / 57
Page 14 / 57
Relationship Diagram Notes: For clarity, the instances table (to which all these tables are related) is not shown. There are 17 historical tables, so please excuse the mess. :-)
Page 15 / 57
acknowledgements Table Description: This table is used to store host and service acknowledgements for historical purposes. Structure: Field acknowledgement_id instance_id entry_time entry_time_usec acknowledgement_type object_id state
Notes Unique number identifying the acknowledgement record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Date and time the acknowledgement was entered. Microsecond portion of acknowledgement entry time. Indicates whether this is a host or service acknowledgement. The object id of the host or service this acknowledgement applies to. Integer indicating the state the host or service was in when the acknowledgement was made.
Values
0 = Host ack 1 = Service ack Host acks 0 = UP 1 = DOWN 2 = UNREACHABLE Service acks 0 = OK 1 = WARNING 2 = CRTICAL 3 = UNKNOWN
Text field containing the name of the person who made the acknowledgement. Text field containing notes on the acknowledgement. Indicates whether or not the acknowledgement is considered "sticky". Indicates whether or not the comment associated with the acknowledgement is persistent. Indicates whether or not contacts are to be notified of the acknowledgement. 0 = Not sticky 1 = Sticky 0 = Not persistent 1 = Persistent 0 = Don't notify 1 = Notify
Foreign Key instances.instance_id objects.object_id NDOUtils Database Model www.nagios.org Copyright (c) 2006-2007 Ethan Galstad
commenthistory Table Description: This table is used to store historical host and service comments. Current comments will also appear in this table, but it is recommended to use the comments table to retrieve a list of current host and service comments. Structure: Field commenthistory_id instance_id entry_time entry_time_usec comment_type entry_type
Notes Unique number identifying the comment record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Date and time the comment was entered. Microsecond portion of comment entry time. Indicates whether this is a host or service comment. Indicates how this comment came to be entered.
Values
object_id comment_time internal_comment_id author_name comment_data is_persistent comment_source expires expiration_time deletion_time deletion_time_usec Relationships:
INT DATETIME INT VARCHAR(64) VARCHAR(255) SMALLINT SMALLINT SMALLINT DATETIME DATETIME INT
The object id of the host or service this acknowledgement applies to. Date and time associated with the comment. The comment ID internal to the Nagios daemon, which may no longer be valid or present. Text field containing the name of the person who made the comment. Text field containing the comment. Indicates whether or not the comment is persistent. Indicates the source of the comment. Indicates whether or not the comment expires. Date and time at which the comment expires. Date and time (if any) when the comment was deleted. Microsecond time (if any) when the comment was deleted. 0 = Not persistent 1 = Persistent 0 = Internal (Nagios) 1 = External (user) 0 = Doesn't expires 1 = Expires
Page 17 / 57
contactnotifications Table Description: This table is used to store a historical record of host and service notifications that have been sent out to individual contacts. Structure: Field contactnotification_id instance_id notification_id contact_object_id start_time start_time_usec end_time end_time_usec Relationships: Field instance_id notification_id contact_object_id
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The id of the notification this record is associated with The object id of the contact this notification was send to. The date/time the notification to this contact was started. The microsecond portion of the time the notification started. The date/time the notification to this contact ended. The microsecond portion of the time the notification ended.
Values
Page 18 / 57
contactnotificationmethods Table Description: This table is used to store a historical record of commands (methods) that were used to contact individuals about host and service problems and recoveries. Structure: Field contactnotificationmethod_id instance_id contactnotification_id start_time start_time_usec end_time end_time_usec command_object_id command_args Relationships: Field instance_id contactnotification_id command_object_id
Type INT SMALLINT INT DATETIME INT DATETIME INT INT VARCHAR
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The id of the contact notification this record is associated with. The date/time the notification command started. The microsecond portion of the time the notification command started. The date/time the notification command ended. The microsecond portion of the time the notification command ended. The id of the command that was used for the notification command. The arguments that were passed to the notification command.
Values
Page 19 / 57
downtimehistory Table Description: This table is used to store a historical record of scheduled host and service downtime. Structure: Field downtimehistory_id instance_id downtime_type object_id entry_time author_name comment_data internal_downtime_id triggered_by_id
Type INT SMALLINT SMALLINT INT DATETIME VARCHAR VARCHAR INT INT
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. A number identifying what type of scheduled downtime this is. The object id of the host or service this scheduled downtime is associated with. The date/time the scheduled downtime was entered/submitted. The name of the person who scheduled this downtime. A comment, as entered by the author, associated with the scheduled downtime. A number (internal to the Nagios daemon) associated with the scheduled downtime. The id of another scheduled downtime entry that scheduled downtime is optionally triggered by. Non-triggered downtimes will have a value of 0 in this field.
Values
is_fixed
SMALLINT
A number indicating whether or not this scheduled downtime is fixed 0 = Flexible (Not fixed) (i.e. its start and end times are exactly what they are listed below as) 1 = Fixed or if it is flexible. The number of seconds that the scheduled downtime should last. This is only used by Nagios is the downtime is flexible. If the downtime is fixed, this value should reflect the difference between the start and end times. The date/time the scheduled downtime is supposed to start. If this is a flexible (non-fixed) downtime, this refers to the earliest possible time that the downtime can start. The date/time the scheduled downtime is supposed to end. If this is a flexible (non-fixed) downtime, this refers to the last possible time that the downtime can start. Number indicated whether or not the scheduled downtime was started. Some flexible downtimes may never actually start if the host/service they are associated with never enter a problem state. 0 = Was not started 1 = Was started
duration
SMALLINT
scheduled_start_time
DATETIME
scheduled_end_time
DATETIME
was_started
SMALLINT
Page 20 / 57
Notes The date/time the scheduled downtime was actually started (if applicable). Microsecond portion of the actual start time. The date/time the scheduled downtime actually ended. Microsecond portion of the actual end time. Number indicating whether or not the scheduled downtime was cancelled before it ended normally.
Values
Page 21 / 57
eventhandlers Table Description: This table is used to store a historical record of host and service event handlers that have been run. NOTE: This table is usually trimmed periodically by the NDO2DB daemon, as it would otherwise grow to an enormous size. Structure: Field eventhandler_id instance_id eventhandler_type
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. A number indicating what type of event handler ths is.
Values
0 = Host event handler 1 = Service event handler 2 = Global host event handler 3 = Global service event handler
object_id state
INT SMALLINT
The object id of the host or service associated with this event handler. Number indicating the state of host or service when the event handler was run. For host event handlers: 0 = UP 1 = DOWN 2 = UNREACHABLE For service event handlers: 0 = OK 1 = WARNING 2 = CRITICAL 3 = UNKNOWN
state_type start_time start_time_usec end_time end_time_usec command_object_id command_args command_line timeout early_timeout Page 22 / 57
SMALLINT DATETIME INT DATETIME INT INT ARGS ARGS SMALLINT SMALLINT
Number indicating the state type of the host or service when the event handler was run. The date/time the event handler started. The microsecond portion of the time the event handler started. The date/time the event handler ended. The microsecond portion of the time the event handler ended. The id of the command that was run. Arguments to the event handler command that was run. Fully expanded command line of the event handler that was run. Timeout value in seconds for the event handler.
Number indicating whether or not the event handler command timed 0 = Did NOT time out NDOUtils Database Model www.nagios.org Copyright (c) 2006-2007 Ethan Galstad
Notes out. Time in seconds that the event handler command was running. The return code value from the event handler command. The first line of text output (if any) from the event handler command.
Page 23 / 57
externalcommands Table Description: This table is used to store a historical record of external commands that have been processed by the Nagios daemon. Structure: Field externalcommand_id instance_id entry_time command_type command_name command_args Relationships: Field instance_id
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The date/time the external command was processed. A number indicating what type of external command this is. Each external command has its own type or "id". The name of the command that was processed. Optional arguments that were specified with the command.
Values
Page 24 / 57
flappinghistory Table Description: This table is used to store a historical record of host and service flapping events. Structure: Field flappinghistory_id instance_id event_time event_time_usec event_type reason
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The date/time of the flapping event. The microsecond portion of the time of the flapping eent. The type of flapping event indicated by this record. Number indicating the reason (if any) that the host or service stopped flapping. This is only valid if this records is a flapping stopped event (see event_type field). Number indicating whether this flapping event relates to a host or service. The id of the host or service associated with the flapping event. The percent state change of the host or service at the time of the event. The low flapping percent state change threshold (as configured in Nagios) of the host or service. The high flapping percent state change threshold (as configured in Nagios) of the host or service. The date/time of the comment associated with the flapping event. The number (internal to the Nagios daemon) of the comment associated with the flapping event.
Values
1000 = Flapping started 1001 = Flapping stopped 1 = Flapping stopped normally 2 = Flapping was disabled 0 = Host 1 = Service
Page 25 / 57
hostchecks Table Description: This table is used to store a historical record of "raw" and "processed" host checks. What's the difference between raw and processed host checks? Raw checks are the raw results from a host check command that gets executed. Nagios must do some processing on the raw host check results before it can determine the real state of the host. Host checks (plugins) cannot directly determine whether a host is DOWN or UNREACHABLE only Nagios can do that. In fact, host checks return the same status codes as service checks (OK, WARNING, UNKNOWN, or CRITICAL). Nagios processes the raw host check result to determine the true state of the host (UP, DOWN, or UNREACHABLE). These "processed" checks contain the the true state of the host. NOTE: This table is usually trimmed periodically by the NDO2DB daemon, as it would otherwise grow to an enormous size. Structure: Field hostcheck_id instance_id host_object_id check_type is_raw_check current_check_attempt max_check_attempts state
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The id of the host this check applies to. Number indicating whether this is an active or passive check.
Values
Number indicating whether this is a "raw" or "processed" host check. 0 = Processed check 1 = Raw check Current check attempt of the host. Max check attempts (as defined in Nagios) for the host. Current state of the host. For raw checks: 0 = UP 1 = DOWN/UNREACHABLE For processed checks: 0 = UP 1 = DOWN 2 = UNREACHABLE
Number indicating whether the host is in a soft or hard state. The date/time the host check was started. Microsecond portion of the time the host check was started. The date/time the host check was completed. Microsecond portion of the time the host check was completed.
Page 26 / 57
Notes The id of the command that was used to perform the host check. The arguments that were passed to the host check command. The fully expanded command line that was used to check the host. Number of seconds before the host check command would time out. Number indicating whether or not the host check timed out early. Number of seconds it took to execute the host check. Number of seconds the host check was "late" in being executed. Scheduled host checks can have a latency, but on-demand checks will have a latency of 0. Latency is the difference between the time the check was scheduled to be executed and the time it was actually executed. For passive checks it is the different between the timestamp on the passive host check result (submitted through the external command file) and the time the passive check result was processed by Nagios. The return code from the host check command. Status text output from the host check command. Optional performance data returned from the host check command.
Values
Page 27 / 57
logentries Table Description: This table is used to store a historical record of entries from the Nagios log. Structure: Field logentry_id instance_id logentry_time
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The date/time associated with the log entry. This is NOT necessarily the same as the date/time that Nagios wrote the log entry to the log file (see below). The date/time that Nagios wrote this log entry to the log file. The microsecond portion of the time that Nagios wrote this log entry. A number indicating what general type of log entry this is. The log entry that was written out to the log file. A number used internally by the NDO2DB daemon. A number used internally by the NDO2DB daemon.
Values
Page 28 / 57
notifications Table Description: This table is used to store a historical record of host and service notifications that have been sent out. For each notification, one or more contacts receive notification messages. These contact notifications are stored in the contactnotifications table. Structure: Field notification_id instance_id notification_type notification_reason
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Number indicating whether this is a host or service notification Number indicating the type of or reason for the notification.
Values
0 = Host notification 1 = Service notification 0 = Normal notification 1 = Problem acknowledgement 2 = Flapping started 3 = Flapping stopped 4 = Flapping was disabled 5 = Downtime started 6 = Downtime ended 7 = Downtime was cancelled 99 = Custom notification
The id of the host or service this notification applies to. The date/time the notification was started. Microsecond portion of the time the notification was started. The date/time the notification ended. Microsecond portion of the time the notification ended. Number indicating the state of the host or service when the notification was sent out. For Host Notifications: 0 = UP 1 = DOWN 2 = CRITICAL For Service Notifications: 0 = OK 1 = WARNING 2 = CRITICAL 3 = UNKNOWN
output escalated
VARCHAR SMALLINT
The current plugin (text) output of the host or service when the notification was sent out. Number indicating whether or not this notification was escalated or 0 = NOT escalated
Page 29 / 57
Field contacts_notifified
Type SMALLINT
Notes not. Number of contacts that were notified about the host or service as part of this notification.
Values 1 = Escalated
Page 30 / 57
processevents Table Description: This table is used to store a historical record of Nagios process events (program starts, restarts, shutdowns, etc.). Structure: Field processevent_id instance_id event_type
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Number indicating the type of process event that occurred.
Values
100 = Process start 101 = Process daemonized 102 = Process restart 103 = Process shutdown 104 = Prelaunch 105 = Event loop start 106 = Event loop end
The date/time that the event occurred. The microsecond portion of the time the event occurred. The current process ID (PID) of the Nagios daemon. "Nagios" Version of Nagios that is running (e.g. "3.1") Release date of Nagios
Page 31 / 57
servicechecks Table Description: This table is used to store a historical record of service checks that have been performed. NOTE: This table is usually trimmed periodically by the NDO2DB daemon, as it would otherwise grow to an enormous size. Structure: Field servicecheck_id instance_id service_object_id check_type current_check_attempt max_check_attempts state
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The id of the service this record refers to. Number indicating whether this was an active or a passive service check. Number indicating the current check attempt for the service. Number indicating the max number of check attempts for the service. Number indicating the current state of the service.
Values
state_type start_time start_time_usec end_time end_time_usec command_object_id command_args command_line timeout early_timeout execution_time Page 32 / 57
SMALLINT DATETIME INT DATETIME INT INT VARCHAR VARCHAR SMALLINT SMALLINT DOUBLE
Number indicating the current state type of the service. The date/time the service check was started. Microsecond portion of the time the service check was started. The date/time the service check ended. Microsecond portion of the time the service check ended. The id of the command that was run to perform the service check. The arguments passed to the command that was run to perform the service check. The fully expanded command line that was executed to perform the service check. Number of seconds before the service check command was scheduled to timeout. Number indicating whether or not the service check timed out. Number of seconds it took to execute the service check command. NDOUtils Database Model www.nagios.org
Field latency
Type DOUBLE
Notes Number of seconds the service check was "late" in being executed. For active checks this is the difference between the scheduled service check time and the time the check actually occurred. For passive checks this is the difference between the timestamp on the passive check result (submitted through the external command file) and the time the passive check result was picked up by the Nagios daemon for processing. The return code from the service check command. The status output that was returned from the service check command. Optional performance data that was returned from the service check command.
Values
Page 33 / 57
statehistory Table Description: This table is used to store a historical record of host and service state changes. Structure: Field statehistory_id instance_id state_time state_time_usec object_id state_change state
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The date/time that the state change occurred. The microsecond portion of the time the state change occurred. The id of the host or service object this state change applies to. Number indicating whether or not a state change occurred for the host or service. Number indicating the current state of the host or service.
Values
0 = No state change 1 = State change For Hosts: 0 = UP 1 = DOWN 2 = UNREACHABLE For Services: 0 = OK 1 = WARNING 2 = CRITICAL 3 = UNKNOWN
Number indicating whether the service is in a soft or hard state. Number indicating the current check attempt for the host or service. Number indicating the max check attempts (as configured in Nagos) for the host or service.
Number indicating the last state (whether hard or soft) of the host or For Hosts: service (if available). -1 = <unavailable> 0 = UP 1 = DOWN 2 = UNREACHABLE For Services: -1 <unavailable> 0 = OK 1 = WARNING 2 = CRITICAL
Page 34 / 57
Field last_hard_state
Type SMALLINT
Notes Number indicating the last hard state of the host or service (if available).
Values 3 = UNKNOWN For Hosts: -1 = <unavailable> 0 = UP 1 = DOWN 2 = UNREACHABLE For Services: -1 <unavailable> 0 = OK 1 = WARNING 2 = CRITICAL
VARCHAR
Page 35 / 57
systemcommands Table Description: This table is used to store a historical record of system commands that are run by the Nagios daemon. Note that each event handler, notification, OCSP command, etc. requires that Nagios execute a system command. NOTE: This table is usually trimmed periodically by the NDO2DB daemon, as it would otherwise grow to an enormous size. Structure: Field systemcommand_id instance_id state_time state_time_usec end_time end_time_usec command_line timeout early_timeout execution_time return_code output
Type INT SMALLINT DATETIME INT DATETIME INT VARCHAR SMALLINT SMALLINT DOUBLE SMALLINT VARCHAR
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The date/time the command was executed. The microsecond portion of the time the command was executed. The date/time the command finished executing. The microsecond portion of the time the command finished executing. Fully expanded command line that was executed. Number of seconds before the command should timeout. Number indicating whether or not the command timed out early. Number of seconds it took to execute the command. Return code of the command. First line of text output (if available) that was returned from the command.
Values
Page 36 / 57
timedevents Table Description: This table is used to store a historical record of timed events that the Nagios process handled. Timed events are internal to the Nagios daemon and used to initiate service checks, host checks, status file updates, etc. They are at the heart of what Nagios does and how it operates. NOTE: This table is usually trimmed periodically by the NDO2DB daemon, as it would otherwise grow to an enormous size. Structure: Field systemcommand_id instance_id event_type queued_time queued_time_usec event_time event_time_usec scheduled_time recurring_event object_id
Type INT SMALLINT SMALLINT DATETIME INT DATETIME INT DATETIME SMALLINT INT
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Number indicating the type of event that was run. The date/time the event was added to the event queue. Microsecond portion of the time the event was added to the event queue. The date/time the event was handled. Microsecond portion of the time the event was handled. The date/time the event was scheduled to be handled/run. Number indicating whether or not the event is a recurring one or a one-time event. The id of the host or service that the event applies to. Not all events apply to hosts or services in these cases the value of this field will be 0. The date/time the event was deleted/removed from the event queue. Microsecond portion of the time the event was removed from the event queue.
Values
deletion_time deletion_time_usec
DATETIME INT
Page 37 / 57
Page 38 / 57
Page 39 / 57
Relationship Diagram Notes: To reduce clutter, the links to the instances table (to which all these tables are related) is not shown.
Page 40 / 57
comments Table Description: This table is used to store current host and service comments. Historical comments can be found in the commenthistory table. Structure: Field comment_id instance_id entry_time entry_time_usec comment_type entry_type
Notes Unique number identifying the comment record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Date and time the comment was entered. Microsecond portion of comment entry time. Indicates whether this is a host or service comment. Indicates how this comment came to be entered.
Values
object_id comment_time internal_comment_id author_name comment_data is_persistent comment_source expires expiration_time Relationships: Field instance_id object_id
The object id of the host or service this acknowledgement applies to. Date and time associated with the comment. The comment ID internal to the Nagios daemon. Text field containing the name of the person who made the comment. Text field containing the comment. Indicates whether or not the comment is persistent. Indicates the source of the comment. Indicates whether or not the comment expires. Date and time at which the comment expires. 0 = Not persistent 1 = Persistent 0 = Internal (Nagios) 1 = External (user) 0 = Doesn't expires 1 = Expires
Page 41 / 57
customvariablestatus Table Description: This table is used to store the current state/values of all custom host, service, and contact variables. Custom variables are only support in Nagios 3.x and higher, so this table will be empty for Nagios 2.x. Structure: Field customvariablestatus_id instance_id object_id status_update_time has_been_modified varname varvalue Relationships: Field instance_id object_id
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The object id of the host or service this acknowledgement applies to. Date and time the status of the custom variable was last updated. Indiciates whether the value of the custom variable has been modified (during runtime) from its original value in the config files. Text field containing the name of the custom variable. Text field containing the value of the custom variable.
Values
Page 42 / 57
hoststatus Table Description: This table is used to store the current status of hosts that are being monitored. Structure: Field hoststatus_id instance_id host_object_id status_update_time output perfdata current_state
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The object id of the host this status entry is associated with. Date and time the status data was updated. Plugin output from the latest host check Performance data from the latest host check Number indicating the current state of the host
Values
has_been_checked should_be_scheduled current_check_attempt max_check_attempts last_check next_check check_type last_state_change last_hard_state_change last_time_up last_time_down
SMALLINT SMALLINT SMALLINT SMALLINT DATETIME DATETIME SMALLINT DATETIME DATETIME DATETIME DATETIME
Number indicating whether or not the host has been checked yet Number indicating whether or not checks should be regularly scheduled for this host. Number indicating the current check attempt of the host. This is only interesting during soft host states. Number indicating how many maximum check attempts will be made to determine the hard state of the host. Time the host was last checked. The the host is scheduled to be checked next. Will be set to the epoch if the host is not scheduled for another check. Number indicating if the last host check was an active or passive check. Time the host last had a hard or soft state change. Will be set to the epoch if the host has not changed state. The the host last had a hard state change. Will be setup to the epoch if the host has not changed state. Time the host was last in an UP state (if ever). Time the host was last in a DOWN state (if ever).
0 = Active 1 = Passive
Page 43 / 57
Notes Time the host was last in an UNREACHABLE state (if ever). Number indicating the type of state the host is in Time a notification was last sent out for the host (if ever). Next possible time that a notification can be sent out for the host.
Values
Number indicating whether or not more notifications can be 0 = Send notifications sent out about the current host problem. 1 = Do not send notifications Number indicating whether or not notifications are enabled for this host. Number indicating whether or not the current host problem has been acknowledged. Number indicating the type of acknowledgement associated with the host. Number indicating the current notification number for the current host problem. This number gets reset to 0 when the host recovers. Number indicating whether or not passive checks are enabled for this host. Number indicating whether or not active checks are enabled for this host. Number indicating whether or not the host's event handler is enabled. Number indicating whether or not flap detection is enabled for this host. Number indicating whether or not the host is currently flapping. Number indicating the current percent state change (a measure of stability/volatility) for the host. Number of seconds that the host check was "late" in being executed. The different between the checks scheduled time and the time it was actually checked. Number of seconds it took to perform the last check of the host. Number indicating how many periods of scheduled NDOUtils Database Model www.nagios.org 0 = Not in scheduled dowtime Copyright (c) 2006-2007 Ethan Galstad 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Not flapping 1 = Flapping 0 = Notifications disabled 1 = Notifications enabled 0 = Not acknowledged 1 = Acknowledged 0 = None 1 = Normal 2 = Sticky
current_notification_number
SMALLINT
DOUBLE SMALLINT
Number indicating whether or not failure prediction (not yet 0 = Disabled implemented) is enabled for this host. 1 = Enabled Number indicating whether or not performance data should 0 = Disabled be processed for this host. 1 = Enabled Number indicating whether or not this host should be obsessed over. Number indicating which attributes of the host have been modified during runtime. Used by the retention data routines. The current event handler command associated with the host. The current check command associated with the host. Number of seconds between normal checks of the host. Number of seconds between retry checks of the host. Unique number of the timeperiod object currently used for determining times the host can be checked. 0 = Do not obsess 1 = Obsess
Page 45 / 57
programstatus Table Description: This table stored status information on the currently (or previously) running Nagios process/daemon. Structure: Field programstatus_id instance_id status_update_time program_start_time program_end_time is_currently_running process_id daemon_mode last_command_check last_log_rotation notifications_enabled active_service_checks_enabled passive_service_checks_enabled active_host_checks_enabled passive_host_checks_enabled event_handlers_enabled flap_detection_enabled failure_prediction_enabled Page 46 / 57
Type INT SMALLINT DATETIME DATETIME DATETIME SMALLINT INT SMALLINT DATETIME DATETIME SMALLINT SMALLINT SMALLINT SMALLINT SMALLINT SMALLINT SMALLINT SMALLINT
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Date and time the status of the process was last updated. Date and time the Nagios process was started. Date and time the Nagios process as stopped (if currently not running). Indicates whether or not the Nagios process is currently running. The processed ID (PID) of the Nagios process. Indicates whether Nagios is running as a foreground process or a daemon. Date and time the Nagios process last checked external commands. Date and time the log file was last rotated (if at all). Indicates whether or not notifications are enabled. Indicates whether or not active service checks are enabled. Indicates whether or not passive service checks are enabled. Indicates whether or not active host checks are enabled. Indicates whether or not passive host checks are enabled. Indicates whether or not event handlers are enabled. Indicates whether or not flap detection is enabled. Indicates whether or not failure prediction is enabled. NDOUtils Database Model www.nagios.org
Values
0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled Copyright (c) 2006-2007 Ethan Galstad
Notes Indicates whether or not performance data is enabled/being processed. Indicates whether or not hosts are being obsessed over. Indicates whether or not services are being obsessed over. Indicates what (if any) host-related program status variables have been modified during runtime. Indicates what (if any) service-related program status variables have been modified during runtime. Text field indicating the current global host event handler command that is being used. Text field indicating the current global service event handler command that is being used.
Values 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled * See Nagios source code for values * See Nagios source code for values
Page 47 / 57
runtimevariables Table Description: This table is used to store some runtime variables from the Nagios process that may be useful to you. The only variables currently stored in this table are some initial variables calculated at startup, but more variables may be stored here in future versions. Structure: Field runtimevariable_id instance_id varname varvalue Relationships: Field instance_id
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Text field containing the name of the variable. Text field containing the value of the variable.
Values
Page 48 / 57
scheduleddowntime Table Description: This table is used to store current host and service downtime, which may either be current in effect or scheduled to begin at a future time. Historical scheduled downtime information can be found in the downtimehistory table. Structure: Field scheduleddowntime_id instance_id downtime_type object_id entry_time author_name comment_data internal_downtime_id triggered_by_id
Type INT SMALLINT SMALLINT INT DATETIME VARCHAR(64) VARCHAR(255) INT INT
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Indicates whether this is a host or service downtime entry. The object id of the host or service this downtime applies to. Date and time this downtime was entered. Text field containing the name of the person who created this scheduled downtime. Text field containing information about this scheduled downtime (as entered by the user). The ID number (internal to the Nagios daemon) associated with this scheduled downtime entry. The internal Nagios ID number (if any) of another scheduled downtime entry that this downtime is "triggered" (started) by. If this field is nonzero, this is a triggered downtime entry, otherwise it is not. Indicates whether this is a "fixed" scheduled downtime entry (that should start and end at the start and end times indicated) or a "flexible" entry that can start at a variable time. Indicates the number of seconds that the scheduled downtime should last. This is usually only needed if this is "flexible" downtime, which can start at a variable time, but lasts for the specified duration. Date and time that the downtime is scheduled to start if it is "fixed" dowtime. If this is a "flexible" downtime entry, this is the first possible time the downtime can start. Date and time the downtime is scheduled to end if it is "fixed" downtime. If this is a "flexible" downtime entry, this is the last possible time the downtime can start. Indicates whether or not the downtime was started (is currently
Values
is_fixed
SMALLINT
duration
SMALLINT
scheduled_start_time
DATETIME
scheduled_end_time
DATETIME
was_started
SMALLINT
Page 49 / 57
Notes active). Date and time the scheduled downtime was actually started. Microsecond portion of time the scheduled downtime was actually started.
Page 50 / 57
servicestatus Table Description: This table is used to store current status information for all services that are being monitored. Structure: Field servicestatus_id instance_id service_object_id status_update_time output perfdata current_state
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. The id of the service this record is associated with. The date/time the status record was updated. The text output from the most current service check. Optional performance data from the most current service check. Number indicating the current state of the service.
Values
has_been_checked should_be_scheduled current_check_attempt max_check_attempts last_check next_check check_type last_state_change last_hard_state_change last_time_ok last_time_warning last_time_unknown last_time_critical
SMALLINT SMALLINT SMALLINT SMALLINT DATETIME DATETIME SMALLINT DATETIME DATETIME DATETIME DATETIME DATETIME DATETIME
Number indicating whether or not the service has been checked yet. 0 = Has NOT been checked 1 = Has been checked Number indicating whether or not the service should be scheduled for periodic checks on a regular basis. The current check attempt for the service. The max check attempts (as configured in Nagios) for the service. The date/time the service was last checked. Set to the epoch if the service has not been checked yet. The date/time the service is scheduled to be checked next. Number indicating whether or not the last service check was active or passive. The date/time the service last changed state (if at all). This gets updated for both HARD and SOFT state changes. The date/time the service last changed HARD states (if at all). The date/time the service was last in an OK state (if at all). The date/time the service was last in a WARNING state (if at all). The date/time the service was last in an UNKNOWN state (if at all). The date/time the service was last in a CRITICAL state (if at all). 0 = Active 1 = Passive 0 = Not scheduled 1 = Scheduled
Page 51 / 57
Notes Number indicating whether the service is in a hard or soft state. The date/time that a notification was last sent out for the current service problem (if applicable). The earliest date/time that the next notification can be sent out for the current service problem (if applicable).
Number indicating whether or not future notifications can be sent out 0 = Do not send more notifications for the current service problem. 1 = Keep sending notifications Number indicating whether notifications are enabled for the service. Number indicating whether or not the current status problem has been acknowledged. Number indicating the type of acknowledgement (if any). 0 = Disabled 1 = Enabled 0 = Not acknowledged 1 = Acknowledged 0 = No acknowledgement 1 = Normal acknowledgement 2 = Sticky acknowledgement
Number indicating how many notifications have been sent out about the current service problem (if applicable). Number indicating whether or not passive checks are enabled for the service. Number indicating whether or not active checks are enabled for the service. Number indicating whether or not the service event handler is enabled. Number indicating whether or not flap detection is enabled for the service. Number indicating whether ot not the service is currently flapping. Number indicating the current percent state change (a measure of volatility) for the service. Number indicating how "late" the last service check was in being run. For active checks, this is the difference between the time the service was scheduled to be the checked and the time it was actually checked. For passive checks, this is the difference between the timestamp on the passive check (submitted via an external command) and the time Nagios processed the check result. Number of seconds it took to run the last service check. Number indicating how many periods of scheduled downtime are NDOUtils Database Model www.nagios.org Copyright (c) 2006-2007 Ethan Galstad 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Disabled 1 = Enabled 0 = Not flapping 1 = Flapping
DOUBLE SMALLINT
Field
Type
Notes currently in effect for the service. A value of 0 indicates the service is not in a period of downtime.
Values
Number indicating whether or not failure prediction is enabled for the 0 = Disabled service. This feature has not yet been implemented. 1 = Enabled Number indicating whether or not performance data should be processed for the service. Number indicating whether or not Nagios should obsess of check results of the service. Number indicating what service attributes have been modified during runtime. The current event handler command that is associated with the service. The current check command that is used to check the status of the service. The current normal check interval for the service (in seconds). The current retry check interval for the service (in seconds). The currently timeperiod that is used to determine when the service can be checked. 0 = Do NOT process perfdata 1 = Process perfdata 0 = Do NOT obsess 1 = Obsess See Nagios source code.
Page 53 / 57
timedeventqueue Table Description: This table is used to store all timed events that are in the Nagios event queue, scheduled to be executed at a future time. Historical timed events can be found in the timedevents table. Structure: Field timedeventqueue_id instance_id event_type queued_time queued_time_usec scheduled_time recurring_event object_id
Notes Unique number identifying the record. Unique number identifying the distinct instance of Nagios which this entry is associated with. Value indicating the type of event. Date and time the event was originally placed into the timed event queue. Microsecond portion of time the event was queued. Date and time the event is scheduled to be executed. Indicates whether or not this is a recurring event. The object id of the host, service, contact, etc. that this scheduled event applies to (if applicable). If the event is not associated with any particular object, this field will have a value of zero (0).
Values
Page 54 / 57
Configuration Tables
Page 55 / 57
Configuration Tables
There are many tables in the database that are used to store Nagios configuration. Note that the data in these tables represents a read-only output view of the configuration that Nagios was using during its last (or current) run. Configuration information from these tables is NOT read by the Nagios daemon in any way, and thus cannot be used to configure Nagios. Table List commands configfiles configfilevariables contact_addresses contact_notificationcommands contactgroup_members contactgroups contactnotificationmethods contacts customobjectvariables host_contactgroups host_parenthosts hostdependencies hostescalation_contactgroups hostescalations hostgroup_members hostgroups hosts service_contactgroups servicedependencies serviceescalation_contactgroups serviceescalations servicegroup_members servicegroups services timeperod_timeranges timeperiods
Page 56 / 57
Page 57 / 57