Example: populate a CI with text file values using a custom Discovery probe

This custom Discovery probe helps you if you need to read a text file from a Windows computer and populate a CI in the CMDB with the values from the file.

About this task

In this example the user wanted to read files created by BGinfo.
Note: When you have completed the probe and sensor, place the probe in the appropriate Windows classifier at Discovery Definition > CI Classification > Windows.

Procedure

  1. Navigate to Discovery Definition > Probes, and then click New.
  2. Complete the following fields:
    • Name: Unique and descriptive name for the probe
    • Probe type: Select Probe.
    • Description: Describe the function of this probe.
    • Used by Discovery: Select this check box
    • ECC queue topic: This is name of the probe the MID server is to run. In this example, we use WMIRunner.
    • ECC queue name: In this example, we use the descriptive name WMI: BGInfo files.
  3. Right-click in the header bar and select Save from the context menu.
  4. Select the Probe Parameters tab in the Probe form, and then click New.
  5. Enter WMI_GetFiles.js as the Name of this parameter.
  6. Copy the script below into the Script field and edit as needed.
    Probe parameters
  7. Click Submit.
    The completed probe form looks like this:
    New probe
    //
     // Use ServiceNow WMIAPI to gather stats
     //
     var CMD_RETRIES = 3;
     var scanner = getScanner();
     if (scanner) {
       var output = "";
       for(var i = 0; i < CMD_RETRIES; i++) {
          output = scanner.winExec("%SystemRoot%\\system32\\cmd.exe /C type \\\"C:\\Information Systems\\BgInfo\\*.txt\\\"");
          if (output)
             break;
       }
       scanner.appendToRoot("output", output);
     }