Bringing log entries while testing custom sensors

Ankush13
Kilo Guru

Hi,

I am currently troubleshooting network switch's whose serial number wasn't brought by discovery. It took some investigation but I found the OID table with the desired serial number. (1.3.6.1.2.1.47.1.1.1.1 - entPhysicalSerialNum).

I am developing a sensor to parse the same but I am unable to determine if I am on the right track because I can't verify my progress. Can you guys help me with putting some logs under "Output and Artifacts>Discovery Log" link (Or any other place).

My sensor currently looks like(below).

new DiscoverySensor({  

      process: function(result) {  

                  //var snmp = new SNMPResponse(result);

                  //logWarning('Executed successfully', 'Troubleshooting');                   **Didn't work


                  var dlogger = new DiscoveryLogger(current.sys_id);                             **Ain't working either

                  dlogger.info('Executed successfully', 'Troubleshooting');

                  this.parseOutput(result.output);  

      },  

 

      parseOutput: function(output) {  

      },  

 

      type: "DiscoverySensor"  

});

I am trying to figure out how to bring logs under "Output and Artifacts>Discovery Log" with "Test probe" option (Comes when we are under a specific probe).

Thanks,

Ankush Latawa

4 REPLIES 4

StephenHey
Mega Guru

Try this:


g_device.log("Your message", this.getSensorName(), this.getEccQueueId());



Here's an example from DiscoveryFunctions() script include:


updatedHistory: function(gr, sensor, eccID) {


              var fieldsChanged = this.getFieldsThatChanged(gr);


              if (fieldsChanged.length > 0)


                      g_device.log("Updated device fields " + fieldsChanged.join(", "), sensor, eccID);


      },



g_device is the product of a function call DeviceHistory.getFromContext()


DeviceHistory is a SN java object: Packages.com.snc.discovery.logging.DeviceHistory


Thanks for your help Stephen. Unfortunately it didn't work.


Where does this command log the information? Is there a specific link? Being a discovery administrator, I have access to "Discovery Log" only(screenshot below).



View.jpg


As far as I can tell, the g_device.log should log to the Discovery Log table you've indicated.



Are you running just the probe by clicking the "test probe" UI action in the probe?   This doesn't process in quite the same way as if you ran an ad-hoc discovery against the IP address starting with Shazzam.   I think you'd need to run a full discovery against the IP in order for g_device to work.



On Berlin, putting g_device.log("A Message", this.getSensorName(), this.getEccQueueId());




Yields a line in the log file of the table you screen shot.


actually log statements are in the system log or script log statements modules.. Check there you might just see them... also I like using gs.log, search the community for that, plenty of references on its use!