Command Package

Command Package

The Command module is capable of sending commands to Nagios via the configured communication path.

pynag.Control.Command.acknowledge_host_problem(host_name, sticky, notify, persistent, author, comment, command_file=None, timestamp=0)

Allows you to acknowledge the current problem for the specified host. By acknowledging the current problem, future notifications (for the same host state) are disabled. If the “sticky” option is set to two (2), the acknowledgement will remain until the host returns to an UP state. Otherwise the acknowledgement will automatically be removed when the host changes state. If the “notify” option is set to one (1), a notification will be sent out to contacts indicating that the current host problem has been acknowledged. If the “persistent” option is set to one (1), the comment associated with the acknowledgement will survive across restarts of the Nagios process. If not, the comment will be deleted the next time Nagios restarts.

pynag.Control.Command.acknowledge_svc_problem(host_name, service_description, sticky, notify, persistent, author, comment, command_file=None, timestamp=0)

Allows you to acknowledge the current problem for the specified service. By acknowledging the current problem, future notifications (for the same servicestate) are disabled. If the “sticky” option is set to two (2), the acknowledgement will remain until the service returns to an OK state. Otherwise the acknowledgement will automatically be removed when the service changes state. If the “notify” option is set to one (1), a notification will be sent out to contacts indicating that the current service problem has been acknowledged. If the “persistent” option is set to one (1), the comment associated with the acknowledgement will survive across restarts of the Nagios process. If not, the comment will be deleted the next time Nagios restarts.

pynag.Control.Command.add_host_comment(host_name, persistent, author, comment, command_file=None, timestamp=0)

Adds a comment to a particular host. If the “persistent” field is set to zero (0), the comment will be deleted the next time Nagios is restarted. Otherwise, the comment will persist across program restarts until it is deleted manually.

pynag.Control.Command.add_svc_comment(host_name, service_description, persistent, author, comment, command_file=None, timestamp=0)

Adds a comment to a particular service. If the “persistent” field is set to zero (0), the comment will be deleted the next time Nagios is restarted. Otherwise, the comment will persist across program restarts until it is deleted manually.

pynag.Control.Command.change_contact_host_notification_timeperiod(contact_name, notification_timeperiod, command_file=None, timestamp=0)

Changes the host notification timeperiod for a particular contact to what is specified by the “notification_timeperiod” option. The “notification_timeperiod” option should be the short name of the timeperiod that is to be used as the contact’s host notification timeperiod. The timeperiod must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_contact_modattr(contact_name, value, command_file=None, timestamp=0)

This command changes the modified attributes value for the specified contact. Modified attributes values are used by Nagios to determine which object properties should be retained across program restarts. Thus, modifying the value of the attributes can affect data retention. This is an advanced option and should only be used by people who are intimately familiar with the data retention logic in Nagios.

pynag.Control.Command.change_contact_modhattr(contact_name, value, command_file=None, timestamp=0)

This command changes the modified host attributes value for the specified contact. Modified attributes values are used by Nagios to determine which object properties should be retained across program restarts. Thus, modifying the value of the attributes can affect data retention. This is an advanced option and should only be used by people who are intimately familiar with the data retention logic in Nagios.

pynag.Control.Command.change_contact_modsattr(contact_name, value, command_file=None, timestamp=0)

This command changes the modified service attributes value for the specified contact. Modified attributes values are used by Nagios to determine which object properties should be retained across program restarts. Thus, modifying the value of the attributes can affect data retention. This is an advanced option and should only be used by people who are intimately familiar with the data retention logic in Nagios.

pynag.Control.Command.change_contact_svc_notification_timeperiod(contact_name, notification_timeperiod, command_file=None, timestamp=0)

Changes the service notification timeperiod for a particular contact to what is specified by the “notification_timeperiod” option. The “notification_timeperiod” option should be the short name of the timeperiod that is to be used as the contact’s service notification timeperiod. The timeperiod must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_custom_contact_var(contact_name, varname, varvalue, command_file=None, timestamp=0)

Changes the value of a custom contact variable.

pynag.Control.Command.change_custom_host_var(host_name, varname, varvalue, command_file=None, timestamp=0)

Changes the value of a custom host variable.

pynag.Control.Command.change_custom_svc_var(host_name, service_description, varname, varvalue, command_file=None, timestamp=0)

Changes the value of a custom service variable.

pynag.Control.Command.change_global_host_event_handler(event_handler_command, command_file=None, timestamp=0)

