[ZBXNEXT-3451] Improve nested host group selection Created: 2016 Sep 21  Updated: 2024 Apr 10  Resolved: 2017 Feb 15

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F), Server (S)
Affects Version/s: 3.2.0
Fix Version/s: 3.2.2, 3.4.0alpha1, 3.4 (plan)

Type: Change Request Priority: Major
Reporter: Andris Zeila Assignee: Unassigned
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File h0.conf     File h2.conf     PNG File opcommand_configuration.png     PNG File sorted_dropdown.png     PNG File unsorted_europe.png     PNG File unsorted_riga.png     Zip Archive zbxnext_3451_testfiles.zip    
Team: Team A
Sprint: Sprint 1

 Description   

Currently filtering by host group and its nested host groups is possible in frontend by appending /* to the host group. For example if there are groups
server/mysql, server/oracle then to include both groups server/* has to be specified.

It's not obvious, is only partially supported by frontend and not supported by server at all.

To improve it frontend and server should automatically assume that all nested groups are included if simply the top group name is given (server in the above example).



 Comments   
Comment by Aleksandrs Saveljevs [ 2016 Sep 26 ]

After the current behavior is redesigned, documentation may need to be updated - see ZBX-11262.

Comment by Andris Zeila [ 2016 Sep 27 ]

Server side done in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-3451

However frontend specification is not complete, so its probably early for testing.

Comment by Oleg Egorov (Inactive) [ 2016 Oct 04 ]

Frontend side ready to testing

Comment by Oleg Egorov (Inactive) [ 2016 Oct 04 ]

(1) [F] Changed translation strings:

Strings added:

  • All groups
  • including subgroups
  • Include subgroups

gunarspujats CLOSED

Comment by Gunars Pujats (Inactive) [ 2016 Oct 06 ]

(2) [F] PHPUnit test CHostGroupNameValidatorTest fails

oleg.egorov RESOLVED in r63034

gunarspujats CLOSED

Comment by Gunars Pujats (Inactive) [ 2016 Oct 06 ]

(3) [F] Page filter in hostinventoriesoverview.php doesn't select subgroups

oleg.egorov RESOLVED in r63034

gunarspujats CLOSED

Comment by Gunars Pujats (Inactive) [ 2016 Oct 06 ]

(4) [F] Multiselect parameter "subgroupids" is not needed anymore:
app/controllers/CControllerProblemView.php
app/controllers/CControllerWidgetHostsView.php
app/controllers/CControllerWidgetIssuesView.php
app/controllers/CControllerWidgetSystemView.php
app/controllers/CControllerWidgetWebView.php
include/classes/api/services/CHostGroup.php
dashconf.php
latest.php
toptriggers.php

oleg.egorov RESOLVED in r63037

gunarspujats CLOSED

Comment by Gunars Pujats (Inactive) [ 2016 Oct 06 ]

(5) [F] Coding style

  • js/multiselect.js
    :304 - variable request_data used one time
    :729 - redundant variable "postfix"
  • popup.php:379 - comment outdated, IMO could be removed

oleg.egorov RESOLVED in r63035

gunarspujats CLOSED

Comment by Gunars Pujats (Inactive) [ 2016 Oct 07 ]

Frontend tested.

Comment by Andris Zeila [ 2016 Oct 07 ]

Server side yet to be tested.

Comment by Natalja Romancaka [ 2016 Oct 12 ]

(6) [F] filter on page "Monitoring->Web" and "Reports->Availability report" does not select subgroups

oleg.egorov Fixed in r63142 and r63403

gunarspujats

  • In Availability report subgroup selection doesn't work when report mode set to "By trigger template"
  • report2.php : 230 - this block repeats multiple times, maybe it's worth to make separate function?

oleg.egorov RESOLVED in r63795

gunarspujats CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Oct 14 ]

(7) [D] From https://www.zabbix.com/documentation/3.4/manual/config/hosts/host#configuring_a_host_group .

To create a nested host group, use the '/' forward slash separator, for example Europe/Latvia/Riga/Zabbix servers.

Ok, got that.

You can create this group even if none of the three parent host groups (Europe/Latvia/Riga) exist.

Yes, you can, but you won't be able to filter by Europe or Europe/Latvia in this case. For that you have to create these host groups.

martins-v This seems only partially true. In global search and in some filters it is possible to search by any string. In multiselect fields yes, only existing groups can be used.

sandis.neilands Exactly. While "orphan" child groups are allowed it's hard to conceive a use case other than allowing creating child groups before creating the corresponding parent groups. What I wanted to clarify here was that Zabbix will not automatically create or update parent groups for the user. The user has to do it manually. Currently the documentation hints otherwise.

martins-v RESOLVED for 3.2, 3.4. Please review.

sandis.neilands Looks fine. Just noticed another detail that has changed - asterisks are now allowed.

martins-v Thanks, updated that part as well.

sandis.neilands Looks good, CLOSED.

Comment by Natalja Romancaka [ 2016 Oct 17 ]

(8) [F] selected "Host group" not include the nested host groups in global scripts

oleg.egorov Not related to the main issue, but can be discussed

natalja.zabbix Now all global scripts available to all host groups, even if selected certain host group for script

oleg.egorov RESOLVED in r63422

gunarspujats

  • error is returned when execute script on subgroup host:
    You do not have permission to perform this operation.
    
  • include/classes/api/services/CScript.php:411 - variable ''$macrosData'' left unrenamed.

oleg.egorov Moved to ZBXNEXT-3565
CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Oct 18 ]

(9) [D] Consider the following setup.

Host groups:
a/b/c
a/b
a

Hosts:
host_0 in a/b/c
host_1 in a/b

Scenario: filter by a/b.

Result: both host_1 of a/b and host_0 of a/b/c are returned. This has implications on host group hierarchy design.

martins-v Discussed with sandis.neilands. Decided that this information is best suited for a how-to style documentation. For now, WON' T FIX.

Comment by Sandis Neilands (Inactive) [ 2016 Oct 19 ]

(10) [D] (and [F]?) Take a look at the screenshot opcommand_configuration.png. What is the meaning of "Execute on" option for each target type: current host, host, host group.

martins-v There is more detail now for these options in documentation. Please review. RESOLVED

sandis.neilands Thanks! CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Oct 21 ]

(11) [S] [F] Upgrade will break action conditions.

Before this feature condition host group == a filtered out the hosts that are in a itself but are not in a/b, a/b/c, etc.

After this feature the same condition will include all hosts of a and also its subhostgroups. The way to get only the a's hosts is this: host group == a and host group <> a/b and host group <> a/another_subgroup and ... e.g. set substraction: a - a's subgroups. The problem with this approach is that each time a subgroup is added all expresions filtering for just the a's hosts must be updated.

We could resolve this by introducing new operators for host group conditions. Perhaps "in" and "not in"?

The same applies to 'Host group' target of remote command action operations, and other places.

wiper We are not currently adding new operations and the new behaviour is documented:

This means that a host group that is set, for example, in action conditions, now silently includes all its nested host groups.

CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Oct 21 ]

(12) [S] Remote command is executed twice on one of the hosts.

host_group     host
----------------------------------------------
a              h2
a/b0           h0

Operation and recovery operation configured to execute custom remote command via agent for group a. Result: according to agents' logs upon an event the command is executed once on h2 but twice on h0.

Agent configuration files attached for reference.

# /tmp/h0.log
  7860:20161021:194406.325 Executing command 'logger problem'
  7858:20161021:194406.333 Executing command 'logger problem'
  7859:20161021:194421.424 Executing command 'logger recovery'
  7860:20161021:194421.433 Executing command 'logger recovery'

# /tmp/h2.log
  7946:20161021:194406.341 Executing command 'logger problem'
  7945:20161021:194421.441 Executing command 'logger recovery'

sandis.neilands WONTFIX. Configuration error on my part - another host was "hiding" from me in the filter.

Comment by Sandis Neilands (Inactive) [ 2016 Oct 31 ]

(13) [D] Describe semantics of:

  • overlapping host groups for target of remote command action operation;
    • command executed once per host even if it is in multiple matching host groups or if it's specified explicitly and also is found in one of the target host groups;
  • overlapping/conflicting host groups for target of remote command action operation and global script host group;
    • global script host group acts as filter in this case (e.g. union of hosts from action operation and global script host group).

martins-v Added to documentation (see 'Target list'). RESOLVED

sandis.neilands Thanks! CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Oct 31 ]

(14) [D] For discussion. Remote commands can be executed on hosts that are in "no data collection" maintenance.

Scenario: trigger action on host h0. Action operation: remote command on host h1 (which is in maintenance).

Expected: remote command is not run on h1.

Actual: remote command is run on h1 possibly interfering with maintenance work being done on the host.

sandis.neilands Discussed with sasha, decided to document it for now.

martins-v Added to the remote command page. RESOLVED

sandis.neilands CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Nov 01 ]

(15) [F] In multi-select forms suggested host groups are not sorted in lexicographic order. Instead they are sorted by host group ID (group creation order).

  • This is a severe usability issue when one is actually searching for some host group in the list instead of using it as spell-check.
  • This is inconsistent from the top-right host group selection drop-down in Configuration -> Hosts, etc.

See the attached screenshots unsorted_europe.png, unsorted_riga.png, sorted_dropdown.png

oleg.egorov RESOLVED in r63515

gunarspujats Broken creating/editing of map elements:

Undefined index: hostname_0000 [map.php:116 -> add_elementNames() in include/maps.inc.php:392]

oleg.egorov RESOLVED in r63624 and r63636

gunarspujats CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Nov 01 ]

(16) [F] Items for child groups are not shown in "Latest data". Problems of child host groups are not shown in "Problems" view. Possibly other filters are not working as expected as well.

Example.

  • "Host groups": Europe
  • Europe: dummy_host_2
  • Europe/Riga: dummy_host_2, dummy_host_1, dummy_host_0.
  • All hosts have items with data.

If it is left as-is then filtering in Monitoring and Configuration pages differs - which is misleading. In Monitoring pages - child host groups are not included, in Configuration - they are included.

oleg.egorov Fixed only "Latest data" in r63530, other parts will be fixed under other ZBXNEXT

gunarspujats When multiple groups are selected, then hosts from child groups are not shown.

natalja.zabbix When selected only hosts in filter: Undefined variable: groupids [ in latest.php:152]

oleg.egorov RESOLVED in r63801

gunarspujats CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

(17) [S] Should aggregated items become unsupported if non-existent host groups are specified? See aggregate_get_items()

/* TODO: make item notsupported when zbx_dc_get_nested_hostgroupids_by_names() fails */

