Difference between revisions of "SNMP Access Using Scripts"
From Observer GigaFlow Support | VIAVI Solutions Inc.
Kevin Wilkie (Talk | contribs) |
Kevin Wilkie (Talk | contribs) |
||
Line 5: | Line 5: | ||
var uptime = actions.querySNMPNumber(thisDevice, '.1.3.6.1.2.1.1.3.0', -1); | var uptime = actions.querySNMPNumber(thisDevice, '.1.3.6.1.2.1.1.3.0', -1); | ||
log.warn('Uptime for device ' + ip+" "+thisDevice.getName()+" "+uptime); | 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{ | }else{ | ||
log.warn("No such managed device "+ip); | log.warn("No such managed device "+ip); | ||
} | } |
Revision as of 09:42, 23 January 2017
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); }