Now that we have installed Icinga2 and used it to monitor Linux and Windows nodes we take a little closer look at Icinga Webserver 2.
When we take a look at our Windows server 2016 node we see a couple of services.
We see that most services are within acceptable ranges. But this is only interesting when you want to check the real time situation. What if we wanted to see how these services perform over time? Then we need some sort of graph/chart.
Installing Graphite
For these situations Icinga2 has a module called Graphite. It is really easy to install on the Icinga2 Master. Let’s do that now.
First we need to add the debmon sources to get the dependencies with apt-get.
1 2 3 4 5 |
# cat <<EOF>/etc/apt/sources.list.d/debmon.list deb http://debmon.org/debmon debmon-jessie main EOF # wget -O - http://debmon.org/debmon/repo.key 2>/dev/null | apt-key add - # apt-get update |
Icinga2 Graphite module needs… yes… Graphite!
1 |
# apt-get install graphite-web graphite-carbon libapache2-mod-wsgi |
Graphite needs other packages too but we already installed these in part 1. We also need to enable the graphite module in Icinga2.
1 2 |
# icinga2 feature enable perfdata graphite # systemctl restart icinga2 |
We need to create a database for graphite. Don’t create a Django superuser.
1 2 |
# graphite-manage syncdb # chown _graphite:_graphite /var/lib/graphite/graphite.db |
Graphite needs Apache to output its charts. Learn more about Graphite here. For simplicity we install Graphite on the Icinga2 master on port 8000.
1 2 |
# a2enmod wsgi # nano /etc/apache2/ports.conf |
Add: Listen 8000 (leave 80 for the Icinga2 webserver)
1 2 |
#cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available/graphite.conf # nano /etc/apache2/sites-available/graphite.conf |
Add: <Virtualhost *:8000>
1 2 |
# a2ensite graphite # systemctl restart apache2 |
The Graphite website is now available at: http://[ip-icinga2-master]:8000/
Installing Icinga2 Graphite module
Now that Graphite has been setup, we need to download and add the Icinga2 Graphite module. Icinga2 modules are stored in: /usr/share/icingaweb2/modules
1 2 3 |
# cd /usr/share/icingaweb2/modules/ # git clone https://github.com/findmypast/icingaweb2-module-graphite.git # mv icingaweb2-module-graphite graphite |
If you don’t have Git, install it with: apt-get install git.
We only have to configure the module to point to our Graphite webserver, which is in our case the same host (local-host). Don’t forget adding the question mark to the render url!
1 |
# nano /etc/icingaweb2/modules/graphite/config.ini |
1 2 3 |
[graphite] metric_prefix = icinga base_url = http://localhost:8000/render? |
The standard Graphite configuration at /etc/icinga2/features-enabled/graphite.conf is good.
We only need Carbon. Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend. Its acts like a cache in memory and writes the metrics to disk at certain periods to alleviate disk usage.
1 |
# apt-get install graphite-carbon |
We need to tell Carbon what the data-retention will be on the Icinga2 metrics. Icinga2 documentation has the following suggestion:
1 |
# nano /etc/carbon/storage-schemas.conf |
1 2 3 4 5 6 |
[icinga_internals] pattern = ^icinga\..*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type) retentions = 5m:7d [icinga_default] pattern = ^icinga\. retentions = 1m:2d,5m:10d,30m:90d,360m:4y |
After altering the configuration we need to restart the carbon deamon:
1 2 3 |
# systemctl restart carbon-cache.service # systemctl restart icinga2 # systemctl restart apache2 |
Make sure the Graphite module is enabled in the Icinga2 webserver (Configuration -> Module -> Graphite -> enable)
Conclusion
We now have installed Graphite and by doing so making Icinga2 much more useful. In the last part we are taking a look at custom dashboards for Icinga2 using Dashing. It can be used to setup a monitor or big TV in the office for real-time network information.