justinmassiot
10/18/2016 - 8:45 AM

Icinga2 installation and configuration


# http://www.it-connect.fr/installation-icinga2-icingaweb2-sur-debian-8/
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/getting-started#getting-started


# service icinga2 reload
# service icinga2 restart



#######################
# Master installation #
#######################

# add repositories to the list of sources
wget -O - http://packages.icinga.org/icinga.key | apt-key add -
echo 'deb http://packages.icinga.org/debian icinga-jessie main' >> /etc/apt/sources.list
echo 'deb-src http://packages.icinga.org/debian icinga-jessie main' >> /etc/apt/sources.list
apt-get update

# Icinga2 core
apt-get install icinga2 icinga2-doc
service icinga2 start

# apt-get install mysql-server mysql-client
# apt-get install icinga2-ido-mysql
# icinga2 feature enable ido-mysql command
# service icinga2 restart

# Icinga web interface
# apt-get install apache2
apt-get install icingaweb2
icingacli setup token create
nano /etc/php5/apache2/php.ini # => date.timezone = europe/paris
# apt-get install php5-intl php5-imagick
service apache2 restart

########################
# Master configuration #
########################

# edit the configuration
nano /etc/icinga2/conf.d/hosts.conf
# http://docs.icinga.org/latest/en/objectdefinitions.html#host
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#monitoring-basics

# see the list of hosts
icinga2 object list --type Host

# make master (http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/icinga2-client)
icinga2 node wizard
# Please specify if this is a satellite setup  ->  n
# Enter
# Enter
# Enter
service icinga2 restart

# enable and configure notifications
icinga2 feature enable notification
# define a mail address for the user "icingaadmin"
nano /etc/icinga2/conf.d/users.conf
# => email = "{{me@mydomain.com}}"
# Normally, mail notifications are sent only if host/service objects have the custom attribute `notification` defined and containing `mail` as key. This is true by default

# edit scheduled downtimes
nano /etc/icinga2/conf.d/downtimes.conf

service icinga2 reload


# web access: http://X.X.X.X/icingaweb2/



################################
# Remote installation (Debian) #
################################

# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-remote-systems
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/icinga2-client

# add repositories to the list of sources
wget -O - http://packages.icinga.org/icinga.key | apt-key add -
echo 'deb http://packages.icinga.org/debian icinga-jessie main' >> /etc/apt/sources.list
echo 'deb-src http://packages.icinga.org/debian icinga-jessie main' >> /etc/apt/sources.list
apt-get update

# Icinga2 core
apt-get install icinga2
# Icinga2 plugins
apt-get install monitoring-plugins

# make client (satellite)
icinga2 node wizard
# Please specify if this is a satellite setup  ->  y
# Enter
# Enter
# Master Common Name  ->  [[the name (CN) of the master Icinga server]]
# Do you want to establish a connection to the master from this node  ->  y
# Master endpoint host  ->  [[IP address of the master]]
# Master endpoint port  ->  Enter
# Add more master endpoints?  ->  n
# Enter
# Enter
### Execute the following command on the master server: icinga2 pki ticket --cn '[[client CN]]'
### Give the PKI to the client
# Enter
# Enter
# Accept config from master?  ->  y
# Accept commands from master?  ->  y
service icinga2 restart
# icinga2 node list
#####
# register the new client on the master (on the master side)
icinga2 node update-config
service icinga2 reload

# edit the client configuration (on the client side)
nano /etc/icinga2/conf.d/hosts.conf
nano /etc/icinga2/conf.d/downtimes.conf
service icinga2 reload

# update the master (on the master side)
icinga2 node update-config
service icinga2 reload



################################
# Remote installation (CentOS) #
################################

# add repositories to the list of sources
rpm --import http://packages.icinga.org/icinga.key
wget http://packages.icinga.org/epel/ICINGA-release.repo -O /etc/yum.repos.d/ICINGA-release.repo
# curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo
yum makecache

