- 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 11:15 AM
I'm not sure this is possible without something like Orchestration. If you try to run a Discovery against a CI without an IP Address listed you'll get an error because there is no means of identifying which MID Server to use.
Something like this, which occurred when I clicked on Discover Now on a CI with no IP address:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:42 AM
If you go to the Discovery Schedules page, the Quick Discovery button calls to the instance to identify / validate a mid server.
You could mimic that behavior to start a discovery for an IP.
...but you would still need to send a probe to a mid to do the name -> IP lookup.
Now, probes do work with names rather than discovery, so you could run a probe on the target to get its ip address. Maybe ifconfig / ipconfig? But you would need to parse out the address from the response and feed it back into your quick discovery script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 11:53 AM
Tim,
Honestly, I have been waiting for you input. I had great solutions from you in the past. Can you please give me more insight into how can I build that probe and kick off from the action script?
Here is my other question on the same issue. My whole point is to pull the IP and run a quick scan. I really appreciate your time on this. Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 12:44 PM
Yeah, go for the flattery to get me to go the extra mile. Maybe some day I'll learn to resist that.
The SncProbe object is what you would use to kick off a probe. If there is some documentation on how to use it, I haven't found it yet, but you can search on your instance for script includes and sensors whose script field contains SncProbe to find just dozens of good examples.
There are two ways to use it:
- Build a new probe from scratch in your script with new SncProbe().
DiscoveryLongRunner has some nice examples of this.
Note the use of SncProbe.create() to allow load-balancing vs SncProbe.createForMidServer() to forbid load-balancing.
(One nice trick if you go this way is to include a parameter sensor = <sensor script to handle input>.
This way you don't have to create a separate sensor record or get errors because there is no sensor define.) - Get an existing probe and then customize a few things, and use an existing sensor
- By sysid with SncProbe.getById() as in DiscoveryIDSensor
- By name with SncProbe.get() as in Service Discovery - Device Complete
Hope that helps as a starting point, and best of luck with your efforts.
(Bonus geek FYI: SncProbe.create() is actually the most future-proof way to create a probe because it can select the mid server later. Even if you do specify an agent, it can pick another in the same cluster. Currently, mid selection within a cluster is done at random when you create the probe, so it doesn't matter if you specify the mid yourself or let SncProbe pick one for you, but by using SncProbe.create(), you allow a future version of SncProbe to pick the selected mid server later in response to real-time conditions.)
Do, please, let us know how it works out,
- Tim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2019 01:29 PM
This is great Tim. Thanks a lot for that. I apologize if my question seems dumb. I tried this way from background script when I checked queue I don't see anything. Please advice. Thanks.
var probeSysID = '8e2007e60a0a0b500044825832ac3d63';//Windows - Identity
var values = '10.26.113.240';//Windows PC
var probe = SncProbe.getById(probeSysID,'values');
