Ngaios安装文档
Nagios安装文档
1.创建nagios和apache用户和nagcmd用户组
useradd -M -s /sbin/nologin nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
[root@CentOS ~]# useradd -M -s /sbin/nologin nagios
[root@CentOS ~]# groupadd nagcmd
[root@CentOS ~]# usermod -G nagcmd nagios
[root@CentOS ~]# usermod -G nagcmd apache
2.安装相关的软件包
yum install gcc gcc-c++ glibc glibc-common gd-devel gd -y
[root@CentOS ~]# yum install gcc gcc-c++ glibc glibc-common gd-devel gd -y
3.安装Apache和php
yum install httpd php -y
[root@CentOS ~]# yum install httpd php -y
4.下载nagios源码包。
5.解压nagios源码包并编译安装
tar xf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
[root@CentOS ~]# tar xf nagios-4.0.8.tar.gz
[root@CentOS ~]# cd nagios-4.0.8
[root@CentOSnagios-4.0.8]#./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
[root@CentOS nagios-4.0.8]# make all
[root@CentOS nagios-4.0.8]# make install
[root@CentOS nagios-4.0.8]# make install-init
[root@CentOS nagios-4.0.8]# make install-commandmode
[root@CentOS nagios-4.0.8]# make install-config
[root@CentOS nagios-4.0.8]# make install-webconf
make install-webconf这命令有个提示:因为这条命令默认是把配置文件复制到/etc/httpd/conf.d/下边的,如果是编译安装的Apache就需要创建/etc/httpd/conf.d/这个目录,然后在httpd.conf配置文件中添加include /etc/httpd/conf.d/。用yum安装的httpd则不需要创建/etc/httpd/conf.d/目录。
sed -i ‘s/nagios@localhost/[email protected]/‘ /usr/local/nagios/etc/objects/contacts.cfg
[root@CentOS nagios-4.0.8]#sed -i ‘s/nagios@localhost/[email protected]/‘ /usr/local/nagios/etc/objects/contacts.cfg
#必须开启sendmail、检查端口
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
[root@CentOS nagios-4.0.8]#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#添加nagios管理用户、就是http://IP/nagios/所使用的用户。
#如果使用其他的用户名,请修改/usr/local/nagios/etc/cgi.cfg配置文件的参数
#我的建议是把nagiosadmin替换掉,因为nagiosadmin每个人都知道,这样不安全。
service nagios start
[root@CentOS nagios-4.0.8]# service nagios start
#启动nagios服务
[root@CentOS nagios-4.0.8]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
或
[root@CentOS nagios-4.0.8]# /etc/init.d/nagios checkconfig
#检查配置文件语法
6.下载nagios-plugins插件包
7.解压nagios-plugins插件包并编译安装
tar xf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
[root@CentOS ~]# tar xf nagios-plugins-2.0.3.tar.gz
[root@CentOS ~]# cd nagios-plugins-2.0.3
[root@CentOSnagios-plugins-2.0.3]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
root@CentOS nagios-plugins-2.0.3]# make
#如果编译遇到make:***[all] Error 2则confiure加--with-mysql=/usr/local/mysql 解决
root@CentOS nagios-plugins-2.0.3]# make install
[root@CentOS nagios-plugins-2.0.3]# ls /usr/local/nagios/libexec/ | wc -l
58
#查看安装了多少个插件、我这里是58个。
8.下载nrpe插件包
9.解压nrpe插件包并编译安装
[root@CentOS ~]# tar xf nrpe-2.15.tar.gz
[root@CentOS ~]# cd nrpe-2.15
[root@CentOS nrpe-2.15]# ./configure
[root@CentOS nrpe-2.15]# make all
[root@CentOS nrpe-2.15]# make install-plugin
[root@CentOS nrpe-2.15]# make install-daemon
[root@CentOS nrpe-2.15]# make install-daemon-config
[root@CentOS nrpe-2.15]# /usr/sbin/ntpdate pool.ntp.org
[root@CentOS nrpe-2.15]# echo ‘*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1‘ >>/var/spool/cron/root
#同步时间并定义计划任务
[root@CentOS nrpe-2.15]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@CentOS nrpe-2.15]# netstat -lnpt | grep 5666
#启动nrpe服务
[root@CentOS nrpe-2.15]# pkill nrpe
#关闭nrpe服务
10.客户端安装nagios-plugins和nrpe插件
useradd -M -s /sbin/nologin nagios
tar xf nagios-plugins-2.0.3.tar.gz
cd nagios-pligins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
[root@CentOS ~]# useradd -M -s /sbin/nologin nagios
[root@CentOS ~]# tar xf nagios-plugins-2.0.3.tar.gz
[root@CentOS ~]# cd nagios-pligins-2.0.3
[root@CentOS nagios-plugins-2.0.3]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@CentOS nagios-plugins-2.0.3]# make
[root@CentOS nagios-plugins-2.0.3]# make install
[root@CentOS ~]# tar xf nrpe-2.15.tar.gz
[root@CentOS ~]# cd nrpe-2.15
[root@CentOS nrpe-2.15]# ./configure
#出现这个错误是因为缺少openssl-devel软件包,使用yum install openssl-devel -y 即可
[root@CentOS nrpe-2.15]# make all
[root@CentOS nrpe-2.15]# make install-plugin
[root@CentOS nrpe-2.15]# make install-daemon
[root@CentOS nrpe-2.15]# make install-daemon-config
[root@CentOS ~]# sed -i ‘s/allowed_hosts=127.0.0.1/allowed_hosts=192.168.0.148/‘ /usr/local/nagios/etc/nrpe.cfg
#允许192.168.0.148的主机来监控本主机
[root@CentOS ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@CentOS ~]# netstat -lnpt | grep 5666
或
[root@CentOS ~]# lsof -i tcp:5666
#启动nrpe服务、关闭nrpe服务的命令是pkill nrpe
11.服务器配置
#hosts.cfg的配置
define host{
use linux-server
host_name lamp-1
alias lamp-1
address 192.168.1.114
check_command check-host-alive
}
#某些参数请看模板文件,templates.cfg
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members lamp-1
}
#services.cfg配置
define service{
use generic-service
host_name lamp-1
service_description DISK
check_command check_disk!20%!10%!/
}
define service{
use generic-service
host_name lamp-1
service_description LOAD
check_command check_load!15,10,5!30,25,20
}
12.客户端配置
#编辑/usr/local/nagios/etc/nrpe.cfg,添加一下内容
#启动nrpe服务
[root@CentOS ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@CentOS ~]# netstat -lnpt | grep 5666
本文出自 “小疯魔” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1652602
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。