Changes the global host event handler command to be that specified by the “event_handler_command” option. The “event_handler_command” option specifies the short name of the command that should be used as the new host event handler. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_global_svc_event_handler(event_handler_command, command_file=None, timestamp=0)

Changes the global service event handler command to be that specified by the “event_handler_command” option. The “event_handler_command” option specifies the short name of the command that should be used as the new service event handler. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_host_check_command(host_name, check_command, command_file=None, timestamp=0)

Changes the check command for a particular host to be that specified by the “check_command” option. The “check_command” option specifies the short name of the command that should be used as the new host check command. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_host_check_timeperiod(host_name, timeperiod, command_file=None, timestamp=0)

Changes the valid check period for the specified host.

pynag.Control.Command.change_host_event_handler(host_name, event_handler_command, command_file=None, timestamp=0)

Changes the event handler command for a particular host to be that specified by the “event_handler_command” option. The “event_handler_command” option specifies the short name of the command that should be used as the new host event handler. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_host_modattr(host_name, value, command_file=None, timestamp=0)

This command changes the modified attributes value for the specified host. Modified attributes values are used by Nagios to determine which object properties should be retained across program restarts. Thus, modifying the value of the attributes can affect data retention. This is an advanced option and should only be used by people who are intimately familiar with the data retention logic in Nagios.

pynag.Control.Command.change_max_host_check_attempts(host_name, check_attempts, command_file=None, timestamp=0)

Changes the maximum number of check attempts (retries) for a particular host.

pynag.Control.Command.change_max_svc_check_attempts(host_name, service_description, check_attempts, command_file=None, timestamp=0)

Changes the maximum number of check attempts (retries) for a particular service.

pynag.Control.Command.change_normal_host_check_interval(host_name, check_interval, command_file=None, timestamp=0)

Changes the normal (regularly scheduled) check interval for a particular host.

pynag.Control.Command.change_normal_svc_check_interval(host_name, service_description, check_interval, command_file=None, timestamp=0)

Changes the normal (regularly scheduled) check interval for a particular service

pynag.Control.Command.change_retry_host_check_interval(host_name, service_description, check_interval, command_file=None, timestamp=0)

Changes the retry check interval for a particular host.

pynag.Control.Command.change_retry_svc_check_interval(host_name, service_description, check_interval, command_file=None, timestamp=0)

Changes the retry check interval for a particular service.

pynag.Control.Command.change_svc_check_command(host_name, service_description, check_command, command_file=None, timestamp=0)

Changes the check command for a particular service to be that specified by the “check_command” option. The “check_command” option specifies the short name of the command that should be used as the new service check command. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_svc_check_timeperiod(host_name, service_description, check_timeperiod, command_file=None, timestamp=0)

Changes the check timeperiod for a particular service to what is specified by the “check_timeperiod” option. The “check_timeperiod” option should be the short name of the timeperod that is to be used as the service check timeperiod. The timeperiod must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_svc_event_handler(host_name, service_description, event_handler_command, command_file=None, timestamp=0)

Changes the event handler command for a particular service to be that specified by the “event_handler_command” option. The “event_handler_command” option specifies the short name of the command that should be used as the new service event handler. The command must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.change_svc_modattr(host_name, service_description, value, command_file=None, timestamp=0)

This command changes the modified attributes value for the specified service. Modified attributes values are used by Nagios to determine which object properties should be retained across program restarts. Thus, modifying the value of the attributes can affect data retention. This is an advanced option and should only be used by people who are intimately familiar with the data retention logic in Nagios.

pynag.Control.Command.change_svc_notification_timeperiod(host_name, service_description, notification_timeperiod, command_file=None, timestamp=0)

Changes the notification timeperiod for a particular service to what is specified by the “notification_timeperiod” option. The “notification_timeperiod” option should be the short name of the timeperiod that is to be used as the service notification timeperiod. The timeperiod must have been configured in Nagios before it was last (re)started.

pynag.Control.Command.del_all_host_comments(host_name, command_file=None, timestamp=0)

Deletes all comments assocated with a particular host.

pynag.Control.Command.del_all_svc_comments(host_name, service_description, command_file=None, timestamp=0)

Deletes all comments associated with a particular service.

pynag.Control.Command.del_host_comment(comment_id, command_file=None, timestamp=0)

Deletes a host comment. The id number of the comment that is to be deleted must be specified.

pynag.Control.Command.del_host_downtime(downtime_id, command_file=None, timestamp=0)

Deletes the host downtime entry that has an ID number matching the “downtime_id” argument. If the downtime is currently in effect, the host will come out of scheduled downtime (as long as there are no other overlapping active downtime entries).

