On classification script objects for Discovery
Summarize
Summary of On classification script objects for Discovery
ServiceNow’s On classification script in a process classifier allows you to customize application records discovered during the Discovery process.
By default, application names follow the format
Show less
Customizing Application Names
You can change the default application name using the On classification script field in the process classifier record. For example:
- Appending a suffix:
mysql@machineAbecomesmysql999@machineA. - Incorporating parameters: An Eclipse application running on
machineAwith parameters can be namedeclipse-psn01884620@machineA, by appending process parameters to the name.
Passing Parameters to Triggered Probes
You can use the gprobeparameters object within your script to pass custom name/value pairs to probes triggered during process classification. For example, passing the process command as a probe parameter enables probes to receive contextual information about the process.
Important Script Objects
- current: Represents a JavaScript object containing the properties to update the application record.
- gsensor: References the DiscoverySensor object, including
deviceGR, which points to the computer CI record. - gclassification: Points to the process classifier record, giving access to process properties such as
name,command,parameters,PID, andtable name. - name, command, parameters: Variables holding the process name, command, and parameters respectively.
- gprobeparameters: Allows passing parameters to probes triggered by the classification.
Practical Benefits for ServiceNow Customers
Utilizing On classification scripts enables you to:
- Tailor application names for clearer identification and alignment with organizational naming conventions.
- Enhance discovery accuracy by dynamically modifying application records based on process details.
- Pass relevant parameters to probes, improving the precision of subsequent discovery steps.
This flexibility helps you maintain a more accurate and meaningful configuration management database (CMDB) and improves the overall Discovery process effectiveness.
Use an On classification script in a process classifier to customize an application record.
Renaming the default application name
By default, application names are in this format: <name of the process classifier>@<the name of the computer CI where the process resides>;
mysql@machineA. You can use the On classification script field in the process classifier record 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 processClassifierName = g_classification.name;
current.name = processClassifierName + "999" + "@" + computerName;In this example, the name of the application record becomes mysql999@machineA. | name | "eclipse" |
| command | "/glide/eclipse/Eclipse.app/Contents/MacOS/eclipse" |
| parameter | "-psn_0_1884620" |
var computerName = g_sensor.deviceGR.name;
var processClassifierName = g_classification.name;
current.name = processClassifierName + parameters + "@" + computerName;In this example, the name of the application record becomes eclipse-psn_0_1884620@machineA.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.
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 DiscoverySensor object defined in the DiscoverySensor script include. 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. This object is set in the Application Dependency Mapping sensor and is available in the On Classification script field. Use it to access the classified process properties: name, command, parameters, PID, and table name. |
| 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 enables parameter passing to the triggered probes. |