Ad Widget

Collapse

Zabbix Auto Registration with AWS Auto Scaling Groups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bwhelan
    Junior Member
    • Sep 2014
    • 2

    #1

    Zabbix Auto Registration with AWS Auto Scaling Groups

    I'm looking for some recommendations regarding the Zabbix Auto Registration process and AWS Auto Scaling groups.

    I would like to include the zabbix agent in the AMI attached to an auto scaling group. The problem I've encountered is the hostname must be unique for auto registration to register a new server. When the ASG scales up the newly created instances fail to auto register with the Zabbix server because they have the same hostname (configured in the AMI attached to the ASG).

    I guess the best solution would be to dynamically change the hostname when it is created. I'm not sure the best way to go about this in AWS. I have encounter some scripts related to Puppet and Chef that would accomplish this. Unfortunately, I don't have these systems in place in my environment.

    Is there an alternate means to accomplish this by relaxing the requirement for a unique hostname in the auto registration process?

    Any advice would be appreciated.

    I am using Zabbix 2.2.
    The AWS instances are running CentOS 6.5.
  • basante
    Junior Member
    • Nov 2013
    • 14

    #2
    Hi bwhelan,

    did you manage to sort this out ?

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Originally posted by basante
      Hi bwhelan,

      did you manage to sort this out ?
      What is he problem?
      With active agents all what you need to do is create autodiscoery action where depends on subnet/used/proxy/host metadata/pattern in hostname you can autoregister host applying to use on this host template(s), adding to the group(s), sending email notifications, etc

      Everything is working OOTB ..
      http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
      https://kloczek.wordpress.com/
      zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
      My zabbix templates https://github.com/kloczek/zabbix-templates

      Comment

      • basante
        Junior Member
        • Nov 2013
        • 14

        #4
        kloczek, don't think you get the right question. auto discovery is not a problem, is working with aws instances.
        problem is when you have custom hostname on instance, auto scaling kicks in and new lunched instances are using same hostname. zabbix will not auto add them to monitoring, since it's not a unique hostname.

        Comment

        • kloczek
          Senior Member
          • Jun 2006
          • 1771

          #5
          Originally posted by basante
          kloczek, don't think you get the right question. auto discovery is not a problem, is working with aws instances.
          problem is when you have custom hostname on instance, auto scaling kicks in and new lunched instances are using same hostname. zabbix will not auto add them to monitoring, since it's not a unique hostname.
          So .. what is the problem put on initialize system started from AMI thing like:

          Code:
          echo "Hostname=$(hostname)" > /etc/zabbix/zabbix_agent.d/Hostname
          ?
          I'm using at the moment above on AWS hosts. Zabbix agent in /etc/zabbix/zabbix_agentd.conf has line:
          Code:
          Include=/etc/zabbix/zabbix_agent.d/
          (On our systems no one is chaging /etc/zabbix/zabbix_agent.conf file and all per host changes are injected in per conf variable file in etc/zabbix/zabbix_agent.x/)

          With above you will have in zabbix hosts registered using private network hostnames.
          Above is not so elegant because every new instance will have unique hostname and on scale down group and up you will have constant flow of new hosts in monitoring.

          To be honest I have plan to change this to a little different way.
          On http://docs.aws.amazon.com/AWSEC2/la...-metadata.html you can find information ami-launch-index.

          I'm going to change above line to injecting Hostname to:

          Code:
          echo "Hostname=<AS_group_name>-$(curl http://169.254.169.254/latest/meta-data/ami-launch-index)" > /etc/zabbix/zabbix_agent.d/Hostname
          Another part of this plan is add to my base AWS template zabbix trap item and using zabbix_sender command on shutdown host to send value indicating that host is down. On start host of course the same but indicating that host is up.
          with additional two triggers detesting ON<>OFF changes will be possible to create action changing host state monitored/not monitored.

          With above will be possible to have fixed set of zabbix host entries and monitoring data will be preserved without additional manipulations.
          Some monitoring data/graphs/screens will be with gaps but still will be possible for example observe some long term changes.
          Last edited by kloczek; 27-11-2014, 21:06.
          http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
          https://kloczek.wordpress.com/
          zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
          My zabbix templates https://github.com/kloczek/zabbix-templates

          Comment

          • basante
            Junior Member
            • Nov 2013
            • 14

            #6
            kloczek, thank you.
            i'll try this.

            Comment

            • bwhelan
              Junior Member
              • Sep 2014
              • 2

              #7
              Thanks for the feedback. I ended up creating unique hostnames for the instance during the server's initialization appending their AWS instanceId.

              Right now, I'm manually purging stale systems, but I like the idea you set forth, kloczek. I have some tinkering to do.

              Comment

              Working...