nagios软件安装包存放目录:/home/oldboy/tools

nagios服务安装目录:/usr/local/nagios





1、配置yum源

echo "------ step 1: config yum ------"

cd /etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo





报错:

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

--2016-07-21 09:10:05--  http://mirrors.aliyun.com/repo/Centos-6.repo

Resolving mirrors.aliyun.com... failed: Name or service not known.

wget: unable to resolve host address “mirrors.aliyun.com”

是不能解析域名,编辑DNS即可

[root@node4 yum.repos.d]# vim /etc/resolv.conf 

nameserver 192.168.8.251





2、配置profile文件

echo "------ step 2: config  profile------"

echo 'export LC_ALL=C'>> /etc/profile

source /etc/profile





3、停用防火墙和selinux

echo "------ step 3: stop iptables and selinux------"

/etc/init.d/iptables stop

chkconfig iptables off

setenforce 0

也可以用脚本

if [ -f /etc/selinux/config ]; then

sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

setenforce 0

fi





4、时间同步

echo "------ step 4: config time sync------"

/usr/sbin/ntpdate pool.ntp.org

echo '#time sync by jack at 2016-7-21'>>/var/spool/cron/root

echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root

crontab -l





5、安装依赖包

echo "------ step 5: install gcc and lamp env etc------"

yum install gcc glibc glibc-common -y

yum install gd gd-devel -y

yum install httpd php php-gd -y

yum install mysql* -y





6、添加nagios用户和组

echo "------ step 6: add nagios  user and group------"

/usr/sbin/useradd -m nagios

#/usr/sbin/useradd apache

/usr/sbin/groupadd nagcmd

/usr/sbin/usermod -a -G nagcmd nagios

/usr/sbin/usermod -a -G nagcmd apache





7、安装服务端软件

echo "------ step 7: download and install nagios------"

[ ! -f oldboy_training_nagios_soft.zip ] && exit 1

unzip oldboy_training_nagios_soft.zip 

tar xzf nagios-3.5.1.tar.gz

cd nagios

./configure --with-command-group=nagcmd

make all

make install

make install-init

make install-config

make install-commandmode

make install-webconf

cd ../

echo "------ step 8: config web auth------"

htpasswd -cb /usr/local/nagios/etc/htpasswd.users jack jack





9、安装插件

echo "------ step 9: install nagios-plugins------"

yum -y install perl-devel

tar zxf nagios-plugins-1.4.16.tar.gz

cd nagios-plugins-1.4.16

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

make && make install

cd ../

ls /usr/local/nagios/libexec/|wc -l





报错:

check_http.c:312: error: ‘ssl_version’ undeclared (first use in this function)

check_http.c:312: error: (Each undeclared identifier is reported>





解决办法:

yum install -y openssl*





echo "------ step 10: install nrpe------"

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure 

make all

make install-plugin

make install-daemon

make install-daemon-config

cd ..





10、启动nagios和apache

echo "------ step 11: startup service and check------"

/etc/init.d/nagios start

/etc/init.d/httpd start

echo -----------

lsof -i tcp:80

echo ----------

ps -ef|grep nagios

echo "NAGIOS is successfully installed."

echo ok

hosts.cfg文件定义:

services.cfg文件说明:

最新文章

  1. Partition Stats
  2. CSS3中的Rem值与Px之间的换算
  3. 1025WHERE执行顺序以及MySQL查询优化器
  4. Javascript高级程序设计——引用类型
  5. maven 依赖查询
  6. [深入浅出WP8.1(Runtime)]Socket编程之UDP协议
  7. form 编译命令
  8. DiscuzX程序升级教程_不知道关闭论坛的看过来
  9. LUA之面向对象
  10. asp.net网站 提示Ambiguous match found
  11. Spring MVC 教程,快速入门,深入分析(转)
  12. C++求二叉树的最大高度差
  13. Delphi ADO数据操作封装类
  14. Finally-操作返回值
  15. Log4net日志使用教程-控制台、文本、数据库三种记录方式
  16. SpringBoot:Invalid character found in method name. HTTP method names must be tokens
  17. 【原创】数据库基础之Mysql(2)主从库配置
  18. thinkphp5.0引入类
  19. Linux记录-安装LAMP和R环境
  20. Github Upload Large File 上传超大文件

热门文章

  1. JAVA多线程之中断机制(如何处理中断?)
  2. OI生涯回忆录 2017.9.10~2018.11.11
  3. zoj3707(Calculate Prime S)解题报告
  4. dijkstra 的优先队列优化
  5. java代码示例(3)
  6. 将本地的代码推送到公网的github账号去
  7. Python全栈问答小技巧_1
  8. 整理备忘一波liunx命令(持续更新)
  9. centos7下安装nginx的方法
  10. python 小程序,输错三次密码锁定账户