pynag.Control.Command.del_svc_comment(comment_id, command_file=None, timestamp=0)

Deletes a service comment. The id number of the comment that is to be deleted must be specified.

pynag.Control.Command.del_svc_downtime(downtime_id, command_file=None, timestamp=0)

Deletes the service downtime entry that has an ID number matching the “downtime_id” argument. If the downtime is currently in effect, the service will come out of scheduled downtime (as long as there are no other overlapping active downtime entries).

pynag.Control.Command.delay_host_notification(host_name, notification_time, command_file=None, timestamp=0)

Delays the next notification for a parciular service until “notification_time”. The “notification_time” argument is specified in time_t format (seconds since the UNIX epoch). Note that this will only have an affect if the service stays in the same problem state that it is currently in. If the service changes to another state, a new notification may go out before the time you specify in the “notification_time” argument.

pynag.Control.Command.delay_svc_notification(host_name, service_description, notification_time, command_file=None, timestamp=0)

Delays the next notification for a parciular service until “notification_time”. The “notification_time” argument is specified in time_t format (seconds since the UNIX epoch). Note that this will only have an affect if the service stays in the same problem state that it is currently in. If the service changes to another state, a new notification may go out before the time you specify in the “notification_time” argument.

pynag.Control.Command.disable_all_notifications_beyond_host(host_name, command_file=None, timestamp=0)

Disables notifications for all hosts and services “beyond” (e.g. on all child hosts of) the specified host. The current notification setting for the specified host is not affected.

pynag.Control.Command.disable_contact_host_notifications(contact_name, command_file=None, timestamp=0)

Disables host notifications for a particular contact.

pynag.Control.Command.disable_contact_svc_notifications(contact_name, command_file=None, timestamp=0)

Disables service notifications for a particular contact.

pynag.Control.Command.disable_contactgroup_host_notifications(contactgroup_name, command_file=None, timestamp=0)

Disables host notifications for all contacts in a particular contactgroup.

pynag.Control.Command.disable_contactgroup_svc_notifications(contactgroup_name, command_file=None, timestamp=0)

Disables service notifications for all contacts in a particular contactgroup.

pynag.Control.Command.disable_event_handlers(command_file=None, timestamp=0)

Disables host and service event handlers on a program-wide basis.

pynag.Control.Command.disable_failure_prediction(command_file=None, timestamp=0)

Disables failure prediction on a program-wide basis. This feature is not currently implemented in Nagios.

pynag.Control.Command.disable_flap_detection(command_file=None, timestamp=0)

Disables host and service flap detection on a program-wide basis.

pynag.Control.Command.disable_host_and_child_notifications(host_name, command_file=None, timestamp=0)

Disables notifications for the specified host, as well as all hosts “beyond” (e.g. on all child hosts of) the specified host.

pynag.Control.Command.disable_host_check(host_name, command_file=None, timestamp=0)

Disables (regularly scheduled and on-demand) active checks of the specified host.

pynag.Control.Command.disable_host_event_handler(host_name, command_file=None, timestamp=0)

Disables the event handler for the specified host.

pynag.Control.Command.disable_host_flap_detection(host_name, command_file=None, timestamp=0)

Disables flap detection for the specified host.

pynag.Control.Command.disable_host_freshness_checks(command_file=None, timestamp=0)

Disables freshness checks of all hosts on a program-wide basis.

pynag.Control.Command.disable_host_notifications(host_name, command_file=None, timestamp=0)

Disables notifications for a particular host.

pynag.Control.Command.disable_host_svc_checks(host_name, command_file=None, timestamp=0)

Enables active checks of all services on the specified host.

pynag.Control.Command.disable_host_svc_notifications(host_name, command_file=None, timestamp=0)

Disables notifications for all services on the specified host.

pynag.Control.Command.disable_hostgroup_host_checks(hostgroup_name, command_file=None, timestamp=0)

Disables active checks for all hosts in a particular hostgroup.

pynag.Control.Command.disable_hostgroup_host_notifications(hostgroup_name, command_file=None, timestamp=0)

Disables notifications for all hosts in a particular hostgroup. This does not disable notifications for the services associated with the hosts in the hostgroup - see the DISABLE_HOSTGROUP_SVC_NOTIFICATIONS command for that.

pynag.Control.Command.disable_hostgroup_passive_host_checks(hostgroup_name, command_file=None, timestamp=0)

Disables passive checks for all hosts in a particular hostgroup.

pynag.Control.Command.disable_hostgroup_passive_svc_checks(hostgroup_name, command_file=None, timestamp=0)

Disables passive checks for all services associated with hosts in a particular hostgroup.

pynag.Control.Command.disable_hostgroup_svc_checks(hostgroup_name, command_file=None, timestamp=0)

Disables active checks for all services associated with hosts in a particular hostgroup.

pynag.Control.Command.disable_hostgroup_svc_notifications(hostgroup_name, command_file=None, timestamp=0)

Disables notifications for all services associated with hosts in a particular hostgroup. This does not disable notifications for the hosts in the hostgroup - see the DISABLE_HOSTGROUP_HOST_NOTIFICATIONS command for that.

pynag.Control.Command.disable_notifications(command_file=None, timestamp=0)

Disables host and service notifications on a program-wide basis.

pynag.Control.Command.disable_passive_host_checks(host_name, command_file=None, timestamp=0)

Disables acceptance and processing of passive host checks for the specified host.

pynag.Control.Command.disable_passive_svc_checks(host_name, service_description, command_file=None, timestamp=0)

Disables passive checks for the specified service.

pynag.Control.Command.disable_performance_data(command_file=None, timestamp=0)

Disables the processing of host and service performance data on a program-wide basis.

pynag.Control.Command.disable_service_flap_detection(host_name, service_description, command_file=None, timestamp=0)

Disables flap detection for the specified service.

pynag.Control.Command.disable_service_freshness_checks(command_file=None, timestamp=0)

Disables freshness checks of all services on a program-wide basis.

pynag.Control.Command.disable_servicegroup_host_checks(servicegroup_name, command_file=None, timestamp=0)

Disables active checks for all hosts that have services that are members of a particular hostgroup.

pynag.Control.Command.disable_servicegroup_host_notifications(servicegroup_name, command_file=None, timestamp=0)

Disables notifications for all hosts that have services that are members of a particular servicegroup.

pynag.Control.Command.disable_servicegroup_passive_host_checks(servicegroup_name, command_file=None, timestamp=0)

Disables the acceptance and processing of passive checks for all hosts that have services that are members of a particular service group.

pynag.Control.Command.disable_servicegroup_passive_svc_checks(servicegroup_name, command_file=None, timestamp=0)

Disables the acceptance and processing of passive checks for all services in a particular servicegroup.

pynag.Control.Command.disable_servicegroup_svc_checks(servicegroup_name, command_file=None, timestamp=0)

Disables active checks for all services in a particular servicegroup.

pynag.Control.Command.disable_servicegroup_svc_notifications(servicegroup_name, command_file=None, timestamp=0)

Disables notifications for all services that are members of a particular servicegroup.

pynag.Control.Command.disable_svc_check(host_name, service_description, command_file=None, timestamp=0)

Disables active checks for a particular service.

pynag.Control.Command.disable_svc_event_handler(host_name, service_description, command_file=None, timestamp=0)

Disables the event handler for the specified service.

pynag.Control.Command.disable_svc_flap_detection(host_name, service_description, command_file=None, timestamp=0)

Disables flap detection for the specified service.

pynag.Control.Command.disable_svc_notifications(host_name, service_description, command_file=None, timestamp=0)

Disables notifications for a particular service.

pynag.Control.Command.enable_all_notifications_beyond_host(host_name, command_file=None, timestamp=0)

Enables notifications for all hosts and services “beyond” (e.g. on all child hosts of) the specified host. The current notification setting for the specified host is not affected. Notifications will only be sent out for these hosts and services if notifications are also enabled on a program-wide basis.

pynag.Control.Command.enable_contact_host_notifications(contact_name, command_file=None, timestamp=0)

Enables host notifications for a particular contact.

pynag.Control.Command.enable_contact_svc_notifications(contact_name, command_file=None, timestamp=0)

Disables service notifications for a particular contact.

pynag.Control.Command.enable_contactgroup_host_notifications(contactgroup_name, command_file=None, timestamp=0)

Enables host notifications for all contacts in a particular contactgroup.

pynag.Control.Command.enable_contactgroup_svc_notifications(contactgroup_name, command_file=None, timestamp=0)

Enables service notifications for all contacts in a particular contactgroup.

pynag.Control.Command.enable_event_handlers(command_file=None, timestamp=0)

Enables host and service event handlers on a program-wide basis.

pynag.Control.Command.enable_failure_prediction(command_file=None, timestamp=0)

Enables failure prediction on a program-wide basis. This feature is not currently implemented in Nagios.

pynag.Control.Command.enable_flap_detection(command_file=None, timestamp=0)

Enables host and service flap detection on a program-wide basis.

pynag.Control.Command.enable_host_and_child_notifications(host_name, command_file=None, timestamp=0)

Enables notifications for the specified host, as well as all hosts “beyond” (e.g. on all child hosts of) the specified host. Notifications will only be sent out for these hosts if notifications are also enabled on a program-wide basis.

pynag.Control.Command.enable_host_check(host_name, command_file=None, timestamp=0)

Enables (regularly scheduled and on-demand) active checks of the specified host.

pynag.Control.Command.enable_host_event_handler(host_name, command_file=None, timestamp=0)

Enables the event handler for the specified host.

pynag.Control.Command.enable_host_flap_detection(host_name, command_file=None, timestamp=0)

Enables flap detection for the specified host. In order for the flap detection algorithms to be run for the host, flap detection must be enabled on a program-wide basis as well.

pynag.Control.Command.enable_host_freshness_checks(command_file=None, timestamp=0)

Enables freshness checks of all hosts on a program-wide basis. Individual hosts that have freshness checks disabled will not be checked for freshness.

pynag.Control.Command.enable_host_notifications(host_name, command_file=None, timestamp=0)

Enables notifications for a particular host. Notifications will be sent out for the host only if notifications are enabled on a program-wide basis as well.

pynag.Control.Command.enable_host_svc_checks(host_name, command_file=None, timestamp=0)

Enables active checks of all services on the specified host.

pynag.Control.Command.enable_host_svc_notifications(host_name, command_file=None, timestamp=0)

Enables notifications for all services on the specified host. Note that notifications will not be sent out if notifications are disabled on a program-wide basis.

pynag.Control.Command.enable_hostgroup_host_checks(hostgroup_name, command_file=None, timestamp=0)

Enables active checks for all hosts in a particular hostgroup.

pynag.Control.Command.enable_hostgroup_host_notifications(hostgroup_name, command_file=None, timestamp=0)

Enables notifications for all hosts in a particular hostgroup. This does not enable notifications for the services associated with the hosts in the hostgroup - see the ENABLE_HOSTGROUP_SVC_NOTIFICATIONS command for that. In order for notifications to be sent out for these hosts, notifications must be enabled on a program-wide basis as well.

pynag.Control.Command.enable_hostgroup_passive_host_checks(hostgroup_name, command_file=None, timestamp=0)

Enables passive checks for all hosts in a particular hostgroup.

pynag.Control.Command.enable_hostgroup_passive_svc_checks(hostgroup_name, command_file=None, timestamp=0)

Enables passive checks for all services associated with hosts in a particular hostgroup.

pynag.Control.Command.enable_hostgroup_svc_checks(hostgroup_name, command_file=None, timestamp=0)

Enables active checks for all services associated with hosts in a particular hostgroup.

pynag.Control.Command.enable_hostgroup_svc_notifications(hostgroup_name, command_file=None, timestamp=0)

Enables notifications for all services that are associated with hosts in a particular hostgroup. This does not enable notifications for the hosts in the hostgroup - see the ENABLE_HOSTGROUP_HOST_NOTIFICATIONS command for that. In order for notifications to be sent out for these services, notifications must be enabled on a program-wide basis as well.

pynag.Control.Command.enable_notifications(command_file=None, timestamp=0)

Enables host and service notifications on a program-wide basis.

pynag.Control.Command.enable_passive_host_checks(host_name, command_file=None, timestamp=0)

Enables acceptance and processing of passive host checks for the specified host.

pynag.Control.Command.enable_passive_svc_checks(host_name, service_description, command_file=None, timestamp=0)

Enables passive checks for the specified service.

pynag.Control.Command.enable_performance_data(command_file=None, timestamp=0)

Enables the processing of host and service performance data on a program-wide basis.

pynag.Control.Command.enable_service_freshness_checks(command_file=None, timestamp=0)

Enables freshness checks of all services on a program-wide basis. Individual services that have freshness checks disabled will not be checked for freshness.

pynag.Control.Command.enable_servicegroup_host_checks(servicegroup_name, command_file=None, timestamp=0)

Enables active checks for all hosts that have services that are members of a particular hostgroup.

pynag.Control.Command.enable_servicegroup_host_notifications(servicegroup_name, command_file=None, timestamp=0)

Enables notifications for all hosts that have services that are members of a particular servicegroup. In order for notifications to be sent out for these hosts, notifications must also be enabled on a program-wide basis.

pynag.Control.Command.enable_servicegroup_passive_host_checks(servicegroup_name, command_file=None, timestamp=0)

Enables the acceptance and processing of passive checks for all hosts that have services that are members of a particular service group.

pynag.Control.Command.enable_servicegroup_passive_svc_checks(servicegroup_name, command_file=None, timestamp=0)

Enables the acceptance and processing of passive checks for all services in a particular servicegroup.

pynag.Control.Command.enable_servicegroup_svc_checks(servicegroup_name, command_file=None, timestamp=0)

Enables active checks for all services in a particular servicegroup.

pynag.Control.Command.enable_servicegroup_svc_notifications(servicegroup_name, command_file=None, timestamp=0)

Enables notifications for all services that are members of a particular servicegroup. In order for notifications to be sent out for these services, notifications must also be enabled on a program-wide basis.

pynag.Control.Command.enable_svc_check(host_name, service_description, command_file=None, timestamp=0)

Enables active checks for a particular service.

pynag.Control.Command.enable_svc_event_handler(host_name, service_description, command_file=None, timestamp=0)

Enables the event handler for the specified service.

pynag.Control.Command.enable_svc_flap_detection(host_name, service_description, command_file=None, timestamp=0)

Enables flap detection for the specified service. In order for the flap detection algorithms to be run for the service, flap detection must be enabled on a program-wide basis as well.

pynag.Control.Command.enable_svc_notifications(host_name, service_description, command_file=None, timestamp=0)

Enables notifications for a particular service. Notifications will be sent out for the service only if notifications are enabled on a program-wide basis as well.

pynag.Control.Command.find_command_file(cfg_file=None)

Returns path to nagios command_file by looking at what is defined in nagios.cfg

Args:
cfg_file (str): Path to nagios.cfg configuration file
Returns:
str. Path to the nagios command file
Raises:
PynagError
pynag.Control.Command.process_file(file_name, delete, command_file=None, timestamp=0)

Directs Nagios to process all external commands that are found in the file specified by the <file_name> argument. If the <delete> option is non-zero, the file will be deleted once it has been processes. If the <delete> option is set to zero, the file is left untouched.

pynag.Control.Command.process_host_check_result(host_name, status_code, plugin_output, command_file=None, timestamp=0)

This is used to submit a passive check result for a particular host. The “status_code” indicates the state of the host check and should be one of the following: 0=UP, 1=DOWN, 2=UNREACHABLE. The “plugin_output” argument contains the text returned from the host check, along with optional performance data.

pynag.Control.Command.process_service_check_result(host_name, service_description, return_code, plugin_output, command_file=None, timestamp=0)

This is used to submit a passive check result for a particular service. The “return_code” field should be one of the following: 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN. The “plugin_output” field contains text output from the service check, along with optional performance data.

pynag.Control.Command.read_state_information(command_file=None, timestamp=0)

Causes Nagios to load all current monitoring status information from the state retention file. Normally, state retention information is loaded when the Nagios process starts up and before it starts monitoring. WARNING: This command will cause Nagios to discard all current monitoring status information and use the information stored in state retention file! Use with care.

pynag.Control.Command.remove_host_acknowledgement(host_name, command_file=None, timestamp=0)

This removes the problem acknowledgement for a particular host. Once the acknowledgement has been removed, notifications can once again be sent out for the given host.

pynag.Control.Command.remove_svc_acknowledgement(host_name, service_description, command_file=None, timestamp=0)

This removes the problem acknowledgement for a particular service. Once the acknowledgement has been removed, notifications can once again be sent out for the given service.

pynag.Control.Command.restart_program(command_file=None, timestamp=0)

Restarts the Nagios process.

pynag.Control.Command.save_state_information(command_file=None, timestamp=0)

Causes Nagios to save all current monitoring status information to the state retention file. Normally, state retention information is saved before the Nagios process shuts down and (potentially) at regularly scheduled intervals. This command allows you to force Nagios to save this information to the state retention file immediately. This does not affect the current status information in the Nagios process.

