Monday 29 July 2013

SAR time format을 24시간 형식으로 변경하기

SAR은 디폴트로 AM/PM형태의 시간 형식을 사용한다. 이를 24시간 형식으로 변경하기위해서는 다음과 같이 한다.
  • 설정으로 변경하기
~/.bashrc
export LC_TIME="POSIX"
or
alias sar='LC_TIME="POSIX" sar'
  • 일회성 설정 사용
LC_TIME="POSIX" sar

Tuesday 23 July 2013

Jasper Reporting Integration

Install JDK & Tomcat

Change default JVM Options
/usr/share/tomcat6/bin/setenv.sh
export CATALINA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m -XX:PermSize=32m -XX:MaxPermSize=128m -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"

Firewall

/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

Install JasperServer

이 항목은 JasperServer에 번들로 제공되는 Tomcat과 PostgreSQL을 사용하지 않고 JasperReports Server WAR File Installer 을 통해 설치를 진행한다.

Extract file

unzip jasperreports-server-cp-5.1.0-bin_2.zip -d /tmp/

Create database

CREATE DATABASE jasperserver character set utf8;
GRANT ALL on *.* to 'jasperdb'@'localhost' IDENTIFIED BY 'tRe56Tr4V';
FLUSH PRIVILEGES; 
jasperdb account password : tRe56Tr4V (tango - ROMEO - echo - Five - Six - TANGO - romeo - Four - VICTOR)

Setting install configuration

cd /tmp/jasperreports-server-cp-5.1.0-bin/buildomatic/
cp sample_conf/mysql_master.properties default_master.properties
default_master.properties
appServerType = tomcat6
appServerDir = /usr/share/tomcat6
CATALINA_HOME = /usr/share/tomcat6
CATALINA_BASE = /usr/share/tomcat6


dbType=mysql


dbHost=localhost
dbUsername=jasperdb
dbPassword=tRe56Tr4V


deployJDBCDriver=false

Download MySQL JDBC Connector

tar zxvf mysql-connector-java-5.1.25.tar.gz -C /tmp
cd /tmp/mysql-connector-java-5.1.25/
cp mysql-connector-java-5.1.25-bin.jar /tmp/jasperreports-server-cp-5.1.0-bin/buildomatic/conf_source/db/mysql/jdbc/
cp mysql-connector-java-5.1.25-bin.jar /usr/share/tomcat6/lib/
chown tomcat: /usr/share/tomcat6/lib/mysql-connector-java-5.1.25-bin.jar

Deploying

./js-install-ce.sh

Change Permission JasperServer Web Context

chown -R tomcat: /usr/share/tomcat6/webapps/jasperserver

Connect

http://<IP>:8080/jasperserver
  • default account : User: jasperadmin Password: jasperadmin
  • sample end-user : User: joeuser Password: joeuser
  • CAUTION: For security reasons, always change the default passwords immediately after installing JasperReports Server.

Install Icinga Reports

Extract package

tar zxvf icinga-reports-1.9.0.tar.gz -C /tmp
cd /tmp/icinga-reports-1.9.0

Modifying Icinga Database

mysql -uroot -p icinga < db/icinga/mysql/availability.sql
Check Grant options
SHOW GRANTS FOR 'icinga'@'localhost';
+---------------------------------------------------------------------------------------------------------------+
| Grants for icinga@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'icinga'@'localhost' IDENTIFIED BY PASSWORD '*88D4515B04D41BAB8B950A069A26A2D449460144' |
| GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW ON `icinga`.* TO 'icinga'@'localhost'                 |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MySQL
GRANT EXECUTE ON icinga.* to 'icinga'@'localhost';
SHOW GRANTS FOR 'icinga'@'localhost';
+---------------------------------------------------------------------------------------------------------------+
| Grants for icinga@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'icinga'@'localhost' IDENTIFIED BY PASSWORD '*88D4515B04D41BAB8B950A069A26A2D449460144' |
| GRANT SELECT, INSERT, UPDATE, DELETE, DROP, EXECUTE, CREATE VIEW ON `icinga`.* TO 'icinga'@'localhost'        |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)


FLUSH PRIVILEGES;

Import Icinga jasper report & Copy icinga report JAR

./configure --with-jasper-server=/tmp/jasperreports-server-cp-5.1.0-bin
make js-import-icinga
cp ./jsp-server/classes/icinga/icinga-reporting.jar /usr/share/tomcat6/webapps/jasperserver/WEB-INF/lib
make install 명령은 Jasper Report Server 설치본으로 설치한 경우에만 제대로 동작하므로 여기서는 각각 설치하도록 하였다.

Change IDO Settings

  • root -> Icinga -> Data Sources -> IDO Select -> Click Edit Button on the right panel
  • Change icinga password and Click Test Connection button
  • Click Save button when the connection test is passed

Wednesday 3 July 2013

NagiosQL 3.2.0 SP2 설치하기

Installing

