Forum Discussion

A_Olvera's avatar
11 years ago

how to monitor a UNC path to make sure a new file is added to the folder at 10am everyday.

I need to monitor a UNC path to make sure a new file is added to the folder at 10am everyday. How can I set LogicMonitor to alert us when a new file has NOT been added to the folder at 10am?

thanks

  • Alex I do something similar. I wrote a powershell script that performs the check for me. Now you have two ways to do this.

    One is to run the powershell script on the server(s) in question via scheduled task and have it write to the event log if the file is not there. Logic Monitor will pick this up and report it. This works pretty good if you are only needing to do this a small number of servers.

    The second is to have your powershell accept the server name on a command line and return some value if the server does not contain the file in question. Then create a datasource based on the powershell script and have it pass the Host name to the script and error if the return value is x. This works well if you have lots of systems you want to check. The downside is I am not sure you can schedule it to run exactly at 10:00 in this method. You easily can have it run one a day though.

  • Does anyone has any readymade datasource available? If so can you please share?

  • I don't specifically have a ready made one, but if you make a DS that "AppliesTo" a system.hostname=="oneOfYourCollectors" (make sure it's in the same domain as the resource with the UNC path you want to check).  Then something like:

    if ( test-path "\\servername\C$\Path\To\File.txt" ) { write-output "1" } else { write-output "0" }

    as a powershell script should do the trick.

  • My ability to edit the previous post timed out (annoying)... here's the final thing I was going for:

    if (get-date -format HH -eq 10) {
      if ( test-path "\\servername\C$\Path\To\File.txt" ) {
        write-output "1"
      } else {
        write-output "0"
      }
    }

    Just checks the 24hr Hour to see if it's 10.  Have it fire once an hour.