Testing a new Probe and parsing the results for Discovery Storage

devpc
Tera Contributor

Hi everyone, I need to discover some IBM SVC (I'm reading this doc Storage Discovery via SMI-S and CIM) and I've created some probes since the OOTB CIM probes won't work,  with these parameters:
Class = Probe, ECC queue topic = sshcommand, ECC queue name = lsvdisk (an example of command I need) and allow_unsupported_shells is setted as true in probe parameters.

 

If I run the Test Probe I can see in the ECC queue that the response is positive, I can access the machine in question, but if I run Discover Now I get these errors:
Sensor error when processing [probe name]: No sensors defined

As I can read in this doc Create or modify a probe the post processing script can be used as
"Define an optional post-processing script that runs on the MID Server. The script accepts probe results as an input and outputs a JSON string that is sent back to the instance for a sensor to use as input. Use this type of script to accomplish tasks like parsing data."

So I don't need to create a sensor for my custom probes? How can I parse the ecc queue data into table records?


I hope my request is clear and without misunderstandings

10 REPLIES 10

Kieran Anson
Kilo Patron

Hey,

Post-processor is different to a sensor. Your probe is currently missing a sensor (related list on the probe) so SN doesn't know what to do with the returned data. 

I've created a new custom sensor and wrote a code in the script but it enters in a loop and never stops so if don't cancel the discovery it will continue adding the same records in the table again and again

new DiscoverySensor({
output = output.replace(/\(Shell is not in supported shell list\)/g, "").trim();

var rows = output.match(/\d+ [^\n]+/g);}

// Loop su ogni riga estratta
rows.forEach(function(row) {
var values = row.trim().split(/\s+/);

var gr = new GlideRecord(cmdb_ci_storage_node);
gr.initialize();
gr.setValue("name", values[1]);

gr.insert();
});},

type: "DiscoverySensor"
});

 

You need to wrap your logic in a process function which SN then calls

 

new DiscoverySensor({
	process: function(sensorResult){
		var commandResult = sensorResult['@result'];
		//do work here
	},

    type: "DiscoverySensor"
});

I suppose I lost it in the copy and paste, sorry

 

new DiscoverySensor({
    process: function(result) {
        var output = result.output.trim();
        output = output.replace(/\(Shell is not in supported shell list\)/g, "").trim();
        var rows = output.match(/\d+ [^\n]+/g);

        rows.forEach(function(row) {
            var values = row.trim().split(/\s+/);

            var gr = new GlideRecord('cmdb_ci_storage_node');
            gr.initialize();
            gr.setValue("name", values[1]);

            gr.insert();
        });

    },

    type: "DiscoverySensor"
});