/dashing-icinga2

Dashing dashboard for Icinga 2 using the REST API

Primary LanguageJavaScript

General

Dashing is a Sinatra based framework that lets you build beautiful dashboards.

This dashing implementation uses the Icinga 2 API to show alerts on your dashboard.

Dashing Icinga 2

Demo

A demo is available inside the Icinga Vagrant Box "icinga2x".

Support

This is intended for demo purposes. You may use the provided examples in your own implementation.

If you have any questions, please hop onto the Icinga community channels.

License

  • Dashing is licensed under the MIT license.
  • Icinga specific jobs and dashboards are licensed under the GPLv2+ license.

Requirements

  • Ruby, Gems and Bundler
  • Dashing Gem
  • Icinga 2 API (v2.5+)

Gems:

gem install bundler
gem install dashing

In case the installation takes quite long and you do not need any documentation, add the --no-document flags.

Configuration

Icinga 2

Icinga 2 provides either basic auth or client certificates for authentication.

Therefore add a new ApiUser object to your Icinga 2 configuration:

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

object ApiUser "dashing" {
  password = "icinga2ondashingr0xx"
  permissions = [ "status/query", "objects/query/*" ]
}

Set the ApiUser permissions according to your needs. By default we will only fetch data from the /v1/status and /v1/objects endpoints, but do not require write permissions.

In case you want to use client certificates, set the client_cn accordingly.

Dashing Configuration

Edit config/icinga2.json and adjust the settings for the Icinga 2 API credentials.

$ vim config/icinga2.json
{
  "icinga2": {
    "api": {
      "host": "localhost",
      "port": 5665,
      "user": "dashing",
      "password": "icinga2ondashingr0xx"
    }
  }
}

If you don't have any configuration file yet, the default values from the example above will be used.

If you prefer to use client certificates, set pki_path accordingly. The Icinga 2 job expects the certificate file names based on the local FQDN e.g. pki/icinga2-master1.localdomain.crt.

Note: If both methods are configured, the Icinga 2 job prefers client certificates.

Run

Linux

Install all required ruby gems into the system path.

bundle install --system

Now start dashing:

./restart-dashing

Additional options are available through ./restart-dashing -h.

Navigate to http://localhost:8005

Unix and OSX

On OSX El Capitan OpenSSL was deprecated, therefore you'll need to fix the eventmachine gem:

brew install openssl
bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
bundle install --path binpaths

Note: Dashing is running as thin server which by default uses epoll from within the eventmachine library. This is not available on unix-based systems, you can safely ignore this warning:

warning: epoll is not supported on this platform

Now start dashing:

./restart-dashing

Additional options are available through ./restart-dashing -h.

Navigate to http://localhost:8005

Thanks

fugstrolch for the Icinga Web 2 iframe integration. tobiasvdk for check stats widget and suggestions. bodsch for the job rewrite and config file support inspiration. spjmurray for styling and 1080p resolution. micke2k for proper time formatting. roidelapliue for the Icinga 1.x dashing script.

Development

Fork the repository on GitHub, commit your changes and send a PR please :)

The Icinga 2 dashboard mainly depends on the following files:

  • dashboards/icinga2.erb
  • jobs/icinga2.rb
  • lib/icinga2.rb
  • config/icinga2.json

Additional changes are inside the widgets. simplemon was added. meter was modified to update the maximum value at runtime. list was updated to highlight colors and change font sizes.

Icinga 2 Library

lib/icinga2.rb provides a class icinga which is responsible for reading the configuration file, initializing the api connection and fetching data.

Several public attributes are exposed by this class already. You'll need to instantiate a new object and then call the run method.

Then you are able to access these attributes and public functions such as getHostobjects and getServiceObjects. These two functions can be called by passing

  • attrs as an array of attribute strings
  • filter as Icinga 2 API filter string
  • joins as an array of joined objects and/or attributes

A simple test runner for testing own modifications has been added into test/icinga2.rb. You can find additional examples over there as well.

TODO

  • Add ticket system demo (e.g. dev.icinga.org)
  • Add Grafana dashboard
  • Hints for Docker integration (docker-icinga2)
  • Replace Dashing with Smashing