I've written some VBScript custom sensors for the PRTG monitoring software, and these use temporary files for various purposes within a given sensor run.
That's quite easy to do with:
dim filesys : set filesys = createobject("Scripting.FileSystemObject")
dim tempfolder : set tempfolder = filesys.getspecialfolder(2)
tempfspec = tempfolder.path & "\" & filesys.gettempname
and, I can simply create the tempfspec
file to use for whatever I want.
However, I have a need to store persistent state between runs of the sensor so a randomly named temporary file isn't going to do it.
How can I get a unique file name (I don't want mutiple sensors trying to use the same file) that's identical for a given sensor, any time that it runs?
From PRTG, pass your custom exe script the %sensorID varible. (Read more about PRTG varibles here: https://kb.paessler.com/en/topic/373-what-placeholders-can-i-use-with-prtg)
Then create a new file based on the sensor ID.