Unable to find class windows server or unix server while dot walking a reference variable

Atheher Fathima
Mega Guru

Hi Team,

 

I have created a reference variable ,reference is cmdb_ci table. in filter condition i would like to fetch the windows server and unix server with sub status is not decommissioning. however i am unable to dot walk and find windows server or unix server. i can however find linux and other server classes. please help

find_real_file.png

1 ACCEPTED SOLUTION

Atheher Fathima
Mega Guru

Hi All,

 

We have an option to dot walk to hardware -> substatus. The Hardware include all the server class CI's. This helped me to resolve my issue

find_real_file.png

View solution in original post

3 REPLIES 3

Sean Walters
Tera Expert

Hi Atheher, 

You would not be able to dot walk to find the substatus for windows server or unix server because they are not reference fields on the cmdb table. 

Where as Windows Cluster/Node/Service etc are reference fields on the config item table, and therefore can be used to dot walk. 

You could do the following query which is: 
Class is Windows Server 
However because substatus does not exist on the cmdb_ci table as a field (only on its child table) you cannot choose that as an option either. 

There are two options: 
1. Create the filter at the right table - I believe the Server table would allow you to do the filters you require 

find_real_file.png


2. Create a script include that provides you with the required results as you can script this query

You can do name is one Of (javascript: new getActiveServers.getWindowsandUnix())
or 
sysId is one of (javascript: new getActiveServers.getWindowsandUnix())

And then return back a list of sys ids with the script checking the following 

var getActiveServers = Class.create();

getActiveServers.prototype = {
    initialize: function() {},

    getWindowsandUnix: function() {

        var serverRecs = new GlideRecord('cmdb_ci_server');
        serverRecs.addEncodedQuery('sys_class_name=cmdb_ci_unix_server^hardware_substatus!=sold^ORhardware_substatus=^NQsys_class_name=cmdb_ci_win_server^hardware_substatus!=sold^ORhardware_substatus!=');
        serverRecs.query();

        var serverList = [];

        while (serverRecs.next()) {
            serverList.push(serverRecs.getUniqueValue());
        }


        return 'sys_idIN' + serverList;
    },

    type: 'getActiveServers'
};

Might need some tweaking with the filters just because I made up some of the choices as I did not have a decomissioned option. (Make sure the script include is client callable)

Then you could the filter like so: 
find_real_file.png

Hope that helps. 

Please mark my answer correct and helpful if this resolves your issue.



Hi Sean,

 

I tweaked the filters and tried as suggested,however the logs show 

below is the code I used

var getActiveServers = Class.create();

getActiveServers.prototype = {
        initialize: function() {},

        getWindowsandUnix: function() {

                var serverRecs = new GlideRecord('cmdb_ci_server'); serverRecs.addEncodedQuery('sys_class_name=cmdb_ci_unix_server^hardware_substatus!=decommissioning^ORhardware_substatus=^NQsys_class_name=cmdb_ci_win_server^hardware_substatus!=decommissioning^ORhardware_substatus!=');
        serverRecs.query();
        gs.log("server", serverRecs);

        var serverList = [];
        while (serverRecs.next()) {
            serverList.push(serverRecs.getUniqueValue());
        }


        return 'sys_idIN' + serverList;
    },

    type: 'getActiveServers'
};

 

below is the filters that i tried

find_real_file.png

Atheher Fathima
Mega Guru

Hi All,

 

We have an option to dot walk to hardware -> substatus. The Hardware include all the server class CI's. This helped me to resolve my issue

find_real_file.png