Applications Systems
SAM Server Clock Drift (PowerShell) template returns scripting error if clock drift is small, negative number
If the clock drift is a small negative number, the SAM Server Clock Drift (PowerShell) template returns an invalid result, the application monitor shows an Unknown status and the following message may appear: Scripting Error: Script does not contain the expected parameters or is improperly formatted. 'Statistic' missing.
First published date
Last published date
Overview
Product section
Cause
$Skew = $remoteToSolarSkew.TotalSeconds - $ntpToSolarSkew;
$symb=$Skew.ToString().Substring(0,1);
if ($symb -eq "-")
{
$stat=[math]::round($Skew,2);
$tmp=$stat.ToString().Remove(0,1);
Write-Host "Message: Clock drift: $stat.";
Write-Host "Statistic: $tmp";
exit 0;
}
else
{
$stat=[math]::round($Skew,2);
Write-Host "Message: Clock drift: $symb $stat s.";
Write-Host "Statistic: $stat";
exit 0;
}
For example, if the $Skew is -0.001, the returned script will look like this:
Message: Clock drift: 0. Statistic:
Resolution
If you began using an earlier version of SAM, note that only AppInsight templates are updated automatically during upgrades. Standard SAM templates like Server Clock Drift are not updated to avoid overwriting custom changes.
To resolve this issue, you can either:
- Download the updated template from THWACK at https://thwack.solarwinds.com/docs/DOC-166983. For details, see Import and export SAM templates.
- Update the template/application monitor with the following code:
$Skew = $remoteToSolarSkew.TotalSeconds - $ntpToSolarSkew;
$stat=[math]::round($Skew,2);
$symb=$stat.ToString().Substring(0,1);
if ($symb -eq "-")
{
$tmp=$stat.ToString().Remove(0,1);
Write-Host "Message: Clock drift: -$tmp s.";
Write-Host "Statistic: $tmp";
exit 0;
}
else
{
Write-Host "Message: Clock drift: $stat s.";
Write-Host "Statistic: $stat";
exit 0;
}