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

size of single multiple files in one sensor possible?

Votes:

0

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

file-monitoring files snmp-sensor

Created on Aug 3, 2018 9:49:19 AM



2 Replies

Accepted Answer

Votes:

5

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

Created on Aug 3, 2018 6:42:27 PM

Last change on Aug 6, 2018 4:24:39 AM by  Luciano Lingnau [Paessler]



Votes:

0

Thank you for sharing your script, Florian.

Kind regards,

Erhard

Created on Aug 6, 2018 11:14:55 AM by  Erhard Mikulik [Paessler Support]




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.