Writing the discovery formulas with the interactive tool

The discovery-helper-tool script is a wizard-based interactive tool that can be used to write discovery formulas by providing some inputs.

Before you begin

Make sure you have Python version 2.x or 3.x is installed.

About this task

The tool has several steps that are tied back to the discovery formula structure.

Procedure

Run the tool with the following command:
./bin/discovery-helper-tool <my_pack>
The following interactive output is shown:
First step: provide general information
 Enter resource type that you want to create : memory
 Specify vendor for the resource type:
 ....
 option [<keyword> to search, ENTER for next page]: 9
 Second step: Identify primary table
 Choose Mib Module where your Mib table to discover property from:
 ....
 option [<keyword> to search, ENTER for next page]: 0
 Selected module is CISCO-ENHANCED-MEMPOOL-MIB

 Choose Mib table from the module:
 ....
 option : 2
 Selected table is cempMemPoolTable

 Choose Mib objects from the table (one by one):
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: cempmempooli
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: 75
 Selected objects are ['cempMemPoolIndex']
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: 86,91,92
 Selected objects are ['cempMemPoolIndex', 'cempMemPoolType', 'cempMemPoolValid', 'cempNotificationConfig']
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: -92
 Selected objects are ['cempMemPoolIndex', 'cempMemPoolType', 'cempMemPoolValid']
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: 80
 Selected objects are ['cempMemPoolIndex', 'cempMemPoolName', 'cempMemPoolType', 'cempMemPoolValid']
 ....
 option [D to done, -<number> to delete, <keyword> to search, ENTER for next page]: d

 Specify TNCP propery name for the mib objects (one by one):
 Name for index [ENTER for index] :
 Name for cempMemPoolIndex [ENTER for cempMemPoolIndex] : memoryPoolIndex
 Name for cempMemPoolName [ENTER for cempMemPoolName] : memoryPoolName
 Name for cempMemPoolType [ENTER for cempMemPoolType] : memoryPoolType
 Name for cempMemPoolValid [ENTER for cempMemPoolValid] : memoryPoolValid

 Third step: Identify secondary tables
 Do you want to enrich discovery from another mib table [y/n] : n

 Output :
 when resource.type = 'device' and resource.sysobjectid like '1.3.6.1.4.1.9'
 select index, cempMemPoolIndex AS memoryPoolIndex, cempMemPoolName AS memoryPoolName, cempMemPoolType AS memoryPoolType, cempMemPoolValid AS memoryPoolValid from CiscoEnhancedMempoolMib.cempMemPoolTable
 set type='memory'
 set vendor='Cisco'
 set id=context.host + '_Cisco_memory:<' + resource.index + '>'

 Forth step: Writing discovery to pack
 Do you want to save this to a discovery file [y/n] : y
 file saved as ~/sdk/workspace/pack-demo/discovery/pack-demo/cisco-memory.discovery