Linux记录-批量安装zabbix(转载)
同一文件夹下建立pwd.txt,格式如下:
ip username password
ip username password
#!/bin/bash
cat pwd.txt | while read line
do
hostip=`echo $line | cut -d" " -f1`
uname=`echo $line | cut -d" " -f2`
pwd=`echo $line | cut -d" " -f3` /usr/bin/expect <<-EOF
set timeout 600
spawn scp -r /tmp/zabbix-3.4.12.tar.gz $uname@$hostip:/tmp/
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$pwd\r" }
}
spawn scp -r /tmp/3.sh $uname@$hostip:/tmp/
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$pwd\r" }
}
spawn ssh $uname@$hostip
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$pwd\r" }
}
expect "*]#"
send "chmod +x /tmp/3.sh\r"
expect "*]#"
send "sh /tmp/3.sh\r"
expect "*]#"
send "exit\r"
interact
expect eof
EOF done
3.sh
#!/bin/bash
yum -y install pcre*
egrep "^zabbix" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
groupadd zabbix
fi
egrep "^zabbix" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
useradd -g zabbix zabbix -s /sbin/nologin
fi
cd /tmp/
tar -zxvf /tmp/zabbix-3.4.12.tar.gz
cd /tmp/zabbix-3.4.12/
./configure --prefix=/usr/local/zabbix-agent --enable-agent
make
make install
cd /tmp/zabbix-3.4.12/misc
cp init.d/tru64/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
cp -r /etc/init.d/zabbix_agentd /tmp/zabbix_agentd.bak
sed -i 's/DAEMON=\/usr\/local\/sbin\/zabbix_agentd/DAEMON=\/usr\/local\/zabbix-agent\/sbin\/zabbix_agentd/g' /etc/init.d/zabbix_agentd
sed -i '/#!\/bin\/sh/a\#chkconfig: 345 95 95' /etc/init.d/zabbix_agentd
sed -i '/#chkconfig: 345 95 95/a\#description: Zabbix_Server' /etc/init.d/zabbix_agentd
chkconfig zabbix_agentd on
sed -i 's/Server=127.0.0.1/Server=193.168.120.77/g' /usr/local/zabbix-agent/etc/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=193.168.120.77/g' /usr/local/zabbix-agent/etc/zabbix_agentd.conf
HOSTNAME=`hostname`
sed -i 's/Hostname=Zabbix server/Hostname='$HOSTNAME'/g' /usr/local/zabbix-agent/etc/zabbix_agentd.conf
sed -i 's/LogFile=\/tmp\/zabbix_agentd.log/LogFile=\/var\/log\/zabbix\/zabbix_agentd.log/g' /usr/local/zabbix-agent/etc/zabbix_agentd.conf
mkdir -p /var/log/zabbix
chown -R zabbix.zabbix /var/log/zabbix/
chown -R zabbix.zabbix /usr/local/zabbix-agent/ /etc/init.d/zabbix_agentd start
Linux记录-批量安装zabbix(转载)的更多相关文章
- Linux记录-批量安装LNMP(转载)
#!/bin/bash # Describe: This is a one - button installation service script # 提示:使用此脚本时,尽量先选择第一项配置Yum ...
- Linux记录-批量安装ssh(转载)
首先,需要检查expect是否安装:rpm -qa|grep expect 然后,在操作机上创建公钥:ssh-keygen 一路回车即可 创建好之后到/root/.ssh/下就可以看到id开头的2个文 ...
- Linux记录-批量安装软件服务(转载)
#!/bin/bash # 安装函数 install(){ for soft in $* do echo "$soft"安装中... y ...
- Zabbix 4.0.2试用(七):在Linux主机中安装zabbix agent并添加该主机(yum源安装)
Zabbix 4.0.2试用(七):在Linux主机中安装zabbix agent并添加主机(yum源安装) 2018年12月20日, 上午6:42 之前介绍的是下载源安装包,编译安装的方式来安装ag ...
- Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装(转载)(1)
Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装 一.引言 设计模式写完了,相当于重新学了一遍,每次学习都会有不同的感受,对设计模式的理解又加深了,理解的更加透彻了.还差一篇 ...
- ansible 批量安装zabbix agentd客户端
目录结构 # tree /etc/ansible/ /etc/ansible/ ├── ansible.cfg ├── hosts ├── roles │ └── zabbix-agentd │ ...
- Linux记录-salt-minion安装
python -m SimpleHTTPServer 8888#!/bin/bash sed -i 's/^#//g' /etc/yum.repos.d/centos7.4.repo sed -i ' ...
- Linux记录-AWK语法(转载)
1.原理 awk,一个行文本处理工具,逐行处理文件中的数据 语法:awk 'pattern + {action}' 说明:(1)单引号''是为了和shell命令区分开:(2)大括号{}表示一个命令分组 ...
- Linux记录-批量更改当前目录的文件后缀名
#!/bin/bash path=. for file in $(ls $path) do if [ -f $file ] then filename=${file%.*} bak=${file#*. ...
随机推荐
- [BeiJing2010组队]次小生成树 Tree
1977: [BeiJing2010组队]次小生成树 Tree Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 5168 Solved: 1668[S ...
- 评估预测函数(3)---Model selection(选择多项式的次数) and Train/validation/test sets
假设我们现在想要知道what degree of polynomial to fit to a data set 或者 应该选择什么features 或者 如何选择regularization par ...
- ldap系列-基础知识
来源:关键字排名 ldap 是什么? LDAP(Lightweight Directory Access Protocol)即轻量级目录访问协议,提供信息服务.那啥是目录服务呢? 目录服务是一种特殊的 ...
- C++ 类的静态成员
https://www.cnblogs.com/lvxiaoning/p/7598062.html
- 学习Spring-Data-Jpa(七)---JpaRepository
之前我们学习的Repository都是Spring-Data为了兼容NoSQL而进行的一些抽象封装,从JpaRepository开始是对关系型数据库进行抽象封装.JpaRepository位于spri ...
- [Flutter] Custom a Slider with SliderTheme
SliderTheme( data: SliderTheme.of(context).copyWith( activeTrackColor: Colors.white, inactiveTrackCo ...
- python中string、json、bytes的转换
json->string str = json.dumps(jsonobj) bytes->string str = str(bytes,‘utf-8’) string->json ...
- SQL Server 2008R2安装
SQL Server 2008详细安装过程及配置 https://www.cnblogs.com/rewwensoftware/p/9580697.html SQL Server 2008R2 百 ...
- WAMP本地环境升级php版本操作步骤(详细)
php版本下载地址:http://windows.php.net/download/ 步骤:下载php版本-解压文件-放到bin/php目录下-更改文件 图片教程: 更改文件内容: 1.从已存在的ph ...
- 13.mysql数据库
1.mysql数据库建立 yum install mysql-server mysql -u root mysqladmin ...