linux+lighttpd+nagios安装配置V1.0,nagios+web

八月 3rd, 2010 Posted in WEB架构 | 阅读次数: 454 次

Author:gaojinbo
Time:2010

linux+lighttpd+nagios安装配置V1.0,nagios+web

image

通过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/

 

完成!

相关日志:

Tags:

6 Responses to “linux+lighttpd+nagios安装配置V1.0,nagios+web”

  1. 灯杆 Says:

    管用!


  2. 虫虫博客 Says:

    唉…LINUX是我一直希望了解学习,却一直没有办法学的东西….


  3. How to create bootable linux os DVD? Says:

    {Hey|Hi|Definitely|Heya|Hello}…

    What a great article I will follow up from now on…


  4. 淘客吧 Says:

    不会赚钱就要省钱,不会省钱就上淘客吧


  5. Related Resources Says:

    My Recommended Websites…

    [...]some new websites on the web we love, even if they are not related to ours. Check them out[...]…


  6. Valentino Solbriller Says:

    Cool sites……

    [...]we came across a cool site that you might enjoy. Take a look if you want[...]………


留下您的脚印