Add host to Icinga2

icinga_logo

Adding a Windows 2008 Server to Icinga2 master Server using Icinga2 agent

Setup the Icinga2 master for node clients and make shure the answer to the first question is n (no).

# icinga2 node wizard

Dowload  the agent from Icinga2 website and run it.

After the installation the setup wizzard will pop up.

icinga1

Remember the Instance Name as you will need it to generate the Setup Ticket in the Icinga2 server.

Add the Icinga2 master

Click the Add button and fill in the box

icinga2

Run this command in Icinga2 server to generate the Setup Ticket

# icinga2 pki ticket -cn infra-veeam.domain.local

Now copy the ticket and past it to the box

icinga3

Firewall

Before you click next check if the port 5665 is open in the Windows server and add a rule in Icinga2 server to permit connections

Check your active zones

# firewall-cmd --get-active-zones

I just had one “public” zone

At this point i added the rule to the firewall by running the command

# firewall-cmd --zone=public --add-port=5665/tcp --permanent

Continue the installation and finish it.

Open a command prompt and type in the command:

command

If all goes well you should get this output

command1

Now update the configured hosts by running and restart icinga2

# icinga2 node update-config
# systemctl reload icinga2

And that’s it! If you have Icinga Web 2 the host should pop up.
This post was based on the Documentation shared by the Icinga project

 

Icinga2 on CentOS7

icinga_logo

A Software to monitor the health of an infrastructure is a vital component to a good system administrator.

After looking arround for open source software i decided to give Icinga2 a try.

Icinga2 is a fork of Nagios (it’s a good start) and looks much cooler 🙂 (IMO The cool factor is very important)

CentOS7 was the choice for the Operating System.

After reading the documentation in Icinga website and having some trouble i decided to add some crucial steps that i had to take to perform a successful installation.

All the steps described are performed as root user

First thing firts, after CentOS installation update your system:

# yum update

Now add the Icinga repository to your package management configuration

# rpm --import http://packages.icinga.org/icinga.key
# curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo
# yum makecache

Install Icinga2

# yum install icinga2
# systemctl enable icinga2
# systemctl start icinga2

Congratulations Icinga2 is installed.

CheckPlugins

It’s time to install the checkplugins.

As Icinga2 is a Nagios fork we are going ot install the same plugins for it to work properly by installing the Monitoring Plugins.

# wget https://www.monitoring-plugins.org/download/monitoring-plugins-2.1.2.tar.gz
# yum install gcc
# gzip -dc monitoring-plugins-2.x.tar.gz | tar -xf -
# cd monitoring-plugins-2.x
# ./configure
# make
# make install

Vim editor

Icinga2 comes with some color schemes for vim that you can install by

# PREFIX=~/.vim
# mkdir -p $PREFIX/{syntax,ftdetect}
# cd /usr/share/doc/icinga2-common-2.4.1/syntax/
# cp vim/syntax/icinga2.vim $PREFIX/syntax/
# cp vim/ftdetect/icinga2.vim $PREFIX/ftdetect/

