Hello,

Is there a skript out there where you can put multiple files in one sensor? The prtg filesensor only can show one file per sensor. I have 20 Database files and want to see the grow of each file in a graph, but dont want make one sensor for every one. There would be although a disadvantage by the adding and removing of a file. I can group them (e.g 5 files to one group etc.)

Thanks


Article Comments

Hi,

You could simply write a VBScript to accomplish this. See below, this is pretty variable and allows you to accomplish this.

'Execute:
'Argument 0 = amount of files
'Argument 1 to x = file-path in ""
'CheckMultipleFileSizes.vbs 2 "C:\path\file" "\\server\share\path\file"

Dim iFiles
Dim strPaths
Dim cnt

If WScript.Arguments.Count > 1 Then
	iFiles = WScript.Arguments.Item(0)
	For cnt = 1 To iFiles
		If Len(strPaths) > 0 Then
			strPaths = strPaths & "|&|"
		End If
		strPaths = strPaths & WScript.Arguments.Item(cnt)
	Next
Else
	Wscript.Echo "Usage: cscript CheckMultipleFileSizes.vbs 2 ""C:\path\file"" ""\\server\share\path\file"""
	Wscript.Quit
End If
 
Dim fs
Dim objFile
 
Dim strPathTemp

WScript.echo "<prtg>"
Set fs = CreateObject("Scripting.FileSystemObject")
	strPathTemp = Split(strPaths,"|&|")
	For cnt = 0 To UBound(strPathTemp)
		If fs.FileExists(strPathTemp(cnt)) Then
			Set objFile = fs.GetFile(strPathTemp(cnt))
			WScript.echo "<result>"
			WScript.echo "<channel>" & objFile.Name & "</channel><value>" & objFile.Size & "</value>"
			WScript.echo "</result>"
		End If
	Next
Set fs = Nothing
WScript.echo "</prtg>"

Will post this as well on my personal blog since it seems to be a valuable and pretty variable sensor.

Regards

Florian Rossmark

www.it-admins.com

EDIT: changed line 13 form If Len(strPath) > 0 Then to If Len(strPaths) > 0 Then


Aug, 2018 - Permalink

Thank you for sharing your script, Florian.

Kind regards,

Erhard


Aug, 2018 - Permalink