JP Vossen on 7 Jan 2014 15:04:34 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Quick & Dirty NTP monitoring

On 01/07/2014 06:52 AM, Jeremy Kister wrote:
On 1/4/2014 3:51 PM, JP Vossen wrote:
So...  Anyone have a better quick & dirty method for this?  And if not,
steal this one...

If your ntp server can't sync time, your test is actually doing it's job
by crying.  You can add some retries in there if you can't get the core
issue solved.

Well, yes and no. My original test was creating false positive email alerts. My new test stopped that, but in general I dislike seeing lots of timeouts. I think the root cause it folks locking NTP servers down after the attacked (which is overall a good thing).

The overall goal is just an out-of-band sanity check that NTP really is working across my network. This came out of some issues years ago with firewall rules (lack thereof), down daemons, etc.

I can't say better, but i'd use some perl to actually query the ntp. You
can jam it all on one line easily.

perl -MNet::NTP -e '
for($i; $i<3; $i++){
  if( $r{Stratum} <= 4 && $r{"Receive Timestamp"} >= time()-600 ){
  sleep 60;
print "error with ntp server\n" unless $s;'

I'd need to install 'libnet-ntp-perl' for that to work on my various Debuntu machines, and I'm not sure it gains me much more than this: ntptrace 2> /dev/null | head -n1 | perl -ne 'm/^[\w.]+: stratum (\d+),/ or next; print qq(NTP not in sync: $_) if ( $1 > 5 );'

(Note 'ntptrace' comes with NTP and is Perl without Net::NTP.)

Am I missing something?

Thanks for thinking about it,
JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --