-
Notifications
You must be signed in to change notification settings - Fork 0
/
nagios_install.sh
71 lines (53 loc) · 1.92 KB
/
nagios_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
##From https://github.com/nic-instruction/NTI-320/blob/master/nagios/nagios_install.sh
#####INSTALL NAGIOS
yum -y install nagios
systemctl enable nagios
systemctl start nagios
#####TURN OFF SE LINUX
setenforce 0
#####INSTALL APACHE
yum -y install httpd
systemctl enable httpd
systemctl start httpd
#####NAGIOS
yum -y install nrpe
systemctl enable nrpe
systemctl start nrpe
#####INSTALL NAGIOS SERVER PLUGINS
yum -y install nagios-plugins-all
#####INSTALL NAGIOS CLIENT PLUGINS
yum -y install nagios-plugins-nrpe
#####ENABLE SWAP#####
#####https://www.digitalocean.com/community/tutorials/how-to-install-nagios-on-centos-6
dd if=/dev/zero of=/swap bs=1024 count=2097152
mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap
echo /swap swap swap defaults 0 0 >> /etc/fstab
echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p
#####CREATE PASSWORD
htpasswd -b -c ~/temp/password nagiosadmin nagiosadmin
#####ENABLE rw/rw/rw FOR LOGS
chmod 666 /var/log/nagios/nagios.log
#####UNCOMMENT LINE TO ENABLE NAGIOS.CFG
sed -i '51 s/^#//' /etc/nagios/nagios.cfg
#####RESTARTING NAGIOS TO BYPASS SE LINUX PREVENTIONS
systemctl restart nagios
# Need to put the NRPE changes into your config file
echo '########### NRPE CONFIG LINE #######################
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}' >> /etc/nagios/objects/commands.cfg
#####CREATING EMPTY FILE FOR NAGIOS TO FETCH THAT IT IS NOT FORBIDDEN FROM#####
touch /var/www/html/index.html
chmod 755 /var/www/html/index.html
#####RESTARTING NAGIOS TO BYPASS SE LINUX PREVENTIONS
systemctl restart nagios
#######Making Servers File for configuration######
####mkdir
mkdir /etc/nagios/servers
sed '51i\ cfg_dir=/etc/nagios/servers'
####Need to add user to nagios group so secure copy to nagios works
usermod -a -G nagios g42dfyt
####elevate /etc/nagios/servers
chmod 777 /etc/nagios/servers