1、添加nagios用户

echo "------ step 1: add nagios user------"

#create user group

/usr/sbin/useradd -m nagios -s /sbin/nologin





2、解压nagios软件包

echo "------ step 2: unzip nagios soft------"

mkdir -p /home/oldboy/tools/

cd /home/oldboy/tools/

[  ! -f ./oldboy_training_nagios_soft.zip ] &&{

echo "nagios soft is not exist."

exit 1

}

/bin/cp oldboy_training_nagios_soft.zip /home/oldboy/tools/

cd /home/oldboy/tools/





3、安装nagios插件

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

yum -y install perl-devel

tar zxf nagios-plugins-1.4.16.tar.gz

cd nagios-plugins-1.4.16

./configure --prefix=/usr/local/nagios --enable-perl-modules --enable-redhat-pthread-workaround 

make && make install

cd ../

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





echo "------ step 4: install nrpe------"

cd /home/oldboy/tools/

tar zxf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

cd ..





4、安装iostat监控相关插件

echo "------ step 4: install soft for iostat------"

cd /home/oldboy/tools/

tar zxvf Params-Validate-0.91.tar.gz 

cd Params-Validate-0.91 

perl Makefile.PL 

make

make install





#---------------------------------------- 

cd /home/oldboy/tools/

tar zxvf Class-Accessor-0.31.tar.gz

cd Class-Accessor-0.31

perl Makefile.PL

make

make install





#---------------------------------------- 

cd /home/oldboy/tools/

tar zxvf Config-Tiny-2.12.tar.gz

cd Config-Tiny-2.12

perl Makefile.PL

make

make install





#---------------------------------------- 

cd /home/oldboy/tools/

tar zxvf Math-Calc-Units-1.07.tar.gz

cd Math-Calc-Units-1.07

perl Makefile.PL

make

make install





#---------------------------------------- 

cd /home/oldboy/tools/

tar zxvf Regexp-Common-2010010201.tar.gz

cd Regexp-Common-2010010201

perl Makefile.PL

make

make install





#---------------------------------------- 

cd /home/oldboy/tools/

tar zxvf Nagios-Plugin-0.34.tar.gz

cd Nagios-Plugin-0.34

perl Makefile.PL

make

make install





#______________________ 





#for monitor iostat 

yum install sysstat -y





/bin/cp /home/oldboy/tools/check_memory.pl /usr/local/nagios/libexec

/bin/cp /home/oldboy/tools/check_iostat /usr/local/nagios/libexec





chmod 755 /usr/local/nagios/libexec/check_memory.pl

chmod 755 /usr/local/nagios/libexec/check_iostat





dos2unix /usr/local/nagios/libexec/check_memory.pl

dos2unix /usr/local/nagios/libexec/check_iostat





5、修改nrpe.cfg文件,添加服务端

echo "------ step 5: 修改nrpe.cfg------"

perl -pi -e 's/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,192.168.8.42/g' /usr/local/nagios/etc/nrpe.cfg 





#delete 199--203

cp /usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg.ori

sed -i '199,203d' /usr/local/nagios/etc/nrpe.cfg





echo "command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,6 -c 30,25,20">>/usr/local/nagios/etc/nrpe.cfg

echo "command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 6% -c 3%">>/usr/local/nagios/etc/nrpe.cfg

echo "command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 8% -p /">>/usr/local/nagios/etc/nrpe.cfg

echo "command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%">>/usr/local/nagios/etc/nrpe.cfg

echo "command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10">>/usr/local/nagios/etc/nrpe.cfg





6、启动nagios客户端

echo "------ step 6: start nagios client------"

#start nagios client

pkill nrpe 

sleep 2

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

echo  "#nagios nrpe process cmd by jack 2016-07-21" >> /etc/rc.local

echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d">>/etc/rc.local

netstat -lnt|grep 5666 && echo "nagios client is ok"

自动化安装脚本:

将oldboy_training_nagios_soft.zip压缩包拷贝到系统中

