Adoptable Cookbooks List

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

node['nagios']['multi_environment_monitoring'] - Chef server will monitor hosts in all environments, not just its own, default 'false'

client

The following attributes are used for the client NRPE checks for warning and critical levels.

node['nagios']['client']['install_method'] - whether to install from package or source. Default chosen by platform based on known packages available for Nagios 3: debian/ubuntu 'package', redhat/centos/fedora/scientific: source

node['nagios']['checks']['smtp_host'] - default relayhost to check for connectivity. Default is an empty string, set via an attribute in a role.

node['nagios']['server_role'] - the role that the nagios server will have in its run list that the clients can search for.

server

Default directory locations are based on FHS. Change to suit your preferences.

node['nagios']['server']['install_method'] - whether to install from package or source. Default chosen by platform based on known packages available for Nagios 3: debian/ubuntu 'package', redhat/centos/fedora/scientific: source

node['nagios']['server']['service_name'] - name of the service used for nagios, default chosen by platform, debian/ubuntu "nagios3", redhat family "nagios", all others, "nagios"

node['nagios']['server_auth_method'] - authentication with the server can be done with openid (using apache2::mod_auth_openid), or htauth (basic). The default is openid, any other value will use htauth (basic).

node['nagios']['templates']

node['nagios']['interval_length'] - minimum interval.

node['nagios']['default_host']['check_interval']

node['nagios']['default_host']['retry_interval']

node['nagios']['default_host']['max_check_attempts']

node['nagios']['default_host']['notification_interval']

node['nagios']['default_service']['check_interval']

node['nagios']['default_service']['retry_interval']

node['nagios']['default_service']['max_check_attempts']

node['nagios']['default_service']['notification_interval']

Recipes

default

Includes the nagios::client recipe.

client

Includes the correct client installation recipe based on platform, either nagios::client_package or nagios::client_source.

The client recipe searches for servers allowed to connect via NRPE that have a role named in the node['nagios']['server_role'] attribute. The recipe will also install the required packages and start the NRPE service. A custom plugin for checking memory is also added.

Searches are confined to the node's chef_environment.

Client commands for NRPE can be installed using the nrpecheck resource. (See Resources/Providers below.)

client_package

client_source

Installs the Nagios client libraries from source. Default for Red Hat / CentOS / Fedora systems as native packages of Nagios 3 are not available in the default repositories.

server

Includes the correct client installation recipe based on platform, either nagios::server_package or nagios::server_source.

The server recipe sets up Apache as the web front end. The nagios::client recipe is also included. This recipe also does a number of searches to dynamically build the hostgroups to monitor, hosts that belong to them and admins to notify of events/alerts.

Searches are confined to the node's chef_environment.

The recipe does the following:

Searches for members of the sysadmins group by searching through 'users' data bag and adds them to a list for notification/contacts.

Search all nodes for a role matching the app_environment.

Search all available roles and build a list which will be the Nagios hostgroups.

Search for all nodes of each role and add the hostnames to the hostgroups.

Installs various packages required for the server.

Sets up some configuration directories.

Moves the package-installed Nagios configuration to a 'dist' directory.

Sets up the configuration templates for services, contacts, hostgroups and hosts.

NOTE: You will probably need to change the services.cfg.erb template for your environment.

To add custom commands for service checks, these can be done on a per-role basis by editing the 'services.cfg.erb' template. This template has some pre-configured checks that use role names used in an example infrastructure. Here's a brief description:

server_package

server_source

Installs the Nagios server libraries from source. Default for Red Hat / CentOS / Fedora systems as native packages of Nagios 3 are not available in the default repositories.

pagerduty

Installs and configures pagerduty plugin for nagios. You need to set a node['nagios']['pagerduty_key'] attribute on your server for this to work. This can be set through environments so that you can use different API keys for servers in production vs staging for instance.

This recipe was written based on the Nagios Integration Guide from PagerDuty which explains how to get an API key for your nagios server.

email notifications

You need to set default['nagios']['notifications_enabled'] = 1 attribute on your nagios server to enable email notifications.

For email notifications to work an appropriate mail program package and local MTA need to be installed so that /usr/bin/mail or /bin/mail is available on the system.

Data Bags

Users

Create a users data bag that will contain the users that will be able to log into the Nagios webui. Each user can use htauth with a specified password, or an openid. Users that should be able to log in should be in the sysadmin group. Example user data bag item:

When using server_auth_method 'openid', use the openid in the data bag item. Any other value for this attribute (e.g., "htauth", "htpasswd", etc) will use the htpasswd value as the password in /etc/nagios3/htpasswd.users.

The openid must have the http:// and trailing /. The htpasswd must be the hashed value. Get this value with htpasswd:

For example use the {SHA}oCagzV4lMZyS7jl2Z0WlmLxEkt4= value in the data bag.

Services

Create a nagios_services data bag that will contain definitions for services to be monitored. This allows you to add monitoring rules without mucking about in the services and commands templates. Each service will be named based on the id of the data bag and the command will be named withe the same id prepended with "check_". Just make sure the id in your data bag doesn't conflict with a service or command already defined in the templates.

Here's an example of a service check for sshd that you could apply to all hostgroups:

You may optionally define the service template for your service by including service_template and a valid template name. Example: "service_template": "special_service_template". You may also optionally add a service description that will be displayed in the Nagios UI using "description": "My Service Name". If this is not present the databag name will be used.

Templates

Templates are optional, but allow you to specify combinations of attributes to apply to a service. Create a nagios_templates\ data bag that will contain definitions for templates to be used. Each template need only specify id and whichever parameters you want to override.

Here's an example of a template that reduces the check frequency to once per day and changes the retry interval to 1 hour.

Search Defined Hostgroups

Create a nagios_hostgroups data bag that will contain definitions for Nagios hostgroups populated via search. These data bags include a Chef node search query that will populate the Nagios hostgroup with nodes based on the search.

Here's an example to find all HP hardware systems for an "hp_systems" hostgroup:

Monitoring Systems Not In Chef

Create a nagios_unmanagedhosts data bag that will contain definitions for hosts not in Chef that you would like to manage. "hostgroups" can be an existing Chef role (every Chef role gets a Nagios hostgroup) or a new hostgroup.
Here's an example host definition:

Event Handlers

You can optionally define event handlers to trigger on service alerts by creating a nagios_eventhandlers data bag that will contain definitions of event handlers for services monitored via Nagios.

This example event handler data bags restarts chef-client. Note: This assumes you have already defined a NRPE job restart_chef-client on the host where this command will run. You can use the NRPE LWRP to add commands to your local NRPE configs from within your cookbooks.

Environments

The searches used are confined to the node's chef_environment. If you do not use any environments (Chef 0.10+ feature) the _default environment is used, which is applied to all nodes in the Chef Server that are not in another defined role. To use environments, create them as files in your chef-repo, then upload them to the Chef Server.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.