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

Without seeing the content of your ecc_queue record, it's hard to say whether your script is causing an infinite loop.

 

My discovery schedule is using a Behaviour (so custom functionality, custom port probe, custom probe)

devpc_0-1741641130262.png

and the payload contains

<?xml version="1.0" encoding="UTF-8"?><results probe_time="64" result_code="0"><result><output>id name         UPS_serial_number WWNN             status IO_group_id IO_group_name   config_node UPS_unique_id hardware iscsi_name                                    iscsi_alias panel_name enclosure_id canister_id enclosure_serial_number site_id site_name 
[ all the data taken from this IP ] 
 (Shell is not in supported shell list)</output></result><parameters><parameter name="mid_selector_details" value="{&quot;mode&quot;:&quot;specific_mid&quot;}"/><parameter name="agent" value="mid.server.xxxxx"/><parameter name="used_by_runbook" value="true"/><parameter name="glide.xmlhelper.trim.enable" value="true"/><parameter name="signature" value=""/><parameter name="source" value="10.5x.yy.zz"/><parameter name="command_to_run" value="lsnode"/><parameter name="sys_id" value="c5c22a80871ca610b794fc46cebb3556"/><parameter name="from_host" value=""/><parameter name="sys_created_on" value="2025-03-10 18:56:50"/><parameter name="sys_domain" value="global"/><parameter name="used_by_discovery" value="true"/><parameter name="state" value="ready"/><parameter name="probe_name" value="Nodi storage"/><parameter name="deviceHistoryParams" value="{&quot;result&quot;:{&quot;ip&quot;:&quot;10.5x.yy.zz&quot;,&quot;active&quot;:true,&quot;alive&quot;:true,&quot;hostName&quot;:null,&quot;domainName&quot;:null,&quot;scanners&quot;:[{&quot;result&quot;:&quot;open&quot;,&quot;service&quot;:&quot;ssh&quot;,&quot;protocol&quot;:&quot;tcp&quot;,&quot;name&quot;:&quot;SSH&quot;,&quot;port&quot;:&quot;22&quot;,&quot;portProbe&quot;:&quot;ssh custom storage&quot;,&quot;contents&quot;:{&quot;banner_text&quot;:&quot;SSH-2.0-OpenSSH_8.0&quot;,&quot;banner_bytes&quot;:&quot;.53.53.48.2d.32.2e.30.2d.4f.70.65.6e.53.53.48.5f.38.2e.30.0d.0a.&quot;},&quot;scanners&quot;:[],&quot;hostName&quot;:null,&quot;domainName&quot;:null}]},&quot;ecc_queue&quot;:&quot;0ca2aec88750e610b5f433770cbb3578&quot;,&quot;errMsgs&quot;:[],&quot;status&quot;:{&quot;valid&quot;:true,&quot;sysID&quot;:&quot;3ef1a240871ca610b794fc46cebb3547&quot;,&quot;number&quot;:&quot;DIS0366673&quot;,&quot;scheduleID&quot;:&quot;151eab3b8720d294b5f433770cbb355f&quot;,&quot;jobID&quot;:&quot;6ef12200871ca610b794fc46cebb3581&quot;,&quot;discover&quot;:&quot;CIs&quot;,&quot;include&quot;:null,&quot;description&quot;:&quot;Discover Now&quot;,&quot;createdOn&quot;:&quot;2025-03-10 18:53:23&quot;,&quot;updatedOn&quot;:&quot;2025-03-10 18:56:10&quot;,&quot;useSnmpVersion&quot;:&quot;all&quot;,&quot;source&quot;:&quot;Discover_now_schedule&quot;,&quot;priority&quot;:&quot;2&quot;,&quot;includeAlive&quot;:false,&quot;logStateChanges&quot;:false,&quot;scratchpad&quot;:{&quot;behavior:cd7ca7b78720d294b5f433770cbb3568&quot;:2,&quot;unique&quot;:&quot;e792aec88750e610b5f433770cbb3529&quot;}}}"/><parameter name="response_to" value="fcc2e60c8750e610b5f433770cbb3543"/><parameter name="from_sys_id" value=""/><parameter name="priority" value="2"/><parameter name="agent_correlator" value="3ef1a240871ca610b794fc46cebb3547"/><parameter name="use_snc_ssh" value="true"/><parameter name="probe" value="bd23cdf24780e694f6b9fedbd36d43e6"/><parameter name="processed" value=""/><parameter name="error_string" value=""/><parameter name="sequence" value="195816ab9b70000001"/><parameter name="port" value="22"/><parameter name="name" value="lsnode"/><parameter name="topic" value="SSHCommand"/><parameter name="allow_unsupported_shells" value="true"/><parameter name="classification_probe" value="bd23cdf24780e694f6b9fedbd36d43e6"/><parameter name="queue" value="output"/><parameter name="ecc_queue" value="c5c22a80871ca610b794fc46cebb3556"/><parameter name="credential_id" value="17cd04b087675610b5f433770cbb3528"/></parameters></results>



I can't see an issue with your script. But potentially something wrong with the regex?

 

Perhaps debug this by changing the script to the following

 

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);

       gs.log("is Rows an array?"  + Array.isArray(rows));
gs.log("Row count is " + rows.length)

    },

    type: "DiscoverySensor"
});

I've changed the ECC queue name parameter with lsnode -nodhr -delim ,;
so I can manage the output better
this is the script now but the ecc queue keeps looping and with input and output and gr.setValue("size", values[5]);
gr.setValue("free_space", values[7]);
won't set any value, only gr.setValue("name", values[1]); is working

new DiscoverySensor({
    process: function(result) {
        var output = result.output.trim();
        output = output.replace(/\(Shell is not in supported shell list\)/g, "").trim();
        output = output.replace(/,,,[^,]+(?:,[^,]+){4},[^,]+,,,.*$/g, "").trim();
        var rows = output.split("\n");
        gs.log("Parsing1 " + output);
        gs.log("Parsing2 " + output.length);
        gs.log("Parsing3 " + rows);
        gs.log("Parsing4 " + rows.length);

        for (var i = 0; i < rows.length; i++) {
            var row = rows[i].trim();
            var values = row.split(",");
			
            gs.log("Parsing5 " + ", Name=" + name + ", Size=" + size + ", Free=" + free);

            var gr = new GlideRecord('cmdb_ci_storage_pool');
            gr.initialize();
            gr.setValue("name", values[1]);
            gr.setValue("size", values[5]);
            gr.setValue("free_space", values[7]);
            gr.insert();
        }
    },

    type: "DiscoverySensor"
});

 

doug_schulze
ServiceNow Employee
ServiceNow Employee

You absolutely do need to create a sensor for a probe...Post processing scripts was/is a way to easier parse the data, but ive always just created a sensor for any new probes Ive created..