Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

StartDiscovery- Global

The StartDiscovery script include provides methods to start discovery jobs.

Use this script include during the discovery scanning phase.

Parent Topic:Server API reference

StartDiscovery - addAdditionalIP(String status, String ip, String sensor)

Adds an IP (or comma-separated list of IPs) to an existing discovery (used by networks discovery).

NameTypeDescription
statusStringThe discovery status
ipStringAn IP address, or a comma-separated list of IP addresses.
sensorStringThe discovery sensor
TypeDescription
void 

StartDiscovery - discoverFromSchedule(String ip, Boolean samePhase, String sensor)

Handles discovery of devices (whether basic or advanced) from a schedule.

NameTypeDescription
ipStringAn IP address, or a comma-separated list of IP addresses.
samePhaseBoolean 
sensorStringThe discovery sensor
TypeDescription
void 

StartDiscovery - getCancelScript()

Returns the cancel script.

NameTypeDescription
None  
TypeDescription
StringThe cancel script

StartDiscovery - scheduleCancelJob()

If the schedule specifies a cancel time, if necessary, schedules a job to cancel the discovery.

NameTypeDescription
None  
TypeDescription
void 

The following example shows how to use the scheduleCancelJob() method to cancel a current discovery job.

var discoveryScheduleGR = new GlideRecord('discovery_schedule'); // Create a discovery schedule Gliderecord
discoveryScheduleGR.get('name', 'Disco'); // Put the discovery schedule job name

var discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); 
var discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.167.31.231'); // Initiate discovery
gs.info(discoveryStatusSysId); // Display the sys_id of the discovery status record

discoveryStatusSysId.scheduleCancelJob(); // Schedule a cancel job, located in the sys_trigger table

Output:

Operation   Table       Row Count
insert      discovery_result    1
update      discovery_status    1
insert      sys_trigger      1
insert      discovery_status    1
*** Script: Fired started event for: undefined Disco
*** Script: Scheduling Discovery DIS0010023 for cancellation at 2022-02-13 16:42:44
*** Script: 1828b05f1b6d811070cb96c6b04bcb53

StartDiscovery - startFromIP(DiscoverySchedule schedule, String ip)

Starts a discovery for a single IP using the specified schedule to get information such as MID servers and behaviors.

NameTypeDescription
scheduleDiscoveryScheduleDiscoverySchedule instance for the schedule to use.
ipStringIP address to discover.Format: dot-formatted string
TypeDescription
StringSys_id of the status record created.

This example uses the startFromIP() method to obtain the record that contains the discover information.

// Get a discovery schedule gliderecord
var discoveryScheduleGR = new GlideRecord('discovery_schedule'); 
discoveryScheduleGR.get('name', 'Discover Management Range 172.x.x.x');

// Create a DiscoverySchedule object to get information such as MID servers and behaviors
var discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); 
var discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.1.1.10');

// Sys_id of the genterated status record
gs.info(discoveryStatusSysId);

Output:

9d3c1197c611228701cd1d94bc32d76d

StartDiscovery - startFromSchedule(GlideRecord schedule, GlideRecord job)

Invoked by the discovery script include to kick off a scheduled (or discover now) discovery.

NameTypeDescription
scheduleGlideRecordThe instance of discovery_schedule that this discovery is based on.
jobGlideRecordThe instance of sys_trigger that triggered this discovery.
TypeDescription
void