########################################################################
一、安装nagios服务端安装
1.修改机器名字,设置yum源,关闭防火墙,selinux,后面根据实际情况开启,我这用的163的源
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo CentOS-Base.repo
yum clean all
2.解决perl编译问题
[root@master ~]# echo 'export LC_ALL=C'>>/etc/profile
[root@master ~]# source /etc/profile
[root@master ~]# echo $LC_ALL
3.解决系统时间同步
[root@master ~]# echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1' >/var/spool/cron/root
[root@master ~]# crontab -l
*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1
[root@master ~]#
4.安装nagios所需基础软件包
[root@master ~]# yum install gcc glibc* gd* httpd php*
5.添加nagios需要的用户及用户组
[root@master ~]# /usr/sbin/useradd -m nagios
[root@master ~]# /usr/sbin/useradd apache
[root@master ~]# /usr/sbin/groupadd nagcmd
[root@master ~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@master ~]# /usr/sbin/usermod -a -G nagcmd apache
检查所属的用户及用户组
[root@master ~]# id -n -G nagios
nagios nagcmd
[root@master ~]# id -n -G apache
apache nagcmd
[root@master ~]#
6.下载nagios源码
https://www.nagios.org/downloads/nagios-core/thanks/
https://www.nagios.org/downloads/nagios-plugins/
7.开始安装
(1)创建目录并上传包
[root@master ~]# mkdir -p /home/tangbo/tools/nagios
[root@master nagios]# ls
nagios-4.1.1.tar.gz nagios-plugins-2.1.1.tar.gz
(2)开始解压
[root@master nagios]# tar -zxvf nagios-4.1.1.tar.gz
[root@master nagios]# cd nagios-4.1.1
(3)开始编译及安装
[root@master nagios-4.1.1]# ./configure --with-command-group=nagcmd
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs. 这样提示表示正确了
[root@master nagios-4.1.1]# make all
For more information on obtaining support for Nagios, visit:
https://support.nagios.com
*************************************************************
Enjoy. 最后有Enjoy.表示编译正常
[root@master nagios-4.1.1]# make install
(4)继续安装初始化
[root@master nagios-4.1.1]# make install-init 这个表示安装初始化脚本
[root@master nagios-4.1.1]# make install-commandmode 安装命令模式
[root@master nagios-4.1.1]# make install-config 安装样例配置文件
8.安装nagios web配置文件及创建登陆用户
[root@master nagios-4.1.1]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf 去查看和理解这个文件
*** Nagios/Apache conf file installed ***
[root@master nagios-4.1.1]#
9.创建nagios web监控界面登陆时需要的用户名(唐波)及其密码
[root@master nagios-4.1.1]# htpasswd -c /usr/local/nagios/etc/htpasswd.users tangbo
New password:
Re-type new password:
Adding password for user tangbo
[root@master nagios-4.1.1]#
[root@master nagios-4.1.1]# cat /usr/local/nagios/etc/htpasswd.users
tangbo:7mdQ02yZfJLjQ
[root@master nagios-4.1.1]#
10.添加监控报警的接收email地址
[root@master nagios-4.1.1]# vim /usr/local/nagios/etc/objects/contacts.cfg +35
lt values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email 79313760@qq.com ; /etc/profile
[root@master ~]# source /etc/profile
[root@master ~]# echo $LC_ALL
3.解决系统时间同步
[root@master ~]# echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1' >/var/spool/cron/root
[root@master ~]# crontab -l
*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1
[root@master ~]#
4.安装nagios客户端插件
[root@master ~]# mkdir -p /home/tangbo/tools/nagios
[root@master nagios]# ls
nagios-4.1.1.tar.gz nagios-plugins-2.1.1.tar.gz
开始安装nagios-plugins-2.1.1.tar.gz
[root@slave nagios]# useradd nagios -M -s /sbin/nologin
cd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules --with-mysql=/usr/local/mysql
make
make install
5.安装nrpe
tar -zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
提示:服务端也要安装nrpe,不然会缺少相关检查插件,另外可以监控自身的基本健康状态。
6.安装其它相关的插件Params-Validate-0.91.tar.gz ,Class-Accessor-0.34.tar.gz,Config-Tiny-2.23.tgz,perl-Math-Calc-Units-1.07-6.el6.noarch.rpm,Regexp-Common-2016010801.tar.gz
(1)tar -zxvf Params-Validate-0.91.tar.gz
cd Params-Validate-0.91
perl Makefile.PL
make
make install
cd ..
(2)tar zxvf Class-Accessor-0.34.tar.gz
cd Class-Accessor-0.34
perl Makefile.PL
make
make install
(3)[root@slave nagios]# rpm -ivh perl-Math-Calc-Units-1.07-6.el6.noarch.rpm
(4)tar -zvxf Config-Tiny-2.23.tgz
cd Config-Tiny-2.23
perl Makefile.PL
make
make install
(5) tar -zxvf Regexp-Common-2016010801.tar.gz
cd Regexp-Common-2016010801
perl Makefile.PL
make
make install
(6)yum -y install sysstat
7.配置开发的几个基础插件
[root@slave etc]# vim nrpe.cfg +79
allowed_hosts=192.168.11.34
8.启动nagios client
[root@slave etc]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@slave etc]# echo '/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d' >>/etc/rc.local
[root@slave etc]# ps -ef | grep nagios
重新启动[root@slave etc]# pkill nrpe && /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@slave etc]# netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 22616/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1258/master
tcp 0 0 0.0.0.0:5666 0.0.0.0:* 这是nrpe跑的端口
###########################################################################################
安装完成。。。。。。。。。。。。。。。。。。。。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com