Ad Widget

Collapse

auto-registering hosts on disparate networks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tolland
    Junior Member
    • Apr 2008
    • 20

    #1

    auto-registering hosts on disparate networks

    Hi,

    I would like to use the zabbix agent for monitoring our EC2 instances, and our build currently includes the zabbix_agentd which starts up fine.

    However I was looking to configure autodiscovery, and it appears to have been removed at some point. I looked at the discovery options (in 1.4.4) and there doesn't seem to be anything suitable for what I am after. Obviously I don't want to be scanning the entire Amazon EC2 public IP range for zabbix agents, and scripting something up to use the Import XML function looks like I would need to store and pass an admin password from my EC2 hosts, which I would prefer not to do.

    Any suggestions?

    Many Thanks,

    T
  • lamont
    Member
    • Nov 2007
    • 89

    #2
    Originally posted by tolland
    Hi,

    I would like to use the zabbix agent for monitoring our EC2 instances, and our build currently includes the zabbix_agentd which starts up fine.

    However I was looking to configure autodiscovery, and it appears to have been removed at some point. I looked at the discovery options (in 1.4.4) and there doesn't seem to be anything suitable for what I am after. Obviously I don't want to be scanning the entire Amazon EC2 public IP range for zabbix agents, and scripting something up to use the Import XML function looks like I would need to store and pass an admin password from my EC2 hosts, which I would prefer not to do.

    Any suggestions?

    Many Thanks,

    T
    In your build, have a script which on boot, and periodically once a day reports to some centralized known service that the host is alive and what IP interfaces are configured on it. Then you will have a directory of all your EC2 hosts and which IP addresses they are on (although can't you get this from EC2 somewhere? Amazon has that information stored in a database associated with your account, can you just grab it from there?).

    Once you've got that information there's several ways to skin the cat. One way is to write some SQL which will insert /32 entries into drules and dchecks (just be sure to increment druleid and dcheckid values in the ids tables). Zabbix will then scan those IP addresses and do auto-discovery on them. Once this is running as an automated processes, then you can just use the discovery interface in Zabbix to control how you discover what kind of host it is and what kind of monitoring gets applied to it.

    Comment

    • Alexei
      Founder, CEO
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2004
      • 5654

      #3
      FYI Support of auto-registration will be restored in one of 1.6.x releases, quite likely that in 1.6.
      Alexei Vladishev
      Creator of Zabbix, Product manager
      New York | Tokyo | Riga
      My Twitter

      Comment

      • tolland
        Junior Member
        • Apr 2008
        • 20

        #4
        Originally posted by lamont
        Once you've got that information there's several ways to skin the cat. One way is to write some SQL which will insert /32 entries into drules and dchecks (just be sure to increment druleid and dcheckid values in the ids tables). Zabbix will then scan those IP addresses and do auto-discovery on them. Once this is running as an automated processes, then you can just use the discovery interface in Zabbix to control how you discover what kind of host it is and what kind of monitoring gets applied to it.
        I looked at writing the SQL directly, but I couldn't find any documentation on the DB schema and the mysql binlog viewer showed a whole bunch of records being written, and I don't really understand how the templates worked so I sacked that off.

        Then I moved onto trying to pull the relevant classes out of the php frontend files, and call the "function add_host($host,$port,$status,$useip,$dns,$ip,$temp lates,$newgroup,$groups)"
        function from a script. But I ran into all sorts of problems with understanding the include files, and web context/environments settings that I couldn't replicate in a scripted version.

        In the end, the simpliest being the best, I chucked a short bash script together which replicates logging in, and sending the required POST variables to hosts.php - It goes a little something like this;

        PHP Code:
        #!/bin/bash

        #called as add_zabbix_host.sh $public_hostname $instance_id $public_ipv4

        DNS=$1
        HOST
        =$2
        IP
        =$3

        USERNAME
        =myuseretc
        PASSWORD
        =mypasss

        wget 
        --keep-session-cookies --save-headers --save-cookies /tmp/cookies -O- --post-data="form=1&form_refresh=1&name=$USERNAME&password=$PASSWORD&enter=Enter" http://dcdev01.osti.local/zabbix/index.php

        wget --keep-session-cookies --save-headers --load-cookies /tmp/cookies -O- --post-data="form=Create+Host&form_refresh=5&config=0&groupid=0&devicetype=&name=&os=&serialno=&tag=&macaddress=&hardware=&software=&contact=&location=&notes=&host=$HOST&groups%5B%5D=15&newgroup=&dns=$DNS&ip=$IP&useip=0&port=10050&status=0&save=Save&templates%5B10001%5D=Template_Linux"  http://dcdev01.osti.local/zabbix/hosts.php 

        Comment

        • nelsonab
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Sep 2006
          • 1233

          #5
          A rough outline of the schema can be found in the 1.1 documentation. It has changed a little since then but it does give you a good start.
          RHCE, author of zbxapi
          Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
          Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

          Comment

          • lamont
            Member
            • Nov 2007
            • 89

            #6
            Yeah, you're trying to be a bit aggressive about it. I would use Zabbix's auto-discovery feature but feed the auto-discovery a set of IP addresses that you know are all of your hosts. Then all you have to do is insert a row into dchecks and a row into drules for the IP address.

            Then zabbix will be able to auto-discover the agent on that IP address. Then you setup your discovery actions to associate the discovered hosts with groups, templates, etc.

            And you might need to clean out dhosts and dservices to force a re-discovery ("delete from dhosts; delete from dservices;") I've found that's a convenient way to keep templates and groups associated with hosts in a repeatable way by keeping my discovery action rules updated and then forcing re-discovery.

            Anyway this keeps the SQL fiddling down to just the dchecks and drules tables. All the addition of hosts, association of templates and groups and items and all that other junk happens through normal Zabbix code as a function of the discovery event.

            Originally posted by tolland
            I looked at writing the SQL directly, but I couldn't find any documentation on the DB schema and the mysql binlog viewer showed a whole bunch of records being written, and I don't really understand how the templates worked so I sacked that off.

            Then I moved onto trying to pull the relevant classes out of the php frontend files, and call the "function add_host($host,$port,$status,$useip,$dns,$ip,$temp lates,$newgroup,$groups)"
            function from a script. But I ran into all sorts of problems with understanding the include files, and web context/environments settings that I couldn't replicate in a scripted version.

            In the end, the simpliest being the best, I chucked a short bash script together which replicates logging in, and sending the required POST variables to hosts.php - It goes a little something like this;

            PHP Code:
            #!/bin/bash

            #called as add_zabbix_host.sh $public_hostname $instance_id $public_ipv4

            DNS=$1
            HOST
            =$2
            IP
            =$3

            USERNAME
            =myuseretc
            PASSWORD
            =mypasss

            wget 
            --keep-session-cookies --save-headers --save-cookies /tmp/cookies -O- --post-data="form=1&form_refresh=1&name=$USERNAME&password=$PASSWORD&enter=Enter" http://dcdev01.osti.local/zabbix/index.php

            wget --keep-session-cookies --save-headers --load-cookies /tmp/cookies -O- --post-data="form=Create+Host&form_refresh=5&config=0&groupid=0&devicetype=&name=&os=&serialno=&tag=&macaddress=&hardware=&software=&contact=&location=&notes=&host=$HOST&groups%5B%5D=15&newgroup=&dns=$DNS&ip=$IP&useip=0&port=10050&status=0&save=Save&templates%5B10001%5D=Template_Linux"  http://dcdev01.osti.local/zabbix/hosts.php 

            Comment

            • lamont
              Member
              • Nov 2007
              • 89

              #7
              Originally posted by Alexei
              FYI Support of auto-registration will be restored in one of 1.6.x releases, quite likely that in 1.6.
              Oh, I see discovery got broken? I'm using 1.4.4 and so far its been working fine with addition of my dont-trust-DNS patch.

              Comment

              • thunderbolt
                Junior Member
                • Sep 2008
                • 1

                #8
                Alexei,

                Any update on whether auto-registration will make it into the upcoming 1.6 release that I saw is scheduled for the 18th?

                I'd really like to use it instead of writing a bunch of custom scripts to make discovery work for remote systems on different networks.

                Thanks,
                Ron

                Comment

                • pierre-hoffmann
                  Senior Member
                  • Jan 2008
                  • 133

                  #9
                  Hi,

                  i'm also use wget to auto-create host in Zabbix from ksh shell scripts;
                  it exists a cleanner method to do this or not.

                  Nothing in 1.6 or greater ??

                  Regards,
                  P.Hoffmann
                  System & Network Admin.
                  __________________________
                  Zabbix version 1.8.1
                  Hosts monitored 1300
                  OS Novell SLES 10 SP2
                  __________________________

                  Comment

                  Working...