[ZBXNEXT-1241] default Host Inventory Mode & changing it via discovery actions Created: 2012 May 30  Updated: 2015 Nov 05  Resolved: 2015 Sep 11

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: API (A), Frontend (F), Server (S)
Affects Version/s: 2.0.0
Fix Version/s: 3.0.0alpha2

Type: Change Request Priority: Trivial
Reporter: Larry Assignee: Unassigned
Resolution: Fixed Votes: 49
Labels: actions, discovery, inventory
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There does not appear to be any method from the UI for controlling host inventory mode (Disabled, Manual, Automatic) except on the host itself. Would like to see the following two additions:

1. In the General settings create an option for the "Default" host inventory mode and then use that when new devices are created.
2. Under Actions -> Discovery create an operation to set the host inventory mode so that as we automatically detect certain devices this can be set to the appropriate value.

This will save the need to remember to manually enable this for devices, especially considering we are trying to use discover / actions to pretty much create an "automatic" environment. Thanks!



 Comments   
Comment by Jori Hämäläinen [ 2012 Jun 08 ]

Or even added template to host should be able to change inventory mode to auto. Like if I add Zabbix 2.0 template_SNMP_Generic to host which tries to polulate inventory automatically but it cannot.

Also massupdate for autoinventory I find not working.

Comment by richlv [ 2012 Jun 25 ]

inventory massupdate is ZBX-5060

Comment by Raymond Kuiper [ 2012 Aug 02 ]

I also would like to see the possibility to enable 'automatic inventory' on a host when applying discovery actions. (via a configurable action)
I currently have to mass update all the discovered hosts to enable automatic inventory.
The inventory should be populated by the items from the templates that were assigned by the discovery or auto-registration actions.

I guess the default mode in the general settings makes sense too, but I personally don't need it if discovery and auto-registration can be told to enable automatic inventory.

Comment by Jon [ 2012 Sep 03 ]

I agree with qix comment of setting this option on Discovery Actions

Comment by Janne Enberg [ 2014 Jan 23 ]

Not just discovery actions, but auto-registration as well

Comment by adriano [ 2014 Feb 06 ]

Agree too .. I have the need to auto enable the automatic inventory on my site.

I do already have automatic installation and configuration of Zabbix monitoring, the inventory is the next step to make it perfect.

Comment by Mickael Martin (Cyres) [ 2014 Feb 21 ]

Have you got a patch to set mode_inventory to HOST_INVENTORY_AUTOMATIC by default when creating a host ?
I think it's not a big change in source code, but I didn't find the way...

Comment by adriano [ 2014 Feb 21 ]

There is a patch for that? It would be nice to have it. Is it safe to use that? Won't change something else too?

Comment by Mickael Martin (Cyres) [ 2014 Feb 21 ]

$inventoryMode = (isset($dbHost['inventory']['inventory_mode'])) ? $dbHost['inventory']['inventory_mode'] : HOST_INVENTORY_DISABLED;
-> $inventoryMode = (isset($dbHost['inventory']['inventory_mode'])) ? $dbHost['inventory']['inventory_mode'] : HOST_INVENTORY_AUTOMATIC;

in /usr/share/zabbix2.2.1/include/views/configuration.host.edit.php line 741 for information.
But It would be nice to change this value since general options and/or since templates. Moreover, this change make nothing for import host or API.

Comment by adriano [ 2014 Feb 21 ]

This should work for hosts automatically inserted by discovery?

I'm starting new Zabbix Server deploy, there's about 100+ servers to add, I'll deploy GPO for Windows Servers and a custom script for Linux Servers installation, then Discovery will make the host configuration and default template will be applyed.

Inventory would changed to AUTOMATIC on new discovered servers too?

I mean, it is for manually created hosts or for automatically created hosts by discovery?

Comment by Mickael Martin (Cyres) [ 2014 Feb 21 ]

It's manually when you create a host. No change elsewhere.

Comment by Natalia Kagan [ 2014 Sep 23 ]

It will be very useful if the DEFAULT of host inventory mode will be "Automatic" instead of "Disabled"

Is there any chance that you will implement this change in 2.4.1 or 3.0 ?

Thanks !

Comment by Michelle Taggart [ 2015 Feb 04 ]

Any update on this? I think it'll really be a good option to have especially on an automated environment.

Comment by Raymond Kuiper [ 2015 Feb 05 ]

I've created a Python script that uses the API to switch inventory mode on hosts, all hosts in a hostgroup or all hosts in the Zabbix system.
You can find it here:

https://github.com/q1x/zabbix-gnomes/blob/master/zhinvswitcher.py

You'll need an API user with write permissions for the hosts. If you run the script periodically from cron, you won't have to think about the inv. mode ever again

Comment by Nicola Worthington [ 2015 Jun 24 ]

Any update on this? It seems ridiculous that there is auto-discovery and auto-registration, but the inventory is effectively disabled by default.

Comment by Andris Zeila [ 2015 Aug 13 ]

Specification available at https://www.zabbix.org/wiki/Docs/specs/ZBXNEXT-1241

Comment by Andris Zeila [ 2015 Aug 17 ]

