Kaseya Community

Script to monitor clock time

  • I'm gonna make one modification for desktops as they don't need really Allsync (/syncfromflags:manual,domhier), laptops on the otherhand can benefit from it :)

  • I just imported this script and will be testing it before deployment, but so far it works great! After some testing and if I don't find any issues I will probably run this against all my servers. I also went through and created a filter view to filter by the state of the custom field Time Offset, so I can in one view see all servers with a time drift, which is very usefull for me as we work with so many different clients with distinct architectures and individual issues.

    We also do a lot of Mac support, so I think I will have my Mac engineer give me the equivalent bash command to:

    w32tm /monitor /computers:us.pool.ntp.org

    and see if I can apply the parsing methodology of:

    | find "NTP:" >> #vAgentConfiguration.agentTempDir#\offset.txt & for /f "tokens=2 delims=+-." %a IN (#vAgentConfiguration.agentTempDir#\offset.txt) DO ECHO %a

    If I get it I will post it here.


  • I just cobbled the following command sequence together, which works on my Mac:

    ntpdate -q pool.ntp.org | head -1 | awk -F '[, -]+' '{print int($6)}'

  • Joelby,

    I tested that and it and kept getting 0 even when my time was wrong. Turns out we want column 4, not 6. Column 6 is the delay in receiving a reply, column 4 is the offset in seconds.

    ntpdate -q pool.ntp.org | head -1 | awk -F '[, -]+' '{print int($4)}'

    I will test it as a kaseya script now.

  • That's interesting - there are probably different versions of ntpdate around that will give different output, which makes things pretty difficult to generalise. Here's my complete ntpdate -q output. ntpdate version 4.2.6@1.2089-o on OS X 10.8.2.

    $ ntpdate -q pool.ntp.org

    server, stratum 2, offset -5.888698, delay 0.06490

    server, stratum 2, offset -5.889684, delay 0.06468

    server, stratum 2, offset -5.869253, delay 0.07738

    server, stratum 3, offset -5.868639, delay 0.09471

    19 Dec 09:06:47 ntpdate[35868]: step time server offset -5.889684 sec

    You could probably use awk to check for a token called 'offset' and then use the next token after that.

  • Okay, this is getting a bit more out there:

    ntpdate -q pool.ntp.org | head -1 | awk -F '[, -]+' '{ for (i=1;i<=NF;i++) { if ($i ~ /offset/) { print $(i+1) }  } }'

  • Hi there thanks for posting this but im seeing Script Summary: Failed THEN in Step 6 (Line 28) for NTP:Fix Time

    And Script Summary: Failed THEN in step 2 (Line 4) for NTP:Get Offset

    I tried creating a custom field "Time Offset" as a string (wasn't sure what type it should be eg date/time, or number etc..)

    I tried executing on a SBS 2011 server both physical and virtual and they both produce the same failure message above.  

    If they are UK based should we be changing the pool location from us.pool to time.windows.com?

    Can you help the reason we need this is for Hyper V virtual servers time speeding up over a period.

    [edited by: Daniel at 5:35 AM (GMT -7) on Apr 8, 2014]
  • Daniel,

    the custom field in question is a Kaseya agent info custom field, not a variable in the script.

    go to: audit -> system info -> new custom field (at the top)

  • I do not recommend using time.windows.com in any part of the world. It is very unreliable. For the UK, I suggest using uk.pool.ntp.org

  • I agree with SMason. For the U.S. I use time.nist.gov