Centos6.5-----nagios快速安装编译配置文档-全部虚拟环境

写这个文档的目的,就是为了方便 快捷的部署nagios,涉及到个人喜好的配置,大家自行修改,可以套用。

一、下载并安装所需软件

1,yum install gcc mysql httpd php gd openssl openssl-devel mysql-server vim wget

Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz

Wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

Ls 可以看到nagios-4.0.7.tar.gz nagios-plugins-2.0.3.tar.gz nrpe-2.14.tar.gz

yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

useradd nagios

passwd nagios

groupadd nagcmd

usermod –a –G nagcmd nagios

(nagcmd:x:504:nagios)

tar –xvzf nagios-4.0.7.tar.gz

cd nagios-4.0.7

./configure –with-command-group=nagcmd

可以先./configure –help先看看帮助,应为默认为主是用nagios用户,不需要指定—with-nagios-user或其它什么的。

make all

make install

make install-init

这个安装/etc/rc.d/init.d中的init脚本

make install-commandmode

这个安装和配置权限

  目录的外部命令文件

make install-config

这个安装* * /usr/local/nagios/etc配置文件示例

  你必须修改这些示例文件之前

  使用Nagios。阅读HTML文档

make install-webconf

 这个安装Nagios的Apache配置文件

  Web界面

Cp –R contrib/eventhandlers/ /usr/local/nagios/libexec/

(-R:递归复制目录,即连同目录下的子目录和文件一起复制。)

Chown –R nagios:nagios /usr/local/nagios/libexec/eventhandlers

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (检测配置文件是否有错误)

{ [[email protected] libexec]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

[[email protected] libexec]# ll

total 4

drwxr-xr-x. 4 nagios nagios 4096 Oct 21 01:16 eventhandlers}

/etc/init.d/nagios start 或者service nagios start

Chkconfig --add nagios

Chkconfig nagios on

Chkconfig httpd on

Service httpd start

二、创建web用户

切换到ngios用户

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

输入密码nagios

三、安装nagios-plugins

Tar –xvzf nagios-plugins-2.0.3.tar.gz

Cd nagios-plugins-2.0.3

./configure {–with-nagios-user=nagios –with-nagios-group=nagios}

Make

Make install

前面这步做了可以略过,反正要做一次。

Chkconfig nagios on 或者chkconfig –level 35 nagios on

Chkconfig httpd on 或者 chkconfig –level 35 httpd on

四、关闭防火墙和selinux

service iptables stop

Vim /etc/sysconfig/selinux 把selinux改成disabled这个需重启生效。

http://192.168.1.202/nagios/ 这个是nagios地址,要输入用户名和密码的nagiosadmin nagios

******无法开题notifications报错****************************************

Error: Could not open command file ‘/usr/local/nagios/var/rw/nagios.cmd‘ for update!

这个主要是apache 用户 没有执行权限 /usr/local/nagios/var/rw/nagios.cmd 造成,

解决方法:

usermod -a -G nagcmd apache

将apache用户添加到nagios用户组,就OK了。

date -s 调整日期时间   clock -w 保存

五、安装NRPE插件。

Tar –xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

make && make install

make install-plugin

把check_nrpe放到/usr/local/nagios/libex下。才能使用check_nrpe。

***********************************************************************************

*********************************2***************************************************

在被监控机器上安装。

Nagios-plugins安装.

Useradd nagios

Passwd nagios

Tar –xvzf nagios-plugins-2.0.3.tar.gz

Cd nagios-plugins

./configure

Make

Make install

Chown –R nagios:nagios /usr/local/nagios

安装nrpe-2.14

Tar –xvzf nrpe-2.14.tar.gz

Cd nrpe-2.14

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

yum install xinetd

chkconfig --add xinetd

chkconfig xinetd on

make install-xinetd

vim /etc/xinetd.d/nrpe

在该文件的only_from  = 127.0.0.1 192.168.1.107  //在后面增加监控主机的地址,以空格间隔

vim /usr/local/nagios/etc/nrpe.cfg 这里也是充许访问里添加 192.168.107

vim /etc/services

启动nrpe就好了。

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

service xinetd restart

netstat -at |grep nrpe

Netstat –an | grep 5666

Vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT (该语句有待,不过我另一台也是这样配的)

好像不添加上面这个不得行,会报check_nrpe:Error - Could not complete SSL handshake

运行ipables –F 清空一下规则,然后保存。

然后iptables –L –n 查看确认后。

Service iptables save

Service iptables restart

2、配置文件方面:

(1)/usr/local/nagios/etc/nrpe.cfg 此配置文件是配置正确,多个IP地址逗号隔开,且要注意空格:allowed_host=127.0.0.1,  192.168.0.1 这是不对的,必须是allowed_host=127.0.0.1,192.168.1.202   逗号之后不能有空格;

