Skip to content

Commit dcdcb13

Browse files
steelhead31sxa
andauthored
NagiosPB: Implement Nagios Automated Node Configuration (#2948)
* Create Server Config files Create individual server configurations using templates, and the ansible inventory. * Fix Nagios Config Files For Automation. * Remove debug output from task. * Fix service groups appending. * Add restart task to server config * Add demo secrets file, usable for testing. * Add dockerhost templates and logic. * Add service groups to host templates * Fix appending to servicegroups * Fix typo for path * Typos and perms fixes * Fix plays * Fixes for nagios service groups cfg * Linter fixes. * Fix linter * fix linter * Fix relative pathing lint * Linter fixes * Relative path lint fix * Tidy up blank space. * Tidy blank space * Remove commented code. * Update ansible/playbooks/nagios/roles/Nagios_Config/scripts/Create_Nagios_Server_Configurations.py Co-authored-by: Stewart X Addison <[email protected]> --------- Co-authored-by: Stewart X Addison <[email protected]>
1 parent 412ed3e commit dcdcb13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2325
-56
lines changed

ansible/playbooks/nagios/roles/Nagios_Config/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
task_list:
55
- Download Ansible Inventory File
66
- Run Create Nagios Server Configurations script
7+
- Run Create Nagios Hostgroups script
78
- Run Create Nagios Servicegroups script
9+
- restart_nagios_server
810

911
# Input Path
1012
Input_Path: /tmp/ansible_inventory.yml
@@ -14,3 +16,6 @@ Nagios_Base_Path: /usr/local/nagios
1416

1517
# Ansible Inventory Host Group Types To Monitor -- Maps To Nagios Service Groups
1618
Nagios_Service_Types: 'build test dockerhost'
19+
20+
# Should Ansible Replace Existing Configuration File
21+
Overwrite_Mode: True
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Define Template And Host Mappings
2+
3+
templates = {'build_win': 'build-windows-template.j2',
4+
'test_win': 'test-windows-template.j2',
5+
'build_macos': 'build-macos-template.j2',
6+
'test_macos': 'test-macos-template.j2',
7+
'build_aix': 'build-aix-template.j2',
8+
'test_aix': 'test-aix-template.j2',
9+
'build_centos': 'build-centos-template.j2',
10+
'test_centos': 'test-centos-template.j2',
11+
'build_ubuntu': 'build-ubuntu-template.j2',
12+
'test_ubuntu': 'test-ubuntu-template.j2',
13+
'build_rhel': 'build-rhel-template.j2',
14+
'test_rhel': 'test-rhel-template.j2',
15+
'build_sles': 'build-sles-template.j2',
16+
'test_sles': 'test-sles-template.j2',
17+
'dockerhost_ubuntu': 'dockerhost-ubuntu-template.j2'}
18+
19+
## Define Any Hosts That Should Be Excluded
20+
21+
excluded_hosts = {'build-spearhead-freebsd12-x64-1',
22+
'test-siteox-solaris10u11-sparcv9-1',
23+
'test-equinix_esxi-solaris10-x64-1',
24+
'test-inspira-solaris10u11-sparcv9-1',
25+
'build-equinix_esxi-solaris10-x64-1',
26+
'build-inspira-solaris10u11-sparcv9-1',
27+
'build-inspira-solaris10u11-sparcv9-2',
28+
'build-siteox-solaris10u11-sparcv9-1'}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
define host {
2+
use linux-server
3+
host_name {{ host_name }}
4+
alias Added By Ansible
5+
address {{ host_ip_address }}
6+
check_command check_ssh!-4 -t 60
7+
max_check_attempts 5
8+
check_period 24x7
9+
notification_interval 720
10+
notification_period 24x7
11+
icon_image aix.png
12+
icon_image_alt aix
13+
statusmap_image aix.gd2
14+
15+
}
16+
define service{
17+
use local-service
18+
host_name {{ host_name }}
19+
service_description PING
20+
check_command check_ping!200.0,20%!500.0,60%
21+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
22+
servicegroups build_Servers
23+
}
24+
25+
define service{
26+
use generic-service
27+
host_name {{ host_name }}
28+
service_description Current Load
29+
check_command check_by_ssh!/home/nagios/nagios/libexec/check_load -w 20,15,10 -c 30,24,20
30+
notifications_enabled 0
31+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
32+
}
33+
34+
define service{
35+
use generic-service
36+
host_name {{ host_name }}
37+
service_description Disk Space Root Partition
38+
check_command check_by_ssh!/home/nagios/nagios/libexec/check_disk -w 20% -c 10% -p /
39+
check_interval 60
40+
}
41+
42+
define service{
43+
use generic-service
44+
host_name {{ host_name }}
45+
service_description Disk Space check for Jenkins
46+
check_command check_by_ssh!/home/nagios/nagios/libexec/check_disk -w 20% -c 10% -p /home/jenkins
47+
check_interval 60
48+
}
49+
50+
define service{
51+
use generic-service
52+
host_name {{ host_name }}
53+
service_description Disk Space check for TMP
54+
check_command check_by_ssh!/home/nagios/nagios/libexec/check_disk -w 20% -c 10% -p /tmp
55+
check_interval 60
56+
}
57+
58+
59+
define service {
60+
use generic-service
61+
host_name {{ host_name }}
62+
service_description Check if Jenkins Agent Connected
63+
check_command check_agent!{{ host_name }}
64+
notification_options c,r
65+
check_interval 30
66+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
67+
}
68+
69+
define service{
70+
use generic-service
71+
host_name {{ host_name }}
72+
service_description RAM
73+
check_command check_by_ssh!/home/nagios/nagios/libexec/check_mem -f -C -w 15 -c 5
74+
action_url /nagiosgraph/cgi-bin/show.cgi?host=nagios$&service=$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=nagios$&service=$&period=hour&rrdopts=-w+450
75+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
define host {
2+
use linux-server
3+
host_name {{ host_name }}
4+
alias Added By Ansible
5+
address {{ host_ip_address }}
6+
check_command check_ssh!-4 -t 60
7+
max_check_attempts 5
8+
check_period 24x7
9+
notification_interval 720
10+
notification_period 24x7
11+
icon_image CentOS.png
12+
icon_image_alt CentOS
13+
statusmap_image CentOS.gd2
14+
}
15+
16+
define service{
17+
use local-service
18+
host_name {{ host_name }}
19+
service_description PING
20+
check_command check_ping!200.0,20%!500.0,60%
21+
servicegroups build_Servers
22+
}
23+
24+
define service{
25+
use generic-service
26+
host_name {{ host_name }}
27+
service_description Current Load
28+
check_command check_by_ssh!/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,24,20
29+
notifications_enabled 0
30+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
31+
}
32+
33+
define service{
34+
use generic-service
35+
host_name {{ host_name }}
36+
service_description Disk Space Root Partition
37+
check_command check_by_ssh!/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p /
38+
check_interval 60
39+
}
40+
define service{
41+
use generic-service
42+
host_name {{ host_name }}
43+
service_description RAM
44+
check_command check_by_ssh!/usr/local/nagios/libexec/check_mem -f -C -w 15 -c 5
45+
action_url /nagiosgraph/cgi-bin/show.cgi?host=nagios$&service=$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=nagios$&service=$&period=hour&rrdopts=-w+450
46+
}
47+
48+
define service{
49+
use generic-service
50+
host_name {{ host_name }}
51+
check_period once-a-day-at-8
52+
service_description Updates Required - YUM
53+
check_command check_by_ssh!/usr/local/nagios/libexec/check_yum 2>1 /dev/null
54+
notifications_enabled 0
55+
}
56+
57+
58+
define service {
59+
use generic-service
60+
host_name {{ host_name }}
61+
service_description Check if Jenkins Agent Connected
62+
check_command check_agent!{{ host_name }}
63+
notification_options c,r
64+
check_interval 30
65+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
66+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
define host {
2+
use linux-server
3+
host_name {{ host_name }}
4+
alias Add by Ansible
5+
address {{ host_ip_address }}
6+
check_command check_ssh!-4 -t 60
7+
max_check_attempts 5
8+
check_period 24x7
9+
notification_interval 720
10+
notification_period 24x7
11+
icon_image apple.gif
12+
icon_image_alt Mac OS
13+
statusmap_image apple.gd2
14+
}
15+
16+
define service{
17+
use generic-service
18+
host_name {{ host_name }}
19+
service_description Current Load
20+
check_command check_by_ssh!/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,24,20
21+
notifications_enabled 0
22+
check_interval 30
23+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
24+
25+
}
26+
27+
define service{
28+
use generic-service
29+
host_name {{ host_name }}
30+
service_description Disk Space Root Partition
31+
check_command check_by_ssh!/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
32+
check_interval 60
33+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
34+
35+
}
36+
37+
define service {
38+
use generic-service
39+
host_name {{ host_name }}
40+
service_description Check Jenkins Connection
41+
check_command check_agent!{{ host_name }}
42+
notification_options c,r
43+
check_interval 30
44+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
45+
46+
}
47+
48+
define service{
49+
use local-service
50+
host_name {{ host_name }}
51+
service_description PING
52+
check_interval 15
53+
check_command check_ping!200.0,20%!500.0,60%
54+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
55+
servicegroups build_Servers
56+
}
57+
58+
define service{
59+
use generic-service
60+
host_name {{ host_name }}
61+
service_description RAM
62+
check_command check_by_ssh!/usr/local/nagios/libexec/check_mem -f -C -w 15 -c 5
63+
action_url /nagiosgraph/cgi-bin/show.cgi?host=nagios$&service=$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=nagios$&service=$&period=hour&rrdopts=-w+450
64+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
define host {
2+
use linux-server
3+
host_name {{ host_name }}
4+
alias Add by Ansible
5+
address {{ host_ip_address }}
6+
check_command check_ssh!-4 -t 60
7+
max_check_attempts 5
8+
check_period 24x7
9+
notification_interval 720
10+
notification_period 24x7
11+
icon_image RedHat.png
12+
icon_image_alt RedHat
13+
statusmap_image RedHat.gd2
14+
}
15+
16+
define service{
17+
use generic-service
18+
host_name {{ host_name }}
19+
service_description Current Load
20+
check_command check_by_ssh!/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,24,20
21+
notifications_enabled 0
22+
check_interval 30
23+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
24+
}
25+
26+
define service{
27+
use generic-service
28+
host_name {{ host_name }}
29+
service_description Disk Space Root Partition
30+
check_command check_by_ssh!/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
31+
check_interval 60
32+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
33+
}
34+
35+
define service {
36+
use generic-service
37+
host_name {{ host_name }}
38+
service_description Check if Jenkins Agent Connected
39+
check_command check_agent!{{ host_name }}
40+
notification_options c,r
41+
check_interval 30
42+
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=hour&rrdopts=-w+450
43+
}
44+
45+
define service{
46+
use generic-service
47+
host_name {{ host_name }}
48+
service_description RAM
49+
check_command check_by_ssh!/usr/local/nagios/libexec/check_mem -f -C -w 15 -c 5
50+
action_url /nagiosgraph/cgi-bin/show.cgi?host=nagios$&service=$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=nagios$&service=$&period=hour&rrdopts=-w+450
51+
}
52+
53+
define service{
54+
use generic-service
55+
host_name {{ host_name }}
56+
check_period once-a-day-at-8
57+
service_description Updates Required - YUM
58+
check_command check_by_ssh!/usr/local/nagios/libexec/check_yum 2>1 /dev/null
59+
notifications_enabled 0
60+
}
61+
62+
define service{
63+
use local-service
64+
host_name {{ host_name }}
65+
service_description PING
66+
check_period once-a-day-at-8
67+
check_command check_ping!200.0,20%!500.0,60%
68+
servicegroups build_Servers
69+
}
70+
define service{
71+
use generic-service
72+
host_name {{ host_name }}
73+
service_description Check Network Time System
74+
check_command check_by_ssh!/usr/local/nagios/libexec/check_ntp_timesync
75+
check_interval 15
76+
}

0 commit comments

Comments
 (0)