Prerequisites

  • Apache web server
  • MySQL Server version 4.1 or above
  • PHP version 5.2 or above
  • Nagios 2.x or 3.x
  • Additional PHP Modules:
    • session
    • MySQL
    • gettext
    • filter
    • ftp(for FTP connections to remote servers)
    • ssh
      yum -y install php-devel libssh2-devel
      pecl install -f ssh2
       
      echo "extension=ssh2.so" >> /etc/php.ini
      service httpd restart
      php -m | grep ssh2 명령을 통하여 모듈이 로드되어있는지 확인 할 수 있다.

Prepare directory structure

mkdir -p /etc/nagiosql/{hosts,services}
mkdir -p /etc/nagiosql/backup/{hosts,services}
chown -R apache:icinga /etc/nagiosql

Icinga configuration files

chown apache:icinga /usr/local/icinga/etc/icinga.cfg
chown apache:icinga /usr/local/icinga/etc/cgi.cfg
chown apache:icinga /usr/local/icinga/var/rw/icinga.cmd
chgrp apache /usr/local/icinga/etc /usr/local/icinga/var/spool

chmod 640 /usr/local/icinga/etc/{icinga.cfg,cgi.cfg}
chmod 660 /usr/local/icinga/var/rw/icinga.cmd

  • chgrp apache /usr/local/icinga/etc 는 Tools -> Nagios config 메뉴를 통하여 설정파일을 수정할 수 있게 함
  • chgrp apache /usr/local/icinga/var/spool 는 Tools -> Nagios control -> Check configuration files 메뉴 실행시 Nagios가 재시작 가능한지 여부를 체크하기 위함
Install NagiosQL
tar zxvf nagiosql_320.tar.gz -C /opt/
mv /opt/nagiosql32 /opt/nagiosql
chown -R apache /opt/nagiosql
chmod 750 /opt/nagiosql/config

Prepare PHP configuration

...생략...
file_uploads = On
...생략...
session.auto_start = 0
...생략...
date.timezone = "Asia/Seoul"
...생략...

Prepare Apache configuration

/etc/httpd/conf.d/nagiosql.conf
#NAGIOSQL SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
#Last Modified: 03-24-2011
#This file contains examples of entries that need
#to be incorporated into your Apache web server
#configuration file. Customize the paths, etc. as
#needed to fit your system.
Alias /nagiosql "/opt/nagiosql"
<Directory "/opt/nagiosql">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
        # Order deny,allow
        # Deny from all
        # Allow from 127.0.0.1
        # AuthName "NagiosQL Access"
        # AuthType Basic
        # AuthUserFile /etc/nagiosql/auth/nagiosql.users
        # Require valid-user
</Directory>
service httpd restart

NagiosQL Installer

http://<IP>/nagiosql








MySQL nagiosql_user password : prab8Ute
Nagios config path : /usr/local/icinga/etc/


Apply Service Pack 2

unzip nagiosql_320_sp2.zip -d /tmp
chown -R apache: /tmp/NagiosQL_3.2.0_SP2
cp -vfr /tmp/NagiosQL_3.2.0_SP2/* /opt/nagiosql/

Delete NagiosQL Installer

rm -rf /opt/nagiosql/install

Configuration

Configuration domain administration


Check Icinga Configuration file(icinga.cfg)

NagioSQL은 다음 파일을 사용한다고 가정하므로 반드시 다음 항목들이 icinga.cfg 파일에 들어가도록 한다.
## Timeperiods
cfg_file=/etc/nagiosql/timeperiods.cfg
## Commands
cfg_file=/etc/nagiosql/commands.cfg
## Contacts
cfg_file=/etc/nagiosql/contacts.cfg
cfg_file=/etc/nagiosql/contactgroups.cfg
cfg_file=/etc/nagiosql/contacttemplates.cfg
## Hosts
cfg_dir=/etc/nagiosql/hosts
cfg_file=/etc/nagiosql/hosttemplates.cfg
cfg_file=/etc/nagiosql/hostgroups.cfg
cfg_file=/etc/nagiosql/hostextinfo.cfg
cfg_file=/etc/nagiosql/hostescalations.cfg
cfg_file=/etc/nagiosql/hostdependencies.cfg
## Services
cfg_dir=/etc/nagiosql/services
cfg_file=/etc/nagiosql/servicetemplates.cfg
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_file=/etc/nagiosql/serviceextinfo.cfg
cfg_file=/etc/nagiosql/serviceescalations.cfg
cfg_file=/etc/nagiosql/servicedependencies.cfg

Upgrade 1.8.x to 1.9.0

Stop Services

service icinga stop
service ido2db stop

Upgrade Icinga

su -l icinga
tar zxvf icinga-1.9.0.tar.gz -C /tmp
cd /tmp/icinga-1.9.0
./configure --with-command-group=icinga-cmd --enable-idoutils --enable-ssl
make all
make install install-base install-cgis install-html install-init install-commandmode install-idoutils (as a root)

Upgrade IDO2DB

cd /tmp/icinga-1.9.0/module/idoutils/db/mysql/upgrade 
mysql -uroot -p icinga < mysql-upgrade-1.9.0.sql

Start Services

service ido2db start
service icinga start