Ad Widget

Collapse

Differentiating HostNames

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

    #1

    Differentiating HostNames

    Hi.

    I'm setting up a high availability web server architecture using AWS ELB and Scaling Group.

    As this architecture can seamlessly spin up new machines, it does that with the same hostname to all hosts, and I need to find a method of differentiating hostNames. I was thinkin of adding the IP address, timestamp, random number or any other unique value to the hostname, and by that ensure each server is launching with its own distinguishable hostname value.

    So my question is this: Can the Zabbix Agent's config file be used to setup a hostname made of such a values? If so - how?

    Thank you in advance!

    Amit.
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2
    It's not good idea to make any config change on the device by using Zabbix. Zabbix is monitoring system, not configuration/orchestration tool + Zabbix is usually executed under zabbix user and you usually need root for changing device hostname. Use some config tool (puppet/chef/ansible/salt/...) or just some script. I recommend to use User data for AWS - you can write script to change hostname. It'll be executed once when an instance is launched.
    You can run commands to perform configuration tasks when you launch an instance by passing in a user data script as input.


    If you are not able to monitor new machine, because the hostname already exists in the Zabbix, then it's different issue.
    Just define HostnameItem in zabbix agent config and then this value will be used as hostname in the zabbix. E.g. I use MAC address of eth0:
    Code:
    HostnameItem=system.run[ifconfig | grep eth0 | awk '{print $5}' | tr -d ":"]
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment

    • high-t
      Member
      • Dec 2014
      • 68

      #3
      Thank you, Jan, for the detailed reply.

      I am aware, ofcourse, that Zabbix isn't a configuration nor an orchestration tool, and I wasn't aiming that direction to begin with. I'm sorry if my question wasn't clear enough.

      I needed a way of differentiating the HostnameItem value within the agent's config file. Your offered solution might be a good starting point. I suspected - but didn't know - there's a way of running a "mini script" to update the HostnameItem value. I'm running a Windows host and your solution is for Linux host, but that's a great lead nevertheless.

      Thank you, Jan!

      Amit.

      Comment

      • jan.garaj
        Senior Member
        Zabbix Certified Specialist
        • Jan 2010
        • 506

        #4
        YWC

        Try some WMI request, which will return some unique machine ID; maybe:
        Code:
        HostnameItem=wmi.get["root\cimv2","SELECT IPAddress FROM Win32
        _NetworkAdapterConfiguration where NetConnectionID='Local Area Connection'"]
        Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
        My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

        Comment

        Working...