Hello,
Is there any way for us to monitor system time with APM, and issue warnings if time drift > x, for example?
Best Regards,
Simon
If you read how to check if NTP adjusted system time on Linux? - Super User
you find there is a file named /var/lib/ntp/drift.
It contains the amount of drift that your system is experiencing.
Combine that with the following:
and you could have a viable NTP SAM template.
Have you tried using one of the following Application Template?
Server Clock Drift (PowerShell)
Server Clock Drift (Perl)
Much better answer than mine. I should look @ the available templates more often.
I just put the Server Clock Drift (Perl) template on 40 servers and found 1 out of sync.
Sorry, I'm missed to follow up entirely since my post. I'll get on this asap. Thank you.
Rgrds,
Hi again,
I'm kind of struggling with the poweshell template at the moment. I'm experiencing som kind of reliability issue. It worked fine on the first try, so I made a copy of it but as I tested it again after changing a few parameters (credentials + string arguments) I started getting errors. So I went back to the default template and then it worked again during a few test runs, but as I started assigning the monitor, it stopped working again although nothing has been changed to the template. Seems to occur sporadic. This is the error I get from time to time:
Output: ==============================================
Message: Try to rerrun script. Error: Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
Errors: ==============================================
Exception calling "Connect" with "2" argument(s): "No connection could be made because the target machine actively refused it 216.171.120.36:13"
At line:5 char:20
+ $TcpClient.Connect <<<< ($time_server, 13)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Exception calling "GetStream" with "0" argument(s): "The operation is not allowed on non-connected sockets."
At line:6 char:35
+ $TcpStream = $TcpClient.GetStream <<<< ()
You cannot call a method on a null-valued expression.
At line:7 char:27
+ $length = $TcpStream.Read <<<< ($buffer, 0, $buffer.Length);
+ CategoryInfo : InvalidOperation: (Read:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:10 char:24
+ [DateTime]::ParseExact <<<< ($raw.SubString(7,17), 'yy-MM-dd HH:mm:ss', $null).toLocalTime()
Any idea?
Have you downloaded the latest version of this template from the Thwack Content Exchange, or are you using the one that was included out-of-the-box? I suggest deleting the template entirely, downloading the one available here -> Server Clock Drift (PowerShell) and see if that works better for you.
No, I've used the native template until now. Ok, so I've imported the updated template in your URL, but that one throws me RPC errors instead. Have I missed any prereqs? The target is a standalone server and those usually don't respond that well to WMI in my experience. (I've x'd out the credentials below.)
Message: Unable to Get-WmiObject Win32_UTCTime
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:15 char:42
+ $remoteServerTime = Get-WmiObject <<<< Win32_UTCTime -ComputerName 192.168.xx.x -Credential xxxxxx;
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Get-Date : Cannot validate argument on parameter 'Year'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
At line:23 char:66
+ $remoteToSolarSkew = New-TimeSpan $localTime $(Get-Date -year <<<< $remoteServerTime.Year -month $remoteServerTime.Month -day $remoteServerTime.Day -hour $remoteServerTime.Hour -minute $remoteServerTime.Minute -second $remoteServerTime.Second);
+ CategoryInfo : InvalidData: (:) [Get-Date], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetDateCommand
New-TimeSpan : Cannot bind parameter 'End' to the target. Exception setting "End": "Object reference not set to an instance of an object."
At line:23 char:38
+ $remoteToSolarSkew = New-TimeSpan <<<< $localTime $(Get-Date -year $remoteServerTime.Year -month $remoteServerTime.Month -day $remoteServerTime.Day -hour $remoteServerTime.Hour -minute $remoteServerTime.Minute -second $remoteServerTime.Second);
+ CategoryInfo : WriteError: (:) [New-TimeSpan], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.NewTimeSpanCommand
It sounds as though WinRM has not been configured on the remote node. Ensure that PowerShell 2.0 is installed/enabled on that host and that WinRM has been configured.
1. On the Orion SAM server, open a command prompt as an Administrator. To do this, perform the following step:
· Go to the Start menu and right-click cmd.exe and then select Run as Administrator.
2. Enter the following in the command prompt: winrm quickconfig winrm set winrm/config/client @{TrustedHosts="*"}
3. On the target server, open a command prompt as an Administrator and enter the following: winrm quickconfig winrm set winrm/config/client @{TrustedHosts="IP_ADDRESS"}
where IP address is the IP address of your SAM server.