How to Setup Monitoring using Dashing Icinga2 Dashboard

December 14, 2016 | By in LINUX HOWTO
| 2 Replies More

Hello, today we are going to install Dashing Icinga2 on Ubuntu. It creates dashboards with icinga2 data, giving you a frontend to monitoring information of your environment's systems. Made out of Ruby on top Dashing framework, which designed to deploy pretty and simple dashboards out of complex and ugly data, it makes the task of monitoring much better.

 Contents

  • Requirements
  • Setup
    • Icinga2 - Install Icinga2 service
      • Mysql - Icinga2 database
      • Icinga2 - Icinga packages
    • Install Dashing Icinga2
      • RVM, Ruby and gems
      • Node.js
  • Configure
    • Enable icinga2 API
    • Authenticate dashing
  • Conclusion

Requirements

The following is a list of the technologies that compose the software stack needed to install and run Dashing Icinga2.

  • curl git apt-get gnupg2 - To install the required packages
  • Dashing
    • ruby - The programming language used by dashing platform
      • RVM - Ruby enVironment manager will be used to install Ruby environment
      • Bundler - Bundler manage gems dependency
      • Dashing - Dashing is the dashboard framework
    • nodejs
    • Dashing Icinga - Icinga2 dashboards
  • Icinga2
    • MySQL - To be used as database backend for monitoring data.
    • Icinga2 - Icinga2 service

There are other indirect dependencies such as other gems and system libraries that you get installed automatically during the setup as you will see later.

Setup

Time to install all these things.  The first part of our setup will show you how to setup a basic Icinga2, if you already have a icinga2 skip to Installing Dashing Icinga2. Don't worry as I will talk about how to setup icinga and dashing to talk to each other in the Configuration section.

Installing Icinga2

Now we are going to setup a simple Icinga2 service capable of monitoring the local machine and log data to a database.

MySQL Server

As mentioned before, we are going to use a MySQL database to store Icinga2 information. So let's install mysql-server package with apt-get.

apt-get install mysql-server

In order to have at least minimum security at our MySQL service, we should run the mysql_secure_installation wizard and follow the steps.

mysql_secure_installation

MySQL Secure Installation Wizard

MySQL Secure Installation Wizard

 Icinga2 service

The next step is to install Icinga2 packages, once again we use apt-get.

apt-get install icinga2 icinga2-common icinga2-ido-mysql icinga2-bin

During the package setup you will be asked about the database backend and its credentials.

Icinga2 enable ido-mysql

Icinga2 enable ido-mysql

Icinga2 Configure database

Icinga2 configure database

Configure database application password

Configure database application password

When you are done with the package setup, it's time to run the icinga2 node wizard to make a basic setup.

icinga2 node wizard

Icinga2 node wizard

Icinga2 node wizard

Restart Icinga2

systemctl restart icinga2

You can check if the icinga2 user is able to reach its databases by calling the following command and providing the application password that we have configured.

 mysql -u icinga2 -p icinga2 -e "show tables"

We are done with Icinga2 for now, we will talk about how to setup the Icinga2's REST for Dashing at the configuration section. For a bit more information on Icinga configuration files and things like adding services and hosts check my startup guide on Icinga2.

Installing Dashing Icinga2

We have now a working Icinga2 instance, so we can continue with Dashing setup.

Ruby, Gems and RVM

Dashing Icinga2 is an web application implementation on the Dashing framework, which is based on Sinatra dialect that goes on top of Ruby and is focused quick web application development with little effort. OK, it seems that there is a reasonable complexity until we get to the "little effort".

To make our lives a bit easier, we are going to use Ruby environment Manager (RVM) and let it take care of some of this Ruby mess.

Before you can install RVM you need GnuPG 2.

apt-get install gnupg2

Now use curl to download RVM install script and pipe it to bash.

curl -L https://get.rvm.io | bash -s stable

Once RVM is installed you must to run its profile script so it extend your shell with its functions and create an abstraction to make its versioning.

source /etc/profile.d/rvm.sh

Install Ruby environment

