Browse code

Monitoring Zyppera.

Lukasz P authored on13/03/2021 08:16:35
Showing5 changed files
... ...
@@ -4,14 +4,14 @@
4 4
 
5 5
   tasks:
6 6
   
7
-  - name: Copy check_apt wrapper to Debian-like hosts
7
+  - name: Copy check_apt wrapper to Debian-like and Suse hosts
8 8
     template:
9 9
       src: ../templates/monitoring/check_apt_wrapper
10 10
       dest: /usr/local/bin/check_apt_wrapper
11 11
       owner: root
12 12
       group: nagios
13 13
       mode: 0750
14
-    when: ansible_os_family == 'Debian'
14
+    when: ansible_os_family == 'Debian' or ansible_os_family == 'Suse'
15 15
   
16 16
   - name: Copy check_apt wrapper to Redhat-like hosts
17 17
     template:
... ...
@@ -22,23 +22,14 @@
22 22
       mode: 0750
23 23
     when: ansible_os_family == 'RedHat'
24 24
   
25
-  - name: Copy check_apt wrapper to Suse hosts
26
-    template:
27
-      src: ../templates/monitoring/check_apt_wrapper
28
-      dest: /usr/local/bin/check_apt_wrapper
29
-      owner: root
30
-      group: nagios
31
-      mode: 0750
32
-    when: ansible_os_family == 'Suse'
33
-
34
-  - name: Copy check_dnf wrapper to Debian-like hosts
25
+  - name: Copy check_dnf wrapper to Debian-like and Suse hosts
35 26
     template:
36 27
       src: ../templates/monitoring/check_dnf_wrapper
37 28
       dest: /usr/local/bin/check_dnf_wrapper
38 29
       owner: root
39 30
       group: nagios
40 31
       mode: 0750
41
-    when: ansible_os_family == 'Debian'
32
+    when: ansible_os_family == 'Debian' or ansible_os_family == 'Suse'
42 33
   
43 34
   - name: Copy check_dnf wrapper to Redhat-like hosts
44 35
     template:
... ...
@@ -49,12 +40,21 @@
49 40
       mode: 0750
50 41
     when: ansible_os_family == 'RedHat'
51 42
   
52
-  - name: Copy check_dnf wrapper to Suse hosts
43
+  - name: Copy check_zypper wrapper to Debian-like and Suse hosts
53 44
     template:
54
-      src: ../templates/monitoring/check_dnf_wrapper
55
-      dest: /usr/local/bin/check_dnf_wrapper
45
+      src: ../templates/monitoring/check_zypper_wrapper
46
+      dest: /usr/local/bin/check_zypper_wrapper
56 47
       owner: root
57 48
       group: nagios
58 49
       mode: 0750
59
-    when: ansible_os_family == 'Suse'
60
-
50
+    when: ansible_os_family == 'Debian' or ansible_os_family == 'Suse'
51
+  
52
+  - name: Copy check_zypper wrapper to Redhat-like hosts
53
+    template:
54
+      src: ../templates/monitoring/check_zypper_wrapper
55
+      dest: /usr/local/bin/check_zypper_wrapper
56
+      owner: root
57
+      group: nrpe
58
+      mode: 0750
59
+    when: ansible_os_family == 'RedHat'
60
+  
... ...
@@ -6,25 +6,27 @@ if ! [ -x /usr/bin/dnf ] ; then
6 6
   exit 0
7 7
 fi
8 8
 
9
-# number of bug fixes
9
+# number of bugfixes
10 10
 noup=$(eval "cat /var/local/check_dnf_updates | wc -l")
11 11
 
12 12
 # number of security fixes
13 13
 nosf=$(eval "cat /var/local/check_dnf_updates | grep -E 'security|Sec\.' | wc -l")
14 14
 
15 15
 function check_dnf {
16
-  # print security fixes
17 16
   if [ ${nosf} -gt 0 ] ; then
17
+    # print security fixes
18 18
     echo -n 'CRITICAL - ' 
19 19
     echo -n ${nosf}
20 20
     echo ' security fixes. '
21 21
     return 2
22 22
   elif [ ${noup} -gt 0 ] ; then
23
-    echo -n 'OK - '
23
+    # print bugfixes
24
+    echo -n 'WARNING - '
24 25
     echo -n ${noup}
25 26
     echo ' updates'
26 27
     return 1
27 28
   else
29
+    # print OK status
28 30
     echo 'OK - system up2date.'
29 31
     return 0
30 32
   fi
31 33
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+#!/bin/bash
2
+# Managed with Ansible
3
+
4
+if [ -x /usr/bin/zypper ] ; then
5
+  /usr/lib/nagios/plugins/check_zypper
6
+else
7
+  echo "OK - Not a Suse"
8
+fi
9
+
... ...
@@ -43,16 +43,23 @@ define service{
43 43
 }
44 44
 
45 45
 define service{
46
-    use                     bindir-service-hourly
46
+    use                     bindir-service-updates
47 47
     host_name               {{ item.host_name }}
48 48
     service_description     APT
49 49
     check_command           check_nrpe!-c check_apt
50 50
 }
51 51
 
52 52
 define service{
53
-    use                     bindir-service-hourly
53
+    use                     bindir-service-updates
54 54
     host_name               {{ item.host_name }}
55 55
     service_description     DNF
56 56
     check_command           check_nrpe!-c check_dnf
57 57
 }
58 58
 
59
+define service{
60
+    use                     bindir-service-updates
61
+    host_name               {{ item.host_name }}
62
+    service_description     ZYPPER
63
+    check_command           check_nrpe!-c check_zypper
64
+}
65
+
... ...
@@ -13,3 +13,5 @@ command[check_apt]=/usr/local/bin/check_apt_wrapper 2>/dev/null
13 13
 # Beware of SELinux preventing nrpe from using dnf
14 14
 command[check_dnf]=/usr/local/bin/check_dnf_wrapper 2>/dev/null
15 15
 
16
+command[check_zypper]=/usr/local/bin/check_zypper_wrapper 2>/dev/null
17
+