DEV Community

aylinsdogan for Açıklab

Posted on

3

Zabbix admin yetkisi

Yetki Verme

Servis varsayılanda zabbix servis kullanıcısı ile çalışmaktadır, yetkisi olmayan dosyaları okuma gibi işlemlerde "[13] Permission denied." hatası ile karşılaşılabilir. Hatayı çözebilmek için servisi kullanıcı ile çalıştırmamız gerekmektedir. Aşağıdaki adımlar bunun nasıl yapılacağını göstermektedir.

Step-1

set_zabbix.sh dosyası makine üzerinde yaratılır.

set_zabbix.sh dosyasının içeriği aşağıdaki gibi olmalıdır.

while getopts h:i: flag
do
    case "${flag}" in
        h) zbx_hostname=${OPTARG};;
        i) zbx_ip=${OPTARG};;
    esac
done
if test -z "$zbx_hostname" 
then
    zbx_hostname=$(hostname --short)
fi
if test -z "$zbx_ip" 
then
   echo "ip input olarak verilmek zorundadır!"
   exit
fi
sudo apt install zabbix-agent -y
version=$(dpkg -s zabbix-agent  | grep -i version | cut -d : -f 3 | cut -d . -f 1)
if [ $version -gt 5 ] ; 
then
    echo "Version: $version, yeni yapılandırma uygulanıyor"
    mkdir /etc/systemd/system/zabbix-agent.service.d 2>/dev/null
    echo """
    [Service] 
    User=root 
    Group=root
    """ > /etc/systemd/system/zabbix-agent.service.d/override.conf
    sed -i "/ServerActive=/d" /etc/zabbix/zabbix_agentd.conf; echo  "ServerActive=$zbx_ip" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/Hostname=/d" /etc/zabbix/zabbix_agentd.conf; echo  "Hostname=$zbx_hostname" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/Server=/d" /etc/zabbix/zabbix_agentd.conf; echo  "Server=$zbx_ip" >> /etc/zabbix/zabbix_agentd.conf
    systemctl daemon-reload
    systemctl restart zabbix-agent
else
    echo "Version: $version, eski yapılandırma uygulanıyor"

    mkdir /etc/systemd/system/zabbix-agent.service.d 2>/dev/null
    echo """
    [Service] 
    User=root 
    Group=root
    """ > /etc/systemd/system/zabbix-agent.service.d/override.conf

    sed -i "/ServerActive=/d" /etc/zabbix/zabbix_agentd.conf; echo  "ServerActive=$zbx_ip" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/Server=/d" /etc/zabbix/zabbix_agentd.conf; echo  "Server=$zbx_ip" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/AllowRoot=/d" /etc/zabbix/zabbix_agentd.conf; echo  "AllowRoot=1" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/Hostname=/d" /etc/zabbix/zabbix_agentd.conf; echo  "Hostname=$zbx_hostname" >> /etc/zabbix/zabbix_agentd.conf
    sed -i "/User=/d" /etc/zabbix/zabbix_agentd.conf; echo  "User=root" >> /etc/zabbix/zabbix_agentd.conf
    systemctl daemon-reload
    systemctl restart zabbix-agent
fi 

Enter fullscreen mode Exit fullscreen mode

Step-2

Zabbix arayüzündeki Makine adı ve zabbix ip'si scripte input olarak aşağıdaki gibi verilmelidir.
NOT: hostname verisinin zabbix arayüzündeki gibi olması önemlidir.

sudo bash set_zabbix.sh -h "DNS DTL" -i "zabbix_ip"
Enter fullscreen mode Exit fullscreen mode

Bu sayede Zabbix ve Liman üzerinde auth logları görüntülenebilir

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay