switch to sigar.getNetServicesName

This commit is contained in:
Doug MacEachern 2007-09-16 18:41:17 +00:00
parent a1cd6def29
commit 745c526e07
1 changed files with 5 additions and 6 deletions

View File

@ -22,7 +22,6 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import org.hyperic.sigar.NetServices;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.NetConnection; import org.hyperic.sigar.NetConnection;
import org.hyperic.sigar.NetFlags; import org.hyperic.sigar.NetFlags;
@ -119,12 +118,12 @@ public class Netstat extends SigarCommandBase {
return flags; return flags;
} }
private String formatPort(String proto, long port) { private String formatPort(int proto, long port) {
if (port == 0) { if (port == 0) {
return "*"; return "*";
} }
if (!isNumeric) { if (!isNumeric) {
String service = NetServices.getName(proto, port); String service = this.sigar.getNetServicesName(proto, port);
if (service != null) { if (service != null) {
return service; return service;
} }
@ -132,7 +131,7 @@ public class Netstat extends SigarCommandBase {
return String.valueOf(port); return String.valueOf(port);
} }
private String formatAddress(String proto, String ip, private String formatAddress(int proto, String ip,
long portnum, int max) { long portnum, int max) {
String port = formatPort(proto, portnum); String port = formatPort(proto, portnum);
@ -216,11 +215,11 @@ public class Netstat extends SigarCommandBase {
ArrayList items = new ArrayList(); ArrayList items = new ArrayList();
items.add(proto); items.add(proto);
items.add(formatAddress(proto, items.add(formatAddress(conn.getType(),
conn.getLocalAddress(), conn.getLocalAddress(),
conn.getLocalPort(), conn.getLocalPort(),
LADDR_LEN)); LADDR_LEN));
items.add(formatAddress(proto, items.add(formatAddress(conn.getType(),
conn.getRemoteAddress(), conn.getRemoteAddress(),
conn.getRemotePort(), conn.getRemotePort(),
RADDR_LEN)); RADDR_LEN));