Visgence Inc. 2017
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/
An Icinga Web 2 Module for mapping network topology and displaying realtime status of Icinga 2 Networks
This module implements vis.js http://visjs.org to create a topological network map for Icinga 2 Web. To generate the relationships between the nodes, a custom variable "parents" is used in the host configurtion files, similar to use in Icinga 1/Nagios. To generate depedency information, an apply rule is applied which creates up to date depenency information, including multiple parentage.
- Displays Icinga 2 network topology in either hierarchical or network layouts.
- Displays up-to-date status information for hosts based on state information pulled from Icinga 2 API
- Allows for customization of network topology after initial simulation via dragging nodes to desired locations
- Automatically redraws network when a host is added or removed.
- Directly links to host information via double clicking on nodes.
- Display networks in fullscreen while updateing graph realtime.
These instructions assume all listed operations are being performed on a machine that has icinga 2 and icinga web 2 installed, including a database system such as MySQL or Postgresql.
First clone this repository into /usr/share/icingaweb2/modules
Next rename to dependency_plugin: mv icinga2-dependency-module dependency_plugin
Create directory /etc/icingaweb2/modules/dependency_plugin/
In that directory create file config.ini
and add the following:
[db]
resource = "dependencies"
This module will attempt to graph any dependencies, an example apply rule to generate dependencies is shown below (create new file /etc/icinga2/conf.d/parents.conf):
apply Dependency "Parent" for (parent in host.vars.parents) to Host {
parent_host_name = parent
assign where host.address && host.vars.parents
}
this apply rule generates a dependency between hosts using a custom variable "parents".
To use the example apply rule to generate dependencies, insert the following into host configuration files or modify using icinga director. An example host with the correct parent variable is:
object Host "example-host" {
import "generic-host"
display_name = "example-host"
address = "127.0.0.1"
check_command = "check-host-alive"
groups = [ "homegroup" ]
vars.parents = [ "Parent-1", "Parent-2" ]
}
Note: The apply rule will fail if hosts listed in vars.parents do not exist, ensure that the parents exist before attempting to deploy.
Both Postgresql and MySQL are supported.
With access to psql:
psql -q -c "CREATE DATABASE dependencies WITH ENCODING 'UTF8';"
psql dependencies -q -c "CREATE USER dependencies WITH PASSWORD 'dependencies';
GRANT ALL PRIVILEGES ON DATABASE dependencies TO dependencies;"
Note: replace password "dependencies" with desired password
Depending on postgres configuration, this may be neccesary if "ident" errors are encountered during setup:
add the following to /var/lib/pgsql/data/pg_hba.conf (CentOS) or /etc/postgresql/Postgres Version/main/pg_hba.conf (Debian)
local dependencies dependencies md5
host dependencies dependencies 127.0.0.1/32 md5
host dependencies dependencies ::1/128 md5
and restart postgres systemctl restart postgresql
psql dependencies -d dependencies < /usr/share/icingaweb2/modules/dependency_plugin/application/schema/init.sql
mysql -e "CREATE DATABASE dependencies CHARACTER SET 'utf8';
GRANT ALL ON dependencies.* TO dependencies@localhost IDENTIFIED BY 'dependencies';"
Note: replace password "dependencies" with desired password
mysql -U dependencies -D dependencies < /usr/share/icingaweb2/modules/dependency_plugin/application/schema/init.sql
In order to query data, this module needs full API access to Icinga Web 2. This can be accomplished by adding a new user to api-users.conf file
using sudo vim /etc/icinga2/conf.d/api-users.conf
add the following lines to the configuration file:
object ApiUser "dependencies" {
password = "dependencies"
permissions = [ "status/query", "objects/query/*" ]
}
Note: replace password "dependencies" with desired password
In Icinga Web, navigate to Configuration > Modules, and select dependency plugin. Next to "State" click enable.
- In Icinga Web 2 select configuration menu item.
- Select Application entry.
- Select Resource Tab.
- Select create new resource.
- Create new resosurce using filling in resource name, database name, username, and password. (default is dependencies for all)
- Validate resource and save changes.
- Refresh Icinga 2 Page
Next, navigate to the modules entry in Icinga Web 2 to automatically launch the kickstart page and finish the setup process by selecting created resource and entering in Icinga 2 API information. The icinga2 default API port is 5665. If you have misconfigured the settings and maybe getting an Unexpected Error Encountered, Check Console
you may always call /dependency_plugin/module/kickstart again to correct the settings again.
Navigate to Icinga Director > Define Data Fields. Add new entry with Caption and Field name both equal to 'parents', Data type is Array, click Add.
Navigate to Icinga Director > Hosts > Host Templates. Choose one to modify or add new. Modify: Choose Template, click Fields tab, choose parents from drop down list and click Add. Add: Enter name and other data then click Add. New tabs appear at the top right, click Fields tab, choose 'parents' from drop down list and click Add.
Apply all files ending with -migration.sql
which are in application/schema
in ascending
order.