summaryrefslogtreecommitdiff
path: root/puppet/modules/site_nagios/manifests
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-01-28 16:54:22 +0100
committervarac <varacanero@zeromail.org>2013-01-28 16:54:22 +0100
commitb9dc3194a6023c65cc78988dfc4cf546ba658eac (patch)
treea4675bfdc96dc48caf86b8bae80c3d8c7b4eb630 /puppet/modules/site_nagios/manifests
parent00252d3e425bb385135faf6bda4c462bcce75e59 (diff)
parentf34cecba90941f3e4acbe88cab6ce0b5a76b8ce2 (diff)
Merge branch 'feature/monitoring' into develop
Diffstat (limited to 'puppet/modules/site_nagios/manifests')
-rw-r--r--puppet/modules/site_nagios/manifests/add_host.pp29
-rw-r--r--puppet/modules/site_nagios/manifests/add_service.pp22
-rw-r--r--puppet/modules/site_nagios/manifests/server.pp25
3 files changed, 76 insertions, 0 deletions
diff --git a/puppet/modules/site_nagios/manifests/add_host.pp b/puppet/modules/site_nagios/manifests/add_host.pp
new file mode 100644
index 00000000..d5aac67c
--- /dev/null
+++ b/puppet/modules/site_nagios/manifests/add_host.pp
@@ -0,0 +1,29 @@
+define site_nagios::add_host {
+ $nagios_host = $name
+ $nagios_hostname = $name['domain_full']
+ $nagios_ip = $name['ip_address']
+ $nagios_services = $name['services']
+
+ # Add Nagios host
+ nagios_host { $nagios_hostname:
+ address => $nagios_ip,
+ use => 'generic-host',
+ }
+
+ # Add Nagios service
+
+ # First, we need to turn the serice array into hash, using a "hash template"
+ # see https://github.com/ashak/puppet-resource-looping
+ $nagios_service_hashpart = {
+ 'hostname' => $nagios_hostname,
+ 'ip_address' => $nagios_ip,
+ }
+ $dynamic_parameters = {
+ 'service' => '%s'
+ }
+ $nagios_servicename = "${nagios_hostname}_%s"
+
+ $nagios_service_hash = create_resources_hash_from($nagios_servicename, $nagios_services, $nagios_service_hashpart, $dynamic_parameters)
+
+ create_resources ( site_nagios::add_service, $nagios_service_hash )
+}
diff --git a/puppet/modules/site_nagios/manifests/add_service.pp b/puppet/modules/site_nagios/manifests/add_service.pp
new file mode 100644
index 00000000..5b282ac4
--- /dev/null
+++ b/puppet/modules/site_nagios/manifests/add_service.pp
@@ -0,0 +1,22 @@
+define site_nagios::add_service ($hostname, $ip_address, $service) {
+
+ case $service {
+ #'openvpn': {
+ # $check_command = "check_openvpn_server_ip_port!$ip_address!1194"
+ # $service_description = 'Openvpn'
+ #}
+ 'webapp': {
+ $check_command = 'check_https'
+ $service_description = 'Website'
+ }
+ default: { notice ("No Nagios service check for service \"$service\"") }
+ }
+
+ if ( $check_command != '' ) {
+ nagios_service { $name:
+ use => 'generic-service',
+ check_command => $check_command,
+ service_description => $service_description,
+ host_name => $hostname }
+ }
+}
diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp
new file mode 100644
index 00000000..fe3ab542
--- /dev/null
+++ b/puppet/modules/site_nagios/manifests/server.pp
@@ -0,0 +1,25 @@
+class site_nagios::server {
+
+ $nagios_hiera=hiera('nagios')
+ $nagiosadmin_pw = $nagios_hiera['nagiosadmin_pw']
+ $hosts = $nagios_hiera['hosts']
+
+ include nagios::defaults
+ include nagios::base
+ #Class ['nagios'] -> Class ['nagios::defaults']
+ class {'nagios::apache':
+ allow_external_cmd => true,
+ stored_config => false,
+ #before => Class ['nagios::defaults']
+ }
+
+ # deploy serverside plugins
+ file { '/usr/lib/nagios/plugins/check_openvpn_server.pl':
+ source => 'puppet:///modules/nagios/plugins/check_openvpn_server.pl',
+ mode => '0755',
+ owner => 'nagios',
+ group => 'nagios',
+ }
+
+ site_nagios::add_host {$hosts:}
+}