8 Replies Latest reply on Aug 3, 2018 8:50 AM by Gonzalo Rodriguez

    Find Registry Key with TPL File

      Share:|

      I tried to write a TPL file, in order to find a specific value of a registry key and present it to the ADDM user.

      I read all the information I could get, and saw the videos, I also tried to work with the Application Mapping,

      But the thing is that the ADDM do not find this specific registry key Im looking for.

      And my second problem is that if I'll write a TPL file, I do'nt know where should I present the result- under which object.

       

      Thankes.

        • 1. Find Registry Key with TPL File

          Many, many patterns that ship in each TKU look up values from registry, so feel free to look through for examples of usage.

           

          Your TPL pattern needs to have a trigger condition, and then do whatever work is required off it.

          If the registry value is related to a software product, then presumably your TPL might be triggering off a DiscoveredProcess and would be creating a SoftwareInstance node and the value could be attached to an attribute on the SI node.

           

          If the registry value is related to something on a host, then your TPL may be triggering  on a Host node, and the value obtained from a registry query may be saved in an attribute you add to the Host node.

           

          I cannot really comment more unless you provide a clearer description of what you are trying to do.

          • 2. Find Registry Key with TPL File

            The registry value is ralted to the host.

            And the ADDM can't show me the registry value I am looking for, as it doesn't exist or the ADDM don't find all of the detailes in the registry.

             

            This is what I got so far.

            What do I need to add, or change in order to make it work?

             

            Thank you!

             

             

             

             

            tpl 1.5 module RegDiscoveryModule;

            pattern RegDiscoveryPattern 1.0
              """
              This is pattern is trying to present the value of a key from the windows registry which is yes or no. its importent for the customer.
              """
             
              metadata
                products := "RegValue";
                publishers := "Win";
              end metadata;
             
              overview
                tags REGISTRY, REG, TKU;
              end overview;

              constants
               // The key to be retrieved
            registry_key := "HKEY_LOCAL_MACHINE\\SOFTWARE\\SOME_KEY";
              end constants;

              triggers
                on host := Host created, confirmed where os_type = "Windows";
              end triggers;

            body
            // Get the registry key.
                registry_value := discovery.registryKey(host, registry_key);   
              
            // Retrieving the registry entry may fail, so we must check that we received a value.
            if registry_value then
              regvalue := registry_value.value;
              log.debug("computer description = %regvalue%");
              host.description := regvalue;
            end if;

            end body;

            end pattern;

            • 3. Find Registry Key with TPL File

              I do not see any real issues with this pattern with exception of using 'description' attribute as you will be overwriting data that ADDM writes during host discovery and that is bad.

               

              OK, there is no need for the metadata section (or at best you could put in just an entry for 'additional_attributes' to indicate the attribute you are adding) since you are populating products and publishers field with irrelevant information.

               

              I also wouldn't put a 'TKU' entry in tags since this pattern doesn't come in a TKU. A 'CUSTOM' tag would be better.

               

              If the registry query is failing (registry_value is none, or registry_value.value is none) then have a look at the discovery access of the host and look at the registry queries that were executed, drilling into your registry query to see the error message.

              If ADDM is given the right level of access (local admin rights for the host) and the registry key exists, then it should obtain the value. If either of the 2 conditions are not met, then it won't.

              1 of 1 people found this helpful
              • 4. Find Registry Key with TPL File

                I changed my file by your advice.

                But I want to ask you this, if the 'description' is bad, how should I change my file? Is there a better variable I can put the registry result in?

                 

                 

                tpl 1.5 module RegDiscoveryModule;

                pattern RegDiscoveryPattern 1.0
                  """
                  This is a pattern that trying to present the value of a key from the windows registry which is yes or no. its importent for the customer.
                  """

                  overview
                    tags REGISTRY, REG, CUSTOM;
                  end overview;

                  constants
                   // The key to be retrieved
                registry_key := "HKEY_LOCAL_MACHINE\\SOFTWARE\\SOME_KEY";
                  end constants;

                  triggers
                    on host := Host created, confirmed where os_type = "Windows";
                  end triggers;

                body
                // Get the registry key.
                    registry_value := discovery.registryKey(host, registry_key);   
                  
                // Retrieving the registry entry may fail, so we must check that we received a value.
                if registry_value then
                  if registry_value.value then
                   regvalue := registry_value.value;
                   log.debug("computer description = %regvalue%");
                   host.description := regvalue;
                  end if;
                end if;

                end body;

                end pattern;

                • 5. Find Registry Key with TPL File

                  ADDM does not have a set model so you can just add an attribute to the host node and use a descriptive name for the attribute.

                  An example (a bad one as descriptivness goes) would be:

                   

                  host.my_custom_attribute := regvalue;

                   

                  Then you also add:

                   

                  if regvalue then

                      host._tw_meta_data_attrs := ["my_custom_attribute"];

                  end if;

                   

                  to make it visible when you drill into the host from the ADDM UI.

                   

                  Obviously, use something else as the attribute name.

                   

                  This attribute will of course not be synced to the CMDB by default, for that you will need a custom sync mapping that extends the standard Host node mapping.

                  1 of 1 people found this helpful
                  • 6. Find Registry Key with TPL File

                    Thank you so much.

                    If I want to use custom sync mapping as you said I should, how should I do it?

                    • 7. Find Registry Key with TPL File

                      Under 'Pattern Management' page on ADDM, open up the 'Pattern Templates' section and look for the template whose description is: 'Augment BMC_ComputerSystem CIs synchronized to the CMDB.'

                       

                      Download and modify this template using the custom attribute name, then upload it to ADDM.

                      The attribute you are mapping to has to of course exist on the CI in the CMDB.

                      • 8. Re: Find Registry Key with TPL File
                        Gonzalo Rodriguez

                        Hello, this information helped me a lot! I wanted to know if you have something similar or you know to do the same thing on Linux computers. I could not find anything at the time, please tell me!

                         

                        Thanks