Ad Widget

Collapse

API: hostgroup search by wildcarded name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxlock
    Member
    • Mar 2005
    • 32

    #1

    API: hostgroup search by wildcarded name?

    Hi all,

    I'm trying to do a search of hostgroups by name using the API. I've not having any luck as the API seems to return all hostgroups. the JSON request I'm generating looks like this

    {"jsonrpc": "2.0", "method":"hostgroup.get","params": {"output": "extend", "search": {"name": ["'test*'"]}},"auth": "XXXXX", "id": 0}

    I've tried both a percent and star as the wildcard.

    Any ideas, or an example?

    -Cheers Max.
  • jefftang
    Junior Member
    • Apr 2010
    • 6

    #2
    I think you want either to leave off the wild card or enable them.

    Leave it off;
    Code:
    {"jsonrpc": "2.0", "method":"hostgroup.get","params": {"output": "extend", "search": {"name": ["'test'"]}},"auth": "XXXXX", "id": 0}
    Enable wildcards
    Code:
    {"jsonrpc": "2.0", "method":"hostgroup.get","params": {"output": "extend", "search": {"name": ["'test*'"]},"searchWildcardsEnabled":1},"auth": "XXXXX", "id": 0}

    Comment

    • maxlock
      Member
      • Mar 2005
      • 32

      #3
      Hiya,

      Thanks for the suggestions, I've tried both with no luck, each time I still get all hostgroups?

      Has anyone got a working example?

      -Cheers Max.

      Comment

      • maxlock
        Member
        • Mar 2005
        • 32

        #4
        Must be a bug?

        Hi All,

        Seeing as there are no example searches in the documentation, the forum, or via google etc al, i'm assuming that searches just don't work. I'm going to log a bug report.

        ZBX-4392

        -Max.
        Last edited by maxlock; 25-11-2011, 14:27. Reason: Added bug URL

        Comment

        • WytheNet
          Junior Member
          • Jul 2017
          • 6

          #5
          I have the same problem,and I'm going to log a bug report , too. https://support.zabbix.com/projects/...r=reportedbyme

          Comment

          • Mikael Souza
            Junior Member
            • Oct 2019
            • 1

            #6
            Correct:

            wildcards off:
            {"jsonrpc": "2.0", "method":"hostgroup.get","params": {"output": "extend", "search": {"name": ["test"]}},"auth": "XXXXX", "id": 0}

            Enable wildcards:
            {"jsonrpc": "2.0", "method":"hostgroup.get","params": {"output": "extend", "search": {"name": ["test*"]},"searchWildcardsEnabled":1},"auth": "XXXXX", "id": 0}

            Comment

            Working...