Ad Widget

Collapse

Autoregistering hosts after every reboot/apt upgrade

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GoatZero
    Junior Member
    • May 2019
    • 9

    #1

    Autoregistering hosts after every reboot/apt upgrade

    Seems like I'm getting spammed autoregistration messages, everytime there's a reboot/apt upgrade, for starters, here's my agend.conf

    Code:
    ZABBIX_SERVER="1.1.1.1"        #Main P4-zabbix server
    
    if [[ $EUID -ne 0 ]]; then
            echo "must run as root" 1>&2
            exit 1
    else
            apt-get remove -y zabbix-agent
            apt-get purge -y zabbix-agent
    
            apt-get update
            apt-get install zabbix-agent
    
            sed -i "/^Server=/c\Server=${ZABBIX_SERVER}" /etc/zabbix/zabbix_agentd.conf
            sed -i "/^ServerActive=/c\ServerActive=${ZABBIX_SERVER}" /etc/zabbix/zabbix_agentd.conf
            sed -i "/^Hostname=/c\Hostname=${HOSTNAME}" /etc/zabbix/zabbix_agentd.conf
    
            sed -i "s/# StartAgents=3/StartAgents=5/;
                s/# HostMetadata=/HostMetadataItem=release/;
                s/# UserParameter=/UserParameter=release, uname -s/" /etc/zabbix/zabbix_agentd.conf
    
            systemctl enable zabbix-agent.service
            systemctl restart zabbix-agent.service
    fi
    I have my Discovery rules set up as

    Click image for larger version  Name:	444.JPG Views:	1 Size:	28.3 KB ID:	386792
    AutoRegistration as

    Click image for larger version  Name:	555.JPG Views:	1 Size:	43.0 KB ID:	386793
    Whenever I run this script I get an alert like

    Click image for larger version  Name:	33.png Views:	1 Size:	24.8 KB ID:	386791

    As you can see the script uninstalls and reinstalls the agent, whenever is run so there should be no problem on seeing the autoregistering alert several times each time the script is run.

    I installed the agent in 70 servers, and after 1 month of having no problems at all, today a coworker logged in into a server to run a

    HTML Code:
    apt update
                 reboot
    and we got exactly this (I'm reusing the image from above, be assured that this is the one that triggered)

    Click image for larger version  Name:	33.png Views:	1 Size:	24.8 KB ID:	386791

    He did it in another server and the same happened, and in both servers, there were no changes at all in the host configuration itself

    After reading https://www.zabbix.com/documentation...o_registration

    Where is stated that:

    An auto-registration attempt happens every time an active agent sends a request to refresh active checks to the server. The delay between requests is specified in the RefreshActiveChecks parameter of the agent. The first request is sent immediately after the agent is restarted.
    As you can see I have no RefreshActiveChecks parameter set up, so I'm guessing that if I modify the items list on the Zabbix front end this might happen again,

    I'm trying to troubleshoot this but, it seems that it cant be easily replicated, right I only know that it's time-dependent and can happen in 1 month or 4 months, (leaving the action steps out of being an option), so I'm wondering of whats the cause...

    As far as I can see there are 3 possible scenarios triggering this alert.

    1.- Whenever there's a change in the item list (on the Zabbix server)
    2.- Whenever the Zabbix agent is updated (apt upgrade)
    3.- Whenever the server/hardware reboots

    Whatever the case ends up being after I begin testing, I wanted to ask here beforehand:

    Is there any way to limit this alert to only ONCE (when it's installed via script), instead of seeing it at random whenever any of the 3 scenarios happen?
    Attached Files
    Last edited by GoatZero; 24-09-2019, 15:01.
  • GoatZero
    Junior Member
    • May 2019
    • 9

    #2
    I just found out that If you upgrade the Linux kernel this will trigger an alert about host information changing (and after a reboot, trigger a new auto registration).


    enter image description here

    However, since im using

    Code:
    HostMetadataItem=release
    UserParameter=release, uname -s
    Limiting the user parameter, output to the word "Linux" ( uname -s ), I was expecting this to NOT affect the auto register (since every time the script is run, Zabbix finds the string Linux and does the autoregister)

    Could remove the system information item from the template potentially solve this?
    Last edited by GoatZero; 24-09-2019, 23:10.

    Comment

    Working...