We recommend that you first read the overview on Inventory in order to familiarize yourself with the concept and how it is used in Mender. This tutorial is about how to change the Inventory attributes reported by the Mender client.

Basic rules for inventory attributes

Periodically, the Mender client runs every executable file with the mender-inventory- prefix from the /usr/share/mender/inventory directory. It then parses each line read from the standard output of the script according to the following format:


The client reports the attributes via the device inventory service API calls, by issuing PATCH /device/attributes.

Lists of values

The client merges attributes appearing multiple times into lists. For example, the following output from the inventory executable:


will lead to the following attributes:

interface = [eth0, wlan0]
ip_address_eth0 =
ip_address_wlan0 =

Special characters

You cannot use a literal new line character in attribute names or values. To support new lines or other special characters, use URL-style encoding. For instance, if you want to encode:


you have to use:


Example inventory script

Let's assume you want to create a group of devices called "LinuxDevicesInKrakow". To achieve this, obviously we need to collect the information from the device about its localization and deliver it to the server. Your best choice to do it in a portable manner, is to use an inventory attribute script. The following listing shows an example of such a script, gathering information on the localization from the network.

# The example script collects geo localization information
err() {
 local rc=$1

 echo "${0}: $*" >&2
 exit $rc

# find the ip address
ip=`wget -qO /dev/stdout --header "Content-Type: text/plain;" \
     --header 'Host:' --header 'User-Agent: curl/7.67.0' \
     --header 'Accept: */*' | tail -1`

[ -n "${ip}" ] || err 2 "Unable to get the IP address from"

# get the information, see
geo=`wget -qO /dev/stdout${ip} 2>/dev/null`

[ -n "${geo}" ] || err 3 "Unable to get the geolocalization data from"

# the names of the attributes holding the localization data can be configured here

echo "${geo}" | awk -v ip="${ATTR_NAME_IP}" -v continent="${ATTR_NAME_CONTINENT}" \
    -v country="${ATTR_NAME_COUNTRY}" -v city="${ATTR_NAME_CITY}" -F',' \
    ' length($NF) == 0 { exit(4) }
      { printf("%s=%s\n%s=%s\n%s=%s\n%s=%s\n",ip,$1,continent,$2,country,$3,city,$6) }

The above example first gets the public source ip address of the IP packets originating from the device. It then calls an API endpoint to get the geo localization data, parses the response data, and finally prints it to standard output in the format "attribute_name=attribute_value". You should store this script in the /usr/share/mender/inventory directory, giving it a name, for example and executable permissions:

chmod 700 /usr/share/mender/inventory/

Example output of the above script looks like this:


You can find some more useful scripts in directory.

Default inventory

By default, and without any inventory scripts added, the Mender client sends the following attributes:

name meaning example value
device_type type of the device "raspberrypi4"
artifact_name name of the currently installed artifact "release-v1"
mender_client_version client version "3.5.3"

Final remarks

You should not use inventory attributes to uniquely identify a device. They are intended to store information, for searching, sorting and filtering devices in the Mender Server.

We welcome contributions to improve this documentation. To submit a change, use the Edit link at the top of the page or email us at .