Now we use RVM to a install specific Ruby version. Note that we are using verison 2.2.3 merely as an example and you should not use is version in production environments.

rvm install 2.2.3

RVM install Ruby

RVM install Ruby

It a good idea to explicitly declare the version you want to use. The more you get used to this, more likely you are to avoid future mistakes.

rvm use 2.2.3

The same goes to the default version.

rvm default 2.2.3

Autolibs

Autolibs is a feature of RVM to allow you to automatically install dependencies on your system. This is particularly useful to solve broken dependencies such as openssl libraries installed at custom location, which i struggled myself and other annoying things like that.

rvm autolibs enable

Gems

Now let's install some gems.

Bundler

First we install Bundler, we will be using it to manage gem dependencies.

gem install bundler

Dashing

This gem is the framework which create dashboards.

gem install dashing

gem install bundler, dashing and its dependencies

gem install bundler, dashing and its dependencies

Node.js

In order to run dashing you must have a javascript backend, so install Node.js backend and its package manager.

apt-get install nodejs npm

Dashing Icinga

Last but not least, we have the Dashing Icinga2 project itself, which creates dashboards with Icinga2 data.

location

Create or change to the directory you are going to host the dashing files, as from the restart-dashing script that comes with the project, and that you are going to download now, the default location  is /usr/share/ but you could be using the directory that best fits your needs.

cd /usr/share/

Now we can just clone Dashing Icinga2 from Github.

git clone https://github.com/Icinga/dashing-icinga2.git

Once git is done, enter the project directory.

cd dashing-icinga2/

Use bundle to install required gems into the system.

bundle install --system

We are done installing things now, next section will show you how to configure the services.

Configuration

Dashing framework need to get information from Icinga2, set how they talk to each other as follows.

Icinga2

Enable REST API

Enable API feature in Icinga2 to interface Dashing

icinga2 feature enable api

Authentication

To use the REST API, dashing Icinga2 must be authenticated, then we are going to create its credentials.

Open the api-users.conf file with vi or your favorite editor.

vim /etc/icinga2/conf.d/api-users.conf

Now add the dashing user, its permissions and password.

object ApiUser "dashing" {

password = "icingadashingondebian"
permissions = [ "status/query", "objects/query/*" ]

}

Done configuring, now restart icinga2.

systemctl restart icinga2

You can check if icinga2 is running and listening.

 netstat -putona | egrep icinga

It should print something like this.

tcp        0      0 0.0.0.0:5665            0.0.0.0:*               LISTEN      15040/icinga2    off (0.00/0/0)

Done with icinga2 configuration.

Dashing

Authentication

From within Dashing Icinga2 project directory, open the configuration file.

$ vim config/icinga2.json

In the icinga2.json file we just need to change the credentials as previously created on icinga2, you should also point the correct host if you are running icinga2 and dashing on different hosts.

{

"icinga2": {

"api": {

"host": "localhost",

"port": 5665,

"user": "dashing",

"password": "icingadashingondebian"

}

}

}

Running

We are now ready to run dashing. For this, run the start script from within dashing icinga2 project directory.

./restart-dashing

You can to access your dashboards from the web browser now. Try http://icinga-dashing-server:8005

Dashing Icinga2 dashboard

Note: Remember to change the hostname accordingly.

If something goes worng, you can check if both services are running with netstat.

netstat -putona | egrep '5665|8005'

You can also check if the following command on the server's terminal gives you any output

curl localhost:8005/icinga2

You can also run dashing on the foreground to see what it is doing to debug some error.

dashing start

dashing working on terminal

dashing working on foreground

Conclusion

At this point you can access your pretty dashboard, see what is going on with your server, so am going to stop here as it was quite a journey and you should let your brain work for a while. Later you could dig into Dashing icinga2 project directory and see how it works, take a look at the docs of things used, so you can go further, debug and correct any problem also customise to your needs. That's all, have fun and thanks for reading!

Filed Under : LINUX HOWTO, MONITORING

Tagged With : ,

Free Linux Ebook to Download

Comments (2)

Trackback URL | Comments RSS Feed

  1. hoerup says:

    Which distro + version are you using?

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.