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

运维 系统运维
linux+lighttpd+nagios安装配置V1.0,nagios+web:Nagios是一个监视系统,它可以监视系统运行状态和网络信息。Nagios能监视所指定的本地、远程主机以及服务、异常通知等。本文讲述的是linux+lighttpd+nagios安装配置V1.0,nagios+web。

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

  通过nagiosQL管理nagios非常方便而且简单。

  1.环境:

  ubuntu 9.04 x86_64

  nagios 3.2.1

  nagios-plugins 1.4.14

  lighttpd 1.4.19

nagios/web

  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.添加相关用户

  1.   useradd nagios  
  2.  
  3.   passwd nagios  
  4.  
  5.   usermod -G nagios nagios  
  6.  
  7.   groupadd nagcmd  
  8.  
  9.   usermod -G nagcmd nagios  
  10.  
  11.   usermod -G nagcmd www-data  
  12.  

  5.编译安装Nagios

  tar xvzf nagios-3.2.1.tar.gz

  1.   ./configure –with-command-group=nagcmd 
  2.  
  3.   make all  
  4.  
  5.   make install  
  6.  
  7.   make install-init  
  8.  
  9.   make install-config  
  10.  
  11.   make install-commandmode  
  12.  
  13.   cp sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf  
  14.  

  6.编译安装Nagios插件

  tar xvzf nagios-plugins-1.4.14.tar.gz

  1.   ./configure –with-nagios-user=nagios –with-nagios-group=nagios  
  2.  
  3.   make  
  4.  
  5.   make install  
  6.  

  7.验证Nagios配置文件,启动

  1.   /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  
  2.  
  3.   /etc/init.d/nagios start  
  4.  

  8.lighttpd配置

  生成auth key

  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin #回车后输入2次密码

  启用php fastcgi

  1.   lighty-enable-mod fastcgi  
  2.  

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

  1.   vi /etc/lighttpd/lighttpd.conf  
  2.  
  3.   server.modules = (  
  4.  
  5.   "mod_access",  
  6.  
  7.   "mod_alias",  
  8.  
  9.   "mod_cgi",  
  10.  
  11.   "mod_setenv",  
  12.  
  13.   "mod_auth",  
  14.  
  15.   "mod_compress"  
  16.  
  17.   )  
  18.  
  19.   static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )  
  20.  
  21.   alias.url += (  
  22.  
  23.   "/nagios/cgi-bin" => "/usr/local/nagios/sbin",  
  24.  
  25.   "/nagios" => "/usr/local/nagios/share/"  
  26.  
  27.   )  
  28.  
  29.   $HTTP["url"] =~ "^/nagios/cgi-bin" {  
  30.  
  31.   cgi.assign = ( "" => "" )  
  32.  
  33.   }  
  34.  
  35.   $HTTP["url"] =~ "^/nagios" {  
  36.  
  37.   auth.backend = "htpasswd" 
  38.  
  39.   auth.backend.htpasswd.userfile = "/usr/local/nagios/etc/htpasswd.users" 
  40.  
  41.   auth.require = ( "" => (  
  42.  
  43.   "method" => "basic",  
  44.  
  45.   "realm" => "nagios",  
  46.  
  47.   "require" => "user=nagiosadmin"  
  48.  
  49.   )  
  50.  
  51.   )  
  52.  
  53.   setenv.add-environment = ( "REMOTE_USER" => "user" )  
  54.  
  55.   }  
  56.  

  9.安装配置nagiosql

  1.   unzip nagiosql303.zip  
  2.  
  3.   mv nagiosql3 /www/web/nagadmin  
  4.  
  5.   chown -R www-data:www-data /www/web/nagadmin/  
  6.  
  7.   cd /www/web/nagadmin/install  
  8.  
  9.   touch ENABLE_INSTALLER  
  10.  

  安装sample数据

  1.   lighttpd.conf  
  2.  

  alias添加一行,修改为:

  1.   alias.url += (  
  2.  
  3.   "/nagios/cgi-bin" => "/usr/local/nagios/sbin",  
  4.  
  5.   "/nagios" => "/usr/local/nagios/share/",  
  6.  
  7.   "/nagadmin" => "/www/web/nagadmin"  
  8.  
  9.   )  
  10.  

  10.通过web访问配置nagios

  建立文件夹

  1.   mkdir -p /etc/nagiosql/backup/hosts  
  2.  
  3.   mkdir -p /etc/nagiosql/backup/services  
  4.  
  5.   mkdir -p /etc/nagiosql/hosts  
  6.  
  7.   mkdir -p /etc/nagiosql/services  
  8.  
  9.   mkdir /etc/nagios  
  10.  
  11.   mkdir /etc/nagios/import  
  12.  
  13.   touch /etc/nagios/nagios.cfg  
  14.  
  15.   touch /etc/nagios/cgi.cfg  
  16.  

  Permissions权限设置

  1.   chgrp www-data /etc/nagios  
  2.  
  3.   chgrp www-data /etc/nagios/nagios.cfg  
  4.  
  5.   chgrp www-data /etc/nagios/cgi.cfg  
  6.  
  7.   chmod 775 /etc/nagios  
  8.  
  9.   chmod 664 /etc/nagios/nagios.cfg  
  10.  
  11.   chmod 664 /etc/nagios/cgi.cfg  
  12.  
  13.   chgrp www-data /usr/local/nagios/etc/nagios.cfg  
  14.  
  15.   chgrp www-data /usr/local/nagios/etc/cgi.cfg  
  16.  
  17.   chmod 664 /usr/local/nagios/etc/nagios.cfg  
  18.  
  19.   chmod 664 /usr/local/nagios/etc/cgi.cfg  
  20.  
  21.   chmod 6755 /etc/nagiosql  
  22.  
  23.   chown www-data.nagios /etc/nagiosql  
  24.  
  25.   chmod 6755 /etc/nagiosql/hosts  
  26.  
  27.   chown www-data.nagios /etc/nagiosql/hosts  
  28.  
  29.   chmod 6755 /etc/nagiosql/services  
  30.  
  31.   chown www-data.nagios /etc/nagiosql/services  
  32.  
  33.   chmod 6755 /etc/nagiosql/backup  
  34.  
  35.   chown www-data.nagios /etc/nagiosql/backup  
  36.  
  37.   chmod 6755 /etc/nagiosql/backup/hosts  
  38.  
  39.   chown www-data.nagios /etc/nagiosql/backup/hosts  
  40.  
  41.   chmod 6755 /etc/nagiosql/backup/services  
  42.  
  43.   chown www-data.nagios /etc/nagiosql/backup/services  
  44.  
  45.   chmod 644 /etc/nagiosql/*.cfg  
  46.  
  47.   chown www-data.nagios /etc/nagiosql/*.cfg  
  48.  
  49.   chmod 644 /etc/nagiosql/hosts/*.cfg  
  50.  
  51.   chown www-data.nagios /etc/nagiosql/hosts/*.cfg  
  52.  
  53.   chmod 644 /etc/nagiosql/services/*.cfg  
  54.  
  55.   chown www-data.nagios /etc/nagiosql/services/*.cfg  
  56.  

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

  注释掉所有cfg_file,cfg_dir开始的行,添加以内容到文件最后

  1.   #change for hugwww  
  2.  
  3.   cfg_file=/etc/nagiosql/contacttemplates.cfg  
  4.  
  5.   cfg_file=/etc/nagiosql/contactgroups.cfg  
  6.  
  7.   cfg_file=/etc/nagiosql/contacts.cfg  
  8.  
  9.   cfg_file=/etc/nagiosql/timeperiods.cfg  
  10.  
  11.   cfg_file=/etc/nagiosql/commands.cfg  
  12.  
  13.   cfg_file=/etc/nagiosql/hostgroups.cfg  
  14.  
  15.   cfg_file=/etc/nagiosql/servicegroups.cfg  
  16.  
  17.   cfg_dir=/etc/nagiosql/hosts  
  18.  
  19.   cfg_dir=/etc/nagiosql/services  
  20.  
  21.   cfg_file=/etc/nagiosql/hosttemplates.cfg  
  22.  
  23.   cfg_file=/etc/nagiosql/servicetemplates.cfg  
  24.  
  25.   cfg_file=/etc/nagiosql/servicedependencies.cfg  
  26.  
  27.   cfg_file=/etc/nagiosql/serviceescalations.cfg  
  28.  
  29.   cfg_file=/etc/nagiosql/hostdependencies.cfg  
  30.  
  31.   cfg_file=/etc/nagiosql/hostescalations.cfg  
  32.  
  33.   cfg_file=/etc/nagiosql/hostextinfo.cfg  
  34.  
  35.   cfg_file=/etc/nagiosql/serviceextinfo.cfg  
  36.  
  37.   Administration -> Domains -> 修改  
  38.  
  39.   Nagios base directory* /usr/local/nagios/etc/  
  40.  

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

【编辑推荐】

Nagios不发报警短信问题的解决

用Nagios来监控网络服务器-nagios配置

使用Nagios实现网络监控

责任编辑:zhaolei 来源: gaojinbo
相关推荐

2011-08-22 12:25:02

nagios

2011-03-24 13:00:30

2011-03-31 16:05:18

Redhat配置nagios

2010-05-31 12:22:13

Nagios pnp

2011-03-31 16:05:18

Redhat配置nagios

2014-08-06 15:25:36

LinuxNagios

2011-08-22 12:24:58

nagios

2011-03-21 13:01:56

LinuxNagios安装

2011-03-22 13:37:29

Nagios安装

2011-03-21 15:35:01

Nagiosnagios-plug安装

2011-03-31 16:09:21

Redhat配置nagios

2010-05-31 11:10:37

Nagios pnp

2011-03-21 09:17:06

Nagios

2011-03-28 13:27:36

RHELnagios

2011-03-23 09:07:38

Nagios安装

2011-03-25 17:06:55

Nagios插件plugins

2011-03-24 10:08:38

nagiosweb

2011-11-08 21:58:01

Nagios 配置 流

2011-03-25 10:37:17

2011-03-25 16:49:33

nagios服务
点赞
收藏

51CTO技术栈公众号