icinga 一開始是 nagios 分支出來的一套同樣是監控系統
但比 nagios 整合了 ido2db (資料庫)、icinga-web (API)  在一起
web 介面除了有 classic UI (與 nagios 些微不同,且直覺) 之外,還有 icinga-web 介面 供 API 使用 (從資料庫撈)

操作跟 nagios 機乎差不多,那會用 icinga 基本上是因為有 RESTful API、Classic UI、及 可以期待 icinga 2版 ,也可詳看 Icinga vs. Nagios

# 安裝需要的套件

yum -y install httpd gcc glibc glibc-common gd gd-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install net-snmp net-snmp-devel net-snmp-utils
yum -y install libdbi-drivers libdbi-dbd-mysql libdbi libdbi-devel
yum -y install php-pdo php-mysql php php-gd php-pear php-xml

# 新增使用者

useradd -c icinga -d /usr/local/icinga -s /bin/bash icinga -m
groupadd icinga
groupadd icinga-cmd
/usr/sbin/usermod -a -G icinga-cmd icinga
/usr/sbin/usermod -a -G icinga-cmd apache
chmod 755 /usr/local/icinga/

# 編譯 icinga,使用 GIT 庫

git clone git://git.icinga.org/icinga-core.git
# update
#git pull
#git submodule init
cd /root/icinga-core/
make distclean ; ./configure --prefix=/usr/local/icinga --with-command-group=icinga-cmd --enable-perfdata --enable-idoutils --with-temp-dir=/usr/local/icinga/tmp --with-temp-file=/usr/local/icinga/tmp/icinga.tmp  --with-perlcache --with-web-user=apache --with-web-group=apache --with-httpd-conf=/etc/httpd/conf.d --with-idomod-tmpfile=/usr/local/icinga/tmp/idomod.tmp --with-lockfile=/usr/local/icinga/tmp/icinga.lock --with-ido2db-lockfile=/usr/local/icinga/tmp/ido2db.lock --with-ido-sockfile=/usr/local/icinga/tmp/ido.sock
make all
make install
make install-cgis 
make install-config 
make install-webconf
make install-init 
make install-commandmode
make install-idoutils 
make install-eventhandlers
make install-webconf-auth

# 參數說明

# Install targets:
#        install                 - install core, cgis, html
#        install-base            - install core
#        install-cgis            - install classical web
#        install-html            - install html files
#        install-config          - install sample config
#        install-webconf         - install apache config and http auth file for Classic UI
#        install-init            - install init script
#        install-commandmode     - install external command file
#        install-idoutils        - install idoutils module
#        install-eventhandlers   - install sample eventhandlers
#        install-dev-docu        - install doxygen development documentation
#        install-testconfig      - install test config
#        install-classicui-standalone - install standalone classic ui
#        install-classicui-standalone-conf - install standalone classic ui config

# 建立 tmp 目錄,我特別把 tmp 定義起來

mkdir -p /usr/local/icinga/tmp
chown icinga.icinga /usr/local/icinga/tmp

# 設定 apache 帳密

htpasswd /usr/local/icinga/etc/htpasswd.users icingaadmin

# 安裝外掛,它還是用 nagios-plugins ,已到 2.0 版了

wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
tar zxvf nagios-plugins-2.0.tar.gz
cd /root/nagios-plugins-2.0
./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-nagios-user=icinga --with-nagios-group=icinga --with-openssl --enable-perl-modules
make
make install

# 主設定檔
vi /usr/local/icinga/etc/icinga.cfg

# 註解參數,因為 log 顯示 config setting 'event_profiling_enabled' unknown ,我也不知道為什麼,就把它註解了
#event_profiling_enabled
# or
#sed -i 's/^event_profiling_enabled/#event_profiling_enabled/g' /usr/local/icinga//etc/icinga.cfg

# 設定同時間可以處理的程序,預設為 0 ,即無限,但假如主機效能低的話,這個就不要太高,也有可能會有 session 問題
max_concurrent_checks=150
# or
#sed -i 's/^max_concurrent_checks=.*/max_concurrent_checks=150/g' /usr/local/icinga/etc/icinga.cfg

# 設定顯示時間格式,還是習慣看 2014-07-20 12:12:12
date_format=iso8601
# or
#sed -i 's/^date_format=.*/date_format=iso8601/g' /usr/local/icinga/etc/icinga.cfg

# 設定不要把 log 記錄到 /var/log/messages
use_syslog=0
# or
#sed -i 's/^use_syslog=.*/use_syslog=0/g' /usr/local/icinga/etc/icinga.cfg

# 我把 flapping 關閉,因為打開會讓 check 出來時是無值的
enable_flap_detection=0

# 讓 classic UI 介面顯示全部列表,我不想一直下一頁下一頁
vi /usr/local/icinga/etc/cgi.cfg

result_limit=0
# or
#sed -i 's/^result_limit=.*/result_limit=0/g' /usr/local/icinga/etc/cgi.cfg

# 設定支援 UTF8
# 這項其實是我原本有在 nagios 上設定,是為了讓 web UI可支援中文,在 icinga 我並沒有實際設定測試

# vi "/etc/httpd/conf.d/icinga.conf"
<Directory "/usr/local/icinga/sbin">
# 加入
AddDefaultCharset UTF-8

# or
#sed -i 35a'AddDefaultCharset UTF-8' "/etc/httpd/conf.d/icinga.conf"

# vi /usr/local/icinga/etc/cgi.cfg
escape_html_tags=0
# or
#sed -i 's/^escape_html_tags=.*/escape_html_tags=0/g' /usr/local/icinga/etc/cgi.cfg

到這裡就

service httpd restart
service icinga restart

並可瀏覽 Classic UI

http://1.1.1.1/icinga

# 補充,如何 upgrade icinga
在 make all 之後

make install install-base install-cgis install-html install-init install-commandmode install-idoutils

# 資料庫,看原本版本號是多少,再一一匯入到最新的
mysql -u root -p icinga < icinga-core/module/idoutils/db/mysql/upgrade/mysql-upgrade-1.11.3.sql 
mysql -u root -p icinga < icinga-core/module/idoutils/db/mysql/upgrade/mysql-upgrade-1.11.6.sql 
mysql -u root -p icinga < icinga-core/module/idoutils/db/mysql/upgrade/mysql-upgrade-1.11.7.sql 
mysql -u root -p icinga < icinga-core/module/idoutils/db/mysql/upgrade/mysql-upgrade-1.12.0.sql 
mysql -u root -p icinga < icinga-core/module/idoutils/db/mysql/upgrade/mysql-upgrade-1.13.0.sql 

Related posts 相關文章
使用 Grafana 與 Prometheus 監控主機
More...
簡單容易自己架設的監控平台-Uptime Kuma
More...
再來一個監控系統,一鍵安裝,嚇死人的介面-netdata
More...
icinga2 包入 docker
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。