Ad Widget

Collapse

Zabbix auto register action add jmx

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephen8339
    Junior Member
    • May 2015
    • 2

    #1

    Zabbix auto register action add jmx

    When the host has been registered, how can I let it add the jmx IP and port automaticly?
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    create a notification for the registration that uses a media type pointing to a script. In that script, make API calls.

    It would be nice if there were an easier way :-)

    Comment

    • stephen8339
      Junior Member
      • May 2015
      • 2

      #3
      Originally posted by LenR
      create a notification for the registration that uses a media type pointing to a script. In that script, make API calls.

      It would be nice if there were an easier way :-)
      ok, thx a lot, but I want more details about the script and the API calls, can u help me?

      Comment

      • LenR
        Senior Member
        • Sep 2009
        • 1005

        #4
        Reviewing what I have in place, I didn't use a media type, but something similar. In the operations of the auto registration action, I have a:

        Run remote commands on hosts: some-host-with-API-enabled (I run where the web frontend is installed), type custom script, execute on zabbix-agent, commands "/etc/zabbix/update_autoreg.py {HOST.HOST1}"

        My sanitized script is below, I'm turning on host inventory, so the calls to add the JMX interface will be different. This is using the pyzabbix api (pip install pyzabbix).

        #!/usr/bin/python
        """
        Set host inventory to automatic.
        """

        from pyzabbix import ZabbixAPI
        import json, sys, time

        #print sys.argv[1]

        time.sleep(5)

        # The hostname at which the Zabbix web interface is available
        ZABBIX_SERVER = 'https://localhost/zabbix'

        zapi = ZabbixAPI(ZABBIX_SERVER)

        # Login to the Zabbix API
        zapi.login('user',' password')

        inv = zapi.host.get(filter={'host':sys.argv[1]},output="extend",selectInventory="extend",limit=4 )

        hostIdValue = inv[0]['hostid']
        hostValue = inv[0]['host']
        invinfo = inv[0]['inventory']

        if len(invinfo) == 0:
        response = zapi.host.update(hostid=hostIdValue,inventory_mode =1)

        Comment

        • m081072
          Junior Member
          • Jun 2015
          • 1

          #5
          Some clarification please....

          Originally posted by LenR
          My sanitized script is below, I'm turning on host inventory, so the calls to add the JMX interface will be different.
          What do you mean the calls to add the jmx interface will be different? Are you saying the script needs to add the jmx interface?

          I am trying to do what the OP has asked.

          Thanks,
          Mike.

          Comment

          Working...