logo

NJP

How easy is creating a custom license metric in SAM?

Import · Jan 11, 2021 · article

TLDR Answer: Pretty easy if you put in a couple hours to learn basic JavaScript

Why use custom license metrics?

Publisher Packs and Common Metrics account for the majority of a customers environment and software spend, but sometimes smaller publishers have their own unique licensing. This is where creating custom license metrics fill the gap. The information we’ll need to create a custom license metric is the publisher license definition and some basic JavaScript knowledge.

Example

Shank posted a question on the community forum looking for help with a custom license metric and I thought what better way to understand the custom license metric functionality than by helping a customer. Shank was trying to license the publisher Cohesity with a product licensed based on the storage size of the device to the terabyte (TB). By googling "Cohesity" and "terabyte licensing" I was able to identify the license definition from the Publisher which enables me to whiteboard the license logic.

Steps

  1. Navigate to Software Asset > Administration > Custom License Metrics
  2. Select New
  3. Input License Metric name
  4. Whiteboard license logic
    • When a software installation of the product is found count the disk space of the computer to the nearest terabyte in the cmdb_ci_computer table
    • Since the computer disk space value is in GB we'll need to convert it into TB by dividing by 1000
  5. Code your logic in JavaScript
  6. * getrights();
    • function getrights(){
    • var rights = -1;
    • var device = new GlideRecord('cmdb_ci_computer');
    • if(device.get(entity)){rights = device.getValue('disk_space');
    • }
    • return rights/1000;
    • }
    • image
  7. Discover Software Installs
  8. * We manually imported two installs of Cohesity DataProtect using import sets and transform maps
    • Video link (3min) on importing data and normalization
  9. Create a Software Model
  10. * Publisher = Cohesity
    • Product = DataProtect
    • Version = Anything
    • Edition = Anything
  11. Create a Software Entitlement
  12. * Software Model = Cohesity DataProtect
    • Metric Group = Custom
    • License Metric = Per 1TB Capacity
  13. Run Reconciliation
  14. Results
  15. * Pic 1 - License Workbench showing Cohesity DataProtect licensed by Per 1TB Capacity having two installs being counted toward the license amount. 4 rights are consumed by Server-A and 1 right consumed by VM-A.imagePic 2 - Shows Server-A computer details having a disk space of 3,500GB. 3,5000GB is equivalent to 3.5 terabytes which is then rounded to the nearest whole terabyte of 4.image

Disclaimer: This blogpost and script is solely for demonstration purposes. The opinions expressed in this publication are those of the authors and do not necessarily reflect the views of ServiceNow.

View original source

https://www.servicenow.com/community/sam-blog/how-easy-is-creating-a-custom-license-metric-in-sam/ba-p/2283781