Faidon Liambotis has uploaded a new change for review.

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

Change subject: netops: abstract monitoring checks into a define
......................................................................

netops: abstract monitoring checks into a define

netops::monitoring hasn't been very DRY, which makes things like adding
checks (or even reading the code) a PITA. Abstract the monitoring
definitions into a netops::check define and call create_resources from
the main class.

Change-Id: Ica471beda4fdf0134b5af027d857fe4961a70ca8
---
A modules/netops/manifests/check.pp
M modules/netops/manifests/monitoring.pp
2 files changed, 84 insertions(+), 272 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/66/281466/1

diff --git a/modules/netops/manifests/check.pp 
b/modules/netops/manifests/check.pp
new file mode 100644
index 0000000..7c7e308
--- /dev/null
+++ b/modules/netops/manifests/check.pp
@@ -0,0 +1,54 @@
+# == Define: netops::check
+#
+# Sets up various monitoring checks for a given networking device.
+#
+# === Parameters
+#
+# [*ipv4*]
+#   The IPv4 address of the device.
+#
+# [*snmp_community*]
+#   The SNMP community to use to poll the device
+#
+# [*interfaces*]
+#   Whether to perform interface status checks. Defaults to false.
+#
+# [*bgp*]
+#   Whether to perform BGP checks. Defaults to false.
+#
+# === Examples
+#
+#  netops::check { 'cr1-esams':
+#      ipv4 => '91.198.174.245',
+#      bgp  => true,
+#  }
+
+define netops::check(
+    $ipv4,
+    $snmp_community,
+    $bgp=false,
+    $interfaces=false,
+) {
+    @monitoring::host { $title:
+        ip_address => $ipv4,
+        group      => 'routers',
+    }
+
+    if $interfaces {
+        @monitoring::service { "${title} interfaces":
+            host          => $title,
+            group         => 'routers',
+            description   => 'Router interfaces',
+            check_command => "check_ifstatus_nomon!${snmp_community}",
+        }
+    }
+
+    if $bgp {
+        @monitoring::service { "${title} BGP status":
+            host          => $title,
+            group         => 'routers',
+            description   => 'BGP status',
+            check_command => "check_bgp!${snmp_community}",
+        }
+    }
+}
diff --git a/modules/netops/manifests/monitoring.pp 
b/modules/netops/manifests/monitoring.pp
index abc141c..c30cd47 100644
--- a/modules/netops/manifests/monitoring.pp
+++ b/modules/netops/manifests/monitoring.pp
@@ -11,279 +11,37 @@
 class netops::monitoring {
 
     include passwords::network
-    $snmp_ro_community = $passwords::network::snmp_ro_community
 
-    ### esams ###
-
-    # cr1-esams
-    @monitoring::host { 'cr1-esams':
-        ip_address => '91.198.174.245',
-        group      => 'routers',
+    $defaults = {
+        snmp_community => $passwords::network::snmp_ro_community,
+        interfaces     => true,
     }
-    @monitoring::service { 'cr1-esams interfaces':
-        host          => 'cr1-esams',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
+    $routers = {
+        # eqiad
+        'cr1-eqiad'     => { ipv4 => '208.80.154.196', bgp => true, },
+        'cr2-eqiad'     => { ipv4 => '208.80.154.197', bgp => true, },
+        'mr1-eqiad'     => { ipv4 => '208.80.154.199', },
+        'mr1-eqiad.oob' => { ipv4 => '198.32.107.153', },
+        # eqord
+        'cr1-eqord'     => { ipv4 => '208.80.154.198', bgp => true, },
+        # codfw
+        'cr1-codfw'     => { ipv4 => '208.80.153.192', bgp => true, },
+        'cr2-codfw'     => { ipv4 => '208.80.153.193', bgp => true, },
+        'mr1-codfw'     => { ipv4 => '208.80.153.196', },
+        'mr1-codfw.oob' => { ipv4 => '216.117.46.36',  },
+        # eqdfw
+        'cr1-eqdfw'     => { ipv4 => '208.80.153.198', bgp => true, },
+        # esams
+        'cr1-esams'     => { ipv4 => '91.198.174.245', bgp => true, },
+        'cr2-esams'     => { ipv4 => '91.198.174.244', bgp => true, },
+        'cr2-knams'     => { ipv4 => '91.198.174.246', bgp => true, },
+        'mr1-esams'     => { ipv4 => '91.198.174.247', },
+        'mr1-esams.oob' => { ipv4 => '164.138.24.90',  },
+        # ulsfo
+        'cr1-ulsfo'     => { ipv4 => '198.35.26.192', bgp => true, },
+        'cr2-ulsfo'     => { ipv4 => '198.35.26.193', bgp => true, },
+        'mr1-ulsfo'     => { ipv4 => '198.35.26.194',   },
+        'mr1-ulsfo.oob' => { ipv4 => '209.237.234.242', },
     }
-    @monitoring::service { 'cr1-esams bgp status':
-        host          => 'cr1-esams',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # cr2-esams
-    @monitoring::host { 'cr2-esams':
-        ip_address => '91.198.174.244',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr2-esams interfaces':
-        host          => 'cr2-esams',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr2-esams bgp status':
-        host          => 'cr2-esams',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # cr2-knams
-    @monitoring::host { 'cr2-knams':
-        ip_address => '91.198.174.246',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr2-knams interfaces':
-        host          => 'cr2-knams',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr2-knams bgp status':
-        host          => 'cr2-knams',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # mr1-esams
-    @monitoring::host { 'mr1-esams':
-        ip_address => '91.198.174.247',
-        group      => 'routers'
-    }
-    @monitoring::service { 'mr1-esams interfaces':
-        host          => 'mr1-esams',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::host { 'mr1-esams.oob':
-        host_fqdn => 'mr1-esams.oob.wikimedia.org',
-        group     => 'routers'
-    }
-
-    ### eqiad ###
-
-    # cr1-eqiad
-    @monitoring::host { 'cr1-eqiad':
-        ip_address => '208.80.154.196',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr1-eqiad interfaces':
-        host          => 'cr1-eqiad',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr1-eqiad bgp status':
-        host          => 'cr1-eqiad',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # cr2-eqiad
-    @monitoring::host { 'cr2-eqiad':
-        ip_address => '208.80.154.197',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr2-eqiad interfaces':
-        host          => 'cr2-eqiad',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr2-eqiad bgp status':
-        host          => 'cr2-eqiad',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # mr1-eqiad
-    @monitoring::host { 'mr1-eqiad':
-        ip_address => '208.80.154.199',
-        group      => 'routers',
-    }
-    @monitoring::service { 'mr1-eqiad interfaces':
-        host          => 'mr1-eqiad',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::host { 'mr1-eqiad.oob':
-        host_fqdn => 'mr1-eqiad.oob.wikimedia.org',
-        group     => 'routers'
-    }
-
-    ### eqord ###
-
-    # cr1-eqord
-    @monitoring::host { 'cr1-eqord':
-        ip_address => '208.80.154.198',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr1-eqord interfaces':
-        host          => 'cr1-eqord',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr1-eqord bgp status':
-        host          => 'cr1-eqord',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    ### ulsfo ###
-
-    # cr1-ulsfo
-    @monitoring::host { 'cr1-ulsfo':
-        ip_address => '198.35.26.192',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr1-ulsfo interfaces':
-        host          => 'cr1-ulsfo',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr1-ulsfo bgp status':
-        host          => 'cr1-ulsfo',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # cr2-ulsfo
-    @monitoring::host { 'cr2-ulsfo':
-        ip_address => '198.35.26.193',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr2-ulsfo interfaces':
-        host          => 'cr2-ulsfo',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr2-ulsfo bgp status':
-        host          => 'cr2-ulsfo',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # mr1-ulsfo
-    @monitoring::host { 'mr1-ulsfo':
-        ip_address => '198.35.26.194',
-        group      => 'routers',
-    }
-    @monitoring::service { 'mr1-ulsfo interfaces':
-        host          => 'mr1-ulsfo',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::host { 'mr1-ulsfo.oob':
-        host_fqdn => 'mr1-ulsfo.oob.wikimedia.org',
-        group     => 'routers'
-    }
-
-    ### codfw ###
-
-    # cr1-codfw
-    @monitoring::host { 'cr1-codfw':
-        ip_address => '208.80.153.192',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr1-codfw interfaces':
-        host          => 'cr1-codfw',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr1-codfw bgp status':
-        host          => 'cr1-codfw',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # cr2-codfw
-    @monitoring::host { 'cr2-codfw':
-        ip_address => '208.80.153.193',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr2-codfw interfaces':
-        host          => 'cr2-codfw',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr2-codfw bgp status':
-        host          => 'cr2-codfw',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
-
-    # mr1-codfw
-    @monitoring::host { 'mr1-codfw':
-        ip_address => '208.80.153.196',
-        group      => 'routers',
-    }
-    @monitoring::service { 'mr1-codfw interfaces':
-        host          => 'mr1-codfw',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::host { 'mr1-codfw.oob':
-        host_fqdn => 'mr1-codfw.oob.wikimedia.org',
-        group     => 'routers'
-    }
-
-    ### eqdfw ###
-
-    # cr1-eqdfw
-    @monitoring::host { 'cr1-eqdfw':
-        ip_address => '208.80.153.198',
-        group      => 'routers',
-    }
-    @monitoring::service { 'cr1-eqdfw interfaces':
-        host          => 'cr1-eqdfw',
-        group         => 'routers',
-        description   => 'Router interfaces',
-        check_command => "check_ifstatus_nomon!${snmp_ro_community}",
-    }
-    @monitoring::service { 'cr1-eqdfw bgp status':
-        host          => 'cr1-eqdfw',
-        group         => 'routers',
-        description   => 'BGP status',
-        check_command => "check_bgp!${snmp_ro_community}",
-    }
+    create_resources(netops::check, $routers, $defaults}
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica471beda4fdf0134b5af027d857fe4961a70ca8
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to