New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


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

Votes:

0

Your Vote:

Up

Down

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 by  n-komm (10) 1



1 Reply

Accepted Answer

Votes:

9

Your Vote:

Up

Down

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 by  ages (1,007) 5 1



Please log in or register to enter your reply.


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.