Example: create a sensor from a Discovery probe

In this example, create a custom sensor to use with the probe that reads a text file from a Windows computer and populate a CI in the CMDB

  1. Navigate to Discovery Definition > Sensors, and then click New.
  2. Complete the following fields:
    • Name: Use the same name as the matching probe. In this example, we use Windows - Get BGInfo files.
    • Reacts to probe: The name of the probe created in the previous procedure: Windows - Get BGInfo files
    • Sensor type: Select the type of sensor to create - in this example Sensor.
    • Description: Describes the function of this sensor.
    • Script: Copy the script below into the Script field and edit as needed.
    • Sensor type: Determines how the answer from the probe is processed - in this example JavaScript.
  3. Click Submit.
    new DiscoverySensor({ data: {}, process: function(result) { 
     parseOutput: function(output) {
            var currentFile;
            var files = {};
     if (output.startsWith("<wmi")) {
                var bgout = new XMLHelper(output).toObject();
                if (!bgout)
     output = bgout.output;
     var lines = output.split(/\n/);
     for(var i = 0; i < lines.length; i++) {
                var line = lines[i];
                if (line.startsWith("C:\\Information Systems\\BgInfo\\")) {
                    currentFile = line.substr(30);
                    files[currentFile] = "";
                } else if (currentFile) {
                    var newLine = line.trim();
                    if (newLine)
                        files[currentFile] += (files[currentFile]? "\n"&nbsp;: "") + newLine;
     this.data['u_jack_id'] = files['JackID.txt'];
     this.data['warranty_expiration'] = files['Warranty.txt'];
     this.data['po_number'] = files['Ponum.txt'];},
     type: "DiscoverySensor"
    The completed form looks like this:
    New sensor