11 Replies Latest reply on Apr 20, 2020 1:17 AM by Danny Fleer

    Collection of LastUse for Visio and Project?

    Gene Slaughter
      Share This:

      Has anyone considered or currently doing collection of LastUse for Visio and Project? 

       

      my first attempt at building initial collection involves something like this, just need filters for Visio and Project:

      get-ciminstance -class win32_SoftwareFeature | select ProductName, Version, Caption, Name, InstallDate, Accesses, LastUse -unique| ft -autosize | more

        • 1. Re: Collection of LastUse for Visio and Project?
          Gene Slaughter

          Hi All,

           

          I think I am getting close.

          I would like some help/ideas for getting "Trigger sample" to work and processing ...result/...result[].

           

          What I have so far:

          tpl 1.13 module GetLastUse;

           

          pattern GetLastUse_rc 1.4

           

          """

              A pattern for collecting LastUse for Visio & Project

              tpl 1.13 = ADDM v11.1

              #Host:HostedSoftware:InstalledSoftware:Package.name as 'PkgName'

              Pkg (name): Microsoft Project Professional 2013

              Pkg (name): Microsoft Visio Professional 2013

              1.1 redo trigger and first if statement

              need to combine both queries into one *****

              1.2 split queries into two --> 1.3

              1.4 added logging, failed to show results, string vs array?

           

              Result from running get-ciminstance -class win32_SoftwareFeature | select ProductName, Version, Caption, Name, Description, InstallDate, Accesses, LastUse -unique | Where Name -like "PROJECTFiles" from PowerShell window

              ProductName : Microsoft Project Professional 2013

              Version     : 15.0.4569.1506

              Caption     : Microsoft Office Project

              Name        : PROJECTFiles

              Description : Microsoft Office Project will be installed with only the selected options.

              InstallDate :

              Accesses    : 13

              LastUse     : 3/25/2020 8:00:00 PM

           

              PowerShell sample:

              exec := discovery.runCommand(host, 'powershell.exe -command "date" ');

              if exec and exec.result then

                  log.debug( "date = %exec.result%");

              end if;

             

              Trigger sample:

              triggers

                  on host_Computersystem := Host created, confirmed where os_type matches 'Windows' and (#Host:HostedSoftware:InstalledSoftware:Package.name matches 'Microsoft Project Professional' or #Host:HostedSoftware:InstalledSoftware:Package.name matches 'Microsoft Visio Professional');

              end triggers;

           

              mapping sample:

              mapping from Host_ComputerSystem.host as host

                 traverse Host:HostedSoftware:InstalledSoftware:Package as package

           

                     product -> BMC_Product;

           

                 end traverse;

              end mapping;

           

          """

           

          overview

              tags LastUse;

          end overview;

           

          constants

              query_cmd1 := 'powershell.exe -command "get-ciminstance -class win32_SoftwareFeature | select ProductName, Version, Caption, Name, Description, InstallDate, Accesses, LastUse -unique | Where Name -like "PROJECTFiles""' ;  // takes about 60 sec

              query_cmd2 := 'powershell.exe -command "get-ciminstance -class win32_SoftwareFeature | select ProductName, Version, Caption, Name, Description, InstallDate, Accesses, LastUse -unique | Where Name -like "VISIOFiles""' ;    // untested/unverified

          end constants;

           

          triggers

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

          end triggers;

           

          body

              SFPName    := "";

              SFVer      := "";

              SFCap      := "";

              SFName     := "";

              SFDesc     := "";

              SFInstDate := "";  // all blank so far

              SFAcc      := "";

              SFLU       := "";

             

              ran_query_cmd1 := discovery.runCommand(host_Computersystem, query_cmd1);

              ran_query_cmd2 := discovery.runCommand(host_Computersystem, query_cmd2);

             

              if ran_query_cmd1 and ran_query_cmd1.result then

                  log.debug("GetLastUse Pattern for Project || For %host_Computersystem.name% || Results: %ran_query_cmd1.result%");

              else

                  // log.debug("GetLastUse Pattern for Project || For %host_Computersystem.name% || No Project");

                  log.debug("GetLastUse Pattern for Project || For %host_Computersystem.name% || No Project || Results: %ran_query_cmd1.result%");

              end if;

             

              if ran_query_cmd2 and ran_query_cmd2.result then

                  log.debug("GetLastUse Pattern for Visio  || For %host_Computersystem.name% || Results: %ran_query_cmd2.result%");

              else

                  // log.debug("GetLastUse Pattern  for Visio || For %host_Computersystem.name% || No Visio || Results: %ran_query_cmd1.result%");

                  log.debug("GetLastUse Pattern  for Visio || For %host_Computersystem.name% || No Visio");

              end if;

             

           

          end body;

          end pattern;

          • 2. Re: Collection of LastUse for Visio and Project?
            Gene Slaughter

            I think I am getting close, any ideas for getting the "Trigger sample" to work and processing the result(s)?

            • 3. Re: Collection of LastUse for Visio and Project?
              Danny Fleer

              Please have in mind that executing a command which takes so long (~ 60 seconds) can cause issues with timeouts, increases discovery time dramatically (you execute this command on every windows machine!) and might use a serious amount of system ressources!

               

              I would say discovery is not designed to gather the data you're interested in. This sounds more like a monitoring or logmanagement thing (maybe this is reported in the Windows event log!?).

              1 of 1 people found this helpful
              • 4. Re: Collection of LastUse for Visio and Project?
                Shane Smith

                Doesn't look like that is supported.

                 

                TPL question on traverse

                2 of 2 people found this helpful
                • 5. Re: Collection of LastUse for Visio and Project?
                  Brice-Emmanuel Loiseaux

                  Yes, the where condition into a TPL pattern trigger is expected to be simple - read Triggers - Documentation for BMC Discovery 11.3 - BMC Documentation :

                  "

                  Trigger conditions consist of a subset of the more general where clauses available in searches (described later in the section on search expressions). The only operations supported are simple attribute comparisons of the form:

                   

                  attribute_name operator [ expression ]

                   

                  and combinations of such comparisons using and and or.

                   

                  The only operators available are:

                  =

                  Exact equality

                  matches

                  Regular expression match

                  exists

                  Attribute existence check — does not take an expression.

                   

                  To avoid "greedy" triggers that trigger on almost all data, not expressions are not permitted in triggers.

                  Expressions must be literal values, constants, or expressions based entirely on literal values and constants.

                  "

                  • 6. Re: Collection of LastUse for Visio and Project?
                    Gene Slaughter

                    Thanks, to all three of you for responding. 

                     

                    Guess I need to do some re-thinking of code.

                    Maybe verify Visio or Project in installed first (Package) then and only then, run the collection commands.

                    Any idea how to parse the results of commands?

                    • 7. Re: Collection of LastUse for Visio and Project?
                      Bob Anderson

                      Gene,

                       

                      Just curious...sounds like you are including Desktops in your Discovery, as not may datacenter servers will have Visio or Project installed on them.

                       

                      Your trigger could be only on Desktops, but triggering on Windows, then checking to see they are installed is another option.

                       

                      As for parsing the output, simple regex extractions should work fine, especially if you structure the query to get a particular list of attributes in a well structured format on the ouput.  Make sure you check the output for errors as well as expected data.

                       

                      hth

                       

                      Bob

                      1 of 1 people found this helpful
                      • 8. Re: Collection of LastUse for Visio and Project?
                        Gene Slaughter

                        Hi Bob,

                         

                        what is equivalent of below and then match on package.name fot Visio or Project?

                        mapping from Host_ComputerSystem.host as host

                               traverse Host:HostedSoftware:InstalledSoftware:Package as package

                               end traverse;

                            end mapping;

                         

                        If Visio then run command for Visio...

                        • 9. Re: Collection of LastUse for Visio and Project?
                          Danny Fleer

                          You are referencing a syncmapping here, which is used to sync data from BMC Discovery to the BMC CMDB and not used to discover endpoints.

                           

                          You may want to trigger on desktop systems and then check wether visio is installed:

                           

                           

                          triggers
                              on host := Host created, confirmed where type = "Windows Desktop";
                          end triggers;
                          
                          body
                              // check if Visio is installed
                              visio_pckg := search (in host traverse Host:HostedSoftware:InstalledSoftware:Package
                                                            where name = 'Microsoft Visio Professional');
                          
                              if not visio_pckg then
                                  log.debug("Could not find Visio package. Stopping pattern execution ...");
                                  stop;
                              end if;
                          
                              // Insert your code here ...
                          end body;
                          

                           

                          Note: This code has not been tested.

                           

                          You can do the same for MS Project.

                           

                          Triggering on packages doesn't work. Fore information about this please take a look at Discovered Packages to Software Instances.

                          • 10. Re: Collection of LastUse for Visio and Project?
                            Gene Slaughter

                            Hi Danny, Thanks!  Exactly what i was looking for. 

                            • 11. Re: Collection of LastUse for Visio and Project?
                              Danny Fleer

                              Please note that a "stop;" was missing in line 12. According to this I've updated the code.