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/

本文出自 “一步一个脚印” 博客,转载请与作者联系!

你可能感兴趣的:(linux,数据库,lighttpd,nagios,nagiosql)