#!/bin/sh
################################################
echo "# 安装 nagios 客户端AGENT #"
echo "##############################"
#install nagios client---start---
mkdir -p /home/oldboy/tools/
cd /home/oldboy/tools/
# 将oldboy_training_nagios_soft.zip上传到/home/oldboy/tools/目录中 #install nagios client---start---
yum install -y gcc*
yum install gcc glibc glibc-common -y
yum install -y openssl*
echo "------ step 1: add nagios user------"
#create user group
/usr/sbin/useradd -m nagios -s /sbin/nologin echo "------ step 2: unzip nagios soft------"
cd /home/oldboy/tools/
[ ! -f ./oldboy_training_nagios_soft.zip ] &&{
echo "nagios soft is not exist."
exit 1
}
/bin/cp oldboy_training_nagios_soft.zip /home/oldboy/tools/
cd /home/oldboy/tools/
unzip oldboy_training_nagios_soft.zip echo "------ step 3: install nagios-plugins------"
yum -y install perl-devel
tar zxf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --prefix=/usr/local/nagios --enable-perl-modules --enable-redhat-pthread-workaround
make && make install
cd ../
ls /usr/local/nagios/libexec/|wc -l echo "------ step 4: install nrpe------" cd /home/oldboy/tools/
tar zxf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
cd .. echo "------ step 4: install soft for iostat------"
cd /home/oldboy/tools/
tar zxvf Params-Validate-0.91.tar.gz
cd Params-Validate-0.91
perl Makefile.PL
make
make install
cd ..
#----------------------------------------
cd /home/oldboy/tools/
tar zxvf Class-Accessor-0.31.tar.gz
cd Class-Accessor-0.31
perl Makefile.PL
make
make install
cd ..
#----------------------------------------
cd /home/oldboy/tools/
tar zxvf Config-Tiny-2.12.tar.gz
cd Config-Tiny-2.12
perl Makefile.PL
make
make install
cd ..
#----------------------------------------
cd /home/oldboy/tools/
tar zxvf Math-Calc-Units-1.07.tar.gz
cd Math-Calc-Units-1.07
perl Makefile.PL
make
make install
cd ..
#----------------------------------------
cd /home/oldboy/tools/
tar zxvf Regexp-Common-2010010201.tar.gz
cd Regexp-Common-2010010201
perl Makefile.PL
make
make install
cd ..
#----------------------------------------
cd /home/oldboy/tools/
tar zxvf Nagios-Plugin-0.34.tar.gz
cd Nagios-Plugin-0.34
perl Makefile.PL
make
make install
cd ..
#______________________ #for monitor iostat
yum install sysstat -y /bin/cp /home/oldboy/tools/check_memory.pl /usr/local/nagios/libexec
/bin/cp /home/oldboy/tools/check_iostat /usr/local/nagios/libexec chmod 755 /usr/local/nagios/libexec/check_memory.pl
chmod 755 /usr/local/nagios/libexec/check_iostat dos2unix /usr/local/nagios/libexec/check_memory.pl
dos2unix /usr/local/nagios/libexec/check_iostat
##################################################
echo "------ step 5: 修改nrpe.cfg------"
perl -pi -e 's/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,10.0.0.7/g' /usr/local/nagios/etc/nrpe.cfg #delete 199--203
cp /usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg.ori
sed -i '199,203d' /usr/local/nagios/etc/nrpe.cfg echo "command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,6 -c 30,25,20">>/usr/local/nagios/etc/nrpe.cfg
echo "command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 6% -c 3%">>/usr/local/nagios/etc/nrpe.cfg
echo "command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 8% -p /">>/usr/local/nagios/etc/nrpe.cfg
echo "command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%">>/usr/local/nagios/etc/nrpe.cfg
echo "command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10">>/usr/local/nagios/etc/nrpe.cfg echo "------ step 6: start nagios client------"
#start nagios client
pkill nrpe
sleep 2
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "#nagios nrpe process cmd by oldboy 2012-6-7" >> /etc/rc.local
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d">>/etc/rc.local
netstat -lnt|grep 5666 && echo "nagios client is ok"

nagios系列(二)之nagios客户端的安装及配置的更多相关文章

  1. linux之 NFS服务器与客户端的安装与配置

    今天实验室需要搭建NAS,我负责的是NFS的安装与配置,现将整理的文档分享一下: 参考一:Linux下rpm 安装包方式安装 http://linux.chinaunix.net/techdoc/be ...

  2. Oracle 11g 客户端的安装和配置。

    原文:Oracle 11g 客户端的安装和配置. 数据库和客户端在不同的机器之上. 在安装之前,在安装Oracle数据库的服务器上导航到下面的目录. 将listener.ora和tnsnames.or ...

  3. Git客户端的安装与配置入门

    GitLab与Git客户端的安装与配置入门,每次配置完一段时间,就忘记配置过程了,为了自己和同学们以后有所参照,特记录了本次下载和配置,其实Git就是一个版本控制系统,类似于SVN,CVS等 下载:W ...

  4. 关于Nagios通过NRPE监控客户端的安装与配置

    环境介绍>>>>>>>>>>>>>>>>>>>>>>>> ...

  5. nagios系列(六)之nagios实现对服务器cpu温度的监控

    1.安装硬件传感器监控软件sensors yum install -y lm_sensors* 2.运行sensors-detect进行传感器检测 ##一路回车即可 Do you want to ov ...

  6. nagios系列(五)之nagios图形显示的配置及自定义插件检测密码是否修改详解

    nagios图形显示的配置 在服务端安装相关软件 #1.图形显示管理的依赖库 yum install cairo pango zlib zlib-devel freetype freetype-dev ...

  7. Windows系统下Memcached缓存系列二:CouchbaseClient(c#客户端)的详细试用,单例模式

    在上一篇文章里面 ( Windows系统下Memcached缓存系列一:Couchbase(服务器端)和CouchbaseClient(c#客户端)的安装教程 ),我们介绍了服务器端的安装和客户端的安 ...

  8. nagios系列(四)之nagios主动方式监控tcp常用的80/3306等端口监控web/syncd/mysql及url服务

    nagios主动方式监控tcp服务web/syncd/mysql及url cd /usr/local/nagios/libexec/ [root@node4 libexec]# ./check_tcp ...

  9. nagios系列(三)之nagios被动监控模式之添加系统负载load、swap、磁盘iostat及memory内存监控详解

    环境: nagios server:192.168.8.42 host_name:node4.chinasoft.com nagios client:192.168.8.41 host_name:no ...

随机推荐

  1. SDL源码阅读笔记(1) 基本模块

    write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie 前言 对于大牛来说,写关于阅读源码的文章都会叫源码剖析或者深入浅出啥的,对于我,自己阅读阅读源码,写 ...

  2. 迅雷thunder://协议解密

    echo -n 'thunder://''Cg==' | sed 's?thunder://??' | base64 -d | sed 's/^AA//; s/ZZ$//' 将thunder://替换 ...

  3. Java: md5 加密中文 & 注意编码

    今天使用java的md5加密一个字符串(含有部分中文),遇到问题,百思不得其解. 后面网上搜索了一下,才知道是[编码]的问题. 以前在asp中用md5加密的时候,了解 gb2312和utf-8编码下, ...

  4. Educational Codeforces Round 52 (Rated for Div. 2) E. Side Transmutations

    http://codeforces.com/contest/1065/problem/E 数学推导题 #include <bits/stdc++.h> using namespace st ...

  5. git 子模块

    为了方便各个子模块独立开发,或使用第三方不断更新的仓库,可以使用子模块来引用. 子模块对应的源码是子模块仓库的克隆. git submodule 与 subtree对比 git submodule 允 ...

  6. BRIEF特征简介

    引言 该文是由EPFL的Calonder在ECCV2010上提出了一种可以快速计算且表达方式为二进制编码的描述子.主要思路就是在特征点附近随机选取若干点对,将这些点对的灰度值的大小,组合成一个二进制串 ...

  7. Java + 腾讯邮箱 SSL加密问题 重要通知

    原来的jdk8版本如果不替换jce就会在发邮件的过程中报错,而此次使用的jdk1.8.0_131,并没有出现问题,也就是说,如果你使用的版本是 就不用考虑发邮件因为加密算法而导致的错误了

  8. linux command ------ ls

    -rw-r--r-- [d]: content [-]: file [l]: link file [b]: interface device for storage in a device file ...

  9. centos7使用kubeadm配置高可用k8s集群

    CountingStars_ 关注 2018.08.12 09:06* 字数 464 阅读 88评论 0喜欢 0 简介 使用kubeadm配置多master节点,实现高可用. 安装 实验环境说明 实验 ...

  10. android measure的时候报空指针

    1.使用listview的时候,在代码中动态设置其高度,在android低版本中,这个低版本是以4.4为界,会报measure的空指针,原因是低版本relativelayout有个bug,使用list ...