You are on page 1of 3

#Installation des packages

yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-
snmp

#Creation utilisateurs et groupes pour nagions


useradd nagios
groupadd nagcmd

#Paramatres des droits de groupe


usermod -G nagcmd nagios
usermod -G nagcmd apache

#creation du repertoire pour l'installation de Nagios


mkdir /root/nagios
cd /root/nagios

#telechargement de l'archive Nagios et ses plugins


wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

#Decompresser
tar -xvf nagios-4.4.6.tar.gz
tar -xvf nagios-plugins-2.2.1.tar.gz

#se deplacer dans le repertoire


cd nagios-4.4.6/

#Demarrer la configuration
./configure --with-command-group=nagcmd

#Compilation et installation
make all
make install

make install-init
make install-commandmode
make install-config

#Installer l'interface web


make install-webconf

#Creer un mot de passe pour l'interface web


htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

#demarer le service httpd


systemctl start httpd.service

#reglage du pare-feu
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

#installation des plugins


cd /root/nagios
cd nagios-plugins-2.2.1/
#installation
./configure --with-nagios-user=nagios --with-nagios-group=nagios

#Compilation et installation
make all
make install

#verification
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#Ajustement du selinux
getenforce
setenforce 0

#ajustement des services


systemctl enable nagios
systemctl enable httpd

#installation des packages necessaires


yum install postfix cyrus-sasl-plain mailx -y

#Configuration de postfix pour utiliser Gmail, activer STARTTLS Encryption


sed -i 's/smtp_tls_security_level = may/smtp_tls_security_level = encrypt/'
/etc/postfix/main.cf

echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf

echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf

echo "smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt" >> /etc/postfix/main.cf

echo "smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt" >> /etc/postfix/main.cf

#Definir l'agent relai Gmail et SASL


cat >> /etc/postfix/main.cf << EOF
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
EOF

vim /usr/local/nagios/etc/objects/contacts.cfg

#Configurer SASL pour le Compte gmail avec mot de passe Application


vim /etc/postfix/sasl_passwd

[smtp.gmail.com]:587 aymanadj3@gmail.com:dstbxbbtrsentqis

#Generer un postfix lookup


postmap /etc/postfix/sasl_passwd
#Changer les permissions
chown root:root /etc/postfix/sasl_passwd*
chmod 600 /etc/postfix/sasl_passwd*

#Demarer et activer postfix


systemctl enable postfix --now

#Test de l'envoi de mail sur gmail


echo "Test Postfix Gmail Relay" | mail -s "Postfix Gmail Relay" aymanadj3@gmail.com

#verification de la config nagios


/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#redemarer nagios
systemctl restart nagios

You might also like