My lab network has been missing monitoring for its entire existence, and a week ago, I would have considered it the only major software category not present. Some time ago, I made a screencast and blog post on installing Icinga with Postgres, but never got much further with actual usage. This week, I decided to try an Icinga install again.
Part of the motivation to try again, was stripped down How To from Digital Ocean (How To Use Icinga To Monitor Your Servers and Services On Ubuntu 14.04), which I followed and got a basic Icinga 1 install running. I had to dig to fill in some gaps, but came out with a much better understanding of Icinga itself.
Icinga 2 was recently released, and I decided to try for the ‘latest & greatest’ in my lab, since the knowledge was at least somewhat transferrable between Icinga and Nagios if I ever encountered them. I began by reading the Getting Started guide, but found the guide contained too many disclaimers and variations to be useful as a Quick Start. After burning through a few VMs, I parred down the content of the Getting Started section, in to a Quick Start Guide for Icinga 2 w/ Icinga Web.
I started with a fresh Minimal CentOS 6 install. The Icinga 2 packages require some elements from the EPEL Repository, so we add that first. Then we add the Icinga repository and sync the repo listings.
# yum install http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm # rpm --import http://packages.icinga.org/icinga.key # curl http://packages.icinga.org/epel/ICINGA-release.repo -o /etc/yum.repos.d/ICINGA-release.repo # yum makecache
I struggled with access when I tried Icinga on PostgreSQL previously, so I opted for MySQL. This will install MySQL, start it, set it to start on boot, and allow you to configure a root password.
# yum install mysql-server # service mysqld start # mysql_secure_installation
Now we are ready to actually install Icinga 2.
# yum install icinga2 # yum install nagios-plugins-all # yum install icinga2-ido-mysql # mysql -u root -p mysql> CREATE DATABASE icinga; mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga'; mysql> quit # mysql -u root -p icinga < /usr/share/doc/icinga2-ido-mysql-2.0.1/schema/mysql.sql # vi /etc/icinga2/features-available/ido-mysql.conf ##Remove comment markings ##Password should match the SQL GRANT used above # icinga2-enable-feature ido-mysql # icinga2-enable-feature command # service icinga2 restart
This will install Icinga 2, the Monitoring Plugins, and the IDO Utils for MySQL which will be needed later for Icinga-Web later.
Now we will install the web interface. I’m not quite bold enough to try the Experimental Icinga 2 UI, so we will just use the Icinga 1.x interface (1.x is not Classic).
# yum install icinga-web icinga-web-mysql php-mysql # usermod -a -G icingacmd apache # vi /etc/icinga-web/conf.d/access.xml <resource name="icinga_pipe">/var/run/icinga2/cmd/icinga2.cmd</resource> # mysql -u root -p mysql> CREATE DATABASE icinga_web; mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga_web.* TO 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web'; mysql> quit # mysql -u root -p icinga_web < /usr/share/doc/icinga-web-1.11.0/schema/mysql.sql # icinga-web-clearcache
Here we have installed the requisite packages (I found that php-mysql was not a dependency and had to be installed explicitly). Then we add the web server user to the icingacmd group. This gives the web server access to the file specified by “icinga_pipe” so we can control Icinga from the web interface.
If you navigate to http://server-address/icinga-web, you should be greeted by the login page. Default username and password on RedHat installs is root:password. If everything is working, you should have a few services being checked on the new server and be able to tell Icinga to run commands. (i.e.-run this check right now)
A quick comment on the configuration I discovered.
If you check out /usr/share/icinga2/include/command-plugins.conf, you’ll see that commands have an ‘arguments’ which has a command line flag and a variable. You can pass these in your checks by adding “vars.variable_name” in your Service Object.
/usr/share/icinga2/include/command-plugins.conf object CheckCommand "http" { import "plugin-check-command" command = PluginDir + "/check_http" arguments = { "-H" = "$http_vhost$" "-I" = "$http_address$" "-u" = "$http_uri$" ... "-w" = "$http_warn_time$" "-c" = "$http_critical_time$" } vars.http_address = "$address$" vars.http_ssl = false vars.http_sni = false } /etc/icinga2/conf.d/hosts/www object Service "blog" { import "generic-service" host_name = "nginx" check_command = "http" vars.http_vhost = "blog.slatehorizon.com" vars.sla = "24x7" }
The ‘command-plugins’ file and that tip should help you quickly get basic monitoring setup going.