Troubleshooting discovery of processes listening on ports on Linux systemsIssue <!-- div.margin{ padding: 10px 40px 40px 30px; } table.tocTable{ border: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .6em; padding-bottom: .6em; padding-left: .9em; padding-right: .6em; } table.noteTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:2; } table.internalTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:0; } .sp td{ border-bottom: 1px solid; border-right: 1px solid; border-color:#E0E0E0; background-color: #ffffff; height: 20px; padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; } .sphr td{ border-right: 1px solid; border-bottom: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; height: 20px; } .title { color: #D1232B; font-weight:; font-size:25px; } .hd1{ color: #D1232B; font-weight:; font-size:18px; } .hd2{ color: #646464; font-weight:bold; font-size:16px; } .hd3{ color: #7a7a7a; font-weight:; font-size:16 px; text-decoration:; } .hd4{ color: #000000; font-weight:bold; font-size:14 px; text-decoration:; } --> Problem Service Mapping executes the command correctly and the process number is displayed in the result, but is not extracted properly, and the error message is displayed. Symptoms The following discovery error is displayed: “Failed to find process on port. Failed to detect listening process. tcp 0 0 ::ffff:ip_address LISTEN process_num/process name”. Cause When running the netstat command on Linux systems, Service Mapping may encounter unexpected information related to IPv6 in the result, which breaks the result parsing and prevents Service Mapping from detecting the process number. Resolution A code fix for Geneva P4 and higher addresses the issue. For earlier Geneva releases, we recommend the following solution, which uses an external command to override the ProcessOnPort command for Linux: Navigate to System Definition > Tables.Search for sa_mapping_ext_commands in the name field.Click on the Mapping External Discovery Commands entry.Scroll down, and click on the Operating System Type.On the Reference specification tab, set an additional condition: Click OR.Select Element from the first list.Select Is for the operator.Select os_type from the second list. Click Update.Navigate to Service Mapping > External discovery commands.Click New.Enter Process on port IPv6 - Linux in the Name field.Click the padlock icon next to Operating System Type and select Linux.In the Type field, select PROCESS_ON_PORT.In the order field, enter -1.Paste the following script in the Script pane: var logger = Packages.com.snc.sw.log.DiscoLog.getLogger("LinuxProcessOnPortCommand");logger.debugex("In external command process on port Linux");var portCommand = new Packages.com.snc.sw.commands.ProcessOnPortCommand();var input_port = new JSON().decode(input);var portInt = +input_port['localPort'];var portCommandArguments = new Packages.com.snc.sw.commands.arguments.PortCommandArguments(ctx, portInt);var filter = portCommandArguments.getFilter();var portCommandArguments2 = new Packages.com.snc.sw.commands.arguments.PortCommandArguments(ctx, portInt, input_port['localAddress'], filter);var openPortsCommand = new Packages.com.snc.sw.commands.OpenPortsSshCommandLinux();var openPorts = openPortsCommand.execute(portCommandArguments2);if (openPorts.size() > 0) { var proc = portCommand.execute(portCommandArguments2); if (proc != null) { var output = {}; output['pid'] = proc.pid; output['commandLine'] = proc.commandLine; output['executable'] = proc.executable; output['executablePath'] = proc.executablePath; output['parentProcessId'] = proc.parentProcessId; output['userName'] = proc.userName; output['currentDir'] = proc.currentDir; output['workingDir'] = proc.workingDir; if (proc.environmentVariables != null) { var env = {}; for (var key in proc.environmentVariables.keySet()) { var envVar = {}; envVar['name'] = key; envVar['value'] = proc.environmentVariables[key]; env[key] = envVar; } output['environmentVariables'] = env; } output = new JSON().encodeObject(output); logger.debugex("In external command process on port Linux - DONE");} else {// proc is null. try with similar ipv6 address//Packages.com.glide.util.Log.debug('try to find listening port on ipv6 address');var ipv6 = "::ffff:" + input_port['localAddress'];var portCommandArguments3 = new Packages.com.snc.sw.commands.arguments.PortCommandArguments(ctx, portInt, ipv6, filter); proc = portCommand.execute(portCommandArguments3); if (proc != null) { var output = {}; output['pid'] = proc.pid; output['commandLine'] = proc.commandLine; output['executable'] = proc.executable; output['executablePath'] = proc.executablePath; output['parentProcessId'] = proc.parentProcessId; output['userName'] = proc.userName; output['currentDir'] = proc.currentDir; output['workingDir'] = proc.workingDir; if (proc.environmentVariables != null) { var env = {}; for (var key in proc.environmentVariables.keySet()) { var envVar = {}; envVar['name'] = key; envVar['value'] = proc.environmentVariables[key]; env[key] = envVar; } output['environmentVariables'] = env; } output = new JSON().encodeObject(output); } logger.debugex("In external command process on port Linux - DONE"); }} 14. Enter -1 in the Order field. 15. Select PROCESS_ON_PORT from the Type list. 16. Click Update.