Submit a ticketCall us

AnnouncementsChange Is Inevitable

Get valuable help when it comes to tracking and monitoring changes. SolarWinds® Server Configuration Monitor (SCM) is designed to help you: detect, track, and receive alerts when changes occur, correlate system performance against configuration changes, compare server and application configuration against custom baselines, and verify application and system changes.

Learn more.

Home > Success Center > Server & Application Monitor (SAM) > SAM - Knowledgebase Articles > Server Clock Drift Template Fails on Agent Node in SAM

Server Clock Drift Template Fails on Agent Node in SAM

Updated January 2, 2018

Overview

This article details a resolution in regards to the failure of the "Server Clock Drift (PowerShell)" template to run on the Agent Node in SAM when the default polling method is set to "Agent".

 

Environment

  • SAM 6.4 or later

Cause 

The following command works correctly only for agentless polling:

$remoteServerTime = Get-WmiObject Win32_UTCTime -ComputerName $

{IP}

-Credential $

{CREDENTIAL}

;

 

On an Agent node, the command fails because these credentials cannot be used for a local connection.

Resolution

You can use a simpler script that receives the clock drift directly from the NTP server without the complicated mathematics necessary for remote polling:

$ntpServer = $args.get(0);
if (!$ntpServer)
{
    Write-Host "Message: Can't find ""ntpServer"" argument. Check documentation.";
    exit 1;
}
$ntpQuery = Invoke-Expression "w32tm /monitor /computers:$ntpServer" | Out-String;
$findSkew = [regex]"(?:NTP\: )(?<Value>[^s]+)";
if ($ntpQuery -match $findSkew)
{
    $ntpToLocalSkew = [double]::Parse($Matches['Value'])
    $roundedSkew = [math]::Round($ntpToLocalSkew, 2)
    Write-Host "Message: Clock drift: ${roundedSkew}s"
    Write-Host "Statistic: $([math]::Abs($roundedSkew))"
    exit 0
}
else
{
    Write-Host "Message: Unable to query NTP server $ntpServer."
    exit 1
}

If you need to contact Support about this issue, be sure to provide full logs from the main poller as well as the agent. Configure logging to increase the number of files to gather logs for a longer period of time for observation purposes.

 

 

Last modified

Tags

Classifications

Public