(2)检查是否配置里限制了,在 /etc/xinetd.d/nrpe 文件中要添加允许访问的服务器的IP地址,在 “only_from = ” 这一行添加, 多个IP地址用空格隔开,例如:only_from       = 192.168.0.8 192.168.1.202

被控端:

vi /etc/xinetd.d/nrpe

only_from 增加主控IP

vi /usr/local/nagios/etc/nrpe.cfg

allowed_hosts 增加主控IP

service xinetd restart

主控端:

/usr/local/nagios/libexec/check_nrpe -H 被监控端IP地址       测试是否连接成功

修改nrpe.cfg后一定要重启nrpe,大侠我是这样做的:

pkill nrpe;

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg  -d

二、添加监控节点及service

三】增加验证用户

也就是通过web访问nagios的时候,必须要用这个用户登陆.在这里我们增加用户test:密码为12345

64.   [[email protected] nagios-plugins-1.4.13]# htpasswd -c /usr/local/nagios/etc/htpasswd test

可以用 which命令查看 htpasswd命令的位置,如果是源码安装的apache这里就写htpasswd的全路径。用户是test,命令结束会提示你输入密码,这里输入123456即可。

65.   查看认证文件的内容

66.   [[email protected] nagios-plugins-1.4.13]# less /usr/local/nagios/etc/htpasswd

67.   到这里nagios的安装也就基本完成了,你可以通过web来访问了.

三、检测定义快捷命令

问题1:新建立文件夹及节点无法生效

解决:修改nagios目录文件,使其目录被检测

vi /usr/local/nagios/etc/nagios.cfg

添加 要检测的目录。

cfg_dir=/usr/local/nagios/etc/cfgs

问题2:《《apache 启动失败 》》  默认安装在/usr/sbin/下,执行apachectl start时候,提示如下错误:

httpd: apr_sockaddr_info_get() failed for shiwei

httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName

于是上网查了一下,根据前人的经验,问题终于解决了。总结一下,方便以后使用。

原因:这个问题应该是没有在 /etc/httpd/conf/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。

解决办法:

(1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80

(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)

问题3 NRPE: Unable to read output

我的解决办法是:修改nagios目录的权限

#chown -R nagios:nagios nagios/

#chmod -R 775 nagios/

问题解决。linux

四、添加command

command[check_cpu]=/usr/local/nagios/libexec/check_cpu_pct -w $ARG1$ -c $ARG2$

command[check_memory]=/usr/local/nagios/libexec/check_mem -w $ARG1$ -c $ARG2$

将配置文件拷贝到指定目录后,修改所属及访问权限。

command[check_load]=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$

command[check_swap]=/usr/local/nagios/libexec/check_swap -w $ARG1$ -c $ARG2$228

command[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$

command[check_io]=/usr/local/nagios/libexec/check_iostat -d $ARG3$ -w $ARG1$ -c $ARG2$

五、安装sendmail

首先要确保sendmail相关组件的完整安装,我们可以使用如下的命令来完成sendmail的安装:

# yum install -y sendmail*

然后重新启动sendmail服务:

# service sendmail restart

然后发送测试邮件,验证sendmail的可用性:

# echo "Hello World" | mail [email protected]

[email protected] objects]# service sendmail restart

Shutting down sendmail:                                    [FAILED]

Starting sendmail:                                         [  OK  ]

Starting sm-client:                                        [  OK  ]

chkconfig sendmail off

chkconfig sendmail off  加速开机时间

重启服务器注意1,开机nrpe 二启动sendmail 三 iptables 设置

Nagios 多用户的一些配置

刚开始我想到在搭nagios的时候,用户验证是用apache来做的,接到这个需求后的第一反应是这个东西可能做不了。但接着一想,不应该啊,nagios本身至少会有一些用户配置的吧,于是乎开始寻找相关资料,基本配置如下:

(1)新增一个apache用户,如qiuyuetao

[[email protected] ~]# htpasswd /usr/local/nagios/etc/htpasswd.users  qiuyuetao

(2)更改cgi.cfg配置

[[email protected] ~]# vi /usr/local/nagios/etc/cgi.cfg

use_authentication=1

如果只允许查看,不允许管理,加上下面配置

authorized_for_read_only=qiuyuetao

authorized_for_all_services=qiuyuetao

authorized_for_all_hosts=qiuyuetao

(3)将userA设为联系人

[[email protected] ~]# vi /usr/local/nagios/etc/objects/contacts.cfg  #添加如下配置

define contact{

contact_name                   qiuyuetao

use                                      generic-contact

alias                                     qyt

}

(4)在属于userA的主机、服务配置文件的联系人中加入qiuyuetao

[[email protected] ~]# vi /usr/local/nagios/etc/objects/hosts.cfg

define host {

host_name [email protected]

alias [email protected]

address 10.1.1.22

contacs qyt

contact_groups sys_admins

check_command check-host-alive

max_check_attempts 5

notification_interval  3

notification_period 24x7

notification_options d,u,r

}

(5)重启nagios后生效

[[email protected] ~]#  /etc/init.d/nagios restart

时间: 2024-08-05 11:19:41

Centos6.5-----nagios快速安装编译配置文档-全部虚拟环境的相关文章

Icinga快速安装与配置

Icinga快速安装与配置/* body */body { margin: 20px; padding: 0; font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Helvetica, Arial, sans-serif; font-size: 0.72em; color: #262625; /*background: #EFEFEF;*/ background: #FFFFFF; font-f

linux 下安装编译配置 QT

打算做嵌入式图像处理,计划方案嵌入式Linux+OpenCV+QT,昨天简单入门OpenCV今天看看QT,QT就先弄Linux下面的,回家之前争取把基本的摸通,然后能在板子上跑起来. 软件环境 Linux:Ubuntu 12.04 X86 QT:4.8.4 关于QT安装 QT的早期版本和现在版本有点变化,提供的文件也不尽相同,最新的版本为5.0,我这里用的是4.8.4,一个完整的QT应该包括QT库.IDE也就是QT creator,在Linux下的安装中,目前看到的主要有三种方法: 1..bin

官网 Icinga快速安装与配置

Icinga快速安装与配置 1.1. 绪论 1.2. 前提条件 1.3. 安装软件包 1.4. 创建帐户信息 1.5. 编译和安装Icinga(包括IDOUtils) 1.5.1. 编译和安装 1.6. 定制配置 1.6.1. 启用idomod event broker 模块 1.7. 数据库创建和IDOUtils 1.8. 配置经典的Web界面 1.9. 编译和安装Icing插件 2.0. 调整SELinux的设置 2.1. 启动IDOUtils和Icinga 2.1.1. 配置Icinga开

Hadoop集群安装配置文档

Hadoop集群安装配置文档 日期 内容 修订人 2015.6.3 文档初始化 易新             目录 1 文档概要... 5 1.1软件版本... 5 1.2机器配置... 5 2 虚拟机配置... 5 2.1新建虚拟机... 5 2.2虚拟网络配置... 8 3 CentOS安装及配置... 9 3.1系统安装... 9 3.2系统配置... 10 3.2.1防火墙配置... 10 3.2.2 SElinux配置... 10 3.2.3 IP配置... 11 3.2.4安装vim

Rhel6-cacti+nagios+ganglia(nginx)配置文档

(lnmp平台) 系统环境: rhel6 x86_64 iptables and selinux disabled 主机: 192.168.122.185 server85.example.com 192.168.122.117 server17.example.com (注:时间需同步) 相关网址: rpm.pbone.net http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/ cacti.net nagio

CentOS6.3下DNS安装与配置

1.下载并安装最新的bind包 yum install –y bind bind-chroot bind-utis 2.配置named.conf acl internals{ 127.0.0.0/8; 192.168.0.0/24; }; view "internal" { match-clients {internals; }; zone "youdomian.com" { type master; file "/etc/named/internals/

centos6.x最小化安装后配置网络

centos6.x最小化安装后配置网络 最小化安装CentOS6.x后,试着用yum安装几个软件,发现网卡都没配置! 解决办法: 编辑配置文件: vi /etc/sysconfig/network-script/ifcfg-eth0 修改下列几项配置: NM_CONTROLLED=no ONBOOT=yes BOOTPROTO=dhcp 修改完保存,然后: service network start 启动网卡,yum能用了!

Hadoop配置文档

预节 在这一节中,笔者主要向大家介绍了该配置文档中,所用到的Linux命令和Linux的帮助. 终端提示信息 在Linux中,终端的每一行都有提示信息,其包含了当前终端登录的用户,当前登录的主机,当前终端所在的目录. 如:[[email protected] ~]$其格式为:[[用户名]@[hosts主机名或主机ip [当前所在路径]]$解析后可以知道,例子给的提示,实际上代表的是:当前终端登录的主机为master,所有的操作都是针对master的,登录主机的用户为frank,当前终端cd命令进

服务器安装配置文档JDK、apache、mysql、memcached、JMagick、tomcat

服务器安装配置文档 1.JDK的安装(以jdk-6u13-linux-x64.bin为例)  1.1 下载JDK,  1.2 改变JDK执行权限:    chmod 755 jdk-6u13-linux-x64.bin  1.3 运行安装文件:    ./jdk-6u13-linux-x64.bin  1.4 建立link文件:    ln -s jdk1.6.0_13 jdk  1.5 删除安装文件:    rm jdk-6u13-linux-x64.bin  1.6 设置环境变量:    c