zabbix agent 6.0安装脚本

编程入门 行业动态 更新时间:2024-10-17 18:19:38

zabbix agent 6.0安装<a href=https://www.elefans.com/category/jswz/34/1771291.html style=脚本"/>

zabbix agent 6.0安装脚本

脚本如下:

#!/bin/bash# Function to install Zabbix Agent 2 on RHEL 6
install_zabbix_rhel6() {# Check if the Zabbix repository is already installedif rpm -q zabbix-release &>/dev/null; thenecho "Zabbix repository is already installed."else# Install Zabbix repositoryrpm -Uvh .0/rhel/6/x86_64/zabbix-release-6.0-4.el6.noarch.rpmif [ $? -eq 0 ]; thenecho "Zabbix repository installed successfully."elseecho "Error installing Zabbix repository. Exiting."exit 1fifi# Check if Zabbix Agent 2 is already installedif rpm -q zabbix-agent2 &>/dev/null; thenecho "Zabbix Agent 2 is already installed."else# Install Zabbix Agent 2yum clean allyum install zabbix-agent2 zabbix-agent2-plugin-* -yif [ $? -eq 0 ]; thenecho "Zabbix Agent 2 installed successfully."elseecho "Error installing Zabbix Agent 2. Exiting."exit 1fifi# Modify Zabbix Agent 2 configurationread -p "Enter the desired hostname for Zabbix Agent: " hostnamesed -i "s/^Server=.*/Server=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^ServerActive=.*/ServerActive=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^Hostname=.*/Hostname=$hostname/" /etc/zabbix/zabbix_agent2.conf# Enable and start Zabbix Agent 2service zabbix-agent2 restartchkconfig --level 35 zabbix-agent2 on
}# Function to install Zabbix Agent 2 on RHEL 7
install_zabbix_rhel7() {echo "Installing Zabbix Agent 2 on RHEL 7"# Check if Zabbix repository is already installedif rpm -q zabbix-release &>/dev/null; thenecho "Zabbix repository is already installed."else# Install Zabbix repositoryrpm -Uvh .0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpmif [ $? -eq 0 ]; thenecho "Zabbix repository installed successfully."elseecho "Error installing Zabbix repository. Exiting."exit 1fifi# Check if Zabbix Agent 2 is already installedif rpm -q zabbix-agent2 &>/dev/null; thenecho "Zabbix Agent 2 is already installed."else# Install Zabbix Agent 2yum clean allyum install zabbix-agent2 zabbix-agent2-plugin-* -yif [ $? -eq 0 ]; thenecho "Zabbix Agent 2 installed successfully."elseecho "Error installing Zabbix Agent 2. Exiting."exit 1fifi# Modify Zabbix Agent 2 configurationread -p "Enter the desired hostname for Zabbix Agent: " hostnamesed -i "s/^Server=.*/Server=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^ServerActive=.*/ServerActive=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^Hostname=.*/Hostname=$hostname/" /etc/zabbix/zabbix_agent2.conf# Enable and start Zabbix Agent 2systemctl enable zabbix-agent2systemctl start zabbix-agent2
}# Function to install Zabbix Agent 2 on RHEL 8
install_zabbix_rhel8() {echo "Installing Zabbix Agent 2 on RHEL 8"# Check if the Zabbix repository is already installedif rpm -q zabbix-release &>/dev/null; thenecho "Zabbix repository is already installed."else# Install Zabbix repositoryrpm -Uvh .0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpmif [ $? -eq 0 ]; thenecho "Zabbix repository installed successfully."elseecho "Error installing Zabbix repository. Exiting."exit 1fifi# Check if Zabbix Agent 2 is already installedif rpm -q zabbix-agent2 &>/dev/null; thenecho "Zabbix Agent 2 is already installed."else# Install Zabbix Agent 2dnf clean alldnf install zabbix-agent2 zabbix-agent2-plugin-* -yif [ $? -eq 0 ]; thenecho "Zabbix Agent 2 installed successfully."elseecho "Error installing Zabbix Agent 2. Exiting."exit 1fifi# Modify Zabbix Agent 2 configurationread -p "Enter the desired hostname for Zabbix Agent: " hostnamesed -i "s/^Server=.*/Server=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^ServerActive=.*/ServerActive=10.99.50.112/" /etc/zabbix/zabbix_agent2.confsed -i "s/^Hostname=.*/Hostname=$hostname/" /etc/zabbix/zabbix_agent2.conf# Enable and start Zabbix Agent 2systemctl enable zabbix-agent2systemctl start zabbix-agent2
}# Install Zabbix repository based on the selected OS version
echo "Select the operating system version:"
options=("RHEL 6" "RHEL 7" "RHEL 8" "Quit")
select opt in "${options[@]}"; docase "$opt" in"RHEL 6")install_zabbix_rhel6break;;"RHEL 7")install_zabbix_rhel7break;;"RHEL 8")install_zabbix_rhel8break;;"Quit")echo "Exiting."exit 0;;*)echo "Invalid option. Please select a valid option.";;esac
done  echo "Zabbix Agent 2 installation and configuration complete."

更多推荐

zabbix agent 6.0安装脚本

本文发布于:2023-12-03 10:28:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1654322.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   zabbix   agent

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!