Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import com.santaba.agent.groovyapi.snmp.Snmp;
  2.  
  3. def hostname=hostProps.get("system.hostname");
  4. // def hostname="10.249.5.1"
  5. //the Snmp.walk call will use configured properties for snmp.community and other properties.
  6. def s_walk_out = Snmp.walk(hostname,".1.3.6.1.4.1.9.9.171.1.3.2.1.5");
  7.  
  8. s_walk_out.eachLine { line ->
  9. if(line.contains('.'))
  10. {
  11. tokens = line.split(/ = /, 2)
  12. // println tokens[1]
  13. value=tokens[1];
  14. // if (value != "@=Lz") {
  15. if (tokens[1] ==~ /..?:..?:..?:..?/){
  16. parts = value.split(":");
  17. b1 = Integer.parseInt(parts[0], 16);
  18. b2 = Integer.parseInt(parts[1], 16);
  19. b3 = Integer.parseInt(parts[2], 16);
  20. b4 = Integer.parseInt(parts[3], 16);
  21. out.println(String.format("%s##%d.%d.%d.%d", value, b1, b2, b3, b4));}
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement