On this page
nagios - Perform common tasks in Nagios related to downtime and notifications.
Synopsis
- The
nagios
module has two basic functions: scheduling downtime and toggling alerts for services or hosts. - All actions require the host parameter to be given explicitly. In playbooks you can use the
{{inventory_hostname}}
variable to refer to the host the playbook is currently running on. - You can specify multiple services at once by separating them with commas, .e.g.,
services=httpd,nfs,puppet
. - When specifying what service to handle there is a special service value, host, which will handle alerts/downtime for the host itself, e.g.,
service=host
. This keyword may not be given with other services at the same time. Setting alerts/downtime for a host does not affect alerts/downtime for any of the services running on it. To schedule downtime for all services on particular host use keyword “all”, e.g.,service=all
. - When using the
nagios
module you will need to specify your Nagios server using thedelegate_to
parameter.
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
action |
yes |
|
Action to take.
servicegroup options were added in 2.0.
delete_downtime options were added in 2.2.
|
|
author |
no | Ansible |
Author to leave downtime comments as. Only usable with the downtime action.
|
|
cmdfile |
no | auto-detected |
Path to the nagios command file (FIFO pipe). Only required if auto-detection fails.
|
|
command |
yes |
The raw command to send to nagios, which should not include the submitted time header or the line-feed Required option when using the command action.
|
||
comment
(added in 2.0)
|
no | Scheduling downtime |
Comment for downtime action.
|
|
host |
no |
Host to operate on in Nagios.
|
||
minutes |
no | 30 |
Minutes to schedule downtime for.
Only usable with the downtime action.
|
|
servicegroup
(added in 2.0)
|
no |
The Servicegroup we want to set downtimes/alerts for. Required option when using the servicegroup_service_downtime amd servicegroup_host_downtime .
|
||
services |
yes |
What to manage downtime/alerts for. Separate multiple services with commas.
service is an alias for services . Required option when using the downtime , enable_alerts , and disable_alerts actions.
aliases: service
|
Examples
# set 30 minutes of apache downtime
- nagios:
action: downtime
minutes: 30
service: httpd
host: '{{ inventory_hostname }}'
# schedule an hour of HOST downtime
- nagios:
action: downtime
minutes: 60
service: host
host: '{{ inventory_hostname }}'
# schedule an hour of HOST downtime, with a comment describing the reason
- nagios:
action: downtime
minutes: 60
service: host
host: '{{ inventory_hostname }}'
comment: Rebuilding machine
# schedule downtime for ALL services on HOST
- nagios:
action: downtime
minutes: 45
service: all
host: '{{ inventory_hostname }}'
# schedule downtime for a few services
- nagios:
action: downtime
services: frob,foobar,qeuz
host: '{{ inventory_hostname }}'
# set 30 minutes downtime for all services in servicegroup foo
- nagios:
action: servicegroup_service_downtime
minutes: 30
servicegroup: foo
host: '{{ inventory_hostname }}'
# set 30 minutes downtime for all host in servicegroup foo
- nagios:
action: servicegroup_host_downtime
minutes: 30
servicegroup: foo
host: '{{ inventory_hostname }}'
# delete all downtime for a given host
- nagios:
action: delete_downtime
host: '{{ inventory_hostname }}'
service: all
# delete all downtime for HOST with a particular comment
- nagios:
action: delete_downtime
host: '{{ inventory_hostname }}'
service: host
comment: Planned maintenance
# enable SMART disk alerts
- nagios:
action: enable_alerts
service: smart
host: '{{ inventory_hostname }}'
# "two services at once: disable httpd and nfs alerts"
- nagios:
action: disable_alerts
service: httpd,nfs
host: '{{ inventory_hostname }}'
# disable HOST alerts
- nagios:
action: disable_alerts
service: host
host: '{{ inventory_hostname }}'
# silence ALL alerts
- nagios:
action: silence
host: '{{ inventory_hostname }}'
# unsilence all alerts
- nagios:
action: unsilence
host: '{{ inventory_hostname }}'
# SHUT UP NAGIOS
- nagios:
action: silence_nagios
# ANNOY ME NAGIOS
- nagios:
action: unsilence_nagios
# command something
- nagios:
action: command
command: DISABLE_FAILURE_PREDICTION
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/nagios_module.html