On classification script objects for Discovery

An On classification script can call the following script objects to further customize an application record.

Renaming the default application name

Use these script objects to further customize an application record:

Table 1. On classification script objects
Script object Description
current Points to a JavaScript object with its [property:value] pair to update the application record. (It is not an actual GlideRecord object of the application.)
g_sensor Points to the running process sensor class. This object contains a deviceGR object, which points to the computer CI record on which the process resides.
g_classification Points to the process classifier record itself.
name Points to the process name.
command Points to the process command.
parameters Points to the process parameters.
g_probe_parameters A JavaScript object that will allow parameter passing to the triggered probes.

By default, ServiceNow names applications in this format:

<name of the process classifer>@<the name of the computer CI where the process resides>;

For example, for a MySQL server running on a computer called machineA, ServiceNow names the application mysql@machineA.

You can use the On classification script field to change the default application name to match your business needs.

For example, the following script changes the default application name to include a suffix after the process classifier:
var computerName = g_sensor.deviceGR.name;
var processClassiferName = g_classification.name;
current.name = processClassiferName + "999" + "@" + computerName;
In this example, the name of the application record becomes mysql999@machineA.
Another common technique is to set the application name based on the name, command, and parameter variables. For example, an Eclipse process might have the following values in these variables:
name "eclipse"
command "/glide/eclipse/Eclipse.app/Contents/MacOS/eclipse"
parameter "-psn_0_1884620"
If an Eclipse application runs on a computer called machineA, ServiceNow names the application eclipse@machineA. The following script appends the parameter value as part of the application name.
var computerName = g_sensor.deviceGR.name;
var processClassiferName = g_classification.name;
current.name = processClassiferName + parameters + "@" + computerName;
In this example, the name of the application record becomes eclipse-psn_0_1884620@machineA.

Sometimes it is useful to pass values to the triggered probes in the process classification. You can do this by creating a custom script that defines a name/value pair for the g_probe_parameters object. For example:
g_probe_parameters['processCommand'] = command;

In this example, when a classification record triggers a probe, the script passes the probe a parameter called processCommand with the value of the command variable.