linux + lighttpd +nagiosQL

通過nagiosQL管理nagios非常方便,簡單

 

1.環境:


ubuntu         9.04 x86_64
nagios        3.2.1
nagios-plugins    1.4.14
lighttpd    1.4.19

 

2.下載地址
http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

 

web admins
http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.0.3/nagiosql303.zip?use_mirror=nchc

 

3.安裝依賴包
apt-get install build-essential lighttpd php5-cgi php5-cli php5-curl php5-gd php5-mysql php-html-template-it unzip

 

 

4.添加相關用戶

useradd nagios
passwd nagios
usermod -G nagios nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd www-data

 

 

5.編譯安裝Nagios

tar xvzf nagios-3.2.1.tar.gz

./configure –with-command-group=nagcmd

make all

make install

make install-init

make install-config

make install-commandmode

cp sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf

 

 

6.編譯安裝Nagios插件

tar xvzf nagios-plugins-1.4.14.tar.gz

./configure –with-nagios-user=nagios –with-nagios-group=nagios

make

make install

 

 

7.驗證Nagios配置文件,啓動

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

/etc/init.d/nagios start

 

 

8.lighttpd配置

生成auth key

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin #回車後輸入2次密碼

啓用php fastcgi

lighty-enable-mod fastcgi

修改Lighttpd主配置文件,添加nagios支持

vi /etc/lighttpd/lighttpd.conf

server.modules              = (

            "mod_access",

            "mod_alias",

            "mod_cgi",

            "mod_setenv",

            "mod_auth",

            "mod_compress"

)

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )

alias.url += (

        "/nagios/cgi-bin" => "/usr/local/nagios/sbin",

        "/nagios"       =>      "/usr/local/nagios/share/"

        )

$HTTP["url"] =~ "^/nagios/cgi-bin" {

        cgi.assign = ( "" => "" )

}

$HTTP["url"] =~ "^/nagios" {

        auth.backend = "htpasswd"

        auth.backend.htpasswd.userfile = "/usr/local/nagios/etc/htpasswd.users"

        auth.require = ( "" => (

                "method" => "basic",

                "realm" => "nagios",

                "require" => "user=nagiosadmin"

                )

        )

        setenv.add-environment = ( "REMOTE_USER" => "user" )

}

 

 

9.安裝配置nagiosql

unzip nagiosql303.zip

mv nagiosql3 /www/web/nagadmin

chown -R www-data:www-data /www/web/nagadmin/

cd /www/web/nagadmin/install

touch ENABLE_INSTALLER

http://gaojinbo.com/nagadmin 安裝sample數據

lighttpd.conf

alias添加一行,修改爲:

alias.url += (

        "/nagios/cgi-bin" => "/usr/local/nagios/sbin",

        "/nagios"       =>      "/usr/local/nagios/share/",

        "/nagadmin"             =>      "/www/web/nagadmin"

        )

 

 

10.通過web訪問配置nagios

http://gaojinbo.com/nagadmin

建立文件夾

mkdir -p /etc/nagiosql/backup/hosts

mkdir -p /etc/nagiosql/backup/services

mkdir -p /etc/nagiosql/hosts

mkdir -p /etc/nagiosql/services

mkdir /etc/nagios

mkdir /etc/nagios/import

touch /etc/nagios/nagios.cfg

touch /etc/nagios/cgi.cfg

Permissions權限設置

chgrp www-data /etc/nagios

chgrp www-data /etc/nagios/nagios.cfg

chgrp www-data /etc/nagios/cgi.cfg

chmod 775 /etc/nagios

chmod 664 /etc/nagios/nagios.cfg

chmod 664 /etc/nagios/cgi.cfg

chgrp www-data /usr/local/nagios/etc/nagios.cfg

chgrp www-data /usr/local/nagios/etc/cgi.cfg

chmod 664 /usr/local/nagios/etc/nagios.cfg

chmod 664 /usr/local/nagios/etc/cgi.cfg

chmod 6755 /etc/nagiosql

chown www-data.nagios /etc/nagiosql

chmod 6755 /etc/nagiosql/hosts

chown www-data.nagios /etc/nagiosql/hosts

chmod 6755 /etc/nagiosql/services

chown www-data.nagios /etc/nagiosql/services  
chmod 6755 /etc/nagiosql/backup

chown www-data.nagios /etc/nagiosql/backup

chmod 6755 /etc/nagiosql/backup/hosts

chown www-data.nagios /etc/nagiosql/backup/hosts

chmod 6755 /etc/nagiosql/backup/services

chown www-data.nagios /etc/nagiosql/backup/services

chmod 644 /etc/nagiosql/*.cfg

chown www-data.nagios /etc/nagiosql/*.cfg

chmod 644 /etc/nagiosql/hosts/*.cfg

chown www-data.nagios /etc/nagiosql/hosts/*.cfg  
chmod 644 /etc/nagiosql/services/*.cfg

chown www-data.nagios /etc/nagiosql/services/*.cfg  

修改/usr/local/nagios/etc/nagios.cfg

註釋掉所有cfg_file,cfg_dir開始的行,添加以內容到文件最後

#change for hugwww

   cfg_file=/etc/nagiosql/contacttemplates.cfg

   cfg_file=/etc/nagiosql/contactgroups.cfg

   cfg_file=/etc/nagiosql/contacts.cfg

   cfg_file=/etc/nagiosql/timeperiods.cfg

   cfg_file=/etc/nagiosql/commands.cfg

   cfg_file=/etc/nagiosql/hostgroups.cfg

   cfg_file=/etc/nagiosql/servicegroups.cfg

   cfg_dir=/etc/nagiosql/hosts

   cfg_dir=/etc/nagiosql/services

   cfg_file=/etc/nagiosql/hosttemplates.cfg

   cfg_file=/etc/nagiosql/servicetemplates.cfg

   cfg_file=/etc/nagiosql/servicedependencies.cfg

   cfg_file=/etc/nagiosql/serviceescalations.cfg

   cfg_file=/etc/nagiosql/hostdependencies.cfg

   cfg_file=/etc/nagiosql/hostescalations.cfg

   cfg_file=/etc/nagiosql/hostextinfo.cfg

   cfg_file=/etc/nagiosql/serviceextinfo.cfg

Administration -> Domains -> 修改

Nagios base directory* /usr/local/nagios/etc/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章