Nagios拓扑图:
Nagios环境准备:
首先关闭iptables selinux
安装需求:
主机 | 操作系统 | 安装包:
nagios-4.0.1.tar.gz nagios-plugins-1.5.tar.gz nrpe-2.15.tar.gz nagios-plugins-1.5.tar.gz nrpe-2.15.tar.gz nagios-plugins-1.5.tar.gz nrpe-2.15.tar.gz |
Nagios | CentOS release 6.6 (Final) | |
mysql | CentOS release 6.6 (Final) | |
httpd | CentOS release 6.6 (Final) |
备注:以上的Nagios需要安装http和php提供web页面支持,nrpe需要ssl的支持。
部署Nagios监控系统
[[email protected] ~]# /etc/init.d/iptables stop iptables:将链设置为政策 ACCEPT:filter [确定]iptables:清除防火墙规则: [确定]iptables:正在卸载模块: [确定] [[email protected] ~]# setenforce 0 [[email protected] ~]# chkconfig iptables off [[email protected] ~]# yum -y install httpd php openssl-devel [[email protected] ~]# useradd -s /sbin/nologin nagios [[email protected] ~]# mkdir /usr/local/nagios [[email protected] ~]# chown -R nagios:nagios /usr/local/nagios/ [[email protected] ~]# tar zxf nagios-4.0.1.tar.gz [[email protected] ~]# cd nagios-4.0.1 [[email protected] nagios-4.0.1]# ./configure --prefix=/usr/local/nagios &&make all &&make install &&make install-init &&make install-commandmode &&make install-config &&chkconfig --add nagios &&chkconfig --level 35 nagios on
查看nagios是否完成:
安装nagios插件:
安装nrpe
[[email protected] ~]# tar zxf nrpe-2.15.tar.gz [[email protected] ~]# cd nrpe-2.15 [[email protected] nrpe-2.15]# ./configure &&make all &&make install-plugin
为了安全起见Nagios的web监控界面需要授权才能访问,即修改如下配置:
[[email protected] ~]# vim /etc/httpd/conf/httpd.conf ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Allow from all AuthName "Nagios Access" AuthType Basic AuthUserfile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share"> Options None AllowOverride None Allow from all AuthName "Nagios Access" AuthType Basic AuthUserfile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory>
创建一个nagios登陆用户,并启动httpd服务。
[[email protected] ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadm New password: Re-type new password: Adding password for user nagiosadm [[email protected] ~]# cat /usr/local/nagios/etc/htpasswd.users nagiosadm:L6hnKRp4rJZ9U [[email protected] ~]# /etc/init.d/httpd start
访问测试:
配置Nagios监控系统
[[email protected] ~]# cd /usr/local/nagios/etc/ [[email protected] etc]# vim nagios.cfg ###添加如下行 cfg_file=/usr/local/nagios/etc/objects/commands.cfg cfg_file=/usr/local/nagios/etc/objects/contacts.cfg cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg cfg_file=/usr/local/nagios/etc/objects/templates.cfg cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg cfg_dir=/usr/local/nagios/etc/conf ##主机配置文件放在此文件夹下
时间: 2024-11-05 19:28:59