Icingaにレポーティング機能を追加する

IcingaではJasperReportsと連動できる機能が追加されています。


備忘録として導入時のメモを。

環境説明


環境を簡単にまとめます。

  • CentOS6.4(64bit版)
  • Icinga 1.8.4
  • Jasper Report 5.2.0(64bit版)

※Icingaはバージョン若干古いです。

Jasper Report をインストール


最新版のJasper Report をここからダウンロードします。


以下、Jasper Report を導入手順です。


実行権限をつけます。

# chmod +x jasperreports-server-cp-5.2.0-linux-x64-installer.run


インストールを開始します。ウィザードが実行されます。
今回はデフォルトでインストールを進めます。


# ./jasperreports-server-cp-5.0.0-linux-x64-installer.run
----------------------------------------------------------------------------
Welcome to the JasperReports Server CP 5.2.0 Setup Wizard.

----------------------------------------------------------------------------
Please read the following License Agreement. You must accept the terms of this 
agreement before continuing with the installation.

Press [Enter] to continue :

PLEASE READ THIS AGREEMENT CAREFULLY. BY DOWNLOADING, COPYING, 
INSTALLING OR USING ALL OR ANY PORTION OF THIS PROGRAM YOU ACCEPT ALL
THE TERMS AND CONDITIONS OF THIS AGREEMENT, INCLUDING WITHOUT LIMITATION
THE GNU AFFERO GENERAL PUBLIC LICENSE VERSION 3. YOU AGREE THAT THIS 
AGREEMENT IS LIKE ANY WRITTEN NEGOTIATED AGREEMENT SIGNED BY YOU. THIS 
AGREEMENT IS ENFORCEABLE AGAINST YOU AND ANY LEGAL ENTITY THAT OBTAINED 
THIS PROGRAM AND ON WHOSE BEHALF IT IS USED: FOR EXAMPLE, IF APPLICABLE, 
YOUR EMPLOYER. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, DO 
NOT USE THIS PROGRAM. VISIT http://www.jaspersoft.com AND 
http://www.fsf.org/licensing/licenses/agpl-3.0.html FOR TERMS
AND CONDITIONS.
 
IF YOU HAVE PURCHASED A COMMERCIAL LICENSE AGREEMENT FROM JASPERSOFT, 
YOU MAY HAVE ANOTHER WRITTEN AGREEMENT DIRECTLY WITH JASPERSOFT THAT 
SUPERSEDES ALL OR PORTIONS OF THIS AGREEMENT.
 
JASPERSOFT PERMITS YOU TO DOWNLOAD, COPY, INSTALL, USE, OR OTHERWISE 
BENEFIT FROM THE FUNCTIONALITY OR INTELLECTUAL PROPERTY OF THIS PROGRAM 
ONLY IN ACCORDANCE WITH THE TERMS OF THIS AGREEMENT.  USE OF SOME THIRD 
PARTY MATERIALS AND SERVICES INCLUDED IN OR ACCESSED THROUGH THIS 
PROGRAM MAY BE SUBJECT TO OTHER TERMS AND CONDITIONS TYPICALLY FOUND IN 
A SEPARATE LICENSE AGREEMENT, TERMS OF USE OR "READ ME" FILE LOCATED 
Press [Enter] to continue :
WITHIN OR NEAR SUCH MATERIALS AND SERVICES.
 
Copyright (C) 2005 - 2013 Jaspersoft Corporation. 
All rights reserved.
 
Unless you have purchased a commercial license agreement from
Jaspersoft, the following license terms apply:
 
This program is free software; you can redistribute it and/or modify 
it under the terms of the GNU Affero General Public License version 3 
as published by the Free Software Foundation.
 
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 
Affero General Public License version 3 for more details.
 
You can view a complete copy of the GNU Affero General Public 
License version 3 at 
http://www.fsf.org/licensing/licenses/agpl-3.0.html. You also should 
receive a copy of the GNU Affero General Public License version 3 
along with the program; if not, write to the Free Software Foundation, 
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Press [Enter] to continue :
 
Contact Jaspersoft Corporation
350 Rhode Island St, Ste 250
San Francisco, CA 94103
Web: www.jaspersoft.com
General Inquiries: info@jaspersoft.com
Sales Inquiries: sales@jaspersoft.com


Press [Enter] to continue :

Do you accept this license? [y/n]: y

----------------------------------------------------------------------------
JasperReports Server Installation

Please choose an install option below:

[1] Install All Components and Samples  (requires disk space of: 1.3 GB)
[2] Custom Install
Please choose an option [1] : 1

----------------------------------------------------------------------------
Installation folder

Please, choose a folder to install JasperReports Server CP 5.2.0

Select a folder [/opt/jasperreports-server-cp-5.2.0]: 

----------------------------------------------------------------------------
Setup is now ready to begin installing JasperReports Server CP 5.2.0 on your 
computer.

Do you want to continue? [Y/n]: Y

----------------------------------------------------------------------------
Please wait while Setup installs JasperReports Server CP 5.2.0 on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing JasperReports Server CP 5.2.0 on your computer.

Opt-in for JasperReports Server Heartbeat
Help us build better products by opting in

For more information please visit: 
www.jaspersoft.com/heartbeat
 [Y/n]: n


インストールが終了したら、Jasper Report を起動します。
今回は関連するミドルウェア含めて一式インストールしているので、以下コマンドを実行します。

# /opt/jasperreports-server-cp-5.2.0/ctlscript.sh start
LOG:  database system was shut down at 2013-09-04 01:17:16 JST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
/opt/jasperreports-server-cp-5.2.0/postgresql/scripts/ctl.sh : postgresql  started at port 5432
Using CATALINA_BASE:   /opt/jasperreports-server-cp-5.2.0/apache-tomcat
Using CATALINA_HOME:   /opt/jasperreports-server-cp-5.2.0/apache-tomcat
Using CATALINA_TMPDIR: /opt/jasperreports-server-cp-5.2.0/apache-tomcat/temp
Using JRE_HOME:        /opt/jasperreports-server-cp-5.2.0/java
Using CLASSPATH:       /opt/jasperreports-server-cp-5.2.0/apache-tomcat/bin/bootstrap.jar
/opt/jasperreports-server-cp-5.2.0/apache-tomcat/scripts/ctl.sh : tomcat started

Icinga Report の導入


前提として、自ホストを「/etc/hosts」に登録しておいてください。
そうしないと以降の手順はエラーで終了する事があります。


Icinga Report をダウンロードします。

# wget http://sourceforge.net/projects/icinga/files/icinga-reporting/1.9.0/icinga-reports-1.9.0.tar.gz/download


ソースコードを展開します。

# tar -xvzf icinga-reports-1.9.0.tar.gz


スキーマを作成します。


# mysql -u root -p icinga < icinga-reports-1.9.0/db/icinga/mysql/availability.sql
Enter password: 


また、「icinga@127.0.0.1」のユーザを作成しておきます。
このユーザを作成しないと、後ほど行う、DB接続で拒否されてしまいました。

GRANT ALL ON icinga.* TO 'icinga'@'127.0.0.1' IDENTIFIED BY '******';


その後、icinga-reportsをコンパイルします。

# ./configure --with-jasper-server=/opt/jasperreports-server-cp-5.2.0/
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for jasperserver... configure: creating ./config.status
config.status: creating Makefile


MySQLJDBCドライバをインストールします。

# make install-mysql-connector

*** Installing JDBC driver for MySQL 5.1.18 to your jasper server.....***
*** JDBC driver for MySQL successfully installed ***


そして本体をインストールします。

