Ad Widget

Collapse

Deploying conf files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • high-t
    Member
    • Dec 2014
    • 68

    #1

    Deploying conf files

    Hi.

    I'm using several configuration files for my templates, for UserParameter items.
    The problem is, that whenever I update a conf file, I then need to distribute it across my servers fleet.
    Currently, I'm not using any Configuration Management tool, so I'm simply copying the amended files with scp. However, this is quite a tedious process, and I'm sure you have some idea to make this simpler...

    BTW: Is there a way for Zabbix agent to read a remotely stored configuration file?

    Thank you in advance!
  • tiarnaigh
    Junior Member
    • Sep 2013
    • 27

    #2
    One simple enough solution would be to kick off a remote wget/curl for instance from the remote agent of the file in question (You could host it on a http server in your network say) and then get Zabbix server to kick off the remote agent call as follows:

    /usr/local/bin/zabbix_get -s hostName -k system.run["curl -k https://X.X.X.X/filename.fileExtension -o /path/on/local/server/filename.fileExtension","wait"];


    Or, for a bunch of remote hosts all at once:

    for i in hostA hostB hostC hostD hostE; do echo "#### $i ####"; /use/local/bin/zabbix_get -s $i -k system.run["curl -k https://X.X.X.X/filename.fileExtension -o /path/on/local/server/filename.fileExtension","wait"]; done

    Once you've pulled down the file in question, you can then bounce Zabbix agent likewise using remote agent call to apply changes...........

    Comment

    • high-t
      Member
      • Dec 2014
      • 68

      #3
      Great idea, tiarnaigh, Thank you.

      I like your approach. Having Zabbix Server causing a Zabbix Agent to launch a wget/curl call and retrieve the files from an HTTP source.

      Going forward, the Zabbix agent needs to be restarted to read the new conf files. I don't know if Zabbix Server can get a Zabbix Agent restart itself. But I'll test that and see how it goes.

      Comment

      • tiarnaigh
        Junior Member
        • Sep 2013
        • 27

        #4
        Yep. Sure can (Provided you're running the remote agent as root that is, and allow RemoteCommands). You can set this in your config as follows:

        ### Option: AllowRoot
        # Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent
        # will try to switch to the user specified by the User configuration option instead.
        # Has no effect if started under a regular user.
        # 0 - do not allow
        # 1 - allow
        #
        # Mandatory: no
        # Default:
        AllowRoot=1


        ### Option: EnableRemoteCommands
        # Whether remote commands from Zabbix server are allowed.
        # 0 - not allowed
        # 1 - allowed
        #
        # Mandatory: no
        # Default:
        EnableRemoteCommands=1



        Here's a sample script (updateNtp.sh) I used for something similar recently for instance (Updating all ntp.conf files across my hosts - 100+):

        [root@zbx2atl0 ~]# cat updateNtp.sh
        #!/bin/bash
        cat allHosts.txt | while read i;
        do
        echo "###### $i ####";
        /use/local/bin/zabbix_get -s $i -k system.run["rpm -qa --last | grep ntpdate","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["/etc/init.d/ntpd stop","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["curl -k https://X.X.X.X/ntp.conf -o /etc/ntp.conf","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["chkconfig ntpdate on","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["chkconfig ntpd on","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["/etc/init.d/ntpdate start","wait"];
        /use/local/bin/zabbix_get -s $i -k system.run["/etc/init.d/ntpd start","wait"];
        done


        To call this, simply create a list of hosts "allHosts.txt" and then run as follows say:

        [root@zbx2atl0 ~]# cat allHosts.txt | while read i; do sh updateNtp.sh; done

        In your case, you'd simply call say "/etc/init.d/zabbix_agentd restart" instead once you've updated your config file.

        Comment

        • high-t
          Member
          • Dec 2014
          • 68

          #5
          Awesome.

          I see you're using an RPM based distro.
          I'll translate this into Ubuntu'ish and give it a try.

          BTW: with relation to being able to run Zabbix agent as a root, I also add it to the sudo group:
          Code:
          gpasswd -a zabbix sudo
          Alternatively, run visudo and add the following line:
          Code:
          zabbix ALL=NOPASSWD: ALL
          (remember to restart ssh)

          Comment

          Working...