What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Can I create sensor to compare the data created with the previous day

Votes:

0

I need to compare the "data created" stamp of a file, with the previous day time stamp. If the "data created" stamp an the previous day don't match, the sensor shall warn

data-created date prtg time-stamp

Created on Jan 20, 2015 11:38:15 AM



1 Reply

Accepted Answer

Votes:

9

If the purpose of such a sensor would be check if a file has been changed, we've created a sensor to check a file against a static hash in order to tell if its content has been touched. The script uses PowerShell to check files on Windows systems via CIFS share. Maybe the script can provide a basis for a sensor for your purpose:

param (
	[string]$share = $(throw "-share missing"),
	[string]$path = $(throw "-path missing"),
	[string]$hash = $(throw "-hash missing"),
	[string]$user = "",
	[string]$pass = "",
	[string]$algo = "SHA256"
)

$ret = 0
try
{
	$pw = ConvertTo-SecureString $pass -AsPlainText -Force
	$cred = New-Object System.Management.Automation.PSCredential($user, $pw)
	$null = New-PSDrive -Name tmp_hashcmp -PSProvider FileSystem -Root $share -Credential $cred
}
catch
{
	Write-Host "<prtg><error>1</error><text>"$_.Exception.Message"</text></prtg>"
	Return
}

$filepath = $share + "\" + $path
$filehash = (Get-FileHash -Algorithm $algo $filepath).Hash
Remove-PSDrive -Name tmp_hashcmp

if ($filehash -eq $hash)
{
	$ret = 1
	$msg = "File hash matches expected value"
}
else
{
	$msg = "File hash is '" + $filehash + "', expected '" + $hash + "'"
}
Write-Host "<prtg><result><channel>"$path"</channel><value>"$ret"</value><valuelookup>prtg.ages.filehash.matchok</valuelookup></result><text>"$msg"</text></prtg>"

Created on Jan 20, 2015 1:25:54 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.