@Tom Lasswell I noticed it wasn't pulling anything for switch stacks so I modified it a bit to get around that. Of course, this will only show the data for the stack master, but it can definitely still be useful. I know there's a separate datasource that pulls the data for all the units in each stack, but oh well - better to have it twice than not at all!
import com.santaba.agent.groovyapi.snmp.Snmp;
// set hostname variable.
def hostname = hostProps.get("system.hostname")
// Wrap code in try/catch in case execution experiences an error.
try
{
// OID which contains the serial number of Cisco devices.
def entPhysicalSerialNum = "1.3.6.1.2.1.47.1.1.1.1.11.1"
// Initiate SNMP GET command.
def output = Snmp.get(hostname, entPhysicalSerialNum);
// Null response could mean switch stack.
if (output == null)
try
{
def entPhysicalSerialNum2 = "1.3.6.1.2.1.47.1.1.1.1.11.1001"
def output2 = Snmp.get(hostname, entPhysicalSerialNum)
println "auto.Cisco_Serial_Number=" + output2
}
catch (Exception e)
{
// print out the exception.
println e;
return 1;
}
// Print out the serial number.
println "auto.Cisco_Serial_Number=" + output
}
// Catch the exception.
catch (Exception e)
{
// print out the exception.
println e;
return 1;
}
// exit code 0
return 0;