(1) [S] Database upgrade patch was added to development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1241 r54994

RESOLVED

sasha CLOSED

Comment by Andris Zeila [ 2015 Aug 21 ]

(2) [S] Server side finished in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1241

sasha Successfully tested! CLOSED

Comment by Gunars Pujats (Inactive) [ 2015 Aug 25 ]

(3) [F] Added translation strings:

  • Set host inventory mode
  • Default host inventory mode
  • No inventory mode specified for action operation.
  • Incorrect inventory mode in action operation.

sasha CLOSED

Comment by Gunars Pujats (Inactive) [ 2015 Aug 25 ]

(4) [F] Frontend side finished in developement branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1241-1
RESOLVED in r55126

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(6) [F] CComboBox must be replaced by CRadoButtonList in the action operations and global settings

sasha RESOLVED in r55146,55165

gunarspujats CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(7) [F] Mass update of the host inventory impossible in some cases now.

frontends/php/hosts.php:273

-$newValues['inventory'] = ($newValues['inventory_mode'] == HOST_INVENTORY_DISABLED)
+$newValues['inventory'] = ($newValues['inventory_mode'] == $config['default_inventory_mode'])
    ? [] : getRequest('host_inventory', []);

gunarspujats RESOLVED in r55176.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(8) [F] Default inventory mode should not affect form of the mass-update hosts.

frontends/php/hosts.php:272
frontends/php/hosts.php:724

gunarspujats RESOLVED in r55176.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(9) [F] Minor code improvements in r55170 and r55179. Please take a look.

RESOLVED

gunarspujats CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(10) [F] getHostInventoryModes must be moved into include/hosts.inc.php; Also, this function is incorrectly formatted.

gunarspujats RESOLVED in r55178.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(11) [F] this comments must be removed

frontends/php/include/classes/api/services/CAction.php:869

}//error_log('$opInventoryToInsert');error_log(json_encode($opInventoryToInsert));

gunarspujats RESOLVED in r55176.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(12) [F] we don't use function array dereferencing in our code.

frontends/php/include/actions.inc.php:691

ZBase::getHostInventoryModes()[$operation['opinventory']['inventory_mode']],

gunarspujats RESOLVED in r55178.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(13) [F] this syntax is incorrect

frontends/php/include/classes/api/services/CAction.php:1604

$opmessage = $opcommand = $opgroup = $optemplate = $opinventory = [];

gunarspujats RESOLVED in 55182.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(14) [F] empty() function is prohibited in the new PHP code

frontends/php/include/classes/api/services/CAction.php:1765

if (!empty($opinventory)) {

gunarspujats RESOLVED in 55182.

sasha This must be fixed by other way:

if ($opinventory) {

REOPENED

gunarspujats RESOLVED in r55196.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 26 ]

(15) [S] src/libs/zbxdbhigh/host.c:5040 "hostid" must be removed from this query

sasha RESOLVED in r55177

wiper Thanks, CLOSED

Comment by Alexander Vladishev [ 2015 Aug 27 ]

(16) [A] It is possible to create the broken operation (without record in "opinventory" table)

{
    "name": "discovery action 4",
    "eventsource": 1,
    "operations": [
        {"operationtype": 10}
    ]
}

gunarspujats RESOLVED in r55196.

sasha

  • "inventory_mode" must be validated for valid values
  • now, this condition is useless here
    frontends/php/include/classes/api/services/CAction.php:855
    if (array_key_exists('opinventory', $operation)) {
        ...
    }
    

REOPENED

gunarspujats RESOLVED in r55200.

sasha CLOSED Take a look at my changes in r55201 (formatting & code improvements - "elseif" meaningless here).

Comment by Alexander Vladishev [ 2015 Aug 27 ]

(17) API documentation:

gunarspujats RESOLVED

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 27 ]

(18) [F] is it double translation? _() function call must be removed here:

frontends/php/include/actions.inc.php:685

$result[$i][$j][] = bold(_(operation_type2str(OPERATION_TYPE_HOST_INVENTORY)).': ');

gunarspujats RESOLVED in r55202.

sasha CLOSED

Comment by Alexander Vladishev [ 2015 Aug 27 ]

(19) Label "Type" must be replaced by "Inventory mode" in the new operation type

gunarspujats RESOLVED in r55205.

sasha CLOSED

Comment by Gunars Pujats (Inactive) [ 2015 Aug 28 ]

Fixed in:

  • pre-3.0.0alpha2 (trunk) r55234
Comment by Alexander Vladishev [ 2015 Aug 28 ]

(20) Documentation

martins-v Updated:

Please review. RESOLVED.

sasha Great! CLOSED

Comment by Alexander Vladishev [ 2015 Sep 11 ]

Subissue still open: 5

Comment by Alexander Vladishev [ 2015 Nov 05 ]

(21) Undefined index in the host prototype form.

Undefined index: inventory_mode [host_prototypes.php:358 → CView->render() → include() in include/views/configuration.host.prototype.edit.php:340]

sasha Moved to ZBX-10048.

CLOSED

Generated at Fri Apr 26 21:45:36 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.