- passage de zabbix agent en zabbix agent2

This commit is contained in:
Frogg 2026-05-13 18:10:12 +02:00
parent 6770e2d6b2
commit efdb68a61a
2 changed files with 29 additions and 12 deletions

View File

@ -6,7 +6,7 @@
SERVICES_TO_CHECK=(
# MONITORING
"Zabbix Server|zabbix_server"
"Zabbix Agent|zabbix_agentd"
"Zabbix Agent2|zabbix_agent2"
# DATABASE
"MySQL Server|mysql"
"PostgreSQL|psql"

View File

@ -51,7 +51,7 @@ check_deb_sys_ipv6(){
}
check_deb_sys_zabbix(){
if dpkg -s zabbix-agent >/dev/null 2>&1; then
if dpkg -s zabbix-agent2 >/dev/null 2>&1; then
return 0
else
return 1
@ -59,7 +59,7 @@ check_deb_sys_zabbix(){
}
check_deb_sys_zabbix_conf(){
if dpkg -s zabbix-agent >/dev/null 2>&1; then
if dpkg -s zabbix-agent2 >/dev/null 2>&1; then
return 1
else
return 0
@ -407,23 +407,40 @@ do_deb_sys_apparmor(){
do_deb_sys_zabbix(){
local ip
# 1. Désinstallation de l'ancien agent s'il existe
if dpkg -s zabbix-agent >/dev/null 2>&1; then
msg_info "Ancien Zabbix Agent détecté, suppression..."
$SUDO systemctl stop zabbix-agent >/dev/null 2>&1
$SUDO apt-get purge -y zabbix-agent
$SUDO apt-get autoremove -y
fi
read -rp "IP Zabbix [${CONFIG_DEB_INSTALL_ZABBIX_SERVER_IP}]: " ip;
ip=${ip:-${CONFIG_DEB_INSTALL_ZABBIX_SERVER_IP}}
$SUDO apt-get install -y zabbix-agent;
$SUDO sed -i "s/^Server=.*/Server=$ip/" /etc/zabbix/zabbix_agentd.conf
$SUDO sed -i "s/^ServerActive=.*/ServerActive=$ip/" /etc/zabbix/zabbix_agentd.conf
$SUDO systemctl restart zabbix-agent
msg_success "Zabbix agent configuré."
$SUDO apt-get install -y zabbix-agent2;
$SUDO sed -i "s/^Server=.*/Server=$ip/" /etc/zabbix/zabbix_agent2.conf
$SUDO sed -i "s/^ServerActive=.*/ServerActive=$ip/" /etc/zabbix/zabbix_agent2.conf
# OPTIONNEL : Force l'agent à envoyer son propre nom d'hôte système
$SUDO sed -i "s/^# HostnameItem=.*/HostnameItem=system.hostname/" /etc/zabbix/zabbix_agent2.conf
$SUDO sed -i "s/^Hostname=.*/# Hostname=Zabbix server/" /etc/zabbix/zabbix_agent2.conf
$SUDO systemctl enable zabbix-agent2
$SUDO systemctl restart zabbix-agent2
msg_success "Zabbix agent 2 configuré."
}
do_deb_sys_zabbix_conf(){
local ip
read -rp "IP Zabbix [${CONFIG_DEB_INSTALL_ZABBIX_SERVER_IP}]: " ip;
ip=${ip:-${CONFIG_DEB_INSTALL_ZABBIX_SERVER_IP}}
$SUDO sed -i "s/^Server=.*/Server=$ip/" /etc/zabbix/zabbix_agentd.conf
$SUDO sed -i "s/^ServerActive=.*/ServerActive=$ip/" /etc/zabbix/zabbix_agentd.conf
$SUDO systemctl restart zabbix-agent
msg_success "Zabbix agent configuré."
$SUDO sed -i "s/^Server=.*/Server=$ip/" /etc/zabbix/zabbix_agent2.conf
$SUDO sed -i "s/^ServerActive=.*/ServerActive=$ip/" /etc/zabbix/zabbix_agent2.conf
# OPTIONNEL : Force l'agent à envoyer son propre nom d'hôte système
$SUDO sed -i "s/^# HostnameItem=.*/HostnameItem=system.hostname/" /etc/zabbix/zabbix_agent2.conf
$SUDO sed -i "s/^Hostname=.*/# Hostname=Zabbix server/" /etc/zabbix/zabbix_agent2.conf
$SUDO systemctl enable zabbix-agent2
$SUDO systemctl restart zabbix-agent2
msg_success "Zabbix agent 2 configuré."
}
do_deb_sys_ipv6(){