Time synch monitoring


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Time synch monitoring
# 1  
Old 12-22-2016
Time synch monitoring

I'm using a debian variant. My system clock already auto synchronizes. I'd like to have some sort of alert or log entry if the time is ever off by more than a particular amount. My first choice is to have a new file created on the desktop each day that there is a slip greater than the specified time.

Can anyone suggest how to go about this?
# 2  
Old 12-22-2016
You can look at the last line of output from ntpdate -d which gives you the offset from the time servers defined either on the command line on in /etc/ntp.conf

Does that help?



Robin
# 3  
Old 12-22-2016
Filename drift - don't know Debian but it should be in the same directory tree as some other ntp files. It can be named drift or ntp.drift. Some systems have it in /etc/[something] other have it in /var/lib/ntp It gives you an estimate of your computer's clock accuracy - what it is try to correct. The values are ppm. Not seconds.
So, in an 86400 second day 10ppm is 864ms per day correction required. What this means is that ntp has had to add or subtract (if negative) that amount averaged over days of uptime. If you reset file the drift file every day
Code:
echo " `date`  `cat /etc/ntp/ntp.drift`" > /someplace/somelogfile
> /etc/ntp/ntp.drift

you get an approximation of the corrections going on for that day.

If you check the file periodically and find major changes (you decide the definition of major) you can report a problem.

Now. Locality of the time server, network, local cpu, and the stratum of your time server all affect accuracy. You should have a single server in your network that connects to a known lower stratum time server. If your time server is in house and NOT going outside, good luck with correct time. If this is for legal purposes, like records you keep and report to external agencies, correct time has to be in order.

If this is scientific or research timing between systems, especially logging boxes, is very important. Correct time as defined by an external arbiter is not usually a big deal.

What do you need? Going for a really tiny discrepancy in the drift file is not usually required.

Last edited by jim mcnamara; 12-22-2016 at 01:27 PM..
# 4  
Old 12-24-2016
If you're running ntp for synchronisation, you can use this command:
Code:
ntpq -n -c peers

Resulting in this at my host:
Code:
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
-46.101.140.169  192.53.103.104   2 u  934 1024  377    1.185    5.395   0.463
*31.172.86.173   192.53.103.108   2 u  833 1024  377    0.908    0.278   0.095
+176.221.42.125  109.229.128.40   3 u  439 1024  377    4.442    0.542   1.656
+85.236.36.4     192.53.103.108   2 u  817 1024  377    6.313    0.926   0.267

The line with the asterisk is the server selected for synchronisation. The second last value is supposedly what you like to have: Offset from source.

If you do use some other software to synchronize, there will be other commands to get the offset. E. g. for chrony it's chronyc tracking.

A more general way would be using ntpdate -q on your timeserver to display the offset, without actually setting the time.
# 5  
Old 12-24-2016
stomp's approach is also valid for a lot of situations. In all cases you still need to tell us what you want.

You have three valid answers depending on context.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Red Hat

NTPD service restart and time synch

I am using ntpd service to sync our RHEL 5.9 system to synch with GPS clock. When I change the RHEL system time more than 7 seconds than the present system time (through "Datetime" command), ntpd service does not adjust the system time to the present GPS time.But if the time is with in 7 seconds,... (6 Replies)
Discussion started by: Anjan Ganguly
6 Replies

2. Shell Programming and Scripting

Process monitoring for a fixed time

Hi Gurus, I have a scenario where i need to monitor for a process which starts at a particular time. I need to check if the process has started at the specified time and keep checking this for 5 minutes only and then want to alert me. ps -ef | grep -i process.sh | grep -v grep >... (5 Replies)
Discussion started by: jayadanabalan
5 Replies

3. Shell Programming and Scripting

how to synch 2 processes to start at the same time

Hey Excuse me if this question is repeated everywhere but I am still new with scripting and I couldn't apply what I found to my case :confused::confused: I am trying to run a rec process on a ssh client and at the same time play a file from my computer so i tried this #!/bin/bash echo... (3 Replies)
Discussion started by: Antaha
3 Replies

4. Shell Programming and Scripting

Monitoring a users log in time?

how do i start with this guys? Sample run: $ LOGTIME it2015678 <enter> User it2015678 is CRUZ Tommy H And has logged on to the system for: 8 hours 12 minutes from the time this script was run. (1 Reply)
Discussion started by: skypigeon
1 Replies

5. Shell Programming and Scripting

How to stop monitoring of servers at the time of reboot through shell scripting?

We have number of servers which belongs to platforms Solaris, AIX,HP-UX and LINUX. Monitoring tool 'Patrol Agent' process run on the servers to check for the server health and communicate with the Patrol server through the port 5181. During scheduled reboot and maintenance of servers we do receive... (1 Reply)
Discussion started by: subharai
1 Replies

6. Shell Programming and Scripting

Synch only directory sturcture- Help

Hi All, I am trying to synchronize two folders(test and test1) using rsync. "test" has some sub folders and all of the have some files also. I just want to sync the directory structure not the files in the first folder with the second. i tried the following script. rsync -av --include '*/'... (5 Replies)
Discussion started by: Tuxidow
5 Replies

7. Shell Programming and Scripting

Monitoring system available time

Hi, I am new to Unix. I have an application which i need to monitor it for the available system time. If the system is down, i need to send an email notifying the downtime. Can someone provide a sample code or shell script to perform the above activity. Thanks (3 Replies)
Discussion started by: borncrazy
3 Replies

8. HP-UX

Scripts for monitoring real time for the error code

Hi ! I wish extract one information(error code) from the machine which is running on the HP-UX platform. Can anyone help me? Wanted to write a scripts that monitor real time at the error code and transfer the information out from the machine. The information is then process and SMS out to the... (9 Replies)
Discussion started by: JOHNSON
9 Replies
Login or Register to Ask a Question