# make install
make[1]: Entering directory `/usr/local/src/icinga-reports-1.9.0'

*** Beginning import icinga reports into JasperServer..... ***
Using CE setup
Using Bundled version of Java
First resource path:/opt/jasperreports-server-cp-5.2.0/buildomatic/conf_source/ieCe/applicationContext-data-snapshots.xml
Started to load resources
Resource name: applicationContext.xml
Resource name: applicationContext-cascade.xml
Resource name: applicationContext-data-snapshots.xml
Resource name: applicationContext-events-logging.xml
Resource name: applicationContext-export-config.xml
Resource name: applicationContext-export-import.xml
Resource name: applicationContext-logging.xml
Resource name: applicationContext-olap-connection.xml
Resource name: applicationContext-report-scheduling.xml
Resource name: applicationContext-search.xml
Resource name: applicationContext-security.xml
Resource name: applicationContext-themes.xml
Resource name: applicationContext-virtual-data-source.xml
Creating ActionModelService object.
Creating action model infrastructure.
Created repository folder /icinga
Created repository folder /icinga/datasources
Created repository folder /icinga/datatypes
Created repository folder /icinga/images
Created repository folder /icinga/inputcontrols
Created repository folder /icinga/listofvalues
Created repository folder /icinga/reports
Created repository folder /icinga/styles
Created repository folder /icinga/templates
Created repository folder /icinga/reports/host
Created repository folder /icinga/reports/hostgroup
Created repository folder /icinga/reports/other
Created repository folder /icinga/reports/samples
Created repository folder /icinga/reports/service
Created repository folder /icinga/reports/servicegroup
Created repository folder /icinga/reports/userdefined
Created repository folder /icinga/templates/main
Created repository folder /icinga/templates/sub
Created repository folder /icinga/templates/main/host
Created repository folder /icinga/templates/main/hostgroup
Created repository folder /icinga/templates/main/other
Created repository folder /icinga/templates/main/samples
Created repository folder /icinga/templates/main/service
Created repository folder /icinga/templates/main/servicegroup
Created repository folder /icinga/templates/sub/host
Created repository folder /icinga/templates/sub/object
Created repository folder /icinga/templates/sub/other
Created repository folder /icinga/templates/sub/page
Created repository folder /icinga/templates/sub/samples
Created repository folder /icinga/templates/sub/service
Imported resource /icinga/datasources/IDO
Imported resource /icinga/datatypes/time
Imported resource /icinga/images/icinga_background.jpg
Imported resource /icinga/images/icinga_banner.jpg
Imported resource /icinga/images/icinga_logo_header.png
Imported resource /icinga/inputcontrols/p_date_end
Imported resource /icinga/inputcontrols/p_date_start
Imported resource /icinga/inputcontrols/p_host_object_id
Imported resource /icinga/inputcontrols/p_hostgroup_object_id
Imported resource /icinga/inputcontrols/p_service_object_id
Imported resource /icinga/inputcontrols/p_servicegroup_object_id
Imported resource /icinga/inputcontrols/p_time_end
Imported resource /icinga/inputcontrols/p_time_start
Imported resource /icinga/listofvalues/timeperiods
Imported resource /icinga/inputcontrols/p_timeperiod
Imported resource /icinga/listofvalues/weekdays
Imported resource /icinga/inputcontrols/p_weekday_end
Imported resource /icinga/inputcontrols/p_weekday_start
Imported resource /icinga/styles/IcingaStyleBase.jrtx
Imported resource /icinga/templates/main/host/activityReportInGivenTime
Imported resource /icinga/reports/host/HostActivityReportInGivenTime
Imported resource /icinga/templates/main/host/availabilityReportInGivenTime
Imported resource /icinga/reports/host/HostAvailabilityReportInGivenTime
Imported resource /icinga/templates/main/host/downtimeReportOverAllDowntimes
Imported resource /icinga/reports/host/HostDowntimeReport
Imported resource /icinga/templates/main/host/allNotificationReportInGivenTime
Imported resource /icinga/reports/host/HostNotificationReportAboutAllHostsInGivenTime
Imported resource /icinga/templates/main/host/overviewReport
Imported resource /icinga/reports/host/HostOverviewReport
Imported resource /icinga/templates/main/host/top10ReportInGivenTime
Imported resource /icinga/reports/host/HostTop10ReportInGivenTime
Imported resource /icinga/templates/main/hostgroup/availabilityReportInGivenTime
Imported resource /icinga/reports/hostgroup/HostgroupAvailabilityReportInGivenTime
Imported resource /icinga/templates/main/hostgroup/overviewReport
Imported resource /icinga/reports/hostgroup/HostgroupOverviewReport
Imported resource /icinga/templates/main/other/hostServiceAvailabilityReportInGivenTime
Imported resource /icinga/reports/other/HostServiceAvailabilityReportInGivenTime
Imported resource /icinga/templates/main/other/hostServiceTop10ReportInGivenTime
Imported resource /icinga/reports/other/HostServiceTop10ReportInGivenTime
Imported resource /icinga/templates/main/other/logentriesInGivenTime
Imported resource /icinga/reports/other/LogentriesReportInGivenTime
Imported resource /icinga/templates/main/other/morningReport
Imported resource /icinga/reports/other/morningReport
Imported resource /icinga/templates/main/samples/activityWithGraphInGivenTime
Imported resource /icinga/reports/samples/ServiceActivityReportWithGraphInGivenTime
Imported resource /icinga/templates/main/service/activityReportInGivenTime
Imported resource /icinga/reports/service/ServiceActivityReportInGivenTime
Imported resource /icinga/templates/main/service/availabilityReportInGivenTime
Imported resource /icinga/reports/service/ServiceAvailabilityReportInGivenTime
Imported resource /icinga/templates/main/service/downtimeReport
Imported resource /icinga/reports/service/ServiceDowntimeReport
Imported resource /icinga/templates/main/service/allNotificationReportInGivenTime
Imported resource /icinga/reports/service/ServiceNotificationReportAboutAllHostsInGivenTime
Imported resource /icinga/templates/main/service/top10ReportInGivenTime
Imported resource /icinga/reports/service/ServiceTop10ReportInGivenTime
Imported resource /icinga/templates/main/servicegroup/availabilityReportInGivenTime
Imported resource /icinga/reports/servicegroup/ServicegroupAvailabilityReportInGivenTime
Imported resource /icinga/templates/sub/host/activityInGivenTime
Imported resource /icinga/templates/sub/host/allNotificationsInGivenTime
Imported resource /icinga/templates/sub/host/availabilityInGivenTime
Imported resource /icinga/templates/sub/host/contactgroups
Imported resource /icinga/templates/sub/host/contacts
Imported resource /icinga/templates/sub/host/hostgroups
Imported resource /icinga/templates/sub/host/overview
Imported resource /icinga/templates/sub/host/servicegroups
Imported resource /icinga/templates/sub/host/services
Imported resource /icinga/templates/sub/host/top10InGivenTime
Imported resource /icinga/templates/sub/object/acknowledgementsInGivenTime
Imported resource /icinga/templates/sub/object/downtimes
Imported resource /icinga/templates/sub/object/logEntriesInGivenTime
Imported resource /icinga/templates/sub/object/notificationsInGivenTime
Imported resource /icinga/templates/sub/object/statehistoryInGivenTime
Imported resource /icinga/templates/sub/other/hostServiceAvailabilityInGivenTime
Imported resource /icinga/templates/sub/other/hostServiceTop10InGivenTime
Imported resource /icinga/templates/sub/other/morningReport
Imported resource /icinga/templates/sub/page/footer
Imported resource /icinga/templates/sub/samples/activityWithGraphInGivenTime
Imported resource /icinga/templates/sub/service/activityInGivenTime
Imported resource /icinga/templates/sub/service/allNotificationsInGivenTime
Imported resource /icinga/templates/sub/service/availabilityInGivenTime
Imported resource /icinga/templates/sub/service/top10InGivenTime
*** Icinga reports successfully imported ***


*** Installing icinga-reporting.jar to your jasper server.....***
*** JAR-Files successfully installed ***


*** Installing JDBC driver for MySQL 5.1.18 to your jasper server.....***
*** JDBC driver for MySQL successfully installed ***

make[1]: Leaving directory `/usr/local/src/icinga-reports-1.9.0'

*** Icinga reports successfully installed ***


***  Important Notes *******************************************

Icinga availability report:
---------------------------
   Do not forget to update your IDO,
   if using icinga availability reports!

   SQL script can you find in
   db/icinga/mysql/availability.sql


JDBC driver for MySQL:
---------------------------
   The official JDBC driver for MySQL can you find here
   http://dev.mysql.com/downloads/connector/j/


---> Please don't forget to restart your jasper server!!! <---

*************************************************************


Important Notes にあるSQLをDBに流し込みます。

# mysql -u root -p icinga < /usr/local/src/icinga-reports-1.9.0/db/icinga/mysql/availability.sql


JasperReportsのインストールが完了したため、ログインします。
http://:8080/jasperserver/ へアクセスすると以下の画面が表示されるので、
id:jasperadmin, PW:jasperadmin でログインします。



左メニュー「フォルダ」から「Icinga -> Data Sources」を選択し、リポジトリの「IDO」を編集します。



DB接続確認を行います。下記のようになればOKです。



Icinga用のレポートがこのように登録されています。



レポートのうち、Morning Reportを選択し、実行してみたところです。



今日はこんなところで。