Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.santaba.agent.groovyapi.snmp.Snmp;
- def hostname=hostProps.get("system.hostname");
- // def hostname="10.249.5.1"
- //the Snmp.walk call will use configured properties for snmp.community and other properties.
- def s_walk_out = Snmp.walk(hostname,".1.3.6.1.4.1.9.9.171.1.3.2.1.5");
- s_walk_out.eachLine { line ->
- if(line.contains('.'))
- {
- tokens = line.split(/ = /, 2)
- // println tokens[1]
- value=tokens[1];
- // if (value != "@=Lz") {
- if (tokens[1] ==~ /..?:..?:..?:..?/){
- parts = value.split(":");
- b1 = Integer.parseInt(parts[0], 16);
- b2 = Integer.parseInt(parts[1], 16);
- b3 = Integer.parseInt(parts[2], 16);
- b4 = Integer.parseInt(parts[3], 16);
- out.println(String.format("%s##%d.%d.%d.%d", value, b1, b2, b3, b4));}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement