需求套件

apache
php
gcc
gd

安裝需求套件

yum install httpd php gcc glibc glibc-common gd gd-devel

新增使用者

useradd -c nagios -d /usr/local/nagios -s /bin/bash nagios -m
groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

下載 nagios 3 套件

解開編譯 nagios 3

tar zxvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure –prefix=/usr/local/nagios –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

說明:

  make install
     – This installs the main program, CGIs, and HTML files

  make install-init
     – This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     – This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     – This installs *SAMPLE* config files in /usr/local/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     – This installs the Apache config file for the Nagios
       web interface

問題: check_http.o check_http.c undefined reference to np_net_ssl_cleanup
解決: make clean 後重新 ./configure

安裝 nagios conf for apache

make install-webconf

cp -rp sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

新增網頁存取使用者

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

安裝 nagios plugins

tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios
make
make install

確認 conf 是否正確

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

啟動apache及nagios

service nagios start
service httpd start

設成開機啟動

chkconfig nagios on
chkconfig httpd on

問題: 支持uTF-8 的方法
解決: http://blogold.chinaunix.net/u/12479/showart_695760.html

如果使用nagios-plugin check_http检测url,页面utf-8中文,一旦报警,在nagios的页面出现的关键字将会是乱码,需要修改nagios的cgi程序
路径在源代码/cgi
在所有c源代码中查找着两行,如果有就在这两行下面增加:printf("<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
");
printf("<html>
");
printf("<head>
");

問題: 當nagios.log 一直出現 "Max concurrent service checks (55) has been reached" 這類的訊息
解決: 需要調高 max_concurrent_checks 的數值,且也要搭配,管理介面的 "Check Latency / Duration: 0.231 / 5.201 seconds" 數據,別讓數值 > 10 or 15 seconds

最後
把原本已監控的主機的 cfg檔複製到新nagios3的/usr/local/nagios/etc/目錄底下 (cfg我是用dir的方式分類)
nagios.cfg舊的也不複製了
可能需要比對的新舊設定
cgi.cfg

physical_html_path=     # 就看你的nagios網頁是放在那裡
url_html_path=/            # 預設的當然會是 /nagios,除非我是瀏覽 nagios.ssorc.tw/ 就要改成 /

resource.cfg

$USER1$=                     # 有可能會變,否則照預設的吧

nagios.cfg

date_format=iso8601            # 日期還是這個比較習慣
max_concurrent_checks=      # nagios 3版預設是無限的,但看server機器的等級作調整吧

問題: check_http 1.4.5 會對某些主機監控時抓不到該有的 string
解決: 所以我換回 1.4.2版的

 

最後修改日期: 2011 年 04 月 06 日

作者

留言

撰寫回覆或留言

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