SNMP Access Using Scripts

From Observer GigaFlow Support | VIAVI Solutions Inc.
Revision as of 09:42, 23 January 2017 by Kevin Wilkie (Talk | contribs)

Jump to: navigation, search

Querying a number (uptime in this case) from an infrastructure device

var ip="83.70.199.182"
var thisDevice = actions.getDevice(ip);
if (thisDevice != null) {
 var uptime = actions.querySNMPNumber(thisDevice, '.1.3.6.1.2.1.1.3.0', -1);
 log.warn('Uptime for device ' + ip+" "+thisDevice.getName()+" "+uptime);
}else{
 log.warn("No such managed device "+ip);
}

Getting the SysOID of a device and determining if its a Cisco device

var ip="83.70.199.180"
var thisDevice = actions.getDevice(ip);
if (thisDevice != null) {
 log.warn('sysOID for device ' + ip+" "+thisDevice.getName()+" "+thisDevice.getSysOID());
 if (thisDevice.getSysOID().indexOf('1.3.6.1.4.1.9')==0){
  log.warn("Is Cisco");
 }
}else{
 log.warn("No such managed device "+ip);
}