Example of customization: The OS version attribute in Windows Server 2012 is discovered as 'Server 2012 R2'. Let's say that an end user wants to replace the os value by '6.3.9600' and synchronize it to the cmdb. |
Copy and save the below sample custom pattern to a .tpl file and uploaded it to the Discovery appliance. This would capture the Alternate OS version in the attribute os_version_alt (Display Name: Os Version Alt) and display it on the respective Host node. _____________________________________________________________________________ //Custom Discovery pattern to get the Windows Server OS Version tpl 1.13 module Windows_os_version; metadata origin := "Custom"; tkn_name := "OS_Version"; tree_path := 'Windows', 'systeminfo', 'OS Version'; end metadata; from DiscoveryFunctions import DiscoveryFunctions 1.10; pattern Windows_os_version 1.0 ''' Pattern triggers on the creation of a host Then, find the OS Version. Change History: ''' overview tags CustomWindowsOSVersion; end overview; triggers on host := Host created, confirmed where os_type matches "Windows"; end triggers; body hostname := host.hostname; cmd := discovery.runCommand(host, raw 'systeminfo | findstr /B /C:"OS Version" '); log.debug("custom cmd is %cmd%"); if cmd and cmd.result then //cmd.result is something like this: OS Version: 10.0.15063 N/A Build 15063 cmd_result := cmd.result; log.info("customlog cmd_result := '%cmd_result%'"); os_string := text.split(cmd_result, " "); os_number := ""; if os_string and size(os_string) > 17 then log.info("customlog: OS Version is %os_string%"); os_number := os_string[17]; end if; host.os_version_alt := '%os_number%'; log.info("customlog host.os_version_alt := '%os_number%'"); model.addDisplayAttribute(host, "os_version_alt"); end if; end body; end pattern; _____________________________________________________________________________________ Once the custom attribute on the Host is populated, a custom syncmapping extension pattern can be written to synchronize this data into CMDB. The custom attribute in Discovery can be synced to an OOTB or custom attribute in the CMDB. (If the custom attribute in CMDB is not already present, it will need to be added.) A note about custom syncmappings: An "extension" syncmapping is used to update an existing attribute or to set a new attribute in the CMDB. The "Augment" and "Extend" terms are used interchangeably. Steps to create a custom attribute in CMDB: * From the AR interface, go to Applications > Atrium Core > Atrium Core Console > Advanced > Class Manager. * Select the class where the new attribute should be associated. In this case: BMC_BaseElement > BMC_System > BMC_ComputerSystem > Attributes > new. * Configure Data Type, Attribute Name and Permissions. * Save the changes and verify that the new custom attribute is available on the respective class attribute list. In this case BMC_ComputerSystem Note: After modifying the CMDB to add or edit an attribute or class, it is required to restart the Discovery services. Otherwise, any custom syncmapping will fail to update the new attribute. Here is an example syncmapping pattern to populate the new attribute in the CMDB: ________________________________________________________________________ tpl 1.5 module CMDB.Extension.ComputerSystem_Augment; from CMDB.Host_ComputerSystem import Host_ComputerSystem 2.0; syncmapping ComputerSystem_Augment 1.0 """ Add one or more new attributes to the BMC_ComputerSystem CI, based on attributes in the BMC Discovery Host node. """ overview tags CMDB, Extension; end overview; mapping from Host_ComputerSystem.host as host // No additional structure -- we are just modifying the // existing ComputerSystem CI. end mapping; body computersystem := Host_ComputerSystem.computersystem; // Set as many additional attributes as we need: os_version_alt := host.os_version_alt; computersystem.os_version_alt := os_version_alt; log.debug("os_version_alt is %os_version_alt%"); end body; end syncmapping; NOTE:: In the above example, there are two patterns utilized: First, a Discovery pattern is used to populate a new attribute in BMC Discovery. Second, a syncmapping pattern is used to populate the new attribute in the CMDB. These are provided as examples only and may need to be modified for your requirements. ______________________________________________________________________________________ A "Getting Started creating a CMDB Syncmapping Extension pattern" guide can be found here: https://communities.bmc.com/docs/DOC-111015 Please note that writing/troubleshooting custom patterns, modifying pattern templates, and developing applications are considered to be user customizations and are not within the scope of customer support. If additional assistance is needed: - Many questions can be answered on our community forum: https://communities.bmc.com/community/bmcdn/discovery - For a comprehensive solution, consider asking BMC Professional Services for assistance. Contact your Sales Representative or BMC Account Manager for more details. |