2 Replies Latest reply on Dec 9, 2013 7:57 AM by Dipak Rai

    Log File Monitoring

    Dipak Rai

      Hello Team,

       

      I ahve request of configuring monitoring of jobs, detail are below:

       

      two new jobs running in our production server and this is scheduled under windows scheduler to run every 5 minutes all through the week.

      I would like to have the monitoring enabled on these jobs and alert the Run team (with an email) if this job skips its schedule.

      When this job runs the log file will be updated. So can we based the time modified to monitor and alert the run team.

       

       

      Kindly assist me in getting the correct tempalate to monitor the same.

       

      Thanks & Regards

      Dipak Rai

        • Re: Log File Monitoring
          stripet

          If the logfile filename is the same for each run and exist in Share, you would just need to create a SAM Template with a "File Age Monitor" component.  Set up the File Age Monitor" component pointing to the UNC path to the log file.  This monitor reports in number of hours old.  Set the threshold for Critical to Greater than or equal to .083  (5/60 = .0833333).  then set up an Advanded Alert to send your email when the component goes critical.

           

          Another option is to put the logfile for each job into its own directory so that is the only file in the directory, then set up a SAM Template Windows Script monitor component  (one seperate component for each logfile) using the following script and arguments (no thresholds required to be defined as the script will return a Statistics value of 3 which will determine its status to be critical):

           

          Script Arguments:  ${IP} ${USER} ${PASSWORD} False 1000

          For the Script Arguments:  You must supply exactly five arguments ${IP} ${USER} ${PASSWORD} IgnoreDirFileCountCheck (True|False) FileCountThreshold (int default is the valure of the FileCountThresh variable)

           

          Actual Script (first make sure to set the strPath to the actual UNC path to your directory the logfile exists in):

           

          -------------------start VBScript to Check the Age Of Most Recent File In Directory ----------------------

          Option Explicit
          Dim ObjFSO, objArgs, strIP, strUser, strPwd, strComputer
          Dim strMessage, objFolder
          Dim StartDateTime, ModDateTime, DiffMinutes
          Dim strUNCPath, strPath, file, recentFile, DirFileCount
          Dim FileCountThresh, IgnoreDirFileCountCheck

          Set ObjFSO = CreateObject("Scripting.FileSystemObject")

          strMessage = ""
          FileCountThresh = CLng(1000)
          IgnoreDirFileCountCheck = "False"

          strPath = "\C$\windows\temp"

          Set objArgs = WScript.Arguments
          'strMessage = strMessage & " -" & Date & " " & Time & " Argument count is: " & ObjArgs.Count & " -"

          If ObjArgs.Count < 5 Then
          strIP = objArgs(0)
          strUser = objArgs(1)
          strPwd = objArgs(2)
                  IgnoreDirFileCountCheck = objArgs(3)
                  If IgnoreDirFileCountCheck = "False" Then
               WScript.Echo "Message: " & strMessage & "------" & Date & " " & Time & "  ERROR You must supply a FileCountThresh value which would be exactly five arguments IP USER PASSWORD IgnoreDirFileCountCheck (True|False) FileCountThreshold (int default is " & FileCountThresh & ")"
               WScript.Echo "Statistic: 2"
               WScript.Quit(2)
                  End If
          End If
          If ObjArgs.Count = 5 Then
          strIP = objArgs(0)
          strUser = objArgs(1)
          strPwd = objArgs(2)
                  IgnoreDirFileCountCheck = objArgs(3)
                  FileCountThresh = objArgs(4)
          Else
                  If ObjArgs.Count < 4 Then
               WScript.Echo "Message: " & strMessage & "------" & Date & " " & Time & "  ERROR You must supply exactly five arguments IP USER PASSWORD IgnoreDirFileCountCheck (True|False) FileCountThreshold (int default is " & FileCountThresh & ")"
               WScript.Echo "Statistic: 2"
               WScript.Quit(2)
                  End If
          End If

          strComputer = strIP

          StartDateTime = Now

          strUNCPath = "\\" & strComputer & strPath

          'strMessage = strMessage & "--FileCountThresh is: " & FileCountThresh & "--"
          'strMessage = strMessage & "--IgnoreDirFileCountCheck is: " & IgnoreDirFileCountCheck & "--"

          Set recentFile = Nothing

          Set objFolder = ObjFSO.GetFolder(strUNCPath).Files
          DirFileCount = objFolder.Count
          strMessage = strMessage & "  --Number of Files in " & strUNCPath & " is: " & DirFileCount & "--  "

          If IgnoreDirFileCountCheck = "False" Then
          If CLng(DirFileCount) > CLng(FileCountThresh) Then
            strMessage = strMessage & "  ---" & Date & " " & Time & " ERROR:  There are more than " & FileCountThresh & " files in " & strUNCPath & " so will not process this directory and exiting and doing nothing---  "
            WScript.Echo "Message: " & strMessage & VbCrLf
            WScript.Echo "Statistic: 2" & VbCrLf
            WScript.Quit(2)
          End If
          End If

          'strMessage = strMessage & " --" & Date & " " & Time & " Checking to see if most recent file in " & strUNCPath & " is older than 5 minutes-- "

          For Each file in objFolder
              If (recentFile is Nothing) Then
          Set recentFile = file
          ModDateTime = file.DateLastModified
              ElseIf (file.DateLastModified > recentFile.DateLastModified) Then
          Set recentFile = file
          ModDateTime = file.DateLastModified
              End If
          Next

          strMessage = strMessage & "  --The most recent file " & recentFile.Name & " has a DateLastModified of " & ModDateTime & "--  "

          If recentFile is Nothing Then
          strMessage = strMessage & " ---" & Date & " " & Time & " CRITICAL: There are no files in the directory " & strUNCPath & "!"
          WScript.Echo "Message: " & strMessage & VbCrLf
          WScript.Echo "Statistic: 3"
          WScript.Quit(3)
          Else
          DiffMinutes = DateDiff("n", ModDateTime, StartDateTime)
          ' strMessage = strMessage & "  --The most recent file " & recentFile.Name & " is " & DiffMinutes & " Minutes old.--"
          If DiffMinutes > 5 Then
            strMessage = strMessage & " ------" & Date & " " & Time & " ERROR:  The most recent file " & strUNCPath & "\" & recentFile.Name & " is OLDER THAN 5 MINUTES OLD so you need to check ControlM operations and verify PROCID logfiles are getting generated regularly!-----  "
            WScript.Echo "Message: " & strMessage & VbCrLf
            WScript.Echo "Statistic: 3" & VbCrLf
            WScript.Quit(3)
          Else
            strMessage = strMessage & "  --" & Date & " " & Time & " NORMAL:  The most recent file " & strUNCPath & "\" & recentFile.Name & " is " & DiffMinutes & " Minutes old which is less than the threshold of >5 Minutes"
            WScript.Echo "Message: " & strMessage & VbCrLf
            WScript.Echo "Statistic: 0" & VbCrLf
            WScript.Quit(0)
          End If
          End If

          -------------------end VBScript  to Check the Age Of Most Recent File In Directory----------------------