<task> - Device Inventory (inventory_task)
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:
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
Here`s how it works:
- The task MUST be called
- The task type MUST be namevalue.
- The command formats MUST be
- The command tag valuename attrbute values MUST be one of:
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:
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:
<task name="inventory_task" type="namevalue">
<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>
The three field strings are extracted using regex capturing groups.