nagios监控安装配置Word格式.docx
- 文档编号:3043032
- 上传时间:2023-05-01
- 格式:DOCX
- 页数:13
- 大小:683.52KB
nagios监控安装配置Word格式.docx
《nagios监控安装配置Word格式.docx》由会员分享,可在线阅读,更多相关《nagios监控安装配置Word格式.docx(13页珍藏版)》请在冰点文库上搜索。
1、安装前准备
Nagios安装前,首先安装相关软件包,对于RHEL/CentOS系统:
(依赖包的安装:
wgethttpdphpgccglibcglibc-commongdgd-develmakenet-snmpopensslopenssl-devel)
检看一下是否安装相关软件包:
[root@nagios~]#rpm-qa|grep*****(略)
[root@nagios~]#yuminstall-ywgethttpdphpgccglibcglibc-commongdgd-develmakenet-snmpopensslopenssl-devel
2、添加Nagios用户和组
[root@localhost~]#useraddnagios
[root@localhost~]#groupaddnagcmd
[root@localhost~]#usermod-a-Gnagcmdnagios
源代码下载
切换到/tmp目录下
[root@localhosttmp]#wget
[root@localhosttmp]#wgethttp:
//nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
编译安装Nagios
[root@localhost~]#cd/tmp
[root@localhosttmp]#tar-zxvfnagios-4.0.8.tar.gz
[root@localhosttmp]#cdnagios-4.0.8
[root@localhostnagios-4.0.8]#./configure--with-command-group=nagcmd//编译Nagios配置脚本并使用先前开设的用户及用户组
[root@localhostnagios-4.0.8]#makeall//编译Nagios程序包源码
[root@localhostnagios-4.0.8]#makeinstall
[root@localhostnagios-4.0.8]#makeinstall-init
[root@localhostnagios-4.0.8]#makeinstall-config
[root@localhostnagios-4.0.8]#makeinstall-commandmode
[root@localhostnagios-4.0.8]#makeinstall-webconf
NagiosPlugin安装
[root@localhosttmp]#tar-zxvfnagios-plugins-2.0.3.tar.gz
[root@localhosttmp]#cdnagios-plugins-2.0.3
[root@localhostnagios-plugins-2.0.3]#./configure--with-nagios-user=nagios--with-nagios-group=nagios
[root@localhostnagios-plugins-2.0.3]#make&
&
makeinstall
复制nagios/contrib/eventhandlers目录下所有文件到/usr/local/nagios/libexec下:
#cp-Rcontrib/eventhandlers//usr/local/nagios/libexec/
#chown-Rnagios:
nagios/usr/local/nagios/libexec/eventhandlers//修改用户和主权限
#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg//验证Nagios配置文件,验证配置是否有误:
3、添加开机启动项
#chkconfig
--addnagios
--level
3nagios
on
#chkconfig--level3httpdon
#chkconfig--level3snmpdon
#chkconfig--level3snmptrapdon
#
chkconfig
--list
*****
4、创建一个默认的WEB管理用户。
添加一个默认的WEB管理用户:
htpasswd–c/usr/local/nagios/etc/htpasswd.usersnagiosadmin
修改报警邮箱的发送地址。
shell#vi/usr/local/nagios/etc/objects/contacts.cfg找到如下行
emailnagios@localhost
修改nagios@localhost为你指定的邮箱。
NagiosWeb管理
配置Apache
将nagios的网页目录映射到apache工作目录
#ln–s/usr/local/nagios/share/var/www/html/nagios
#servicenagiosrestart//重新启动nagios
#servicehttpdrestart//重新启动httpd
Nagios的web管理需要cgi的支持。
shell#ln–s/usr/local/nagios/sbin/var/www/html/nagios/cgi-bin
执行:
#setenforce0
经过上述正确的程序,
您应该能从web浏览器进入您的Nagios核心。
登录如下:
http:
//<
你的nagios服务器IP地址>
/nagios
使用您使用htpasswd.users创建的nagios管理用户登录。
针对HTTP警告:
可#echo1>
/var/www/html/index.html
Nagios监控Linux系统
被监控端主机配置
1、先决条件
#yuminstall-ygccmakeperl
2、下载Nagios的插件和nrpe
[root@localhosttmp]#wgethttp:
[root@localhosttmp]#wget
3、添加nagios用户和组:
为Nagios运行添加专门的用户和组:
[root@localhosttmp]#useradd–rnagios//添加系统账户,不能登录系统
4、安装nagios插件解压缩
[root@localhosttmp]#tar-zxvfnagios-plugins-2.0.3.tar.gz
5、安装nrpe服务解压缩
[root@localhosttmp]#tar-zxvfnrpe-2.15.tar.gz
[root@localhosttmp]#cdnrpe-2.15
[root@localhostnrpe-2.15]#./configure
[root@localhostnrpe-2.15]#makeall//正确安装显示如下
[root@localhostnrpe-2.15]#makeinstall-plugin
[root@localhostnrpe-2.15]#makeinstall-daemon
[root@localhostnrpe-2.15]#makeinstall-daemon-config
6、尝试启用nrpe
[root@localhostnrpe-2.15]#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg–d//启用nrpe,查看是否正确安装
[root@localhostnrpe-2.15]#netstat-ant|grep5666//是否监听5666用于nrpe通信的端口
[root@localhostnrpe-2.15]#ps-aux|grepnrpe//查看nrpe的进程号
7、修改配置文件
[root@localhostnrpe-2.15]#vi/usr/local/nagios/etc/nrpe.cfg//修改如下
[root@localhostnrpe-2.15]#vi/usr/local/nagios/etc/nrpe.cfg
监控端主机配置
1、监控端安装nrpe
[root@localhostnrpe-2.15]#tar-zxvfnrpe-2.15.tar.gz
[root@localhostnrpe-2.15]#cd/tmp/
[root@localhostnrpe-2.15]#makeall
[root@localhostnrpe-2.15]#makeinstall-plugin//只运行这一步就行了,因为只需要check_nrpe插件
2、编辑commands.cfg文件定义nrpe对的使用
[root@localhosttmp]#vi/usr/local/nagios/etc/objects/commands.cfg//并增加如下内容:
说明:
command_namecheck_nrpe定义命令名称为check_nrpe,在services.cfg中要使用这个名称.
command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$
这是定义实际运行的插件程序.这个命令行的书写要完全按照check_nrpe这个命令的用法.
不知道用法的就用check_nrpe–h查看
-c后面带的$ARG1$参数是传给nrpedaemon执行的检测命令,之前说过了它必须是nrpe.cfg中所定义的那5条命令中的其中一条.在services.cfg中使用check_nrpe的时候要用!
带上这个参数
3、配置监控对象(工作站及其服务等)
[root@localhostmonitor]#vi/usr/local/nagios/etc/nagios.cfg
注:
在/usr/local/nagios/etc下添加使用#mkdirmonitor#cp/objectes/*/monitor/添加了#testnrep.cfgcplocalhost.cfg
t
4、新建testnrep.cfg设置要监控的内容
[root@localhostmonitor]#vi/usr/local/nagios/etc/monitor/testnrpe.cfg
//对以上的linux.cfg文件编辑如果有错,将会导致nagios无法启动;
要参考被监控主机/nrpe.cfg文档来修改
验证Nagios配置文件
[root@localhostmonitor]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg//正常输出入下
NagiosCore4.0.8
Copyright(c)2009-presentNagiosCoreDevelopmentTeamandCommunityContributors
Copyright(c)1999-2009EthanGalstad
LastModified:
08-12-2014
License:
GPL
Website:
http:
//www.nagios.org
Readingconfigurationdata...
Readmainconfigfileokay...
Readobjectconfigfilesokay...
Runningpre-flightcheckonconfigurationdata...
Checkingobjects...
Checked15services.
Checked2hosts.
Checked2hostgroups.
Checked0servicegroups.
Checked1contacts.
Checked1contactgroups.
Checked25commands.
Checked5timeperiods.
Checked0hostescalations.
Checked0serviceescalations.
Checkingforcircularpaths...
Checked2hosts
Checked0servicedependencies
Checked0hostdependencies
Checked5timeperiods
Checkingglobaleventhandlers...
Checkingobsessivecompulsiveprocessorcommands...
Checkingmiscsettings...
TotalWarnings:
0
TotalErrors:
Thingslookokay-Noseriousproblemsweredetectedduringthepre-flightcheck
测试监控是否可行
监控主机测试
[root@localhosttmp]#/usr/local/nagios/libexec/check_nrpe-H192.168.253.129//正确返回如下,要记得关闭防火墙或添加监控端:
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport5666-jACCEPT
被监控端:
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport5666-jACCEPT
重启nagios#servicenagiosrestart
重启nrpe#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg–d
监控windows主机
部署安装
在windows上安装NSclient++
改为监控主机的IP
一直下一步点下去就可以
检查NSckient++的端口是否成功开启
566612489(#netstat–anbv|find“5666or12489”)
修改监控主机配置文件
[root@localhostetc]#vi/usr/local/nagios/etc/nagios.cfg
#DefinitionsformonitoringaWindowsmachine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg去掉前面的#
[root@localhostetc]#vi/usr/local/nagios/etc/objects/windows.cfg
definehost{
usewindows-server//用
host_namewinserver//主机群名
aliasMyWindowsServer//别名
address192.168.253.130//被监控主机的IP
}
重启nagioshttpd服务
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- nagios 监控 安装 配置