nagios cookbook
May 20, 2026 ยท View on GitHub
Installs and configures a Nagios Core server using Chef Infra custom resources. Chef nodes can be discovered with search, and Nagios object files can be rendered from resources or data bags.
Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. To learn more, visit sous-chefs.org or join the Chef Community Slack in #sous-chefs.
Requirements
Chef
Chef Infra Client 15.3 or later is required.
This cookbook relies on Chef search for automatic user and node discovery, so those features require Chef Infra Server. Chef Solo users can still use the object resources directly, but should not enable search-backed default or data bag configuration.
Platforms
- AlmaLinux 8+
- CentOS Stream 9+
- Debian 12+
- Fedora
- Oracle Linux 8+
- Red Hat Enterprise Linux 8+
- Rocky Linux 8+
- Ubuntu 22.04+
See LIMITATIONS.md for platform and package-source notes.
Cookbooks
- apache2
- build-essential
- nginx
- php
- yum-epel
- zap
Usage
Add nagios_server to a wrapper cookbook recipe:
nagios_server 'default' do
server_auth_method 'htauth'
end
The server resource installs Nagios, configures Apache by default, searches for admin users in the users data bag with the sysadmin group, renders Nagios configuration files, and enables the Nagios service.
To use NGINX instead of Apache:
nagios_server 'default' do
web_server 'nginx'
stop_apache true
end
To install from source:
nagios_server 'default' do
install_method 'source'
source_version '4.4.6'
source_checksum 'ab0d5a52caf01e6f4dcd84252c4eb5df5a24f90bb7f951f03875eef54f5ab0f4'
end
To use a custom Nagios main configuration template:
nagios_server 'default' do
nagios_config_template_cookbook 'my_monitoring'
nagios_config_template_file 'nagios.cfg.erb'
end
To create Nagios objects directly:
nagios_host 'web01' do
options(
'address' => '192.0.2.10',
'use' => 'server'
)
end
nagios_service 'http-web01' do
options(
'host_name' => 'web01',
'service_description' => 'HTTP',
'check_command' => 'check_http'
)
end
The previous nagios::default, nagios::server_package, nagios::server_source, nagios::apache, nagios::nginx, and nagios::pagerduty recipes have been removed. See migration.md for the recipe-to-resource mapping.
Resources
- nagios_server
- nagios_install
- nagios_configure
- nagios_apache
- nagios_nginx
- nagios_default_config
- nagios_data_bag_config
- nagios_pagerduty
- nagios_conf
- Nagios object resources
Data Bags
The server resource searches the users data bag for users in the configured admin group. A minimal item looks like:
{
"id": "alice",
"groups": ["sysadmin"],
"nagios": {
"email": "alice@example.com",
"pager": "alice-sms@example.com"
}
}
Additional object data bags can be loaded by nagios_data_bag_config or by enabling load_databag_config on nagios_server. The default bag names are exposed as nagios_server properties.
PagerDuty contacts can be declared with nagios_pagerduty:
nagios_pagerduty 'default' do
key 'pagerduty-service-key'
end
Multiple PagerDuty contacts can also be loaded from the nagios_pagerduty data bag.
Monitoring Role
The system running the Nagios server should have a role matching the value used by NRPE clients, typically monitoring.
name 'monitoring'
description 'Monitoring server'
run_list 'recipe[my_monitoring::nagios]'
Apply the nrpe cookbook to monitored nodes so NRPE checks are available to Nagios.
Notifications
Set the config property to enable Nagios notifications:
nagios_server 'default' do
config(
'enable_notifications' => 1
)
end
Email notifications require a local mail program and MTA so /usr/bin/mail or /bin/mail is available.
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers!
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.