Discovery sensor - get CI sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 02:23 AM
Hi all
I am created a custom probe/sensor. The input is fine, but i cannot relate the input to a CI. I am trying "g_device.getCmdbCi()" og "this.getCmdbCi()", but none of them returns anything. It seems to be the same code used in "Windows - JBoss Get jboss-service.xml" or "Windows - JBoss Find web.xml List" probes.
I have tried both DiscoveryJSONSensor and DiscoverySensor, but that doesnt change anything.
var gr = new GlideRecord("u_cmdb_ci_vms_package");
gr.addQuery("name", packages.name);
gr.query();
if (!gr.next()) {
gr.initialize();
gr.setNewGuid();
gr.name = packages.name;
gr.description = packages.description;
gr.cmdb_ci = this.getCmdbCi();
gr.insert();
What can the issue be?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 02:56 AM
I think this.getCmdbCi return the GlideRecord object. Can you try with below, I have also added log statement to check if this method is returning any value or not:
var deviceGr = this.getCmdbCi();
gs.info('The device sys id is'+deviceGr.sys_id);
var gr = new GlideRecord("u_cmdb_ci_vms_package");
gr.addQuery("name", packages.name);
gr.query();
if (!gr.next()) {
gr.initialize();
gr.setNewGuid();
gr.name = packages.name;
gr.description = packages.description;
gr.cmdb_ci = deviceGr.sys_id;
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 04:33 AM
Thank you for the response. I tried that too, but same result. The oob sensors are also not doing it this way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 04:42 AM
And just to elaborate, i get the following error:
org.mozilla.javascript.JavaScriptException: TypeError: Cannot read property "sys_id" from null