|Re: [chrony-users] Python code to read chronyc sources|
[ Thread Index |
| More chrony.tuxfamily.org/chrony-users Archives
On Thu, Apr 07, 2016 at 08:58:40AM -0700, Deven Hickingbotham wrote:
> Does anyone have a Python 3 example of how to read chronyc sources? I want
> to read the estimated error of the synced server.
If you can use chronyc compiled from git, there is a new CSV mode
suitable for parsing. To print the last column (in seconds) of the
source that has the '*' state using a python3 one-liner:
$ chronyc -c sources | python3 -c 'import csv,sys; print("".join([s
if s == "*" else "" for s in csv.reader(sys.stdin)]))'
If you need the maximum assumed error of the local clock, it's
better to calculate the root distance from the tracking report:
$ chronyc -c tracking | python3 -c 'import csv,sys; t = list(csv.reader(sys.stdin)); print(float(t) / 2 + float(t))'
Parsing the normal sources output with conversion of the units is
painful. I don't know if anyone did that in python. The tracking
output should be easier to parse.
To unsubscribe email chrony-users-request@xxxxxxxxxxxxxxxxxxxx
with "unsubscribe" in the subject.
For help email chrony-users-request@xxxxxxxxxxxxxxxxxxxx
with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.