# Icinga2 core
yum install icinga2
chkconfig icinga2 on
service icinga2 start

# Icinga2 plug-ins
# get the sources
wget https://www.monitoring-plugins.org/download/monitoring-plugins-2.1.2.tar.gz
tar -xzf monitoring-plugins-2.1.2.tar.gz monitoring-plugins-2.1.2
rm -f monitoring-plugins-2.1.2.tar.gz
# compile the sources
yum install gcc
#yum groupinstall "Development tools"
cd monitoring-plugins-2.1.2
./configure
make
# install the binaries
make install
make install-root
# remove the sources
cd ..
rm -Rf monitoring-plugins-2.1.2
# adapt the Icinga2 configuration to set the plug-ins path
sed -i 's#^const PluginDir = .*#const PluginDir = "/usr/local/libexec"#' /etc/icinga2/constants.conf
service icinga2 restart

# make client (satellite)
icinga2 node wizard
# Please specify if this is a satellite setup  ->  y
# Enter
# Enter
# Master Common Name  ->  [[the name (CN) of the master Icinga server]]
# Do you want to establish a connection to the master from this node  ->  y
# Master endpoint host  ->  [[IP address of the master]]
# Master endpoint port  ->  Enter
# Add more master endpoints?  ->  n
# Enter
# Enter
### Execute the following command on the master server: icinga2 pki ticket --cn '[[client CN]]'
### Give the PKI to the client
# Enter
# Enter
# Accept config from master?  ->  y
# Accept commands from master?  ->  y
service icinga2 restart
# icinga2 node list
#####
# register the new client on the master (on the master side)
icinga2 node update-config
service icinga2 reload

# edit the client configuration (on the client side)
nano /etc/icinga2/conf.d/hosts.conf
nano /etc/icinga2/conf.d/downtimes.conf
service icinga2 reload

# update the master (on the master side)
icinga2 node update-config
service icinga2 reload



################################


# Ubuntu
# https://openmoz.wordpress.com/2015/03/18/installing-icinga-2-monitoring-tool-on-ubuntu/
# http://www.unixmen.com/install-icinga-ubuntu/
sudo add-apt-repository ppa:formorer/icinga
sudo apt-get update
sudo apt-get install icinga2

# Ubuntu 11.10
sudo su -c "echo 'deb http://ppa.launchpad.net/formorer/icinga-web/ubuntu oneiric main' >> /etc/apt/sources.list"
sudo su -c "echo 'deb-src http://ppa.launchpad.net/formorer/icinga-web/ubuntu oneiric main' >> /etc/apt/sources.list"
sudo apt-get update
sudo apt-get install icinga2 ## => ne fonctionne pas





# contacts
http://docs.icinga.org/latest/en/notifications2.html




# NRPE

Sur les serveurs à surveiller :
# http://blog.nicolargo.com/2007/10/surveiller-vos-serveurs-linux-avec-nagios-et-nrpe.html
# https://geekpeek.net/could-not-complete-ssl-handshake/
# https://wiki.icinga.org/display/howtos/Setting+up+NRPE+with+Icinga
# http://docs.icinga.org/latest/en/nrpe.html
/etc/nagios-plugins/config/*.cfg
service nagios-nrpe-server restart
/usr/lib/nagios/plugins/check_nrpe -H [[target server IP]]

# check_svn for NRPE
# https://exchange.nagios.org/directory/Plugins/Others/Check_Svn/details





# Asterisk
http://blog.nicolargo.com/2008/10/superviser-asterisk-dans-nagios-grace-a-nagisk.html

# http://blog.nicolargo.com/2008/10/superviser-asterisk-dans-nagios-grace-a-nagisk.html






# Remove a node
icinga2 remove node [[node_name]]
icinga2 node update-config
service icinga2 restart










# wget -O - http://debmon.org/debmon/repo.key 2> /dev/null | apt-key add -
# echo 'deb http://debmon.org/debmon debmon-jessie main' > /etc/apt/sources.list.d/debmon.list
# apt-get update