6 Replies Latest reply on Feb 3, 2015 4:26 PM by Bill Robinson

    search files using BSA

      I have to check if any of 75 files exists on few hundred Windows Servers with RSCD Agent.

      What is the most efficient way to do it?

        • 1. Re: search files using BSA
          Santhosh Kurimilla

          How about running a compliance job? Create a Component Template with the list of files and check for there existance.

          • 2. Re: search files using BSA

            But I do not know files location. I have to check if files exists in any location on the server.

            Does Compliance job help me?

            How should Component Template look like?

            • 3. Re: search files using BSA
              Bill Robinson

              use the 'find' command in nsh, or nexec the find command on each target.

              • 4. Re: search files using BSA
                Yanick Girouard

                Definitely do NOT use the find command from NSH, as it will run from the app server. If you run this in parallel against multiple servers, that's as many find processes that it will spawn on the app server. Find can take a lot of CPU when it runs and recurses folders, depending on the find command options and parameters. Whatever you do, you want to use the native, remote find equivalent to do it, not NSH.

                 

                For Windows, that would be dir /s. So for example, let's say you want to find all files with a certain name in sub directories recursively, you would do this using a Type 1 NSH Script Job:

                 

                nexec -e -ncq cmd /c "cd \"C:\\directory\\to\\search\\from\" & dir filename /s /b"

                 

                (Feel free to add more switches to the dir command to tweak the output to your liking)

                 

                That is providing the paths of the files can change from server to server. If you know the paths are static and any of the 75 files you need to search for, if found, should always be found in the same location, then you can simply use this in NSH:

                 

                if [ -e /path/to/the/file ] && [ -f /path/to/the/file ]; then
                  echo "file exists"
                else
                  echo "file does not exist"
                fi

                 

                Do this for each file, and run this against all your targets as a Type 1 NSH Scrip Job.

                 

                Whatever you do, do NOT use NSH's find command for this or you'll kill your app server while it runs.

                1 of 1 people found this helpful
                • 5. Re: search files using BSA
                  Yanick Girouard

                  That's fine for a simple, single search, but not when you need to run this in batch against multiple targets. The find process will spawn on the app server for as many targets you run in parallel. This is bad for performance. We've killed our app servers before due to bad compliance EOs using find like this to find world-writable files on Unix. We had to change the EOs to call a remote find instead.

                  1 of 1 people found this helpful
                  • 6. Re: search files using BSA
                    Bill Robinson

                    yeah - that's true about the nsh find.  i'd use the os-native tools executed via nexec or something.  i think there was an idea about maintaining a searchable database of files on the file system - that would be ideal, but for now find/dir.