Exclude CI's based on Host name

Voona Rohila
Kilo Patron
Kilo Patron

Hi

Can anyone help me with discovery related to exclude CI's based on host name i.e starting with d2,D2 not with IPAddress

I Tried with 2 methods

1) I tried modifying DiscoveryJSONIDSensor and DiscoveryIDSensor  script includes by adding the below script at Line89

var regexp = new RegExp('^[dD][2]'); //hostnames ending in p01 or P2 or similar
        var host_name = this.ciData.data.host_name;
      
        if (!host_name)
            host_name = this.ciData.data.name;
		var sub = host_name.substring(0,2);
       if (sub=='d2' || sub=='D2'){
       this.explore = false;

       this.setTriggerProbes(false);         

       logger.info('Non-prod machine: '+ host_name +'. Not exploring device', this.type, this.getEccQueueId());

       return false;

} else {

       logger.info('Production Machine: '+ host_name +'. Continue to explore device', this.type, this.getEccQueueId());

}

2)  I tried changing Classifier by adding Classification Criteria.

Both the cases did not worked 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
1 ACCEPTED SOLUTION

 

Hi Rohila,

Apologies, looks like I have some errors in my notes on this. You could try the following:

hostname instead of host_name with Windows. i.e. hostname does not start with d2:

find_real_file.png

cidata.host_name does not start with d2:

find_real_file.png

If you still have a problem, post a screenshot of the classifier and I will have a look.

I would also test this thoroughly before doing deciding to implement this in a production envrionment.

Regards,

Dave

 

View solution in original post

7 REPLIES 7

Hi Rohila, We are looking to accomplish this in our instance as well. How are things going for you? Curious how you accomplished this for each of the CI classifications (windows server, unix/linux server, VM). Thanks

Hi John

 

Yes it can be accomplished based on CI classification like windows and linux etc.. based on criteria. Best part is we can use RegEx as well to select or ignore the CI's based on match.

I'm using cidata.name does not end with 'T' (to exclude our 'test' servers), and this is not working.  In fact, for a server that does not end with 'T', it is skipping this classification and instead creating an entry in the 'computer' classification.  Any idea why it's not working?

find_real_file.png