Ad Widget

Collapse

Get hosts from hostgroup and NOT from subgroups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • olegus
    Member
    • Dec 2023
    • 68

    #1

    Get hosts from hostgroup and NOT from subgroups

    We have an hierarchy groups like Product/Dep/Group .
    We accidentally put some hosts in /Product/Dep instead of Product/Dep/Group and we need some how to move them down a level.
    Is it possible to achieve that in GUI?
    If I select Product/Dep group it brings all hosts from all subgroups and there is no way to filter hosts by GroupID.
    If not possible in GUI:
    I can query API to receive hosts by specific GroupID and looks like I can use host.massupdate call to replace a group but doc examples are not very clear. Can someone give me a proper host.massupdate example to replace a group?
  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #2
    on a single host: ​Click image for larger version

Name:	image.png
Views:	153
Size:	30.0 KB
ID:	497138
    or use mass update to first add the new host group and then with mass update remove the old host group. This is really basic functionality

    Comment


    • olegus
      olegus commented
      Editing a comment
      Idont think it will work in my case - My first problem is how to filter hosts that only belong to /Product/Dep without selecting those that belong to Product/Dep/Group. When I filter hosts for /Product/Dep , it will also bring hosts from subgroups - Product/Dep/Group1, Product/Dep/Group2 etc. I need to mass update only these hosts that are located in /Product/Dep only and move them to, say, /Product/Dep/Group1.
  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #3
    olegus easiest way is to use tags for each host the (sub)folders are shown and as far as I know you can disable that.
    Setup you tags on the lowest folder level first with a mass update and work you way up the tree.
    e.g. in the sub folder tag hostgroup : dep/group1
    other sub group tag hostgroup : deb/group2
    etc etc and you can filter if a host has a tag hostgroup (or doesn't have it) or maybe a certain value

    Comment


    • olegus
      olegus commented
      Editing a comment
      That should work , but seems too much work, API way seems better at this moment
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #4
    Code:
    {
        "jsonrpc": "2.0",
        "method": "host.massupdate",
        "params": {
            "hosts": [
                {
                    "hostid": "ID1"
                },
                {
                    "hostid": "ID1"
                },
                ...
                {
                    "hostid": "IDn"
                }
            ],
            "groups": [
                {
                    "groupid": "GID1"
                },
                {
                    "groupid": "GID2"
                }
            ]
        },
        "id": 1
    }​
    I think ...

    Comment


    • olegus
      olegus commented
      Editing a comment
      Yep looks like this is the fastest way...
Working...