1 2 Previous Next 15 Replies Latest reply on Nov 19, 2019 2:22 AM by Danny Fleer

    Enrich discovery with product number

    Eslam Farrag
      Share This:

      Dears,

       

      Currently we have a requirement to get the product number AKA SKU. A case was opened with BMC support and its not out of the box and it can only be customized. i found the below command that can be used for retrieving the data for windows but could not implement it. Your help is appreciated.

       

      wmic /namespace:\\root\wmi path MS_SystemInformation get SystemSKU

       

      Regards,

      Eslam Farrag

        • 1. Re: Enrich discovery with product number
          Danny Fleer

          You can create a custom TPL using the function discovery.wmiQuery(). Please see the documentation at discovery.wmiQuery - Documentation for BMC Discovery 11.3 - BMC Documentation.

           

          query = select SystemSKU from MS_SystemInformation

          namespace = root\wmi

           

          Consider that backslash is used to escape special characters. Therefore use double backslash or prefix the string with the "raw" keyword.

          1 of 1 people found this helpful
          • 2. Re: Enrich discovery with product number
            Eslam Farrag

            Im not a TPL professional and would appreciate your help with the the script of TPL, so far i have reached to the below point;

             

            pattern Test_wmi_Query 1.0

             

             

                            A pattern for wmi query testing

             

                            // Required overview section. Some tags must be defined.

             

                            overview

                                            tags SKUNumber;

             

                          end overview;

             

                            constants

             

            query_cmd := 'select SystemSKU from MS_SystemInformation';

             

                                            namespace := '\\root\cimv2';

             

                            end constants;

             

                            triggers

                                            on host := Host created, confirmed where os_type matches 'Windows' ;

             

                            end triggers;

             

                body

                                            ran_query_cmd := discovery.wmiQuery(host, query_cmd, namespace );

            • 3. Re: Enrich discovery with product number
              Danny Fleer

              So what is your question here?

               

              One thing I'd like to mention is that you might need to change the following line from:

              namespace := '\\root\cimv2';

              to

              namespace := '\\root\\cimv2';

              or

              namespace := raw '\root\cimv2';

               

              Have you been able to execute the pattern against a Windows machine?

              2 of 2 people found this helpful
              • 4. Re: Enrich discovery with product number
                Eslam Farrag

                I have executed the pattern against a windows machine below was the output of the script;

                 

                • 5. Re: Enrich discovery with product number
                  Eslam Farrag

                  Update, since i was not able to use WMI to retrieve the required information I have used a Powershell command and updated my TPL accordingly. The TPL successfully retrieved the required information however when i added  the condition (virtual := 'Not set') it stopped working. Kindly check trigger below.

                   

                  on host := Host created, confirmed where virtual = 'Not set' and os_class = "Windows";

                  • 6. Re: Enrich discovery with product number
                    Danny Fleer

                    You're using a wrong namespace. Try "root\\wmi" instead of "root\\cimv2" and the code will work.

                    2 of 2 people found this helpful
                    • 7. Re: Enrich discovery with product number
                      Andrew Waters

                      Not set is what is shown in the UI, the attribute will not actually have that value. You cannot test a negative in a trigger condition.

                      1 of 1 people found this helpful
                      • 8. Re: Enrich discovery with product number
                        Eslam Farrag

                        Dear Andrew,

                         

                        is there anyway I can add this TPL to trigger on none virtual hosts ?

                         

                        Dear Danny,

                         

                        im not getting any result when its executed.

                        • 9. Re: Enrich discovery with product number
                          Danny Fleer

                          Double click on the row and then scroll down to the bottom of the list. There you will see the desired attribute.

                           

                          You can trigger on any windows server and check the virtual condition at the beginning of the body:

                           

                          if virtual defined or virtual then

                              log.debug("Triggered on a virtual host. Stopping pattern now ...");

                              stop;

                          end if;

                          1 of 1 people found this helpful
                          • 10. Re: Enrich discovery with product number
                            Andrew Waters

                            You need the virtual for the Host, i.e.

                            if host.virtual then

                              stop;

                            end if;

                            In your conditions the second could never be evaluated as true. If virtual is not defined then it cannot be true. If virtual is defined then it will never test the condition.

                            2 of 2 people found this helpful
                            • 11. Re: Enrich discovery with product number
                              Eslam Farrag

                              Product number was successfully discovered on windows machines, your support is highly appreciated. Furthermore, is it possible to capture product/SKU number from ESXI, Redhat and Solaris as it is currently a requirement ?

                              • 12. Re: Enrich discovery with product number
                                Eslam Farrag

                                Dears,

                                 

                                Is there any way to resolve the below string to show the SKU number;

                                businesslogic.base.NodeValue(store_id='\x99G\x7fTb\x17\xcf\x0cS\xd6e\xe9', node_id='\x13;\xd0]lY\x85EbO\xed\xeanDiscoveredWMI')

                                 

                                Below the code used. I have read another post in the communities regarding the same issue but couldn't modify the code to work.

                                                            

                                  ran_query_cmd := discovery.wmiQuery(host, query_cmd, namespace );

                                      if ran_query_cmd then

                                     system_SKUnumber := ran_query_cmd;

                                • 13. Re: Enrich discovery with product number
                                  Andrew Waters

                                  You are writing out a node rather than the attribute. You need to access the attribute from run_query_cmd containing the value. The name of the attribute will depend match the name in the query.

                                  2 of 2 people found this helpful
                                  • 14. Re: Enrich discovery with product number
                                    Eslam Farrag

                                    For the SKU number it worked fine, however when i added the same TPL to retrieve memory part number I'm getting the same output i.e ( businesslogic.base.NodeValue(store_id='\x99 ). Please check the TPL below, what can be fixed

                                     

                                     

                                                    constants

                                     

                                     

                                    query_cmd := 'select partnumber from Win32_PhysicalMemory';

                                     

                                     

                                                                    namespace := raw '\root\cimv2';

                                     

                                     

                                                    end constants;

                                     

                                     

                                     

                                     

                                     

                                                    triggers

                                     

                                     

                                                                    on host := Host created, confirmed where os_type matches 'Windows' ;

                                     

                                     

                                                    end triggers;

                                     

                                     

                                     

                                     

                                     

                                        body

                                     

                                     

                                    if host.virtual then

                                     

                                     

                                      stop;

                                     

                                     

                                    end if;

                                     

                                     

                                     

                                     

                                                                    ran_query_cmd := discovery.wmiQuery(host, query_cmd, namespace );

                                     

                                    if ran_query_cmd and ran_query_cmd[0].partnumber then

                                     

                                     

                                      // Successfully made request.

                                     

                                     

                                      host.MemoryPartNumber := ran_query_cmd[0].partnumber;

                                     

                                     

                                    end if;

                                    1 2 Previous Next