wiper Aggregate checks must become unsupported only if there are no matching items in the specified groups. If one of groups are invalid, but other groups have matching items, then the aggregate value is still calculated based on the valid groups.
RESOLVED in r63503

sandis.neilands CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

(18) [S] Memory leak in DCsync_hostgroups(). Memory for the nested_groupids is not freed when host group is deleted.

We might also want to release the memory (reserve 0) in places where we call zbx_vector_uint64_clear() for the nested_groupids as otherwise we hold memory for the maximum amount of child host groups that the parent host group had during the lifetime of server process. To users this might look like a leak.

wiper RESOLVED in r63504

sandis.neilands CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

(19) [S] Maintenance for a single host (e.g. no host groups) causes failed SQL query every minute during maintenance.

15360:20161102:151900.205 [Z3005] query failed: [1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 [select h.hostid,h.host,h.maintenanceid,h.maintenance_status,h.maintenance_type,h.maintenance_from from hosts_groups hg,hosts h where hg.hostid=h.hostid and h.status in (0,1) and]

See process_maintenance_hosts().

Same problem for host-only remote commands (execute_commands()).

15371:20161102:162500.520 [Z3005] query failed: [1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port,o.au' at line 1 [select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port,o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command,h.tls_connect,h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password,h.tls_issuer,h.tls_subject,h.tls_psk_identity,h.tls_psk from opcommand o,hosts_groups hg,hosts h where o.operationid=32 and hg.hostid=h.hostid and h.status=0 and union select distinct h.hostid,h.host,o.type,o.scriptid,o.execute_on,o.port,o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command,h.tls_connect,h.ipmi_authtype,h.ipmi_privilege,h.ipmi_username,h.ipmi_password,h.tls_issuer,h.tls_subject,h.tls_psk_identity,h.tls_psk from opcommand o,opcommand_hst oh,hosts h where o.operationid=oh.operationid and oh.hostid=h.hostid and o.operationid=32 and h.status=0 union select distinct 0,null,o.type,o.scriptid,o.execute_on,o.port,o.authtype,o.username,o.password,o.publickey,o.privatekey,o.command,1,0,2,null,null,null,null,null,null from opcommand o,opcommand_hst oh where o.operationid=oh.operationid and o.operationid=32 and oh.hostid is null]

wiper RESOLVED in r63505

sandis.neilands CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

(20) [S] Similarly to (17), (19) if there is a configuration sync just before call to zbx_dc_get_nested_hostgroupids() and the relevant host group is removed in that sync, then zbx_dc_get_nested_hostgroupids will find nothing and the SQL queries will be incorrect.

Solutions:

  • callers check if something was returned OR
  • always include parent hostid, even if it cannot be found in cache - the next SELECT will find nothing in this case.

wiper Opted for (2) - less cluttered code over performance gains in low probability situations.
RESOLVED in r63507

sandis.neilands CLOSED, added comment in r63712.

wiper reviewed, thanks

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

(21) [S] Double check the header comments to the modified functions - they should mention that child host groups will be included as well. Also in escalator.c change copy-paste comments from maintenance to operations.

wiper RESOLVED in r63506

sandis.neilands CLOSED with another small change in r63508.

wiper reviewed, thanks

Comment by Sandis Neilands (Inactive) [ 2016 Nov 02 ]

Tested nested host group:

  • creation/deletion via API (Robot);
  • filtering and searching via API (Robot);
  • action conditions;
  • action operations (remote command);
  • global scripts (as action operation, didn't check execution via frontend);
  • global event correlations;
  • maintenance;
  • aggregate checks.
Comment by Andris Zeila [ 2016 Nov 03 ]

(22) [F] When selecting hosts to be added to maintenance the Group combobox filter does not include hosts from nested groups.

oleg.egorov Moved to ZBXNEXT-3565
CLOSED

Comment by Sandis Neilands (Inactive) [ 2016 Nov 10 ]

(23) [D] Documentation for (17) - aggregated item becomes not supported when no item can be included (due to incorrect item key, or no such item in any of the specified (possibly incorrect) host groups.

E.g. the aggregated item becomes not supported also if all of the specified host groups are incorrect.

martins-v RESOLVED. See description for cases when aggregate items turn unsupported.

sandis.neilands CLOSED.

Comment by Sandis Neilands (Inactive) [ 2016 Nov 10 ]

(24) [S] [D] Double quoting of groups when aggregated item becomes unsupported. Similarly, if there are no groups specified in the key then we could give a more specific error.

key:
grpsum[["a/b1111", "aaaaaa"],"dummy_item_1",last]

log:
 24968:20161110:160425.018 item "dummy_aggregator:grpsum[["a/b1111", "aaaaaa"],"dummy_item_1",last]" became not supported: No items for key "dummy_item_1" in group(s) ""a/b1111","aaaaaa"".

info in frontend:
No items for key "dummy_item_1" in group(s) ""a/b1111","aaaaaa"".

When quotes are removed from key...

key:
grpsum[[a/b1111, aaaaaa],"dummy_item_1",last]

log:
 24965:20161110:160754.419 error reason for "dummy_aggregator:grpsum[[a/b1111, aaaaaa],"dummy_item_1",last]" changed: No items for key "dummy_item_1" in group(s) "a/b1111,aaaaaa".


info in frontend:
No items for key "dummy_item_1" in group(s) "a/b1111,aaaaaa".

wiper Opted for quoting individual groups in the list:

 -> ""
"" -> ""
a -> "a"
"a" -> "a"
a,b -> "a", "b"
"a","b" -> "a", "b"
"a",b,"c" -> "a", "b", "c"

Added specific error message if no groups are found, but did not make separate error message for empty groups list.

RESOLVED in r63711

sandis.neilands The info message for the unsupported item in case all specified groups are incorrect is now as follows.

No groups in list "aaaaa", "bbbbb", "ccccc".

Let's revisit it to use the same vocabulary as the docs after martins-v updates the relevant page.

martins-v Possibly, "None of the groups in list "..." is correct"

sandis.neilands wiper, please change the error message to the one suggested by martins-v above.

wiper created ZBX-11805 to fix the error message
CLOSED

Comment by Kenneth Palmertree [ 2016 Nov 15 ]

Also I am seeing an issue with nested host groups with spaces in the name before and after '/' when trying to add permission in user groups.

For example:
QA / ENV
QA / ENV / HOST

If you try and add "QA / ENV / *" you get no selection not found do to the spaces before and after the '/'.

Comment by Oleg Egorov (Inactive) [ 2016 Nov 22 ]

Implemented in:

  • 3.2.2rc1 r63904
  • 3.3.0 (trunk) r63905
Comment by Sandis Neilands (Inactive) [ 2016 Nov 23 ]

(25) [S] Two new Coverity issues: CID 154518 and CID 154517.

** CID 154518:  API usage errors  (SWAPPED_ARGUMENTS)


________________________________________________________________________________________________________
*** CID 154518:  API usage errors  (SWAPPED_ARGUMENTS)
/src/zabbix_server/poller/checks_aggregate.c: 352 in aggregate_get_items()
346     	ret = SUCCEED;
347     
348     out:
349     	if (FAIL == ret)
350     	{
351     		aggregate_quote_groups(error, &error_offset, &error_alloc, groups);
>>>     CID 154518:  API usage errors  (SWAPPED_ARGUMENTS)
>>>     The positions of arguments in the call to "zbx_chrcpy_alloc" do not match the ordering of the parameters:
* "&error_offset" is passed to "alloc_len"
* "&error_alloc" is passed to "offset"
352     		zbx_chrcpy_alloc(error, &error_offset, &error_alloc, '.');
353     	}
354     
355     	zbx_vector_uint64_destroy(&groupids);
356     
357     	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);

** CID 154517:  Error handling issues  (CHECKED_RETURN)
/src/zabbix_server/poller/checks_aggregate.c: 250 in aggregate_quote_groups()


________________________________________________________________________________________________________
*** CID 154517:  Error handling issues  (CHECKED_RETURN)
/src/zabbix_server/poller/checks_aggregate.c: 250 in aggregate_quote_groups()
244     		if (NULL == (group = get_param_dyn(groups, i)))
245     			continue;
246     
247     		zbx_strcpy_alloc(str, str_alloc, str_offset, separator);
248     		separator = ", ";
249     
>>>     CID 154517:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "quote_key_param" without checking return value (as is done elsewhere 5 out of 6 times).
250     		quote_key_param(&group, 1);
251     		zbx_strcpy_alloc(str, str_alloc, str_offset, group);
252     		zbx_free(group);
253     	}
254     }
255     

wiper RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-3451_2

sandis.neilands CLOSED, thanks!

wiper Added specific quoting function to quote also groups ending with '\'. In theory this function could be used by quote_key_param() and zbx_get_escape_string_len() functions, but decided against changing existing code in 3.2.
REOPENED & RESOLVED in r63939

sandis.neilands CLOSED.

Comment by Andris Zeila [ 2016 Nov 24 ]

Latest changes released in:

  • pre-3.2.2rc1 r64018
  • pre-3.3.0 r64019
Comment by Martins Valkovskis [ 2016 Dec 06 ]

(26) Updated documentation:

  • What's new for 3.2.2
  • User group permissions 3.2 / 3.4
  • Action conditions 3.2 / 3.4
  • Action operations (remote command target list) 3.2 / 3.4
  • Aggregate items 3.2 / 3.4
  • Maintenance ('hosts & groups' tab) 3.2 / 3.4
  • Global search 3.2 / 3.4

sandis.neilands This functionality requires configuration changes when upgrading to 3.2.2 and 3.4 (see (11)). How about adding this also to the upgrade notes?

martins-v I agree. Please review the upgrade note entry:

  • Upgrade notes for 3.2.2 and 3.4.0 (for upgrades between 3.2.0, 3.2.1 and 3.4.0)

RESOLVED

sandis.neilands Thank you, CLOSED.

Comment by Marcel Jäpel [ 2016 Dec 08 ]

Should there any nested group support in API, too?

I tried with v3.2.2 the following scenario
2 Groups:
ID: 18 Name: group1
ID: 19 Name: group1/subgroup1

There is one host with an active trigger in group1/subgroup1.

If I call event.get via API and search in group id 19 than I get the event for the active trigger. But if I search for group id 18 than there are no events.
So it seems event.get doesn't recognize the nested groups. I checked documentation but can't find any option to activate this via API request. So is there a special syntax for API requests or any hidden option or still not implemented?

sandis.neilands To my knowledge this is not implemented. What you can do is search for all subgroups with hostgroup.get and then call event.get for each found group.

        {
            "jsonrpc": "2.0",
            "id": %d,
            "auth": "%s",
            "method": "hostgroup.get",
            "params": {
                "output": [ "groupid", "name" ],
                "search": {
                    "name": [
                        %s
                    ]
                }
            }
Comment by Sandis Neilands (Inactive) [ 2016 Dec 08 ]

(27) [A] [D] API changes are not documented.

At least these pages should be updated.

oleg.egorov No API changes. CLOSED

Generated at Wed Apr 24 16:29:20 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.