Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Troubleshooting discovery of processes listening on ports on Linux systems - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Troubleshooting discovery of processes listening on ports on Linux systems
KB0563276

Troubleshooting discovery of processes listening on ports on Linux systems


4175 Views Last updated : Jun 19, 2025 public Copy Permalink
KB Summary by Now Assist

Issue

Service Mapping runs the command correctly, displays the process number in the result, but fails to extract it properly and displays an error message.

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, the following solution uses an external command to override the ProcessOnPort command for Linux:

  1. Go to System Definition > Tables.
  2. In the Name field, search for sa_mapping_ext_commands.
  3. Select the Mapping External Discovery Commands entry.
  4. Scroll down, and select the Operating System Type.
  5. On the Reference specification tab, set an additional condition:
    1. Select OR.
    2. From the first list, select Element.
    3. For the operator, select Is.
    4. From the second list, select os_type.
    5. Select Update.

Dictionary Entry page

 

  1. Go to Service Mapping > External discovery commands.
  2. Select New.
  3. In the Name field, enter Process on port IPv6 - Linux.
  4. Next to Operating System Type, select the padlock icon, and then select Linux.
  5. In the Type field, select PROCESS_ON_PORT.
  6. In the Order field, enter -1.
  7. In the Script pane, paste the following script:
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");
}
}
 

8. In the Order field, enter -1.

9. Select PROCESS_ON_PORT from the Type list.

10. Select Update.

 

 

 

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.