Hello Everyone! Having an issue with SNMP Discovery

Gibran Ali
Tera Contributor

Hello All,

I have relatively very little experience with Discovery. I have been given a task to create a Custom Probe and Sensor, to populate the "Location" field on the cmdb_ci_ip_router.

The network Team provided me with an OID, as well as a network range. They also said that the devices are currently 'polling' , however location is not being filled in correctly

OID = 1.3.6.1.4.1.637.3.1.5.3.1.5     / http://oid-info.com/get/1.3.6.1.4.1.637.3.1.5.3.1.5 ( info about the OID)

I have tried following a few posts from the community, but have not found any success.   So far this is what i have done step by step.

1) go into SNMP system OID's and added this ID, with manufacturer name as I do not know the model.

2) Added this device into the SNMP classification for Routers.

3) Created a Probe called 'Routing Location', which has the same information as the OOB probe called (SNMP - Routing)

4) Created a Sensor called Routing Location, Which has same information as the sensor, except i added the following script after finding something similar on the community.

SCRIPT

new DiscoverySensor({

process: function(result) {

var snmp = new SNMPResponse(result);

var oid_mib2 = 'iso.org.dod.internet.private.mib-2.system.sysLocationu';   ////   ***this is not   correct...need to determine correct value****

gs.log(oid_mib2+ 'ALI');

var location = snmp.getOIDText(oid_mib2 + 'system.sysLocation'); ////// **** not sure if this is correct either *****

gs.log(location+ 'ALI'); //// current value of var location

gs.log(current.u_system_location+ 'ALI');

current.u_system_location = location + '\n';

// var loc = new GlideRecord ('cmn_location');                         *****Just In case GR needed for location*****

// loc.addQuery('name' , location);

// loc.query();

// if(loc.next())

//                                 {

// location = loc.sys_id;

// current.u_system_location = location;

//           }

},

type: "DiscoverySensor"

});

5) Also I am sure that the SNMP fields for this probe need some sort of configuration, but I am completely unaware on how to accomplish this. Somewhere i read something about doing an 'SNMP walk' to make sure you are connecting correctly , but again this is a new venue for me so I am completely unaware what to do at this point. Any help would be much appreciated. Thanks.

4 REPLIES 4

Jeff Boltz1
Mega Guru

Hi Gibran Ali,



This is some code shared at Knowledge 15 at one of the Discovery sessions, not sure if it is still relevant/up to date:



SNMP-mib2-sysLocation Sensor


new DiscoverySensor({


      process: function(result) {


              var snmp = new SNMPResponse(result);


              var location = snmp.getOIDText('iso.org.dod.internet.mgmt.mib-2.system.sysLocation');


              current.short_description = location;


              current.device_type = 'firewall';      


      },


     


      type: 'DiscoverySensor'


});



Lab 8.3: Alternate Code to set the location to the location field of the CMDB record


new DiscoverySensor({ process: function(result) {


  var snmp = new SNMPResponse(result);


  var location = snmp.getOIDText('iso.org.dod.internet.mgmt.mib- ­"- ­"- ­" 2.system.sysLocation');


  current.device_type = 'firewall';


  var checkLocation = new GlideRecord('cmn_location');


  //If the GlideRecord query finds a cmn_location record matching the location returned from the OID set the sensor


  //record's location field to the location record from the cmn_location table and update the sensor record in the DB


  if (checkLocation.get(location)){ current.location =   checkLocation.sys_id;


      gs.log("location found " + checkLocation.sys_id,"location found");


      current.update();


}


else {


gs.log("location not found ","location not found"); checkLocation.initialize(); //creating a new cmn_location record checkLocation.name = location; //setting location name of OID t


      the name field on cmn_location record


var x = checkLocation.insert();


gs.log("location location created " + x ,"location not found"); current.location = x; //insert current location to sys_id of new record


current.update(); //update current record


}


},


type:'DiscoverySensor'


});



It was either Discovery 101, 102 or 103, which you may be able to find here; On Demand Library



Take care,
Jeff


Hello Jeff,



Thanks for your response. Just had a few questions if you can clarify.



1) How do I determine what to write in the SNMP field box of the custom probe that I made?


2) In the script , what am I supposed to be assigning this variable to , so I can fetch the location value from this OID?



  var snmp = new SNMPResponse(result);


  var location = snmp.getOIDText('iso.org.dod.internet.mgmt.mib-"-"-" 2.system.sysLocation');



I am positive that the current value it is assigned to is not correct. I have read about SNMP walk and stuff with an OID, but I am not sure on what to assign this variable to? Any help or a nudge in the right direction would be much helpful. Thanks.



This is the current OID.



OID = 1.3.6.1.4.1.637.3.1.5.3.1.5



Kind Regards,



Gibran Ali


If your Discovery Schedule uses an IP Range(s) or Discovery Range Set(s) that are tied to a single Location, e.g. 172.23.45.xxx is 'SLC Office' then you can set Location value in the CI by relating the relevant Location record to the Discovery Schedule.


Dave Smith1
ServiceNow Employee
ServiceNow Employee

gibran ali wrote:



Hello All,



I have relatively very little experience with Discovery. I have been given a task to create a Custom Probe and Sensor, to populate the "Location" field on the cmdb_ci_ip_router



I would advise attending a Discovery course - we cover exactly this problem in one of the labs (creating custom probes and sensors, as well as interrogating SNMP-enabled devices)


5) Also I am sure that the SNMP fields for this probe need some sort of configuration, but I am completely unaware on how to accomplish this.


You're partly correct - the SNMP fields on the device need configuration (i.e.: the location field being set).


Somewhere i read something about doing an 'SNMP walk' to make sure you are connecting correctly , but again this is a new venue for me so I am completely unaware what to do at this point. Any help would be much appreciated. Thanks.


Now that bit I can help with (again, I demo this on Disco courses).   If you're using Windows, head here: https://syslogwatcher.com/cmd-tools/snmp-walk/ - that's a great little tool for interrogating SNMP devices.   If you've got a Linux box, there's a good change "snmpwalk" is already installed (if not, get your Linux admin to add it - it's a 5-second job)



For windows, type something like: snmpwalk.exe -r:10.20.30.40 -v:1 -c:public where:


  • v: is the version
  • c: community string
  • r: is the IP address of the host ("router") being interrogated.


If you want just a specific OID, use -os:1.3.6.1.4.1.637.3.1.5.3.1.5 to get just that info back.



Give that a go, see how it works, and we'll take it from there.   But I always recommend having some SNMP query tool to test info works before beginning Discovery.