Ks Tan (Asia Vad) asked a question.

Script to monitor presence of new file as Up Condition

Client uses vendor solution, include Cisco, Palo Alto, Checkpoint, to handle the network and firewall device backup configuration and store it at shared folder.

Script below, to check the presence of new file in last 1 day, as Up criteria that the backup is executed correctly.

  1. 'Script created to monitor presence of new files, to assess timely and correct execution of backup job.
  2. 'Created by Kstan, Asia Vad.
  3. Set FSO = CreateObject("Scripting.FileSystemObject")
  4. ' Please update it to monitor other backup shared folder
  5. Set Folder = FSO.GetFolder("\\AsiaVADBackupSvr\PaloAlto\")
  6. Set FileList = Folder.Files
  7. Numfiles = 0
  8. For Each File in FileList
  9. On Error Resume Next
  10. ' To look for file less than 1 day old.
  11. ' The logic can be modified to greater sign, to look for files older than X days, or X minutes, if argument change from d to n for minutes, and h for hours.
  12. If DateDiff("d", File.DateLastModified, Now) < 1 then
  13. NumFiles = Numfiles + 1
  14. Else
  15. End If
  16. Next
  17.  
  18. If NumFiles >= 1 Then
  19. Context.SetResult 0, "New backup files less than 1 day old, present in backup directory. Backup job is done correctly."
  20. Else
  21. Context.SetResult 1, "Backup job didn't happen, please check the backup task!"
  22. End If