]> xn--ix-yja.es Git - alex.git/commitdiff
Refine basic Linux monitoring
authoralex <alex@pdp7.net>
Fri, 3 Feb 2023 21:10:23 +0000 (22:10 +0100)
committeralex <alex@pdp7.net>
Fri, 3 Feb 2023 21:10:23 +0000 (22:10 +0100)
* Add ragent
* Use servicegroups/hostgroups

personal_infra/puppet/modules/nagios/manifests/init.pp
personal_infra/puppet/modules/nagios/templates/nagios.cfg.epp
personal_infra/puppet/site/00-common.pp

index 48aaf0a865f99997dc4d0792a2afe0619f38deb1..5568fbf9e9a699d6694918ee425e4ce6a8fac909 100644 (file)
@@ -41,6 +41,50 @@ class nagios {
     owner => 'nagios',
   }
 
+  nagios_command {'check_ragent':
+    command_name => 'check_ragent',
+    command_line => '/usr/bin/check_ragent http://$HOSTADDRESS$:21488/ --warning-units dnf-makecache.service --warning-units dnf-automatic-install.service',
+    require => Package['nagios'],
+    notify => Service['nagios'],
+    owner => 'nagios',
+  }
+
+  nagios_hostgroup {'linux':
+    hostgroup_name => 'linux',
+    require => Package['nagios'],
+    notify => Service['nagios'],
+    owner => 'nagios',
+    ensure => present,
+  }
+
+  nagios_servicegroup {'ragent':
+    require => Package['nagios'],
+    notify => Service['nagios'],
+    owner => 'nagios',
+    ensure => present,
+  }
+
+  nagios_service {'check_ragent':
+    use => 'generic-service',
+    hostgroup_name => 'linux',
+    service_description => 'check_ragent',
+    servicegroups => 'ragent',
+    check_command => 'check_ragent',
+    require => Package['nagios'],
+    notify => Service['nagios'],
+    owner => 'nagios',
+  }
+
+  nagios_service {'check_ssh':
+    use => 'generic-service',
+    hostgroup_name => 'linux',
+    service_description => 'ssh',
+    check_command => 'check_ssh',
+    require => Package['nagios'],
+    notify => Service['nagios'],
+    owner => 'nagios',
+  }
+
   package {'httpd':}
   ->
   service {'httpd':
index 8ed499b83c244c8355aea6bbce0a872fa7904dff..8e28ceb8dce749c2336b69187df32afaef9c49d2 100644 (file)
@@ -33,6 +33,9 @@ cfg_file=/etc/nagios/objects/templates.cfg
 # puppet generated
 cfg_file=/etc/nagios/nagios_contactgroup.cfg
 cfg_file=/etc/nagios/nagios_contact.cfg
+cfg_file=/etc/nagios/nagios_command.cfg
+cfg_file=/etc/nagios/nagios_hostgroup.cfg
+cfg_file=/etc/nagios/nagios_servicegroup.cfg
 cfg_file=/etc/nagios/nagios_host.cfg
 cfg_file=/etc/nagios/nagios_service.cfg
 
index cb0126bb3d606f4e9ee3b598c013bb0a47f5d67b..b9f2a6f71ef262f9e299b6b9c775faf262907349 100644 (file)
@@ -12,15 +12,9 @@ nagios_host {$nagios_host:
   use => 'generic-host',
   address => lookup({name => 'nagios.address', default_value => $facts['networking']['fqdn']}),
   max_check_attempts => 5,
-  contact_groups => "admins",
-  check_command => "check-host-alive",
-}
-
-nagios_service {"${nagios_host}-ssh":
-  use => 'generic-service',
-  host_name => $facts['networking']['fqdn'],
-  service_description => "ssh",
-  check_command => "check_ssh",
+  contact_groups => 'admins',
+  hostgroups => 'linux',
+  check_command => 'check-host-alive',
 }
 
 # https://github.com/alexpdp7/ragent/issues/352