diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Route.java b/bindings/java/src/net/hyperic/sigar/cmd/Route.java index 8e866b7f..ed24df2b 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Route.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Route.java @@ -1,10 +1,36 @@ package net.hyperic.sigar.cmd; -import net.hyperic.sigar.Sigar; +import java.util.ArrayList; + import net.hyperic.sigar.NetFlags; import net.hyperic.sigar.NetRoute; +import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; -public class Route { +public class Route extends SigarCommandBase { + private static final String OUTPUT_FORMAT = + "%-15s %-15s %-15s %-5s %-6s %-3s %-s"; + + //like df -h -a + private static final String[] HEADER = new String[] { + "Destination", + "Gateway", + "Genmask", + "Flags", + "Metric", + "Ref", + "Iface" + }; + + public Route(Shell shell) { + super(shell); + setOutputFormat(OUTPUT_FORMAT); + } + + public Route() { + super(); + setOutputFormat(OUTPUT_FORMAT); + } private static String flags(long flags) { StringBuffer sb = new StringBuffer(); @@ -17,26 +43,33 @@ public class Route { return sb.toString(); } + public String getUsageShort() { + return "Kernel IP routing table"; + } + //netstat -r - public static void main(String[] args) throws Exception { - Sigar sigar = new Sigar(); + public void output(String[] args) throws SigarException { + NetRoute[] routes = this.sigar.getNetRouteList(); - NetRoute[] routes = sigar.getNetRouteList(); - - System.out.println("Destination\tGateway\tGenmask" + - "\tFlags\tMSS\tWindow\tirtt\tIface"); + printf(HEADER); for (int i=0; i