nagios的安装与配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nagios的安装与配置相关的知识,希望对你有一定的参考价值。

安装前准备检查环境

iptables -F

setenforce 0


#gcc环境 lamp环境和其他的一些 nagios 的依赖包

yum -y install gcc* yum -y install httpd mysql mysql-server mysql-devel php php-server glibc glibc-common *gd*


#添加nagios运行所需要的用户和组

groupadd nagcmd 

useradd -G nagcmd nagios

usermod -G nagcmd apache


#编译安装nagios

mkdir /cdrom

cp -a /cdrom/* .

tar -xf nagios-3.3.1..tar.gz


cd nagios

./configure --with-commadn-group=nagcmd --enable-event-broker


make all && make install && make install-init make install-commandmode make install-config && make install-webconf


2.生成密码文件

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



service httpd restart


在浏览器中查看效果输入用户名和密码


安装插件管理器nagios-plugins


解压编译


tar -xf nagios-plugins-1.4.14.tar.gz


cd /root/nagios-plugins-1.4.14


./configure --with-nagios-user=nagios --wtih-nagios-group=nagios --with-mysql --enable-perl-modules


make && make install


配置并启动nagios


chkconfig --add nagios


chkconfig nagios on


/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

#此命令用来检测语法


service nagios start



windows 主机的监控

安装 NSCLIENt ++

技术分享

技术分享


服务器端设置windows监控

cd /usr/local/nagios


cd etc/


cd objects/

技术分享

#进入nagios主目录,启用windows的支持


vim nagios.cf


vim /usr/local/nagios/etc/objects/contacts.cfg


#39  cfg_file=/usr/local/nagios/etc/objects/windows.cfg


vim /usr/local/nagios/etc/objects/contacts.cfg


#35     email    [email protected]报警邮箱根据实际改找个软件最好然后用qq邮箱然后跟微信关联qq号然后微信就可以知道报警了


检测,并启动nagios服务


/usr/local/nagios/bin/nagios -v /usr/local/ngios/etc/nagios.cfg


service nagios restart


Linux的监控


安装gcc,openssl openssl-devel

yum -y install openssl openssl-devel



安装插件管理器nagios-plugins


创建个nagios用户,否则会报错


useradd nagios


cd /root

tar -xf nagios-plugins-1.4.14.tar.gz


cd nagios-plugins-1.4.14


./configure --with-nagios-user=nagios --with-nagios-group=nagios


make all && make install


安装nrpe确保openssl,openss-devel已经安装


tar -xf nrpe-2.8.1.tar.gz


cd nrpe-2.8.1


./configure --enable-ssl --with-ssl-lib=/usr/lib


make all  


make install-plugin


make install-daemon


make install-daemon-config


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


allowed_hosts=192.168.121.1 127.0.0.1


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



服务端装

nagios-plugins


./configure --enable-ssl --with-ssl-lib=/usr/lib


make all


make install-plugin


cd /usr/local/nagios/etc/


cd objects/


ls


vim linux.cfg


技术分享


vim cmmands.cfg


技术分享

启用自定义的liunx.cfg文件


vim /usr/local/nagios/etc/nagios.cfg


31# cfg_file=/usr/local/nagios/etc/objects/linux.cfg



检测并启用

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


service nagios restart


服务的监控

客户端


yum -y install mysql mysql-server


service mysqld start


mysqladmin -uroot password ‘123123‘


mysql -uroot -p


create database nagios;


grant selcet on nagios.* to [email protected]‘%‘ identifed by ‘123123‘;


select user,password,host from mysql.user;


服务端检查一下是否能够连接数据库


/usr/local/nagios/libexec/check_mysql -H 192.168.121.1 -u nagios -d nagios -p 123123


vim mysql.cfg技术分享



启动配置

vim /usr/local/nagios/etc/nagios.cfg

技术分享


vim commadns.cfg

技术分享

检测启动nagios

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


service nagios restart


在浏览器中查看



本文出自 “凌宇的技术博客” 博客,请务必保留此出处http://lampit.blog.51cto.com/12958178/1931116

以上是关于nagios的安装与配置的主要内容,如果未能解决你的问题,请参考以下文章

nagios的安装与配置

nagios的安装与配置

nagios的安装与配置

nagios的安装与配置

nagios的安装与配置

nagios的安装与配置