【zabbix-agent自动安装脚本】人生难得几回搏,此时不搏待何时。这篇文章主要讲述zabbix-agent自动安装脚本相关的知识,希望能为你提供帮助。
1.准备文件
zabbix-4.0.35.tar.gz
zabbix_agentd.conf
zabbix-agent.service
zabbix-agent-install.sh
1.1.zabbix_agentd.conf
root@ubuntu:/data# grep ^[a-Z] zabbix_agentd.conf
---------------------------------------------------------
PidFile=/apps/zabbix_agent/run/zabbix_agentd.pid
LogFile=/apps/zabbix_agent/run/zabbix_agentd.log
EnableRemoteCommands=1
Server=192.168.47.51
StartAgents=3
ServerActive=192.168.47.51
Hostname=
Timeout=30
AllowRoot=1
User=root
Include=/apps/zabbix_agent/conf.d/*.conf
UnsafeUserParameters=1
1.2.zabbix-agent.service
root@ubuntu:/data# cat zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/apps/zabbix_agent/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/default/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/apps/zabbix_agent/run/zabbix_agentd.pid
KillMode=control-group
ExecStart=/apps/zabbix_agent/sbin/zabbix_agentd-c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
1.3.zabbix-agent-install.sh
#!/bin/bash
grep "Kernel" /etc/issue > > /dev/null
if [ $? -eq 0 ]; then
yum installvim iotop bc gcc gcc-c++ glibc glibc-devel pcre \\
pcre-devel opensslopenssl-devel zip unzip zlib-develnet-tools \\
lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \\
bcsystemd-devel bash-completion traceroute firewalld bridge-utils -y
fi
grep "Ubuntu" /etc/issue > > /dev/null
if [ $? -eq 0 ]; then
apt-get update
apt-getinstall iproute2ntpdatetcpdump telnet traceroute nfs-kernel-server \\
nfs-commonlrzsz treeopenssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate \\
tcpdump telnet traceroutegcc openssh-server lrzsz treeopenssl libssl-dev libpcre3 \\
libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip firewalld make -y
fi
DIR=`pwd`
useradd zabbix
tar xf zabbix-4.0.35.tar.gz & & cdzabbix-4.0.35 & & ./configure --prefix=/apps/zabbix_agent --enable-agent & & make & & make install
mkdir /apps/zabbix_agent/conf.d,run
\\cp $DIR/zabbix-agent.service /lib/systemd/system/zabbix-agent.service
\\cp $DIR/zabbix_agentd.conf /apps/zabbix_agent/etc/
IP=`ifconfig eth0 |grep -w inet |awk print $2`
sed -i s/Hostname=/Hostname=$IP/g /apps/zabbix_agent/etc/zabbix_agentd.conf
chown zabbix.zabbix /apps/zabbix_agent -R
systemctl daemon-reload
systemctl start zabbix-agent & & systemctl enable zabbix-agent
echo "zabbix-agent 安装成功"
推荐阅读
- DHCP中继 思科设备
- win_cmd下常用命令
- 使用图形化界面管理防火墙!
- Mac电脑恢复出厂设置教程
- 共读《redis设计与实现》-单机
- 浅论系统重装的几种方法
- 安装LAMP服务
- 7个最常见的ReactJS面试问题和答案合集解析
- 面向开发人员的10个最常见的ES6面试问题和答案