设为首页收藏本站我的广告

运维网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索

nagios攻略(二)----基本安装和配置

2012-5-29 12:46| 发布者: admin| 查看: 30559| 评论: 6|原作者: 运维网|来自: 网络

. 基本安装和配置
本部分主要参考官方文档和田逸的文章<<看我出招之:我用Nagios(技术细节)>>来修改完成.
最后达到如下的功能
监控机自身的信息,包括主机信息以及对外提供的服务
被监控机对外提供的服务
如下所有的操作都在监控机192.168.0.111上进行
 
1.安装nagios主程序
解压缩
tar -zxvf nagios-2.9.tar.gz
cd nagios-2.9
编译,指定安装目录为/usr/local/nagios
./configure --prefix=/usr/local/nagios
输出如下信息
*** Configuration summary for nagios 2.9 04-10-2007 ***:
 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagios
            Embedded Perl:  no
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
                Lock file:  ${prefix}/var/nagios.lock
           Init directory:  /etc/rc.d/init.d
                  Host OS:  linux-gnu
 Web Interface Options:
 ------------------------
                 HTML URL:  [url]http://localhost/nagios/[/url]
                  CGI URL:  [url]http://localhost/nagios/cgi-bin/[/url]
 Traceroute (used by WAP):  /usr/sbin/traceroute
Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.
 
make all
输出如下信息
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
  make install
-          This installs the main program, CGIs, and HTML files
使用make install来安装主程序,CGIHTML文件
  make install-init
-          This installs the init script in /etc/rc.d/init.d
使用make install-init/etc/rc.d/init.d安装启动脚本
  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file
使用make install-commandmode来配置目录权限
  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-commandmode来安装示例配置文件,安装的路径是/usr/local/nagios/etc.
*** Support Notes *******************************************
If you have questions about configuring or running Nagios,
please make sure that you:
     - Look at the sample config files
     - Read the HTML documentation
     - Read the FAQs online at [url]http://www.nagios.org/faqs[/url]
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you.  This might include:
     - What version of Nagios you are using
     - What version of the plugins you are using
     - Relevant snippets from your config files
     - Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
       [url]http://www.nagios.org/support/[/url]
*************************************************************
Enjoy.
很多人都不注意安装过程中的输出信息,直到make install出错了才到处找人求救,而实际上输出的内容包含很多有价值的信息,例如安装路径,版本,每一步做什么,接下来的步骤等.尤其是输出的最后一屏信息,我个人建议好好的读一下.例如上面就列出了很多有价值的信息,我们只需要按照他说的做就行了.
 
安装
make install
输出如下错误
cd ./base && make install
make[1]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'
make install-basic
make[2]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install: invalid user `nagios' 非法用户nagios
make[2]: *** [install-basic] Error 1
make[2]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'
make: *** [install] Error 2
按照文档说明增加用户,修改权限
[root@localhost nagios-2.9]# useradd nagios
[root@localhost nagios-2.9]# mkdir /usr/local/nagios
[root@localhost nagios-2.9]# chown nagios.nagios /usr/local/nagios
查看目录权限
[root@localhost nagios-2.9]# ll /usr/local
drwxr-sr-x    2 nagios   nagios       4096 Jul 10 11:14 nagios
看到nagios目录的权限已经被正确修改了
 
重新执行make install输出信息如下
*** Main program, CGIs and HTML files installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
  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[1]: Leaving directory `/home/yahoon/nagios/nagios-2.9'
 
执行如下命令来安装脚本
make install-init
 
执行
make install-commandmode
输出信息如下
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
*** External command directory configured ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
  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-config
输出信息如下
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg-sample
/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg-sample
/usr/bin/install -c -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg-sample
/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/localhost.cfg-sample
/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/commands.cfg-sample
*** Sample config file installed ***
Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
If you have questions about configuring Nagios properly, please:
       - Look at the sample config files
       - Read the HTML documentation
       - Read the FAQs online at [url]http://www.nagios.org/faqs[/url]
*BEFORE* you post a question to one of the mailing lists.
 
验证程序是否被正确安装。切换目录到安装路径(这里是/usr/local/nagios,看是否存在 etcbin sbin share var这五个目录,如果存在则可以表明程序被正确的安装到系统了。后表是五个目录功能的简要说明:
bin
Nagios执行程序所在目录,nagios文件即为主程序
etc
Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件
sbin
Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share
Nagios网页文件所在的目录
Var
Nagios日志文件、spid 等文件所在的目录
var/archives
Empty directory for the archived logs
var/rw
Empty directory for the external command file
 

下一篇:nagios攻略(三)----使用插件监控更多信息

上一篇:nagios攻略(一)----准备阶段

1234下一页

鲜花

握手

雷人

路过

鸡蛋
加入阿里云推荐返利15%
发表评论

最新评论

引用 homu 2016-5-4 12:39
nagios 可视化用 cloud insight 挺好的 太方便了……http://docs-ci.oneapm.com/services_example/nagios.html
引用 xiaoone 2016-3-11 09:47
欢迎大家使用OneAlert云告警平台,可以实现免费接收电话、短信、微信、App等给告警信息。更能一键集成nagios,方便快捷。Mark一下zabbix配置文档:http://www.onealert.com/open/alert/nagios.jsp
引用 IT-gool 2015-5-19 16:04
这个教程不对跟现在的版本不对呀!
引用 苟忠兴 2014-5-29 13:36
写的挺不错的,值得一看
引用 贵在坚持 2014-3-28 15:46
很老的教程了。  更新下就更好了。
引用 冰晶飞雪 2013-12-30 13:05
nagios算是linux运维的神器了

查看全部评论(6)

QQ|申请友链|sitemap|手机版|小黑屋|Archiver|运维网 ( 京ICP备16008201号  

GMT+8, 2016-12-11 18:06 , Processed in 0.043260 second(s), 28 queries , Xcache On.

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

返回顶部