Chinaunix首页 | 论坛 | 博客
  • 博客访问: 384125
  • 博文数量: 114
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1219
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-07 21:23
文章分类

全部博文(114)

文章存档

2018年(1)

2017年(5)

2016年(87)

2015年(21)

我的朋友

分类: 系统运维

2016-01-16 12:36:39

目录:
一、Nagios安装
二、Nagios配置

系统信息:Centos5.8X86 需要预先安装好apapche服务和PHP环境
软件信息:
nagios-3.5.0.tar.gz
nagios-plugins-1.4.16.tar.gz
sendmail-8.13.8-8.el5
一、Nagios安装
1. 安装Nagios

  1. [root@cacti-nagios ~]# wget http://softlayer-ams.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
  2. [root@cacti-nagios ~]# tar -zxvf nagios-3.5.0.tar.gz
  3. [root@cacti-nagios ~]# cd nagios
  4. [root@cacti-nagios nagios]# ./configure --prefix=/usr/local/nagios
  5. [root@cacti-nagios nagios]# useradd nagios -s /bin/false
  6. [root@cacti-nagios nagios]# make all
  7. [root@cacti-nagios nagios]# make install
  8. [root@cacti-nagios nagios]# make install-init
  9. [root@cacti-nagios nagios]# make install-commandmode
  10. [root@cacti-nagios nagios]# make install-config
  11. [root@cacti-nagios nagios]# make install-webconf
  12. [root@cacti-nagios nagios]# grep AuthUserFile /etc/httpd/conf.d/nagios.conf
  13. AuthUserFile /usr/local/nagios/etc/htpasswd.users
  14. [root@cacti-nagios nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
  15. New password: 123456
  16. Re-type new password: 123456
  17. Adding password for user nagios
  18. [root@cacti-nagios nagios]# cat /usr/local/nagios/etc/htpasswd.users
  19. nagios:FPuu/F25jQpac
2. 安装Nagios插件

  1. root@cacti-nagios ~]# wget http://nagios-plugins.org/download/nagios-plugins-1.4.16.tar.gz
  2. [root@cacti-nagios ~]# tar -zxvf nagios-plugins-1.4.16.tar.gz
  3. [root@cacti-nagios ~]# cd nagios-plugins-1.4.16
  4. [root@cacti-nagios nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios/
  5. [root@cacti-nagios nagios-plugins-1.4.16]# make
  6. [root@cacti-nagios nagios-plugins-1.4.16]# make install
  7. [root@cacti-nagios ~]# /etc/init.d/httpd restart
3. 通过浏览器访问nagios

可以访问页面,但是点击内页时会有报错:Error: Could not read object configuration data!
这是因为没有设置配置文件导致,完成下一步配置文件的操作后便可以正常点击
二、Nagios配置
1. 编辑cgi.cfg文件,修改控制脚本

  1. [root@cacti-nagios ~]# cd /usr/local/nagios/etc/
  2. [root@cacti-nagios etc]# vi cgi.cfg
  3. #:107行取消注释并修改:
  4. default_user_name=nagios
  5. #:119行:
  6. authorized_for_system_information=nagios
  7. #:131行:
  8. authorized_for_configuration_information= nagios
  9. #:144行:
  10. authorized_for_system_commands=nagios
  11. #:157行:
  12. authorized_for_all_services= nagios
  13. #:158行:
  14. authorized_for_all_hosts= nagios
  15. #:171行:
  16. authorized_for_all_service_commands= nagios
  17. #:172行:
  18. authorized_for_all_host_commands= nagios


2. 编辑主配置文件nagios.cfg

  1. [root@cacti-nagios etc]# vi nagios.cfg
  2. # :34行添加:
  3. cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
  4. cfg_file=/usr/local/nagios/etc/objects/services.cfg
3. 编辑timeperiods.cfg文件,定义监控时间段

  1. [root@cacti-nagios etc]# vi objects/timeperiods.cfg
  2. define timeperiod{
  3.         timeperiod_name all_days
  4.         alias 24 Hours A Day, 7 Days A Week
  5.         sunday 00:00-24:00
  6.         monday 00:00-24:00
  7.         tuesday 00:00-24:00
  8.         wednesday 00:00-24:00
  9.         thursday 00:00-24:00
  10.         friday 00:00-24:00
  11.         saturday 00:00-24:00
  12. }
定义主机与服务 以linux-server为模板,服务以generic-service为模板
 vim host.cfg
  1. define host{
  2. use linux-server
  3. host_name SZ149
  4. address 192.168.88.149
  5. }

  1. define service{
  2. use generic-service
  3. host_name web253
  4. service_description CPU Load
  5. check_command check_nrpe!check_load
  6. }



测试配置文件是否正确

  1. [root@cacti-nagios etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  2. Total Warnings: 0
  3. Total Errors: 0









阅读(887) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~