naveen_kumarhr
ServiceNow Employee
ServiceNow Employee

Extending Patterns

Goal

In this lab you will learn two general methods of extending discovery using patterns. Requirement is to add the start date field to the Windows Server record that is not captured out of box.

Extending patterns

  1. in the application Search bar type 'Discovery Patterns' then select the discovery patterns module under pattern designer application

 

 

  1. Search then select for the pattern named 'Windows OS - Servers'

 

 

  1. Select 'New' in the pattern extension section

 

 

  1. Use 'Uptime' as the name, select done

 

 

  1. Click the name Uptime in the extension section to enter the pattern designer

 

 

  1. Click 'Debug'

 

 

  1. Choose your windows midserver and enter the IP of YOUR Midserver, select 'Connect'

 

 

  1. Set up the pattern step
  • Enter a name for the pattern step 'Run Systeminfo Command'
  • Set 'Operation' to 'Parse Command Output
  • Set Command Details to "systeminfo" (quotes required)
  • Click Run Command

 

 

  1. Filter out lines by chosing 'Include Lines' enter System Boot Time:

 

 

  1. Define the Variable strategy
  • Set two values 'start_date' and 'start_time'

 

 

  1. Define the delimiters
  • A space, " "
  • A comma, ","
  • Click 'Done'

 

 

  1. Set the positons Remember patterns start at position '1' not '0'
  • Enter 4,5

 

 

  1. Add a new step
  • top left corner select 'add new step below'

 

 

  1. Select Set Paramater Value

 

 

  1. Set the variables. Easy as dragging the names to the fields
  • Drag 'start_date' temporary variable to the value field
  • Add a space value by doing start_date+ " "+
  • Drag 'start_time' temporary varable to the value field
  • Drag 'start_date' computer attribute to the name field

 

 

  1. Click Test

 

 

  1. See result Return

 

 

  1. Save the pattern

 

 

  1. Run a discovery against your Midserver as you have done in previous steps

 

 

  1. See Valid start date on the Windows Server Record

 

 

Comments
Ragini BG
Tera Contributor

Hi Naveen,

This is very helpful. Thank you very much.

But don't you think you should change the start_time format as well since by default we get 12Hr format and it can be ambiguous?

 

Thanks,

Ragini

Manuel Stimac
Mega Sage

Hi @naveen_kumarhr,

thanks for sharing! I saw this requirement a lot and it's good to find the solution now in the community.

 

I have one little improvement to share with you. To make the Pattern more scalable and secure for future versions I recommend to replace the "Delimited Text" with a RegEx. This one should be scalable and save at a time:

 

Boot Time:\W*([\d\W]*)[\,][\W]*([\d\W]*)

 

 

Let me know what you think.

 

Thanks again for sharing - Regards,
Manuel

GB14
Kilo Patron

@naveen_kumarhr 

would you kindly share how to extend the printer pattern? We are trying to discover some Datamax label printers. 

doug_schulze
ServiceNow Employee
ServiceNow Employee

Printer discovery uses probes and sensors not patterns as my lab above shows. So you would have to do that work there.

GB14
Kilo Patron

@doug_schulze  thank you, do you have a lab or refernce that I can follow? Thanks 

Version history
Last update:
‎07-05-2021 04:59 AM
Updated by: