You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
Write-PrtgLog: safe, timestamped file logging for sensor debugging. One log file per
sensor invocation (<scriptname>_<timestamp>_<PID>.log), so a failing run is one
self-contained file and concurrent runs never interleave. Defaults to %ProgramData%\PrtgSensorKit\Logs\<scriptname>\; old run files are pruned
automatically (newest 30 kept). Never throws, never touches stdout - logging can never
turn a green sensor red.
Invoke-PrtgSensor -EnableLogging (with optional -LogPath and -MaxLogs): opt-in
lifecycle logging via Write-PrtgLog - sensor start, each retry, a success summary,
and on failure the full error details (exception type, message, script line, stack
trace) that PRTG's one-line error text flattens away. -LogPath and -MaxLogs
require the switch; a relative -LogPath resolves against the script's folder.
(Examples/23)
Use-PrtgCachedResult: share one expensive call (REST response, SQL query, WMI sweep)
across all sensors on a machine. Memoizes the script block's result with a TTL
(-MaxAge), holding the state lock across check + fetch + write so concurrent sensors
cannot stampede the source: exactly one fetch per expiry, guaranteed. Cache entries
are ordinary sensor state (Get-PrtgSensorState inspects them,. Clear-PrtgSensorState clears them).
(Examples/24)
Sensor doctor: three new script checks. PSK0011 warns when a script contains
non-ASCII bytes without a BOM (Windows PowerShell 5.1 reads BOM-less files as ANSI
and silently mangles umlauts under PRTG). PSK0012 reminds that channel limit values
are snapshotted when the sensor is first created. PSK0013 reminds that DPAPI secrets
only decrypt under the account that saved them when Get-PrtgSecret is used.
Integration sensors for the new features: working/17 (lifecycle logging to the
default folder under the probe account), working/18 (shared cache across multiple
deployed sensors), and malformed/19 (BOM-less non-ASCII fixture the Doctor flags as
PSK0011 and PRTG displays as mojibake).
Fixed
Get-PrtgSensorState -Latest (and the cache hit path of Use-PrtgCachedResult) could
return an OLDER entry when two saves landed within the clock resolution of [DateTime]::UtcNow (~15 ms on Windows PowerShell 5.1) and their timestamps tied.
Ties now resolve to the last-appended entry.
Changed
Documentation restructured: the README now covers install, quickstart, and navigation;
per-topic detail moved to Docs/ (installation, channels, runtime hosts, secrets,
state, shared cache, logging, resilience, debugging, low-level output). The doctor's
PSK0013 recommendation points at Docs/secrets.md accordingly.
README: the debug tip now shows Write-PrtgLog instead of hand-rolled Add-Content;
the parameterized sensor example now reminds to quote PRTG placeholders
(-DeviceName '%device').