Skip to content

Commit a726356

Browse files
committed
nagios : Start a major low-level cleanup
1 parent 8430570 commit a726356

File tree

14 files changed

+338
-605
lines changed

14 files changed

+338
-605
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2012-05-23 - 0.2.0
2+
* Clean up the module to match current puppetlabs guidelines.
3+
* Add new params.pp and use it from nagios::client for Gentoo specifics.
4+
* Renamed checks.pp to defaultchecks.pp to be more explicit.
5+

LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (C) 2011 Matthias Saou
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+

Modulefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
name 'nagios'
2-
version '0.1.2'
1+
name 'thias-nagios'
2+
version '0.2.0'
3+
source 'git://github.com/thias/puppet-modules/modules/nagios'
4+
author 'Matthias Saou'
5+
license 'Apache 2.0'
6+
summary 'Nagios client and server module'
7+
description "Install and configure one or more nagios servers to monitor all of your puppet-managed nodes."
8+
project_page 'http://glee.thias.es/puppet'

README

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
= Summary
2-
3-
Summary:: Nagios server and client module
4-
Author:: Matthias Saou <[email protected]>
5-
License:: Apache License 2.0
6-
Updated:: February 2012
1+
nagios
72

83
= Requirements
94

10-
This module requires the apache-httpd and php modules for the server part,
5+
This module requires the apache_httpd and php modules for the server part,
116
though they can be disabled.
127

138
The plugin packages used for RHEL with selinux enabled should have the
149
libexecdir directory properly set to /usr/libexec in order to avoid selinux
1510
denials. Such packages can be found on http://dl.marmotte.net/rpms/
1611

12+
When SELinux is enforcing, the selinux::audit2allow definition is required
13+
to allow some basic nagios/nrpe accesses, though it can also be disabled.
14+
1715
= Sample Usage
1816

1917
Nagios server instance (node specific) :
@@ -34,23 +32,25 @@ Nagios server instance (node specific) :
3432

3533
Nagios client instances (from site.pp) :
3634

37-
if ( $operatingsystem == 'Gentoo' ) {
38-
class { 'nagios::client':
39-
nrpe_pid_file => '/var/run/nrpe/nrpe.pid',
40-
nrpe_user => 'nagios',
41-
nrpe_group => 'nagios',
42-
nrpe_allowed_hosts => '127.0.0.1,192.168.1.1',
43-
}
44-
Nagios::Client::Nrpe {
45-
plugin_dir => '/usr/lib64/nagios/plugins',
46-
}
35+
class { 'nagios::client':
36+
nrpe_allowed_hosts => '127.0.0.1,192.168.1.1',
4737
}
4838

49-
Nagios client specific overrides :
39+
Nagios client specific overrides (see var.pp for the list) :
5040

5141
nagios::client::config { 'host_address': value => $ipaddress_eth2 }
5242

43+
Nagios client check configuration examples :
44+
45+
nagios::client::config { 'check_ram_ensure': value => 'absent' }
46+
nagios::client::config { 'check_cpu_args': value => '-w 50 -c 20' }
47+
48+
Global disabling of a default check :
49+
50+
Nagios::Check::Swap { ensure => absent }
51+
5352
Debug any startup or configuration problems on the server with :
53+
5454
nagios -v /etc/nagios/nagios.cfg
5555

5656
To enable nagiosgraph on the server :
@@ -74,6 +74,14 @@ To enable nagiosgraph on the server :
7474
To enable nagiosgraph for the client's services in the server web interface :
7575

7676
class { 'nagios::client':
77-
nagios_service_use => 'generic-service,nagiosgraph-service',
77+
service_use => 'generic-service,nagiosgraph-service',
7878
}
7979

80+
81+
Notes :
82+
Client overrides should be done in this order :
83+
* For all services on some nodes : Using nagios::client service_* parameters
84+
* For all services on a node : Using the nagios::client host_* parameters
85+
* For specific services on all nodes : Using Nagios::Check::Foo { paramname => 'value' }
86+
* For specific services on a node : Using nagios::client::config { 'check_foo_ensure': value => 'absent' }
87+

manifests/check/cpu.pp

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
1-
define nagios::check::cpu ( $args = '' ) {
1+
define nagios::check::cpu (
2+
$args = $::nagios_check_cpu_args,
3+
$servicegroups = $::nagios_check_cpu_servicegroups,
4+
$check_period = $::nagios_check_cpu_check_period,
5+
$max_check_attempts = $::nagios_check_cpu_max_check_attempts,
6+
$notification_period = $::nagios_check_cpu_notification_period,
7+
$use = $::nagios_check_cpu_use,
8+
$ensure = $::nagios_check_cpu_ensure
9+
) {
210

3-
# Generic overrides
4-
if $::nagios_check_cpu_check_period != '' {
5-
Nagios_service { check_period => $::nagios_check_cpu_check_period }
6-
}
7-
if $::nagios_check_cpu_notification_period != '' {
8-
Nagios_service { notification_period => $::nagios_check_cpu_notification_period }
9-
}
10-
if $::nagios_check_cpu_max_check_attempts != '' {
11-
Nagios_service { max_check_attempts => $::nagios_check_cpu_max_check_attempts }
12-
}
13-
14-
# Service specific overrides
15-
if $::nagios_check_cpu_warning != '' {
16-
$warning = $::nagios_check_cpu_warning
17-
} else {
18-
$warning = '10'
19-
}
20-
if $::nagios_check_cpu_critical != '' {
21-
$critical = $::nagios_check_cpu_critical
22-
} else {
23-
$critical = '5'
24-
}
25-
26-
file { "${nagios::client::plugin_dir}/check_cpu":
11+
# Service specific script
12+
file { "${nagios::params::plugin_dir}/check_cpu":
2713
owner => 'root',
2814
group => 'root',
2915
mode => '0755',
3016
content => template('nagios/plugins/check_cpu'),
3117
ensure => $ensure,
3218
}
33-
3419
nagios::client::nrpe { 'check_cpu':
35-
args => "-w ${warning} -c ${critical} ${args}",
20+
args => $args ? { '' => '-w 10 -c 5', default => $args },
21+
ensure => $ensure,
3622
}
3723

38-
@@nagios_service { "check_cpu_${title}":
24+
nagios::service { "check_cpu_${title}":
3925
check_command => 'check_nrpe_cpu',
4026
service_description => 'cpu',
41-
#servicegroups => 'cpu',
42-
tag => "nagios-${nagios::var::server}",
27+
servicegroups => $servicegroups,
28+
check_period => $check_period,
29+
max_check_attempts => $max_check_attempts,
30+
notification_period => $notification_period,
31+
use => $use,
32+
ensure => $ensure,
4333
}
4434

35+
/*
36+
@@nagios_service { "check_cpu_${title}":
37+
host_name => $title,
38+
check_command => 'check_nrpe_cpu',
39+
service_description => 'cpu',
40+
servicegroups => $servicegroups,
41+
# Support an arrays of tags for multiple nagios servers
42+
tag => regsubst($nagios::var::server,'^(.+)$','nagios-\1'),
43+
check_period => $::nagios_check_cpu_check_period,
44+
notification_period => $::nagios_check_cpu_notification_period,
45+
max_check_attempts => $::nagios_check_cpu_max_check_attempts,
46+
ensure => $ensure,
47+
}
48+
*/
49+
4550
}
4651

0 commit comments

Comments
 (0)