Giuseppe Lavagetto has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172530

Change subject: monitoring: move monitor_host to monitoring::host
......................................................................

monitoring: move monitor_host to monitoring::host

Change-Id: I362dac76eb4d2d58d91c138a2b708396888ad721
Signed-off-by: Giuseppe Lavagetto <glavage...@wikimedia.org>
---
M manifests/dns.pp
M manifests/facilities.pp
M manifests/nagios.pp
M manifests/network.pp
M modules/authdns/manifests/monitoring/global.pp
M modules/base/manifests/monitoring/host.pp
M modules/icinga/manifests/gsbmonitoring.pp
M modules/icinga/manifests/monitor/wikidata.pp
M modules/icinga/manifests/naggen.pp
M modules/lvs/manifests/init.pp
A modules/monitoring/manifests/host.pp
11 files changed, 87 insertions(+), 86 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/30/172530/1

diff --git a/manifests/dns.pp b/manifests/dns.pp
index 3931eef..1c9a3ea 100644
--- a/manifests/dns.pp
+++ b/manifests/dns.pp
@@ -43,7 +43,7 @@
     }
 
     # Monitoring
-    monitor_host { $dns_auth_soa_name:
+    monitoring::host { $dns_auth_soa_name:
         ip_address => $dns_auth_ipaddress,
     }
     monitor_service { 'auth dns':
@@ -114,7 +114,7 @@
 
     define monitor() {
         # Monitoring
-        monitor_host { $title:
+        monitoring::host { $title:
             ip_address => $title,
         }
         monitor_service { "recursive dns ${title}":
diff --git a/manifests/facilities.pp b/manifests/facilities.pp
index 373b16d..2a1e07c 100644
--- a/manifests/facilities.pp
+++ b/manifests/facilities.pp
@@ -45,7 +45,7 @@
     $breaker  = '30',
     $redundant= true
 ) {
-    @monitor_host { $title:
+    @monitoring::host { $title:
         ip_address => $ip,
         group      => 'pdus',
     }
diff --git a/manifests/nagios.pp b/manifests/nagios.pp
index f7262e1..5e2fdc8 100644
--- a/manifests/nagios.pp
+++ b/manifests/nagios.pp
@@ -4,66 +4,6 @@
 
 $ganglia_url = 'http://ganglia.wikimedia.org'
 
-define monitor_host(
-    $ip_address    = $::ipaddress,
-    $group         = $nagios_group,
-    $ensure        = present,
-    $critical      = 'false',
-    $contact_group = 'admins'
-)
-{
-    if ! $ip_address {
-        fail("Parameter $ip_address not defined!")
-    }
-
-    # Determine the hostgroup:
-    # If defined in the declaration of resource, we use it;
-    # If not, adopt the standard format
-    $hostgroup = $group ? {
-        /.+/    => $group,
-        default => $cluster ? {
-            default => "${cluster}_${::site}"
-        }
-    }
-
-    # Export the nagios host instance
-    @@nagios_host { $title:
-        ensure               => $ensure,
-        target               => "${::nagios_config_dir}/puppet_hosts.cfg",
-        host_name            => $title,
-        address              => $ip_address,
-        hostgroups           => $hostgroup,
-        check_command        => 'check_ping!500,20%!2000,100%',
-        check_period         => '24x7',
-        max_check_attempts   => 2,
-        contact_groups       => $critical ? {
-            'true'  => 'admins,sms',
-            default => $contact_group,
-        },
-        notification_interval => 0,
-        notification_period   => '24x7',
-        notification_options  => 'd,u,r,f',
-    }
-
-    if $title == $::hostname {
-        $image = $::operatingsystem ? {
-            'Ubuntu'  => 'ubuntu',
-            default   => 'linux40'
-        }
-
-        # Couple it with some hostextinfo
-        @@nagios_hostextinfo { $title:
-            ensure          => $ensure,
-            target          => "${::nagios_config_dir}/puppet_hostextinfo.cfg",
-            host_name       => $title,
-            notes           => $title,
-            icon_image      => "${image}.png",
-            vrml_image      => "${image}.png",
-            statusmap_image => "${image}.gd2",
-        }
-    }
-}
-
 define monitor_service(
     $description,
     $check_command,
diff --git a/manifests/network.pp b/manifests/network.pp
index da2e937..2b1aa12 100644
--- a/manifests/network.pp
+++ b/manifests/network.pp
@@ -283,7 +283,7 @@
     ### ESAMS ###
 
     # cr1-esams
-    @monitor_host { 'cr1-esams':
+    @monitoring::host { 'cr1-esams':
         ip_address => '91.198.174.245',
         group      => 'routers',
     }
@@ -308,7 +308,7 @@
 #    }
 
     # cr2-knams
-    @monitor_host { 'cr2-knams':
+    @monitoring::host { 'cr2-knams':
         ip_address => '91.198.174.246',
         group      => 'routers',
     }
@@ -326,7 +326,7 @@
     }
 
     # mr1-esams
-    @monitor_host { 'mr1-esams':
+    @monitoring::host { 'mr1-esams':
         ip_address => '91.198.174.247',
         group      => 'routers'
     }
@@ -340,7 +340,7 @@
     ### EQIAD ###
 
     # cr1-eqiad
-    @monitor_host { 'cr1-eqiad':
+    @monitoring::host { 'cr1-eqiad':
         ip_address => '208.80.154.196',
         group      => 'routers',
     }
@@ -358,7 +358,7 @@
     }
 
     # cr2-eqiad
-    @monitor_host { 'cr2-eqiad':
+    @monitoring::host { 'cr2-eqiad':
         ip_address => '208.80.154.197',
         group      => 'routers',
     }
@@ -376,7 +376,7 @@
     }
 
     # mr1-eqiad
-    @monitor_host { 'mr1-eqiad':
+    @monitoring::host { 'mr1-eqiad':
         ip_address => '10.65.0.1',
         group      => 'routers',
     }
@@ -388,12 +388,12 @@
     }
 
     # NAS
-    @monitor_host { 'nas1001-a.eqiad.wmnet':
+    @monitoring::host { 'nas1001-a.eqiad.wmnet':
         ip_address => '10.64.16.4',
         group      => 'storage',
         critical   => true,
     }
-    @monitor_host { 'nas1001-b.eqiad.wmnet':
+    @monitoring::host { 'nas1001-b.eqiad.wmnet':
         ip_address => '10.64.16.5',
         group      => 'storage',
         critical   => true,
@@ -402,7 +402,7 @@
     ### ULSFO ###
 
     # cr1-ulsfo
-    @monitor_host { 'cr1-ulsfo':
+    @monitoring::host { 'cr1-ulsfo':
         ip_address => '198.35.26.192',
         group      => 'routers',
     }
@@ -420,7 +420,7 @@
     }
 
     # cr2-ulsfo
-    @monitor_host { 'cr2-ulsfo':
+    @monitoring::host { 'cr2-ulsfo':
         ip_address => '198.35.26.193',
         group      => 'routers',
     }
@@ -438,7 +438,7 @@
     }
 
     # mr1-ulsfo
-    @monitor_host { 'mr1-ulsfo':
+    @monitoring::host { 'mr1-ulsfo':
         ip_address => '10.128.128.1',
         group      => 'routers',
     }
@@ -452,7 +452,7 @@
     ### CODFW ###
 
     # cr1-codfw
-    @monitor_host { 'cr1-codfw':
+    @monitoring::host { 'cr1-codfw':
         ip_address => '208.80.153.192',
         group      => 'routers',
     }
@@ -470,7 +470,7 @@
     }
 
     # cr2-codfw
-    @monitor_host { 'cr2-codfw':
+    @monitoring::host { 'cr2-codfw':
         ip_address => '208.80.153.193',
         group      => 'routers',
     }
diff --git a/modules/authdns/manifests/monitoring/global.pp 
b/modules/authdns/manifests/monitoring/global.pp
index a4b0283..b60f9cc 100644
--- a/modules/authdns/manifests/monitoring/global.pp
+++ b/modules/authdns/manifests/monitoring/global.pp
@@ -10,7 +10,7 @@
 define authdns::monitoring::global($address, $prefixlen=undef) {
     $hostlabel = $title # just for semantic clarity below
 
-    @monitor_host { $hostlabel: ip_address => $address }
+    @monitoring::host { $hostlabel: ip_address => $address }
 
     @monitor_service { $hostlabel:
         host          => $hostlabel,
diff --git a/modules/base/manifests/monitoring/host.pp 
b/modules/base/manifests/monitoring/host.pp
index 7ec0748..7d622e0 100644
--- a/modules/base/manifests/monitoring/host.pp
+++ b/modules/base/manifests/monitoring/host.pp
@@ -19,7 +19,7 @@
 class base::monitoring::host($contact_group = 'admins') {
     include base::puppet::params # In order to be able to use some variables
 
-    monitor_host { $::hostname:
+    monitoring::host { $::hostname:
         contact_group => $contact_group
     }
     monitor_service { 'ssh':
diff --git a/modules/icinga/manifests/gsbmonitoring.pp 
b/modules/icinga/manifests/gsbmonitoring.pp
index 6db5cab..ff4a86e 100644
--- a/modules/icinga/manifests/gsbmonitoring.pp
+++ b/modules/icinga/manifests/gsbmonitoring.pp
@@ -1,5 +1,5 @@
 class icinga::gsbmonitoring {
-    @monitor_host { 'google':
+    @monitoring::host { 'google':
         ip_address => '74.125.225.84',
     }
 
diff --git a/modules/icinga/manifests/monitor/wikidata.pp 
b/modules/icinga/manifests/monitor/wikidata.pp
index 8715e6d..bb357b3 100644
--- a/modules/icinga/manifests/monitor/wikidata.pp
+++ b/modules/icinga/manifests/monitor/wikidata.pp
@@ -3,7 +3,7 @@
 # Monitor wikidata dispatch lag
 class icinga::monitor::wikidata {
 
-    @monitor_host { 'wikidata':
+    @monitoring::host { 'wikidata':
         ip_address => '91.198.174.192',
     }
 
diff --git a/modules/icinga/manifests/naggen.pp 
b/modules/icinga/manifests/naggen.pp
index d9f30ec..3fdbdcb 100644
--- a/modules/icinga/manifests/naggen.pp
+++ b/modules/icinga/manifests/naggen.pp
@@ -34,7 +34,7 @@
     Monitoring::Group <| |> {
         notify  => Service['icinga'],
     }
-    Monitor_host <| |> {
+    Monitoring::Host <| |> {
         notify  => Service['icinga'],
     }
     Monitor_service <| tag != 'nrpe' |> {
diff --git a/modules/lvs/manifests/init.pp b/modules/lvs/manifests/init.pp
index 143dcbf..5bb2404 100644
--- a/modules/lvs/manifests/init.pp
+++ b/modules/lvs/manifests/init.pp
@@ -2,26 +2,26 @@
 
 define lvs::monitor_service_custom ( $description="LVS", $ip_address, 
$port=80, $check_command, $retries=3 ) {
     # Virtual resource for the monitoring host
-    @monitor_host { $title: ip_address => $ip_address, group => "lvs", 
critical => "true" }
+    @monitoring::host { $title: ip_address => $ip_address, group => "lvs", 
critical => "true" }
     @monitor_service { $title: host => $title, group => "lvs", description => 
$description, check_command => $check_command, critical => "true", retries => 
$retries }
 }
 
 define lvs::monitor_service_http ( $ip_address, $check_command, 
$critical="true", $contact_group="admins" ) {
     # Virtual resource for the monitoring host
-    @monitor_host { $title: ip_address => $ip_address, group => "lvs", 
critical => "true", contact_group => $contact_group }
+    @monitoring::host { $title: ip_address => $ip_address, group => "lvs", 
critical => "true", contact_group => $contact_group }
     @monitor_service { $title: host => $title, group => "lvs", description => 
"LVS HTTP IPv4", check_command => $check_command, critical => $critical, 
contact_group => $contact_group }
 }
 
 define lvs::monitor_service_https ( $ip_address, $check_command, $port=443, 
$critical="true" ) {
     $title_https = "${title}_https"
     # Virtual resource for the monitoring host
-    @monitor_host { $title_https: ip_address => $ip_address, group => "lvs", 
critical => "true" }
+    @monitoring::host { $title_https: ip_address => $ip_address, group => 
"lvs", critical => "true" }
     @monitor_service { $title_https: host => $title, group => "lvs", 
description => "LVS HTTPS IPv4", check_command => $check_command, critical => 
$critical }
 }
 
 define lvs::monitor_service_http_https ( $ip_address, $uri, $critical="true", 
$contact_group="admins" ) {
     # Virtual resource for the monitoring host
-    @monitor_host { $title:
+    @monitoring::host { $title:
         ip_address => $ip_address,
         group => "lvs",
         critical => "true",
@@ -47,7 +47,7 @@
 
 define lvs::monitor_service6_http_https ( $ip_address, $uri, $critical="true" 
) {
     # Virtual resource for the monitoring host
-    @monitor_host { "${title}_ipv6":
+    @monitoring::host { "${title}_ipv6":
         ip_address => $ip_address,
         group => "lvs",
         critical => "true"
diff --git a/modules/monitoring/manifests/host.pp 
b/modules/monitoring/manifests/host.pp
new file mode 100644
index 0000000..8a7aaa7
--- /dev/null
+++ b/modules/monitoring/manifests/host.pp
@@ -0,0 +1,61 @@
+# === Define monitoring::host
+# Exports the resource that monitors hosts in icinga/shinken
+#
+define monitoring::host (
+    $ip_address = $::ipaddress,
+    $group         = $nagios_group,
+    $ensure        = present,
+    $critical      = 'false',
+    $contact_group = 'admins'
+    ) {
+    if ! $ip_address {
+        fail("Parameter $ip_address not defined!")
+    }
+
+    # Determine the hostgroup:
+    # If defined in the declaration of resource, we use it;
+    # If not, adopt the standard format
+    $hostgroup = $group ? {
+        /.+/    => $group,
+        default => $cluster ? {
+            default => "${cluster}_${::site}"
+        }
+    }
+
+    # Export the nagios host instance
+    @@nagios_host { $title:
+        ensure               => $ensure,
+        target               => "${::nagios_config_dir}/puppet_hosts.cfg",
+        host_name            => $title,
+        address              => $ip_address,
+        hostgroups           => $hostgroup,
+        check_command        => 'check_ping!500,20%!2000,100%',
+        check_period         => '24x7',
+        max_check_attempts   => 2,
+        contact_groups       => $critical ? {
+            'true'  => 'admins,sms',
+            default => $contact_group,
+        },
+        notification_interval => 0,
+        notification_period   => '24x7',
+        notification_options  => 'd,u,r,f',
+    }
+
+    if $title == $::hostname {
+        $image = $::operatingsystem ? {
+            'Ubuntu'  => 'ubuntu',
+            default   => 'linux40'
+        }
+
+        # Couple it with some hostextinfo
+        @@nagios_hostextinfo { $title:
+            ensure          => $ensure,
+            target          => "${::nagios_config_dir}/puppet_hostextinfo.cfg",
+            host_name       => $title,
+            notes           => $title,
+            icon_image      => "${image}.png",
+            vrml_image      => "${image}.png",
+            statusmap_image => "${image}.gd2",
+        }
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/172530
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I362dac76eb4d2d58d91c138a2b708396888ad721
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <glavage...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to