Discovery Sensor

ananthn
Kilo Contributor

Hi All,

I have buit a probe and sensor to a Linux Machine for Discovery purpose for disk space.

Command used : "fdisk -l | grep GB | awk '{print $3}' | paste -sd+ - | bc"             Sudo : Required.

Sometimes for a few machines we get the input from the probe (command out put) we get the below output :

Disk /dev/dm-0 doesn't contain a valid partition table Disk /dev/dm-1 doesn't contain a valid partition table Disk /dev/dm-2 doesn't contain a valid partition table Disk /dev/dm-3 doesn't contain a valid partition table Disk /dev/dm-4 doesn't contain a valid partition table Disk /dev/dm-5 doesn't contain a valid partition table Disk /dev/dm-6 doesn't contain a valid partition table Disk /dev/dm-7 doesn't contain a valid partition table Disk /dev/dm-8 doesn't contain a valid partition table Disk /dev/dm-9 doesn't contain a valid partition table 321.2

the last few characters are the disk space.

And the sensor i have built is below : There is no error in the below sensor when i check in the syntax checker, and the javascript code gives correct output when we i check the code with the input from the probe, but if the same code below is not updating the CMDB attribute.

new DiscoverySensor({

  process: function(result) {

  if (gs.nil(result.output))

  return;

  this.parseOutput(result.output);

  },

  parseOutput: function(output) {

  var a = output.trim();

  var b = a.slice(-8);

  var c = b.match(/\d+/);

  current.disk_space = c.trim();

  },

  type: "DiscoverySensor"

});

Can someone hemp me where the error is ? I am stuck at this point on this.

1 ACCEPTED SOLUTION

doug_schulze
ServiceNow Employee
ServiceNow Employee

So what you had there was a "problem" that we call a "feature" described in this community post   org.mozilla.javascript.NativeArray@... as CI Name when discovering ESX Hosts



You were getting the same issue with that Native Array@ being populated in the field so Ryan   rzulli and I had some fun this afternoon and re-wrote the sensor.. you'll see it attached to your probe .. We decided to just loop through the lines and reject the ones that contained disk and took the value at the end..




new DiscoverySensor({


  process: function(result) {


  if (gs.nil(result.output))


  return;



  this.parseOutput(result.output);


  },



  parseOutput: function(output) {


  var lines = output.split(/\n/);


  for (var i = 0; i < lines.length; i++) {


  var line = lines[i];


  var disk = line.indexOf("Disk")


  if (disk === 0)


  {


  continue;


  }


  else


  {



  current.disk_space = line;


  }



  }},




  type: "DiscoverySensor"



  });


View solution in original post

12 REPLIES 12

doug_schulze
ServiceNow Employee
ServiceNow Employee

Not sure whats going on there.. just send me an email @ doug.schulze@servicenow.com


doug_schulze
ServiceNow Employee
ServiceNow Employee

So what you had there was a "problem" that we call a "feature" described in this community post   org.mozilla.javascript.NativeArray@... as CI Name when discovering ESX Hosts



You were getting the same issue with that Native Array@ being populated in the field so Ryan   rzulli and I had some fun this afternoon and re-wrote the sensor.. you'll see it attached to your probe .. We decided to just loop through the lines and reject the ones that contained disk and took the value at the end..




new DiscoverySensor({


  process: function(result) {


  if (gs.nil(result.output))


  return;



  this.parseOutput(result.output);


  },



  parseOutput: function(output) {


  var lines = output.split(/\n/);


  for (var i = 0; i < lines.length; i++) {


  var line = lines[i];


  var disk = line.indexOf("Disk")


  if (disk === 0)


  {


  continue;


  }


  else


  {



  current.disk_space = line;


  }



  }},




  type: "DiscoverySensor"



  });


Hi Doug Schulze/Ryan Zulli,




Thanks a lot.



I was not aware of that (Assigning a JS array to a GlideList element results in org.mozilla.javascript.NativeArray@490ee4c8,).




Thanks again for helping.




-Ananth


doug_schulze
ServiceNow Employee
ServiceNow Employee

Glad to, please be sure to mark your question as answered !


Hi Doug,



Please can you explain which probe / sensor to update in order to fix this error.



Regards


Tony