Browse code

Czujki apt oraz cron (cron jeszcze do konca nie dziala).

Lukasz P authored on17/02/2021 18:42:39
Showing7 changed files
... ...
@@ -6,6 +6,7 @@
6 6
 - import_playbook: local_bin_files.yaml
7 7
 - import_playbook: firewall_configuration.yaml
8 8
 - import_playbook: journal_basic_setup.yaml
9
+- import_playbook: setup_cron.yaml
9 10
 - import_playbook: setup_monitoring.yaml
10 11
 - import_playbook: basic_host_role_setup.yaml
11 12
 - import_playbook: disable_unused_services.yaml
12 13
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+---
2
+- name: Copy nrpe wrappers to monitored hosts
3
+  hosts: all
4
+
5
+  tasks:
6
+  
7
+  - name: Copy check_apt wrapper to Debian-like hosts
8
+    template:
9
+      src: ../templates/monitoring/check_apt_wrapper
10
+      dest: /usr/local/bin/check_apt_wrapper
11
+      owner: root
12
+      group: nagios
13
+      mode: 0750
14
+    when: ansible_os_family == 'Debian'
15
+  
16
+  - name: Copy check_apt wrapper to Redhat-like hosts
17
+    template:
18
+      src: ../templates/monitoring/check_apt_wrapper
19
+      dest: /usr/local/bin/check_apt_wrapper
20
+      owner: root
21
+      group: nrpe
22
+      mode: 0750
23
+    when: ansible_os_family == 'RedHat'
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
+  
0 34
new file mode 100644
... ...
@@ -0,0 +1,12 @@
1
+---
2
+- name: Setup Cron jobs
3
+  hosts: all
4
+
5
+  tasks:
6
+
7
+  - name: Touch a file check_cron for monitoring
8
+    cron:
9
+      name: "touch check_cron"
10
+      minute: "*/10"
11
+      job: "/usr/bin/touch /tmp/check_cron &> /dev/null"
12
+
... ...
@@ -1,5 +1,6 @@
1 1
 ---
2 2
 - import_playbook: helpers/monitoring_basic_setup.yaml
3
+- import_playbook: helpers/monitoring_setup_nrpe_wrappers.yaml
3 4
 - import_playbook: helpers/monitoring_setup_nrpe_servers.yaml
4 5
 - import_playbook: helpers/monitoring_setup_nrpe_plugins.yaml
5 6
 - import_playbook: helpers/monitoring_setup_nagios_servers.yaml
6 7
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+#!/bin/bash
2
+# Managed with Ansible
3
+
4
+if [ -x /usr/bin/apt ] ; then
5
+  /usr/lib/nagios/plugins/check_apt -o
6
+else
7
+  echo "OK - Not a Debian"
8
+fi
9
+
... ...
@@ -18,20 +18,34 @@ define service {
18 18
     use                     bindir-service
19 19
     host_name               {{ item.host_name }}
20 20
     service_description     DISK_ROOT
21
-    check_command           check_nrpe!-c check_disk
21
+    check_command           check_nrpe!check_disk
22 22
 }
23 23
 
24 24
 define service{
25 25
     use                     bindir-service
26 26
     host_name               {{ item.host_name }}
27 27
     service_description     LOAD
28
-    check_command           check_nrpe!-c check_load
28
+    check_command           check_nrpe!check_load
29 29
 }
30 30
 
31 31
 define service{
32 32
     use                     bindir-service
33 33
     host_name               {{ item.host_name }}
34 34
     service_description     SWAP
35
-    check_command           check_nrpe!-c check_swap
35
+    check_command           check_nrpe!check_swap
36
+}
37
+
38
+define service{
39
+    use                     bindir-service
40
+    host_name               {{ item.host_name }}
41
+    service_description     CRON
42
+    check_command           check_nrpe!check_cron
43
+}
44
+
45
+define service{
46
+    use                     bindir-service
47
+    host_name               {{ item.host_name }}
48
+    service_description     APT
49
+    check_command           check_nrpe!check_apt
36 50
 }
37 51
 
... ...
@@ -2,4 +2,7 @@
2 2
 command[check_load]={{ item.plugin_path }}/check_load -w "$(($(nproc --all)))" -c "$(($(nproc --all)+1))"
3 3
 command[check_disk]={{ item.plugin_path }}/check_disk / -w 20% -c 10%
4 4
 command[check_swap]={{ item.plugin_path }}/check_swap -w 30% -c 10% -n ok
5
+command[check_cron]={{ item.plugin_path }}/check_file_age -w 610 -c 1210 -W 0 -C 0 -f /tmp/check_cron
6
+
7
+command[check_apt]=/usr/local/bin/check_apt_wrapper
5 8