pynag.Control.Command.schedule_and_propagate_host_downtime(host_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for a specified host and all of its children (hosts). If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The specified (parent) host downtime can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the specified (parent) host should not be triggered by another downtime entry.

pynag.Control.Command.schedule_and_propagate_triggered_host_downtime(host_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for a specified host and all of its children (hosts). If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). Downtime for child hosts are all set to be triggered by the downtime for the specified (parent) host. The specified (parent) host downtime can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the specified (parent) host should not be triggered by another downtime entry.

pynag.Control.Command.schedule_forced_host_check(host_name, check_time, command_file=None, timestamp=0)

Schedules a forced active check of a particular host at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Forced checks are performed regardless of what time it is (e.g. timeperiod restrictions are ignored) and whether or not active checks are enabled on a host-specific or program-wide basis.

pynag.Control.Command.schedule_forced_host_svc_checks(host_name, check_time, command_file=None, timestamp=0)

Schedules a forced active check of all services associated with a particular host at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Forced checks are performed regardless of what time it is (e.g. timeperiod restrictions are ignored) and whether or not active checks are enabled on a service-specific or program-wide basis.

pynag.Control.Command.schedule_forced_svc_check(host_name, service_description, check_time, command_file=None, timestamp=0)

Schedules a forced active check of a particular service at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Forced checks are performed regardless of what time it is (e.g. timeperiod restrictions are ignored) and whether or not active checks are enabled on a service-specific or program-wide basis.

pynag.Control.Command.schedule_host_check(host_name, check_time, command_file=None, timestamp=0)

Schedules the next active check of a particular host at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Note that the host may not actually be checked at the time you specify. This could occur for a number of reasons: active checks are disabled on a program-wide or service-specific basis, the host is already scheduled to be checked at an earlier time, etc. If you want to force the host check to occur at the time you specify, look at the SCHEDULE_FORCED_HOST_CHECK command.

pynag.Control.Command.schedule_host_downtime(host_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for a specified host. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The specified host downtime can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the specified host should not be triggered by another downtime entry.

pynag.Control.Command.schedule_host_svc_checks(host_name, check_time, command_file=None, timestamp=0)

Schedules the next active check of all services on a particular host at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Note that the services may not actually be checked at the time you specify. This could occur for a number of reasons: active checks are disabled on a program-wide or service-specific basis, the services are already scheduled to be checked at an earlier time, etc. If you want to force the service checks to occur at the time you specify, look at the SCHEDULE_FORCED_HOST_SVC_CHECKS command.

pynag.Control.Command.schedule_host_svc_downtime(host_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for all services associated with a particular host. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The service downtime entries can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the services should not be triggered by another downtime entry.

pynag.Control.Command.schedule_hostgroup_host_downtime(hostgroup_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for all hosts in a specified hostgroup. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The host downtime entries can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the hosts should not be triggered by another downtime entry.

pynag.Control.Command.schedule_hostgroup_svc_downtime(hostgroup_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for all services associated with hosts in a specified servicegroup. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The service downtime entries can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the services should not be triggered by another downtime entry.

pynag.Control.Command.schedule_servicegroup_host_downtime(servicegroup_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for all hosts that have services in a specified servicegroup. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The host downtime entries can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the hosts should not be triggered by another downtime entry.

pynag.Control.Command.schedule_servicegroup_svc_downtime(servicegroup_name, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for all services in a specified servicegroup. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The service downtime entries can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the services should not be triggered by another downtime entry.

pynag.Control.Command.schedule_svc_check(host_name, service_description, check_time, command_file=None, timestamp=0)

Schedules the next active check of a specified service at “check_time”. The “check_time” argument is specified in time_t format (seconds since the UNIX epoch). Note that the service may not actually be checked at the time you specify. This could occur for a number of reasons: active checks are disabled on a program-wide or service-specific basis, the service is already scheduled to be checked at an earlier time, etc. If you want to force the service check to occur at the time you specify, look at the SCHEDULE_FORCED_SVC_CHECK command.

pynag.Control.Command.schedule_svc_downtime(host_name, service_description, start_time, end_time, fixed, trigger_id, duration, author, comment, command_file=None, timestamp=0)

Schedules downtime for a specified service. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The specified service downtime can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the specified service should not be triggered by another downtime entry.

pynag.Control.Command.send_command(command_id, command_file=None, timestamp=0, *args)

Send one specific command to the command pipe

Args:

command_id (str): Identifier string of the nagios command Eg: ADD_SVC_COMMENT

command_file (str): Path to nagios command file.

timestamp (int): Timestamp in time_t format of the time when the external command was sent to the command file. If 0 of None, it will be set to time.time(). Default 0.

args: Command arguments.

pynag.Control.Command.send_custom_host_notification(host_name, options, author, comment, command_file=None, timestamp=0)

Allows you to send a custom host notification. Very useful in dire situations, emergencies or to communicate with all admins that are responsible for a particular host. When the host notification is sent out, the $NOTIFICATIONTYPE$ macro will be set to “CUSTOM”. The <options> field is a logical OR of the following integer values that affect aspects of the notification that are sent out: 0 = No option (default), 1 = Broadcast (send notification to all normal and all escalated contacts for the host), 2 = Forced (notification is sent out regardless of current time, whether or not notifications are enabled, etc.), 4 = Increment current notification # for the host (this is not done by default for custom notifications). The comment field can be used with the $NOTIFICATIONCOMMENT$ macro in notification commands.

pynag.Control.Command.send_custom_svc_notification(host_name, service_description, options, author, comment, command_file=None, timestamp=0)

Allows you to send a custom service notification. Very useful in dire situations, emergencies or to communicate with all admins that are responsible for a particular service. When the service notification is sent out, the $NOTIFICATIONTYPE$ macro will be set to “CUSTOM”. The <options> field is a logical OR of the following integer values that affect aspects of the notification that are sent out: 0 = No option (default), 1 = Broadcast (send notification to all normal and all escalated contacts for the service), 2 = Forced (notification is sent out regardless of current time, whether or not notifications are enabled, etc.), 4 = Increment current notification # for the service(this is not done by default for custom notifications). The comment field can be used with the $NOTIFICATIONCOMMENT$ macro in notification commands.

pynag.Control.Command.set_host_notification_number(host_name, notification_number, command_file=None, timestamp=0)

Sets the current notification number for a particular host. A value of 0 indicates that no notification has yet been sent for the current host problem. Useful for forcing an escalation (based on notification number) or replicating notification information in redundant monitoring environments. Notification numbers greater than zero have no noticeable affect on the notification process if the host is currently in an UP state.

pynag.Control.Command.set_svc_notification_number(host_name, service_description, notification_number, command_file=None, timestamp=0)

Sets the current notification number for a particular service. A value of 0 indicates that no notification has yet been sent for the current service problem. Useful for forcing an escalation (based on notification number) or replicating notification information in redundant monitoring environments. Notification numbers greater than zero have no noticeable affect on the notification process if the service is currently in an OK state.

pynag.Control.Command.shutdown_program(command_file=None, timestamp=0)

Shuts down the Nagios process.

pynag.Control.Command.start_accepting_passive_host_checks(command_file=None, timestamp=0)

Enables acceptance and processing of passive host checks on a program-wide basis.

pynag.Control.Command.start_accepting_passive_svc_checks(command_file=None, timestamp=0)

Enables passive service checks on a program-wide basis.

pynag.Control.Command.start_executing_host_checks(command_file=None, timestamp=0)

Enables active host checks on a program-wide basis.

pynag.Control.Command.start_executing_svc_checks(command_file=None, timestamp=0)

Enables active checks of services on a program-wide basis.

pynag.Control.Command.start_obsessing_over_host(host_name, command_file=None, timestamp=0)

Enables processing of host checks via the OCHP command for the specified host.

pynag.Control.Command.start_obsessing_over_host_checks(command_file=None, timestamp=0)

Enables processing of host checks via the OCHP command on a program-wide basis.

pynag.Control.Command.start_obsessing_over_svc(host_name, service_description, command_file=None, timestamp=0)

Enables processing of service checks via the OCSP command for the specified service.

pynag.Control.Command.start_obsessing_over_svc_checks(command_file=None, timestamp=0)

Enables processing of service checks via the OCSP command on a program-wide basis.

pynag.Control.Command.stop_accepting_passive_host_checks(command_file=None, timestamp=0)

Disables acceptance and processing of passive host checks on a program-wide basis.

pynag.Control.Command.stop_accepting_passive_svc_checks(command_file=None, timestamp=0)

Disables passive service checks on a program-wide basis.

pynag.Control.Command.stop_executing_host_checks(command_file=None, timestamp=0)

Disables active host checks on a program-wide basis.

pynag.Control.Command.stop_executing_svc_checks(command_file=None, timestamp=0)

Disables active checks of services on a program-wide basis.

pynag.Control.Command.stop_obsessing_over_host(host_name, command_file=None, timestamp=0)

Disables processing of host checks via the OCHP command for the specified host.

pynag.Control.Command.stop_obsessing_over_host_checks(command_file=None, timestamp=0)

Disables processing of host checks via the OCHP command on a program-wide basis.

pynag.Control.Command.stop_obsessing_over_svc(host_name, service_description, command_file=None, timestamp=0)

Disables processing of service checks via the OCSP command for the specified service.

pynag.Control.Command.stop_obsessing_over_svc_checks(command_file=None, timestamp=0)

Disables processing of service checks via the OCSP command on a program-wide basis.