Browse Source

icinga2: Check for newer kernels and libraries.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 3 years ago
parent
commit
3ae8e8be9b
4 changed files with 50 additions and 0 deletions
  1. 13 0
      icinga2/commands.d/needrestart.conf
  2. 4 0
      icinga2/icinga2.sudoers
  3. 1 0
      icinga2/init.sls
  4. 32 0
      icinga2/services/linux.conf

+ 13 - 0
icinga2/commands.d/needrestart.conf

@@ -0,0 +1,13 @@
+#
+# Check commands for needrestart kernel and library check
+#
+
+object CheckCommand "needrestart_kernel" {
+	import "plugin-check-command"
+
+	command = [ "sudo", "/usr/sbin/needrestart", "-p", "-k" ]
+}
+
+object CheckCommand "needrestart_libs" {
+	command = [ "sudo", "/usr/sbin/needrestart", "-p", "-l" ]
+}

+ 4 - 0
icinga2/icinga2.sudoers

@@ -16,3 +16,7 @@ nagios  ALL=NOPASSWD:	/usr/local/sbin/dhcpd-pool
 
 # Mail
 nagios	ALL=NOPASSWD:	/usr/lib/nagios/plugins/check_mailq
+
+# Needrestart
+nagios	ALL=NOPASSWD:	/usr/sbin/needrestart -p -k
+nagios	ALL=NOPASSWD:	/usr/sbin/needrestart -p -l

+ 1 - 0
icinga2/init.sls

@@ -6,6 +6,7 @@
 include:
   - apt
   - sudo
+  - needrestart
 
 
 # Install icinga2 package

+ 32 - 0
icinga2/services/linux.conf

@@ -99,5 +99,37 @@ apply Service "apt-Updates" {
 		command_endpoint = host.name
 	}
 
+	check_interval = 15m
+
+	assign where host.address && host.vars.os == "Linux"
+}
+
+
+apply Service "running_kernel" {
+	import "generic-service"
+
+	check_command = "needrestart_kernel"
+
+	if (host.name != NodeName) {
+		command_endpoint = host.name
+	}
+
+	check_interval = 15m
+
+	assign where host.address && host.vars.os == "Linux"
+}
+
+
+apply Service "libs" {
+	import "generic-service"
+
+	check_command = "needrestart_libs"
+
+	if (host.name != NodeName) {
+		command_endpoint = host.name
+	}
+
+	check_interval = 15m
+
 	assign where host.address && host.vars.os == "Linux"
 }