Populating inventory data automatically
Populating inventory data automatically
Manually populated inventory data is useful, but doing that on a large scale may not be very feasible. Zabbix can also collect some inventory values automatically for us. This is possible because any item can populate any inventory field. We will use one of our existing items and create a new one to automatically populate two inventory fields.
Let's start by adding the new item. Navigate to Configuration | Hosts, switch to Linux servers from the Group drop-down, and click on Items for A test host. Then, click on Create item. Fill in the following values:
- Name: The full OS name
- Key: system.uname
- Type of information: Text
- Update interval: 300
- Host inventory field:?Software application A
When you're done, click on Add?at the bottom. ?We now have an item?configured to place data in the inventory field, but this alone won't do anything. We have our inventory set to manual mode. From the navigation bar preceding the item list, click on A test host and switch to the Host inventory tab. Then, choose Automatic. Notice how something changed—our field Software application A? here got disabled, and a link appeared to the right of the field:
Values from items are placed in the inventory whenever an item gets a new value. For the full OS version item, we set the interval to a fairly low one: 300 seconds. The agent item, on the other hand, has a large interval. This means that we might have to wait for a long time before the value appears in that inventory field. To make it happen sooner, restart the agent on A test host.
The inventory field we chose, Software application A, is not very representative, but there is no way of customizing inventory fields at this time. If you have data that does not match existing inventory fields well, you'll have to choose the best fit or just use something not really related to the actual data.
With the item supposed to have the value placed in the Inventory field, let's return to Inventory | Overview and choose Software application A from the Grouping by drop-down. This should display only one host:
- Click on 1 in the Host count?column, and you should be able to see that, as expected, it is A test host. The column we chose is not listed in the current view, though.
- Click on A test host in the Host?column and switch to the Details tab.
Here, we can see system information from the system.uname item:
When we ended up on the hosts page, the filter was preset for us to match an exact field value, but we may also search for a substring. For example, if we have systems with OS information containing CentOS 7.5 and CentOS 6.2, we may filter just by CentOS and obtain a list of all the CentOS systems, no matter which exact version they are running: