13 Replies Latest reply on Nov 4, 2019 8:05 AM by Jaime Rivadelo

    Hostname_Shortname_Override

    Hitesh Jha
      Share This:

      Hello Experts,

       

      When ADDM syncs Cis to CMDB, 90% of the time, we get short name in DNS Hostname field. But once in a while we get FQDN.

      We would like to get short name in DNS HostName field.

      This will maintain uniformity and reconciliation will be standardized when we get Cis from SEG automation Team. Also, when SOI sends alerts, if its short name in Alert, we will still get a match against CMDB.

       

      Now when SOI sends alerts with short name and CMDB has FQDN in Name and hostname we are unable to find a match.

       

      DNS Host Name -> Always Sync short Name.

       

      To fix the above issue I have  uploaded the sample  TPL provided by BMC support Pattern Module: CMDB.Extension.Hostname_Shortname_Override.

      As per the current scenarios we have 1300+ devices(Routers,Switch ,network) for which we need short name in Hostname field .

       

      Please suggest!!!

       

      Regards

      Hitesh

       

      CMDB.Extension.Hostname_Shortname_Override

        • 1. Re: Hostname_Shortname_Override
          Hitesh Jha

          Could someone please respond and let me know how to resolve or at least approach in right direction ?

          • 2. Re: Hostname_Shortname_Override
            Lisa Keeler

            I assume you mean this sample pattern:  CMDB.Extension.Host_Name_Override

            (The one on the "Create Patterns" page).

             

            And, perhaps you renamed it to be:  CMDB.Extension.Hostname_Shortname_Override

             

            I reviewed the logic, and it looks like it does what you want for Host objects in Discovery.

             

            >>As per the current scenarios we have 1300+ devices(Routers,Switch ,network) for which we need short name in Hostname field .

             

            The problem is that this pattern does not address other Discovery (other than Host) which cause HostName to be set in the CMDB.

            Those other nodes are:  NetworkDevice, SNMPManagedDevice, Printer.

             

            The best path forward is to change your pattern to use a higher TPL version, such as 1.15 (the latest version showing for 11.3)

             

            With a higher TPL version, your syncmapping TPL can solve the problem for all 4 node types with a single pattern.

            (With earlier TPL versions, you had to have 4 patterns to solve the same problem ... one pattern per node-type in Discovery).

             

            Here is how I think it would look (The "import" versions can change depending on your TKU version.  I used July 2019 TKU in 11.3):

            (added or revised items are in red font)

             

             

            tpl 1.15 module CMDB.Extension.Short_HostName_all;

             

            from CMDB.Host_ComputerSystem              import Host_ComputerSystem              2.2;

            from CMDB.NetworkDevice_ComputerSystem     import NetworkDevice_ComputerSystem     2.1;

            from CMDB.SNMPManagedDevice_ComputerSystem import SNMPManagedDevice_ComputerSystem 2.1;

            from CMDB.Printer_Printer                  import Printer_Printer                  2.0;

             

            syncmapping Host_Name_Override_all 1.0

                """

                Override the default ComputerSystem HostName and TokenId to take

                only the first component of compound dot-separated hostnames.

                """

                overview

                    tags CMDB, Extension;

                end overview;

             

                mapping from Host_ComputerSystem.host

                        from NetworkDevice_ComputerSystem.device

                        from SNMPManagedDevice_ComputerSystem.device

                        from Printer_Printer.printer_node

                    as host

                end mapping;

             

                body

                    computersystem := Host_ComputerSystem.computersystem         or

                                      NetworkDevice_ComputerSystem.device_cs     or

                                      SNMPManagedDevice_ComputerSystem.device_cs or

                                      Printer_Printer.printer_ci;

             

                    hostname := computersystem.HostName;

             

                    if hostname has substring "." then

                        // Modify the HostName to only include content up to the first dot

                        computersystem.HostName := text.split(hostname, ".")[0];

             

                        // If TokenId is the "standard" HostName:Domain format,

                        // modify it with the new HostName.

                        if computersystem.TokenId then            //TokenId only exists for Host

                            if computersystem.TokenId = "%hostname%:%host.dns_domain%" then

                                computersystem.TokenId := "%computersystem.HostName%:%host.dns_domain%";

                            end if;

                        end if;

                    end if;

                end body;

            end syncmapping;

            3 of 3 people found this helpful
            • 3. Re: Hostname_Shortname_Override
              Hitesh Jha

              Lisa Thanks a ton for your help.

              I have uploaded the above TPL in our QA consolidator and validate the outcomes in Dev ITSM but unfortunately no luck.

              I mean to say still many CI's are showing fullname in hostname field.

              • 4. Re: Hostname_Shortname_Override
                Lisa Keeler

                I think a remaining problem would be that there are still other types of Discovery nodes that that create BMC_ComputerSystem... such as HostContainer, HardwareContainer, and StorageSystem.  And, I think you need separate extension patterns for those.  (In my testing about 6 months ago, I wasn't able to combine them with the other pattern .... the big combined pattern didn't work for some reason).

                 

                So, if all of the remaining CI's without the short name are from other nodes (not Host, NetworkDevice, SNMPManagedDevice, Printer), then the pattern is working.

                 

                If you still have CI's without short name, and the CI's came from Host, NetworkDevice, SNMPManagedDevice, or Printer, then check that the record was updated by Discovery recently by looking at these attributes on the CI:

                 

                LastScanDate

                ModifiedDate (only valid if the LastModifiedBy and Submitter are both your CMDB Sync user.  Mine is "Demo".)

                 

                 

                To make sure all records get updated in the CMDB from Discovery, you can just perform a Resync.

                 

                If you need sample patterns for HostContainer, HardwareContainer, and StorageSystem, you should open a ticket.

                I can provide samples... but they need some scrubbing.

                4 of 4 people found this helpful
                • 5. Re: Hostname_Shortname_Override
                  Hitesh Jha

                  Thanks a lot Lisa.

                  I have already opened a case(00738631) to the BMC Support.

                  One more thing Is it possible for us to check and run CMDB Extension pattern manually against non working CI's and validate the same in logs.

                  • 6. Re: Hostname_Shortname_Override
                    Hitesh Jha

                    Hi Lisa,

                     

                    Could you please respond on this.As guided I have created the support case for the same.

                     

                    Regards

                    Hitesh

                    • 7. Re: Hostname_Shortname_Override
                      Duncan Grisby

                      Put CMDB sync into debug logging mode, then use Actions > CMDB Sync Preview when viewing a root node (Host, NetworkDevice, etc.). That does all the transformation work and logs the complete state of all CIs and relationships it would maintain in tw_svc_cmdbsync_transformer.log.

                      2 of 2 people found this helpful
                      • 8. Re: Hostname_Shortname_Override
                        Lisa Keeler

                        Hi Hitesh,

                         

                        I looked at this again, and I see now that the mappings from HardwareContainer, HostContainer, and StorageSystem nodes in Discovery do not set a "HostName" attribute on the BMC_ComputerSystem in the CMDB.

                         

                        They only set the "Name" attribute (not "HostName").

                         

                        Therefore, you actually should not need any other mapping to change HostName to be a short name .... just the one I already provided.  FYI.

                         

                        To update all of the data in the CMDB, a Resync could be necessary?

                         

                        Lisa

                        1 of 1 people found this helpful
                        • 9. Re: Hostname_Shortname_Override
                          Hitesh Jha

                          Hello Lisa/Duncan,

                           

                          I have checked in the tw_svc_cmdbsync_transformer.log and validate for particular CI's and found that pattern is working absolutely fine.

                          139904439228160: 2019-08-09 08:45:59,911: cmdb_sync.interpreter: DEBUG: Create CONTAINED CI BMC_ComputerSystem(KVPDict({'CapabilityList': 'Other', 'Category': 'Hardware', 'HostName': 'ed1ednsifb820-01.broadridge.net', 'SystemOID': '1.3.6.1.4.1.7779.1.1402', 'Name': 'ed1ednsifb820-01.broadridge.net', 'isVirtual': None, 'ShortDescription': 'ed1ednsifb820-01.broadridge.net', 'SerialNumber': '0800201601100410', 'PrimaryCapability': 2, 'Item': 'Other type of processing unit', 'key': 'MngISlrdqkFb6J2Zwe5E5Q==', 'Model': 'IB-820', 'LastScanDate': datetime.datetime(2019, 8, 3, 10, 47, 9, 539665, tzinfo=<UTC>), 'Type': 'Processing unit', 'ManufacturerName': 'Infoblox', 'Description': 'ed1ednsifb820-01.broadridge.net'}))

                           

                           

                          139904439228160: 2019-08-09 08:45:59,924: cmdb_sync.interpreter: DEBUG: Process extension 'CMDB.Extension.Short_HostName_all.Host_Name_Override_all'

                          139904439228160: 2019-08-09 08:45:59,924: cmdb_sync.interpreter: DEBUG: Extension 'CMDB.Extension.Short_HostName_all.Host_Name_Override_all' completed

                           

                          139904439228160: 2019-08-09 08:45:59,925: cmdb_sync.filters: DEBUG: Visiting BMC_ComputerSystem: TargetNodeInstanceWrapper(id=139904655798928, kind='BMC_ComputerSystem', key='MngISlrdqkFb6J2Zwe5E5Q==#BMC_ComputerSystem', instance='', containment=CONTAINED, filter_state=None, state=KVPDict({'CapabilityList': 'Other', 'Category': 'Hardware', 'HostName': 'ed1ednsifb820-01', 'SystemOID': '1.3.6.1.4.1.7779.1.1402', 'Name': 'ed1ednsifb820-01.broadridge.net', 'isVirtual': None, 'ShortDescription': 'ed1ednsifb820-01.broadridge.net', 'SerialNumber': '0800201601100410', 'PrimaryCapability': 2, 'Item': 'Other type of processing unit', 'ManufacturerName': 'Infoblox', 'Model': 'IB-820', 'LastScanDate': datetime.datetime(2019, 8, 3, 10, 47, 9, 539665, tzinfo=<UTC>), 'Type': 'Processing unit', 'Description': 'ed1ednsifb820-01.broadridge.net'}))

                           

                          But It's not updated in the Remedy console.Please suggest.

                          • 10. Re: Hostname_Shortname_Override
                            Lisa Keeler

                            we will need to look at it on a webex.  It looks like it should work, like you said.

                            I put your case into my queue. 

                             

                            Just to check:  You are looking at the BMC.CORE:BMC_ComputerSystem form at the BMC.ADDM dataset, and you are looking at HostName attribute, correct?

                             

                            (maybe send screenshot)

                            • 11. Re: Hostname_Shortname_Override
                              Jaime Rivadelo

                              Hi Lisa,

                               

                              Your override tpl worked on the network devices, thanks.

                               

                              I have another issue with stack switches where the Hostname showing is the "Hostname - SerialNumber".  Is there a way to show only the Hostname without the SerialNumber?

                               

                              Thanks,

                               

                              JaimR.

                              • 12. Re: Hostname_Shortname_Override
                                Lisa Keeler

                                There might be a good reason for the format to be that way for stack switches in the CMDB:  "Hostname - SerialNumber"

                                Probably "name" by itself is not unique.

                                 

                                But, if you want to change it .... you would do something similar to the previous logic.

                                 

                                The original logic is changing the name like this:

                                OLD:  lisa_host@bmc.com

                                NEW:  lisa_host

                                 

                                        if hostname has substring "." then

                                            // Modify the HostName to only include content up to the first dot

                                            computersystem.HostName := text.split(hostname, ".")[0];

                                 

                                 

                                New logic: 

                                OLD:  lisa_host - 12345

                                NEW: lisa_host

                                 

                                        hostname := computersystem.HostName;

                                        if hostname has substring " - " then

                                            // Modify the HostName to only include content up to the space before the dash

                                            computersystem.HostName := text.split(hostname, " -")[0];

                                        end if;

                                 

                                 

                                 

                                So, to put it all together into one pattern (which I have not tested):

                                 

                                 

                                tpl 1.15 module CMDB.Extension.Short_HostName_all;

                                 

                                from CMDB.Host_ComputerSystem              import Host_ComputerSystem              2.2;

                                from CMDB.NetworkDevice_ComputerSystem    import NetworkDevice_ComputerSystem    2.1;

                                from CMDB.SNMPManagedDevice_ComputerSystem import SNMPManagedDevice_ComputerSystem 2.1;

                                from CMDB.Printer_Printer                  import Printer_Printer                  2.0;

                                 

                                syncmapping Host_Name_Override_all 1.0

                                    """

                                    Override the default ComputerSystem HostName and TokenId to take

                                    only the first component of compound dot-separated hostnames.

                                    """

                                    overview

                                        tags CMDB, Extension;

                                    end overview;

                                 

                                    mapping from Host_ComputerSystem.host

                                            from NetworkDevice_ComputerSystem.device

                                            from SNMPManagedDevice_ComputerSystem.device

                                            from Printer_Printer.printer_node

                                        as host

                                    end mapping;

                                 

                                    body

                                        computersystem := Host_ComputerSystem.computersystem        or

                                                          NetworkDevice_ComputerSystem.device_cs    or

                                                          SNMPManagedDevice_ComputerSystem.device_cs or

                                                          Printer_Printer.printer_ci;

                                 

                                        hostname := computersystem.HostName;

                                 

                                        if hostname has substring "." then

                                            // Modify the HostName to only include content up to the first dot

                                            computersystem.HostName := text.split(hostname, ".")[0];

                                 

                                            // If TokenId is the "standard" HostName:Domain format,

                                            // modify it with the new HostName.

                                          if computersystem.TokenId then            //TokenId only exists for Host

                                                if computersystem.TokenId = "%hostname%:%host.dns_domain%" then

                                                    computersystem.TokenId := "%computersystem.HostName%:%host.dns_domain%";

                                                end if;

                                          end if;

                                        end if;

                                 

                                       hostname := computersystem.HostName;

                                        if hostname has substring " - " then

                                            // Modify the HostName to only include content up to the space before the dash

                                            computersystem.HostName := text.split(hostname, " -")[0];

                                        end if;

                                 

                                    end body;

                                end syncmapping;

                                 

                                1 of 1 people found this helpful
                                • 13. Re: Hostname_Shortname_Override
                                  Jaime Rivadelo

                                  Hi Lisa,

                                   

                                  Thank you so much for your help/response.  I really appreciate it and your pattern worked on the stacked switches !!!

                                   

                                  Cheers,

                                  JaimeR