Dzahn has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/368124 )

Change subject: base::monitoring: make it possible to disable monitoring
......................................................................

base::monitoring: make it possible to disable monitoring

Change-Id: Idff6a66567390c438ba2b79dda7e74b8483d3e61
---
M modules/base/manifests/monitoring/host.pp
M modules/profile/manifests/base.pp
2 files changed, 100 insertions(+), 67 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/24/368124/1

diff --git a/modules/base/manifests/monitoring/host.pp 
b/modules/base/manifests/monitoring/host.pp
index c99aec4..d6943df 100644
--- a/modules/base/manifests/monitoring/host.pp
+++ b/modules/base/manifests/monitoring/host.pp
@@ -29,54 +29,78 @@
     $nrpe_check_disk_options = '-w 6% -c 3% -l -e -A -i "/srv/sd[a-b][1-3]" 
--exclude-type=tracefs',
     $nrpe_check_disk_critical = false,
     $raid_write_cache_policy = undef,
+    $enabled = true,
 ) {
     include ::base::puppet::params # In order to be able to use some variables
 
-    # RAID checks
-    class { 'raid':
-        write_cache_policy => $raid_write_cache_policy,
+    $ensure = $enabled ? {
+        true  => 'present',
+        false => 'absent',
     }
 
-    ::monitoring::host { $::hostname: }
+    if $enabled {
+        # TODO: FIX ALL THE THINGS in RAID CLASS TOO, SIGH
+        # RAID checks
+        class { 'raid':
+            write_cache_policy => $raid_write_cache_policy,
+        }
+
+
+    }
+
+    ::sudo::user { 'nagios_puppetrun':
+        ensure     => $ensure,
+        user       => 'nagios',
+        privileges => ['ALL = NOPASSWD: 
/usr/local/lib/nagios/plugins/check_puppetrun'],
+    }
+
+    ::monitoring::host { $::hostname:
+        ensure => $ensure,
+    }
 
     ::monitoring::service { 'ssh':
+        ensure        => $ensure,
         description   => 'SSH',
         check_command => 'check_ssh',
     }
 
-    file { '/usr/local/lib/nagios/plugins/check_puppetrun':
-        ensure => present,
-        owner  => 'root',
-        group  => 'root',
-        mode   => '0555',
-        source => 'puppet:///modules/base/monitoring/check_puppetrun';
+    ::nrpe::monitor_service { 'disk_space':
+        ensure       => $ensure,
+        description  => 'Disk space',
+        critical     => $nrpe_check_disk_critical,
+        nrpe_command => "/usr/lib/nagios/plugins/check_disk 
${nrpe_check_disk_options}",
     }
-    file { '/usr/local/lib/nagios/plugins/check_eth':
-        ensure  => present,
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0555',
-        content => template('base/check_eth.erb'),
-    }
-    file { '/usr/lib/nagios/plugins/check_sysctl':
-        ensure => present,
-        owner  => 'root',
-        group  => 'root',
-        mode   => '0555',
-        source => 'puppet:///modules/base/check_sysctl',
+    
+    ::nrpe::monitor_service { 'dpkg':
+        ensure       => $ensure,
+        description  => 'DPKG',
+        nrpe_command => '/usr/local/lib/nagios/plugins/check_dpkg',
     }
 
-    file { '/usr/lib/nagios/plugins/check-fresh-files-in-dir.py':
-        ensure => present,
-        owner  => 'root',
-        group  => 'root',
-        mode   => '0555',
-        source => 
'puppet:///modules/base/monitoring/check-fresh-files-in-dir.py',
+    $warninginterval = $base::puppet::params::freshnessinterval
+    $criticalinterval = $base::puppet::params::freshnessinterval * 2
+    ::nrpe::monitor_service { 'puppet_checkpuppetrun':
+        ensure       => $ensure,
+        description  => 'puppet last run',
+        nrpe_command => "/usr/bin/sudo 
/usr/local/lib/nagios/plugins/check_puppetrun -w ${warninginterval} -c 
${criticalinterval}",
     }
 
-    ::sudo::user { 'nagios_puppetrun':
-        user       => 'nagios',
-        privileges => ['ALL = NOPASSWD: 
/usr/local/lib/nagios/plugins/check_puppetrun'],
+    ::nrpe::monitor_service {'check_eth':
+        ensure       => $ensure,
+        description  => 'configured eth',
+        nrpe_command => '/usr/local/lib/nagios/plugins/check_eth',
+    }
+
+    ::nrpe::monitor_service { 'check_dhclient':
+        ensure       => $ensure,
+        description  => 'dhclient process',
+        nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 0:0 -c 0:0 -C 
dhclient',
+    }
+
+    ::nrpe::monitor_service { 'check_salt_minion':
+        ensure       => $ensure,
+        description  => 'salt-minion processes',
+        nrpe_command => "/usr/lib/nagios/plugins/check_procs -w 1: -c 1:5 
--ereg-argument-array '/usr/bin/python /usr/bin/salt-minion'",
     }
 
     # Check for disk usage on the root partition for labs instances
@@ -85,57 +109,66 @@
     # to reflect this check name
     if $::realm == 'labs' {
         ::nrpe::monitor_service { 'root_disk_space':
+            ensure       => $ensure,
             description  => 'Disk space on /',
             nrpe_command => '/usr/lib/nagios/plugins/check_disk -w 5% -c 2% -l 
-e -p /',
         }
     }
 
-    ::nrpe::monitor_service { 'disk_space':
-        description  => 'Disk space',
-        critical     => $nrpe_check_disk_critical,
-        nrpe_command => "/usr/lib/nagios/plugins/check_disk 
${nrpe_check_disk_options}",
+    file { '/usr/local/lib/nagios/plugins/check_puppetrun':
+        ensure => $ensure,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 'puppet:///modules/base/monitoring/check_puppetrun';
     }
 
-    ::nrpe::monitor_service { 'dpkg':
-        description  => 'DPKG',
-        nrpe_command => '/usr/local/lib/nagios/plugins/check_dpkg',
+    file { '/usr/local/lib/nagios/plugins/check_eth':
+        ensure  => $ensure,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0555',
+        content => template('base/check_eth.erb'),
     }
-    $warninginterval = $base::puppet::params::freshnessinterval
-    $criticalinterval = $base::puppet::params::freshnessinterval * 2
-    ::nrpe::monitor_service { 'puppet_checkpuppetrun':
-        description  => 'puppet last run',
-        nrpe_command => "/usr/bin/sudo 
/usr/local/lib/nagios/plugins/check_puppetrun -w ${warninginterval} -c 
${criticalinterval}",
+
+    file { '/usr/lib/nagios/plugins/check_sysctl':
+        ensure => $ensure,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 'puppet:///modules/base/check_sysctl',
     }
-    ::nrpe::monitor_service {'check_eth':
-        description  => 'configured eth',
-        nrpe_command => '/usr/local/lib/nagios/plugins/check_eth',
+
+    file { '/usr/lib/nagios/plugins/check-fresh-files-in-dir.py':
+        ensure => $ensure,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0555',
+        source => 
'puppet:///modules/base/monitoring/check-fresh-files-in-dir.py',
     }
-    ::nrpe::monitor_service { 'check_dhclient':
-        description  => 'dhclient process',
-        nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 0:0 -c 0:0 -C 
dhclient',
-    }
-    ::nrpe::monitor_service { 'check_salt_minion':
-        description  => 'salt-minion processes',
-        nrpe_command => "/usr/lib/nagios/plugins/check_procs -w 1: -c 1:5 
--ereg-argument-array '^/usr/bin/python /usr/bin/salt-minion'",
-    }
+
     if $::initsystem == 'systemd' {
+
         file { '/usr/local/lib/nagios/plugins/check_systemd_state':
-            ensure => present,
+            ensure => $ensure,
             source => 'puppet:///modules/base/check_systemd_state.py',
             owner  => 'root',
             group  => 'root',
             mode   => '0555',
         }
-        ::nrpe::monitor_service { 'check_systemd_state':
+
+         ::nrpe::monitor_service { 'check_systemd_state':
+            ensure       => $ensure,
             description  => 'Check systemd state',
             nrpe_command => 
'/usr/local/lib/nagios/plugins/check_systemd_state',
         }
+
     }
 
     if $::productname == 'PowerEdge R320' {
 
         file { '/usr/local/lib/nagios/plugins/check_cpufreq':
-            ensure => present,
+            ensure => $ensure,
             source => 'puppet:///modules/base/monitoring/check_cpufreq',
             owner  => 'root',
             group  => 'root',
@@ -143,8 +176,9 @@
         }
 
         ::nrpe::monitor_service { 'check_cpufreq':
-            description  => 'CPU frequency',
-            nrpe_command => '/usr/local/lib/nagios/plugins/check_cpufreq 600',
+           ensure       => $ensure,
+           description  => 'CPU frequency',
+           nrpe_command => '/usr/local/lib/nagios/plugins/check_cpufreq 600',
         }
     }
 }
diff --git a/modules/profile/manifests/base.pp 
b/modules/profile/manifests/base.pp
index 7567265..9601239 100644
--- a/modules/profile/manifests/base.pp
+++ b/modules/profile/manifests/base.pp
@@ -91,13 +91,12 @@
     }
 
     # unless disabled in Hiera, have Icinga monitoring (T151632)
-    if $monitoring {
-        class { '::base::monitoring::host':
-            contact_group            => $group_contact,
-            nrpe_check_disk_options  => $check_disk_options,
-            nrpe_check_disk_critical => $check_disk_critical,
-            raid_write_cache_policy  => $check_raid_policy,
-        }
+    class { '::base::monitoring::host':
+        enabled                  => $monitoring,
+        contact_group            => $group_contact,
+        nrpe_check_disk_options  => $check_disk_options,
+        nrpe_check_disk_critical => $check_disk_critical,
+        raid_write_cache_policy  => $check_raid_policy,
     }
 
     if os_version('ubuntu == trusty') {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idff6a66567390c438ba2b79dda7e74b8483d3e61
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn <dz...@wikimedia.org>

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

Reply via email to