
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 10:20 AM
Hello,
Is there any way to kick off discovery from JavaScript using just device name.
I am working on vCenter MID extension. I get the device name in the parm fields in the event from vCenter, from there I capture the name and populate it in the CMDB. Once addition is done I wanted to kick off discovery update the CI. I know how to run the discovery from script but not sure about running it without any IP address. Please suggest me any ideas here. Thanks!
Solved! Go to Solution.
- Labels:
-
Discovery
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 02:37 PM
So far so good. You have a probe object. Now you need to stick an address on it and mail it.
I think the values allows you to pass in some parameters, but I honestly don't know. Personally, i would just omit that argument, but if you want to try to work it out by example, by all means, go for it.
So, now you have a probe. Assuming you don't need to fool with other probe parameters, you can just set the ip or hostname in the source field and create the probe.
Here's an example i tried out with a simple Linux probe:
var ipOrHostname = 'timserve';
var mid = 'tims_mid';
var probe = SncProbe.get("Linux - CPU");
probe.setSource(ipOrHostname);
probe.create(mid);
I see an output and then input appear on the ecc_queue as a result of running this script.
If you don't just know which mid to use, that's a little more work.
var source = 'timserve';
var probe = SncProbe.get("Linux - CPU");
probe.setSource(source);
probe.createForAutoSelectMidServer('Discovery', [{'capability': 'ssh'}], null);
The arguments for createForAutoSelectMidServer() are frankly a little baffling. It's SncProbe.createForAutoSelectMidServer(String application, Object[] capabilities, String sensorECCID).
Application is a mid server application such as "Discovery" or "Orchestration".
Capabilities is an array of objects with a capability and a value, but I always wind up ignoring the value. If you poke at your mid server capabilities, you should be able to find what you need. I needed "ssh" for my probe.
sensorECCID is the sysid of the ecc_queue input we're responding to. Ignore it unless you are responding to another probe, which you're not.
Hope it helps,
- Tim.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 10:22 AM
Yes, you can use startDiscovery API functions to start discovery using device name and schedule.
Please check below
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_SDY-getCancelScript
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 10:35 AM
Thanks for the reply Sachin. I think I can only run using IP Address. I need it with a device name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:00 AM
Assuming that the IP Address is not stored and available from the CI record, you would need to execute a remote shell or powershell command and perform an nslookup. From the returned result string, parse out the IP address and then use it to call the Discovery API.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:03 AM
Thanks fro the reply Larry. This is going to be performed from a Script Action. Can you give me an idea or a source to build this from Script Action? Thanks again.