Puppet and Nagios: a Roadmap to Advanced Configuration
Listing 5. modules/nagios/manifests/resource/file.pp
define nagios::resource::file(
$resource_tag,
$requires,
$export = true,
$ensure = 'present',
) {
include nagios::params
if $export {
@@file { $name:
ensure => $ensure,
tag => $resource_tag,
owner => $nagios::params::user,
require => $requires,
}
} else {
file { $name:
ensure => $ensure,
tag => $resource_tag,
owner => $nagios::params::user,
require => $requires,
}
}
}
Listing 6. modules/nagios/manifests/resource/host.pp
define nagios::resource::host(
$address,
$hostgroups,
$export,
$target,
$check_command,
$use,
$ensure = 'present'
) {
include nagios::params
if $export {
@@nagios_host { $name:
ensure => $ensure,
address => $address,
check_command => $check_command,
use => $use,
target => $target,
hostgroups => $hostgroups ? {
'' => undef,
default => $hostgroups,
},
}
} else {
nagios_host { $name:
ensure => $ensure,
address => $address,
check_command => $check_command,
use => $use,
target => $target,
require => File[$nagios::params::resource_dir],
hostgroups => $hostgroups ? {
'' => undef,
default => $hostgroups,
},
}
}
}
Listing 7. modules/nagios/manifests/resource/hostgroup.pp
define nagios::resource::hostgroup(
$target,
$ensure = 'present',
$hostgroup_alias = '',
$export = false
) {
include nagios::params
if $export {
fail("It is not appropriate to export the Nagios_hostgroup
↪type since it will result in duplicate resources.")
} else {
nagios_hostgroup { $name:
ensure => $ensure,
target => $target,
require => File[$nagios::params::resource_dir],
}
}
}
Listing 8 shows our refactored nagios::export class that is meant to be used by all nodes. Notice how we no longer leverage the nagios_host type directly. Instead, we call upon our newly created nagios::resource definition. Both the address and hostgroups parameters will use sane defaults unless they are overridden with node scoped variables. Also, notice how the target parameter is no longer required, as our nagios::resource definition performs the heavy lifting for us.
Listing 8. modules/nagios/manifests/export.pp
# All agents (including the nagios server) will use this
class nagios::export {
nagios::resource { $::hostname:
type => 'host',
address => inline_template("<%= has_variable?('my_nagios_interface') ?
↪eval('ipaddress_' + my_nagios_interface) : ipaddress %>"),
hostgroups => inline_template("<%= has_variable?('my_nagios_hostgroups') ?
↪$my_nagios_hostgroups : 'Other' %>"),
check_command => 'check_host_alive!3000.0,80%!5000.0,100%!10',
export => true,
}
}
As you can see, the nagios::export class is ready to be extended with any kind of resource supported by our nagios::resource definition. Whenever we want all clients to export a particular resource, we just add it here so long as the following requirements are met:
-
The resource name must be unique.
-
The type parameter must be set.
-
The export parameter must be set to a value of true.
Now that all of our agents are exporting a nagios_host resource, we can focus on the collection side of things.
Tip: Short-and-Sweet Nagios Service Descriptions
Efficient Service Names in Nagios
When you get around to extending nagios::resource with support for the nagios_service type, you may want to consider using an inline ERB template to handle the service_description parameter. The following code removes the last word (which should be the hostname) from the description displayed in Nagios:
service_description => inline_template("<%= name.gsub(/\\w+$/,
↪'').chomp(' ') %>"),
Now, a resource defined with a unique title, such as "Puppet Agent $::hostname", is displayed as "Puppet Agent" in Nagios.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Developer Poll
- Dart: a New Web Programming Experience
- What's the tweeting protocol?
- New Products
- Thanks for taking the time to
1 hour 33 min ago - Linux is good
3 hours 31 min ago - Reply to comment | Linux Journal
3 hours 48 min ago - Web Hosting IQ
4 hours 18 min ago - Web Hosting IQ
4 hours 19 min ago - Web Hosting IQ
4 hours 19 min ago - Reply to comment | Linux Journal
7 hours 20 min ago - play with linux? i think you mean work-around linux
15 hours 46 min ago - Where is Epistle?
15 hours 52 min ago - You forgot OwnCloud
16 hours 22 min ago



Comments
Re:
purge logic is cumbersome... set recurse, purge, force on resource dir, and expire your nodes in puppet properly (puppet node clean/deactivate foo) and you'll achieve the same ACHO
file ownership is not a problem
"Before we begin, let's make sure we understand the most important problem—the issue of file ownership and permissions for the newly generated .cfg files. Because these files are created via the target parameter of each associated Nagios type, they'll be written to disk by the user Puppet runs as. This means they will be owned by the root user/group, and Nagios will not have permission to read them (because I know you are not running Nagios as root, correct?)."
I don't get this.
On a default Ubuntu 12.04 machine, Nagios3 runs as user nagios. All .cfg files are are owned by root. Nagios is just fine with that. Doesn't even complain in the logs about it.
Even if it weren't, couldn't I just chown nagios:nagios /etc/nagios3/conf.d and chmod g+s /etc/nagios3/conf.d? This would ensure all newly created files in /etc/nagios3/conf.d/ were owned by the nagios group, of which user nagios is a member.
I don't understand how the filepermissions are the 'most important problem' in this.
Turns out it's not so much
Turns out it's not so much the ownership that is the problem, but permissions. Puppet creates the files with a 0600 mode, making it unreadable for Nagios.
purge logic is cumbersome...
purge logic is cumbersome... set recurse, purge, force on resource dir, and expire your nodes in puppet properly (puppet node clean/deactivate foo) and you'll achieve the same.
Reply to comment | Linux Journal
I am no longer positive the place you are getting your information, but great topic.
I must spend some time finding out more or figuring out
more. Thanks for great info I used to be in search of this information for
my mission.
Reply to comment | Linux Journal
Thаnks fοr fіnally wrіtіng about >
Reply to comment | Linux Journal < Liked it!