Skip to content

Tag: <task> - Device Inventory (inventory_task)

Definition

The special task inventory_task is used to extract information about the device, to be used on the Inventory Report page.

The following fields can be extracted (all fields are optional):

  • Hardware Version
  • Software Version
  • Software Patch

These parameters are extracted and displayed in the Admin Interface as the Inventory report, like this:

Inventory report table

The inventory task is used to read the software version, it is often the same as the version_command task but they are used independently to allow for a more user friendly inventory string to be displayed in the Admin Interface.

Example: Extracting by word and line reference

A typical task used to extract these fields might look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
   <task name='inventory_task' type='namevalue'>
      <commands>
         <command format='output_text' valuename='hw_version'>tmsh show sys hardware
            <response line_nr='15' token_nr='1'/>
         </command>
         <command format='output_text' valuename='sw_version'>tmsh show sys version
            <response line_nr='3' token_nr='1'/>
         </command>
         <command format='output_text' valuename='patch'>tmsh show sys version
            <response line_nr='4' token_nr='1'/>
         </command>
      </commands>
   </task>

Here`s how it works:

  • The task MUST be called inventory_task.
  • The task type MUST be namevalue.
  • The command formats MUST be output_text.
  • The command tag valuename attrbute values MUST be one of: hw_version, sw_version or patch.

Separate commands are issued for each field, so different commands can be used to gather different information.

In this example the response tags use line number and token number to extract the values.

More info here: Tag: <response>.

Example: Extracting using regex capturing groups

An alternative to the line and token numbers is to use a regular expression capturing group.

This makes the task shorter as the regex_capture is on the <command> tag and child response tags are not required.

Here`s an example:

`xml <task name='inventory_task' type='namevalue'> <commands> <command format='output_text' valuename='hw_version' regex_capture='^Hardware:\s+(.*?),.*'>show version | include Hardware:</command> <command format='output_text' valuename='sw_version' regex_capture='^.*(\d+\.\d+).*'>show version | include Cisco Adaptive Security Appliance</command> <command format='output_text' valuename='patch' regex_capture='^.*\d+\.\d+(.*)'>show version | include Cisco Adaptive Security Appliance</command> </commands> </task>

The three field strings are extracted using regex capturing groups.

See Regular expressions

Parent Tags

Child Tags