温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nagios安装配置以及一些常见问题处理

发布时间:2020-07-24 21:54:58 来源:网络 阅读:1232 作者:wescker 栏目:移动开发

进入nagios官网http://www.nagios.org/

下载最新版本nagios

nagios-3.5.0.tar.gz

nagios-plugins-1.4.16.tar.gz

操作系统是centos5.4

1、新建用户

useradd nagios

2、安装nagios

tar zxvf nagios-3.5.0.tar.gz

cd nagios

./configure --prefix=/usr/local/nagios

make all

make install##安装主要的程序、CGIHTML文件

make install-commandmode##给外部命令访问nagios配置文件的权限

make install-config##把配置文件的例子复制到nagios的安装目录

3、安装nagios插件

tar zxvf nagios-plugins-1.4.16.tar.gz

cd nagios-plugins-1.4.16

./configure --prefix=/usr/local/nagios/

make

make install

4、配置http

#setting for nagios

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

##Cgi文件所在目录

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

Alias /nagios /usr/local/nagios/share

##nagios页面文件目录

AuthType Basic

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

5、新建用户认证文件

touch /usr/local/nagios/etc/htpasswd.users

6、创建用户

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

输入两次密码

再添加用户不要使用-c 否则会将htpasswd.users内容覆盖

7、重启http服务

8、访问http://10.1.1.254/nagios

如果提示You don't have permission to access /nagios/ on this server

说明有可能服务器没有安装php

执行yum install php即可

 

vim localhost.cfg

cfg_file=/usr/local/nagios/etc/contactgroups.cfg//联系组配置文件路径

cfg_file=/usr/local/nagios/etc/contacts.cfg//联系人配置文件路径

cfg_file=/usr/local/nagios/etc/hostgroups.cfg//主机组配置文件路径

cfg_file=/usr/local/nagios/etc/hosts.cfg//主机配置文件路径

cfg_file=/usr/local/nagios/etc/services.cfg//服务配置文件路径

cfg_file=/usr/local/nagios/etc/timeperiods.cfg//监视时段配置文件路径

check_external_commands=0check_external_commands=1 这行的作用是允许执行在web界面下重启nagios、停止主机/服务检查等操作。

另外需要注意一下/usr/local/nagios/var/rw/nagiosNaNd的权限prwxrwx--- 1 nagios nagios

command_check_interval的值从默认的1改成command_check_interval=10s(根据自己的情况定这个命令检查时间间隔,不要太长也不要太短)。

authorized_for_system_information=nagiosadmin,nagios

authorized_for_configuration_information=nagiosadmin,nagios

authorized_for_system_commands=nagiosadmin,nagios

authorized_for_all_services=nagiosadmin,nagios

authorized_for_all_hosts=nagiosadmin,nagios

authorized_for_all_service_commands=nagiosadmin,nagios

authorized_for_all_host_commands=nagiosadmin,nagios

安装sendEmail,实现邮件和短信报警

1、下载安装sendEmail-v1.56.tar.gz

sendEmail-v1.56.tar.gz解压到/usr/local/下,并设置权限

tar zxvf sendEmail-v1.56.tar.gz -C /usr/local/

chown nagios.nagios /usr/local/sendEmail-v1.56/

2、修改contacts.cfg配置文件

以下是联系人的设置方式

define contact{

contact_nameliulei

aliasliulei

service_notification_period24x7

host_notification_period24x7

service_notification_optionsw,u,c,r

host_notification_optionsd,u,r

service_notification_commandsnotify-service-by-email

host_notification_commandsnotify-host-by-email

email 12345678901@139.com

pager 12345678901

}

由于nagios是根据联系组来报警的,因此需要设置联系组

define contactgroup{

contactgroup_nameadmins

aliasNagios Administrators

membersliulei

}

安装nagios客户端

下载nagios-plugins-1.4.16.tar.gznrpe-2.14.tar.gz

添加nagios用户

useradd nagios

解压安装以上两个压缩包

tar zxvf nrpe-2.14.tar.gz

cd nrpe-2.14

./configure --prefix=/usr/local/nrpe/

make all

make install-plugin

make install-daemon

make install-daemon-config

tar zxvf nagios-plugins-1.4.16.tar.gz

cd nagios-plugins-1.4.16

./configure --prefix=/usr/local/nrpe/

make && make install

根据监控的需要配置/usr/local/nrpe/etc/nrpe.cfg

server_address=10.1.1.1

allowed_hosts=127.0.0.1,10.1.1.254

启动nrpe

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

问题总结:

1、出现报错CHECK_NRPE: Error - Could not complete SSL handshake

检查客户端与服务端openssl版本是否一致,如果不一致,必定会出错

解决方法:

opensslopenssl-devel降级或升级,这两个包相互依赖要一起操作

降级命令yum downgrade openssl openssl-devel

升级命令yum install openssl openssl-develyum会自动检测安装最新版本)

2、出现报错NRPE: Unable to read output

第一种情况,服务端和客户端无法连接

在服务端使用/usr/local/nagios/libexec/check_nrpe –H xxx.xxx.xxx.xxx

如果没有出现nrpe版本信息,需要检查客户端nrpe.cfg是否添加allowed_hosts

第二种情况,客户端没有响应的扩展插件

需要安装nagios-plugins扩展插件

第三种情况,客户端没有配置对应的监控

服务端监控check_swap,由于客户端的nrpe.cfg中没有配置对应的监控,因此会报错

3、安装nrpe报错

第一种情况:编译时configure: error: no acceptable C compiler found

解决方法:

gcc未安装,yum install gcc

第二种情况:编译时configure: error: Cannot find ssl headers 

解决方法:

opensslopenssl-devel未安装,yum install openssl openssl-devel

4、安装nagios-plugin报错

在编译nagios-plugin是卡在了checking for ICMP ping syntax

解决方法:

在编译时添加--with-ping-command=ping

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI