ESP Workload Automation

 View Only
  • 1.  TEXT_MON Question

    Posted Sep 16, 2016 09:14 AM

    We have a scenario where we need to monitor a file for multiple strings, like "Add User", "Delete User", "Error" and if any of the strings are found send the file in an e-mail to a group and if none of the strings are found send an e-mail stating something like "No String Found", do you know if TEXT_MON can monitor for multiple strings and do you know of a way to send the file? Also we don't want the TEXT_MON job to fail either way, any ideas on how to accomplish this?

     

    Thank you.

    Sharon



  • 2.  Re: TEXT_MON Question

    Posted Sep 16, 2016 10:05 AM

    This is an alternate method using a LINUX_JOB with the grep command with the -E option.  I took a shortcut and just used SEND statements since email is specific to your environment.  With this solution there are no failed jobs.  Depending on the Completion Code of the grep command the next job will be run or bypassed.

     

    Command syntax:

    grep -E 'Add User|Delete User|Error' <file>

     

    ESP PROC

     

    PROCEDURE_SECTION:                                    

                                                          

    LinuxFile = "<file>"          /* Enter file name */                    

    S1 = "Add User"                                      

    S2 = "Delete User"                                    

    S3 = "Error"                                          

                                                          

    APPL TEXTGREP                                        

                                                          

    LINUX_JOB TEXTGREP                                    

      AGENT LJ_LINUX64                                    

      CMDNAME /bin/bash                                   

      USER compops                                        

      ARGS -c "grep -E '%S1|%S2|%S3' %LinuxFile"          

      EXITCODE 0-1 SUCCESS                                

      RUN ANYDAY                                          

      RELEASE ADD(FOUND) COND(RC(0))                      

      RELEASE ADD(NOTFOUND) COND(RC(1))                   

    ENDJOB  

                                                      

    JOB FOUND TASK SELFCOMPLETING                    

      SEND 'STRING FOUND' U(*)                        

      RUN ANYDAY                                      

    ENDJOB                                            

                                                      

    JOB NOTFOUND TASK SELFCOMPLETING                  

      SEND 'STRING NOT FOUND' USER(*)                 

      RUN ANYDAY                                      

    ENDJOB                                                                                        



  • 3.  Re: TEXT_MON Question

    Posted Sep 16, 2016 10:34 AM

    Sorry should have mentioned this was for Windows.



  • 4.  Re: TEXT_MON Question

    Posted Sep 16, 2016 11:28 AM

    This is so much easier in Linux.  I tried unsuccessfully with replacing grep with findstr. 

     

    The findstr command works as expected in a Windows Command prompt, but I have not had success with it in an NT_JOB.

     

    If you are able to create a Windows Batch File on the server a solution is listed below.

     

    Windows Batch File TEXTFIND.bat


    findstr "Add User Delete User Error" %1%

     


    ESP PROC

     

    PROCEDURE_SECTION:                                   
                                                         
    WindowsFile = %USER1                                 
                                                         
    APPL TEXTFIND                                        
                                                         
    NT_JOB TEXTFIND                                      
      AGENT <Agent Name>                           
      CMDNAME <Path>TEXTFIND.bat                 
      ARGS %WindowsFile                                  
      EXITCODE 0-1 SUCCESS                               
      RUN ANYDAY                                         
      RELEASE ADD(FOUND) COND(RC(0))             
      RELEASE ADD(NOTFOUND) COND(RC(1))          
    ENDJOB                                       
                                                 
    JOB FOUND TASK SELFCOMPLETING                
      SEND 'STRING FOUND' U(*)                   
      RUN ANYDAY                                 
    ENDJOB                                       
                                                 
    JOB NOTFOUND TASK SELFCOMPLETING             
      SEND 'STRING NOT FOUND' USER(*)            
      RUN ANYDAY                                 
    ENDJOB                      



  • 5.  Re: TEXT_MON Question
    Best Answer

    Posted Sep 19, 2016 11:50 AM

    Windows solution:

     

    PROCEDURE_SECTION:                                

                                                       

    AgentName = %USER1

    WindowsFile = %USER2              

    S1 = "Add User"                                    

    S2 = "Delete User"                                

    S3 = "Error"                                      

                                                       

    APPL TEXTGREP                                      

                                                       

    NT_JOB TEXTFIND                                    

      AGENT %AgentName                                        

      CMDNAME FINDSTR                                  

      ARGS    "%S1 %S2 %S3" %WindowsFile               

      EXITCODE 0-1 SUCCESS                          

      RUN ANYDAY                                    

      RELEASE ADD(FOUND) COND(RC(0))                

      RELEASE ADD(NOTFOUND) COND(RC(1))             

    ENDJOB                                          

                                                    

    JOB FOUND TASK SELFCOMPLETING                  

      SEND 'STRING FOUND' U(*)                      

      RUN ANYDAY                                    

    ENDJOB                                          

                                                    

    JOB NOTFOUND TASK SELFCOMPLETING                

      SEND 'STRING NOT FOUND' USER(*)               

      RUN ANYDAY                                    

    ENDJOB



  • 6.  Re: TEXT_MON Question

    Posted Sep 20, 2016 08:24 AM

    Thank you, I'll take a look at this and do some testing but it does look promising. Thanks again!