Lets change the installation directory of the plugins from /urs/lib64/* to /urs/local/libexec in the constants.conf file of icinga2. The file is in /etc/icinga2

# cd /etc/icinga2
# vim constants.conf

Creating a systemctl for Icinga2

# systemctl enable icinga2
# systemctl start icinga2

Icinga Web 2 interface

At this point Icinga2 is istalled and configured.
Icinga 2 can be used with Icinga Web 2 and a number of other web interfaces.
For now i am going to install Icinga Web 2.
Firts we are going to install MySQL

# yum install mariadb-server mariadb
# systemctl enable mariadb
# systemctl start mariadb
# mysql_secure_installation

Now install install the icinga2-ido-mysql package

# yum install icinga2-ido-mysql

MySQL setup and configuration

# mysql -u root -p
mysql>  CREATE DATABASE icinga;
        GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql

Enable the IDO MySQL module

# icinga2 feature enable ido-mysql
# systemctl restart icinga2

WebServer install

If you did not install the CenOS web server you need to install httpd

# yum install httpd
# systemctl enable httpd
# systemctl start httpd

Firewall

Add some rules to permit access to the web server

# firewall-cmd --add-service=http
# firewall-cmd --permanent --add-service=http

Command Pipe

For the Icinga2 to receive commands from the Icinga Web 2 you need to enable the command pipe

# icinga2 feature enable command
# systemctl restart icinga2

Icinga Web 2 interface installation

Setting up package repository

# rpm --import http://packages.icinga.org/icinga.key
# curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo
# yum makecache

EPEL install

# yum install epel-release

PHP install

# yum install php php-mysql

Don’t forget to change the date.timezone in /etc/php.ini

Let’s install the web interface

# yum install icingaweb2 icingacli

And now lets prepare for the web setup

# icingacli setup token create

Run this command to mitigate an error at the web setup

chcon -R -t httpd_sys_rw_content_t /etc/icingaweb2/

Copy the token and access the site:
http://<server-ip>/icingaweb2/setup
past the token and continue the setup
If the website does not open restart the httpd by running:

# systemctl restart http

For the web interface to work (send commands to your icinga server) you need to disable SELinx in your system.
To do that just edit the file /etc/selinux/confing and change the enforcing to disabled.

Zabbix tutorial

As Nagios, Zabbix lets you monitor your network. I’ll user the same operating system as before (Ubuntu Server 12.04.2 64btis)

Install it and use zabbix as your username

DO NOT SELECT THE OPTION “ENCRYPT HOME FOLDER”

After installation just run the commnads:

$ sudo apt-get update
$ sudo apt-get install build-essential mysql-server libmysqlclient15-dev php5 php5-gd php5-mysql snmp libsnmp-dev snmpd libcurl4-openssl-dev fping

When prompted for a MySQL password just leave it blank

wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gztar zxvpf zabbix-2.0.6.tar.gz

Now lets create the zabbix database and populate it

sudo mysql -e"create database zabbix;"
$ sudo mysql -e"grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixpassword';"mysql -D zabbix -uzabbix -pzabbixpassword < /home/zabbix/zabbix-2.0.6/database/mysql/schema.sqlmysql -D zabbix -uzabbix -pzabbixpassword < /home/zabbix/zabbix-2.0.6/database/mysql/images.sql
$ mysql -D zabbix -uzabbix -pzabbixpassword < /home/zabbix/zabbix-2.0.6/database/mysql/data.sql

You must respect the order of the commands or you’ll get a bunch of errors in sql database creations (i’ve learned that the hard way).

$ cd /home/zabbix/zabbix-2.0.6/./configure --prefix=/usr --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent && make  
$ sudo make install

now lets configure the rest of the system edit the /etc/services file

$ sudo vi /etc/services

go to the end of the file and add this:

zabbix_agent   10050/tcp           # Zabbix ports

zabbix_trap      10051/tcp

Save and exit

$ sudo mkdir /etc/zabbix
$ sudo chown -R zabbix.zabbix /etc/zabbix/
$ cp /home/zabbix/zabbix-2.0.6/conf/zabbix_*.* /etc/zabbix/

After copying the files we need to make sure that the Server is pointing to 127.0.0.1

We do this by  editing the /etc/zabbix/zabbix_agentd.conf:

$ sudo vi /etc/zabbix/zabbix_agentd.conf

Now lets edit the zabbix_server.conf  (for small sites this default file will do, however if you are into tweaking your config for your 10+ hosts site, this is the place).

Change this:

# Database user

DBUser=zabbix

# Database password

# Comment this line if no password used

DBPassword=Secret

Copy the init.d scripts to the right spot:

$ sudo cp /usr/sbin/zabbix_*.* /etc/init.d/

Now lets correct permissions and set ZABBIX to start when the machine boots:

$ sudo chmod 755 /etc/init.d/zabbix_server
$ sudo update-rc.d zabbix_server defaultssudo chmod 755 /etc/init.d/zabbix_agentsudo update-rc.d zabbix_agent defaults

Its time to start them:

$ sudo /etc/init.d/zabbix_server start
$ sudo /etc/init.d/zabbix_agent start

Configure web interface:

$ mkdir /home/zabbix/public_html 
$ cp -R /home/zabbix/zabbix-2.0.6/frontends/php/* /home/zabbix/public_html/

Configure Apache2:

sudo vi /etc/apache2/sites-enabled/000-default

Add this:

Alias /zabbix /home/zabbix/public_html/
<Directory /home/zabbix/public_html>
  AllowOverride FileInfo AuthConfig Limit Indexes
  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
  <Limit GET POST OPTIONS PROPFIND>
    Order allow,deny
    Allow from all
  </Limit>
  <LimitExcept GET POST OPTIONS PROPFIND>
    Order deny,allow
    Deny from all
  </LimitExcept>
</Directory>

Make php.ini adjustments:

$ sudo vi /etc/php5/apache2/php.ini

Change the values to:

max_execution_time form = 300

max_input_time = 300

post_max_size = 16M

date.timzone = Europe/London

save and exit.

Restart the apache2 service:

$ sudo /etc/init.d/apache2 restart

that’s all for today’s lesson