How to like the same "sigar" get TCP and UDP connection tables?
This looks like it's possible to grab parsing the netstat output with various switches. I am not sure how consistent this is cross-platform, however.
@dbwiddis 'sigar' library By native libraries,dll,so,etc.
OSHI is not SIGAR. We don't write and install native DLLs. If you can point me to C source for the same information I can get it into OSHI using JNA.
Hi is this possible to get the list of NetConnection along with details -
LocalAddress 0.0.0.0
LocalPort 56084
RemoteAddress 0.0.0.0
RemotePort 0
Type UDP
State LISTEN
SendQueue 4294967295
ReceiveQueue 4294967295
Using OSHI,, in any ways ,, @dbwiddis your help is most needful
It's possible to get that information using the command line netstat command. OSHI does have a utility function to put command line output into a list of strings for processing. Otherwise, OSHI does not try to store or report this information in any way.
Thank you @dbwiddis, is there any test/examples to work around oshi utility function to use netstat command?
// add switches to netstat command for data you want
List<String> netstat = ExecutingCommand.runNative("netstat");
for (String line : lines) {
// trim off left whitespace
String leftTrimmed = line.replaceFirst("^\\s+", "");
// split columns by whitespace
String[] split = ParseUtil.whitespaces.split(leftTrimmed);
// make sure we have enough columns
if (split.length < 2) {
return "";
}
// pull out the column you want and process it
return split[1].split(":")[0];
}
Thank you @dbwiddis, , :-)