You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to add the PID column to the netstat function's output? This would improve the value proposition of this function. A proposed updated version of the netstat function is provided below:
function () { os <- Sys.info()["sysname"] switch(os, Windows = { system("netstat -a -n -o", intern = TRUE) }, { system("netstat -a -n -o", intern = TRUE) }) }
If this change proposal is accepted, the parse_netstat function will also require modification.
Upon further analysis and a desire to work with a parsed version of the code provided above, I rewrote the parse_netstat function. The tested result, which I refer to as conv_ns, is provided below:
Would it be possible to add the PID column to the netstat function's output? This would improve the value proposition of this function. A proposed updated version of the netstat function is provided below:
function ()
{
os <- Sys.info()["sysname"]
switch(os, Windows = {
system("netstat -a -n -o", intern = TRUE)
}, {
system("netstat -a -n -o", intern = TRUE)
})
}
If this change proposal is accepted, the parse_netstat function will also require modification.
Upon further analysis and a desire to work with a parsed version of the code provided above, I rewrote the parse_netstat function. The tested result, which I refer to as conv_ns, is provided below:
conv_ns <- function(netstat_output) {
# Formalize vector structure
netstat_output <- netstat_output[4:length(netstat_output)]
# Rename line columns
netstat_output[1] <- " Proto Local_Address Foreign_Address State PID"
# Split the lines into columns
data <- strsplit(netstat_output, "\\s+")
# Create a matrix
m <- stringi::stri_list2matrix(x = data, byrow = TRUE, fill = 0)
# Convert to dataframe
df <- data.frame(m)
# Remove empty column
df$X1 <- NULL
# Set column names
colnames(df) <- c("Proto", "Local_Address", "Foreign_Address", "State", "PID")
# Reset dataframe
df <- df[-c(1),]
return(df)
}
The text was updated successfully, but these errors were encountered: