When using a file sensor (Last Modified) on Server 2008 it's not getting the true last modified timestamp. On Server 2003 the last modified file sensor works great. I believe server 2008 changed the NTFS behavior to reduce disk I/O.
Using SMB or even locally on the server, the file doesn't show it's been updated (time stamp) if you refresh (F5) using windows explorer then the timestamps are updated locally and through SMB.
So PRTG doesn't report the true timestamp unless someone is refreshing the directory.
Any ideas on howto correct this problem?
Article Comments
We are using the normal file sensor.
You have to emulate a program which keeps a log file open and writes updates to it.
Below is a VBS script that duplicates the problem. PRTG can't detect the log file has been updated. I can't try using a local PRTG machine as our install is on Server 2003. We are using the file sensor pointing to a network share on a Windows 2008 Server.
The VBS script creates a file (C:\temp\LogTest.txt) and writes a timestamp into the file every 10 seconds.)
CreateLog.vbs ---------------------------- Dim myFSO, WriteStuff Set myFSO = CreateObject("Scripting.FileSystemObject") Set WriteStuff = myFSO.OpenTextFile("c:\temp\LogTest.txt", 8, True) For count = 0 to 2000 WriteStuff.WriteLine(Now) WScript.Sleep 10000 Next ----------------------------
Apr, 2011 - Permalink
Are the changes also really saved to the file on disk then? Can you try a remote probe to enable local access on the Windows 2008 Server?
Apr, 2011 - Permalink
Yes they are saved to the disk. Using a probe installed on the Server 2008 box, the WMI file sensor does work.
The normal file sensor through SMB from another probe doesn't work. (Timestamps not be updated) - From what I've read this is to reduce disk I/O by design in Server 2008.
My workaround was to create a PowerShell script to monitor the file (not from a local probe).
Here is the powershell for anyone else:
Sensor Properties: Parameters: c:\temp\file.txt OR \\server\share\file.txt (You can use local dir or UNC) Results: Returns the age in seconds. Always returns OK. You need to setup channel limits for up/down status. ------------------ FileSensorLastModified.ps1 $a = New-TimeSpan $(Get-Date((gci $args).LastWriteTime)) $(Get-Date) $result = ("{0:F0}" -f $a.TotalSeconds).ToString() + " :OK" echo $result
Apr, 2011 - Permalink
I'm missing
WriteStuff.Close set WriteStuff = nothing set myFSO = nothing
in the example above, that might explain why the file is not written to disk and changes to the file are simply kept in memory.
Apr, 2011 - Permalink
I found this article explaining the behavior mentioned above.
It seems that getting the file date from a dir listing is not always going to work as expected with 2008. Getting the file date from the file itself should work however and that is exactly what Benjamin's script does!
Apr, 2011 - Permalink
Dear Benjamin,
are you using the "normal" File Sensor or the WMI File Sensor? However it seems we can't reproduce this here, at least not with local files on a PRTG machine.
Best regards.
Apr, 2011 - Permalink