Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
NTPsec
ntpsec
Commits
7226de82
Commit
7226de82
authored
Sep 09, 2016
by
Eric S. Raymond
Browse files
Code reuse - teach ntptrace to use ntp.util.
parent
1a7fed9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
docs/includes/ntptrace-body.txt
View file @
7226de82
...
...
@@ -12,11 +12,16 @@
== DESCRIPTION ==
+ntptrace+ is a python script that uses the {ntpq} utility program to follow
the chain of NTP servers from a given host back to the primary time
source. For ntptrace to work properly, each of these servers must
+ntptrace+ is a python script that uses the {ntpq} utility program to
follow the chain of NTP servers from a given host back to the primary
time source.
For +ntptrace+ to work properly, each of these servers must
implement the NTP Control and Monitoring Protocol specified in RFC 1305
and enable NTP Mode 6 packets.
and enable NTP Mode 6 control packets. Nowadays it is usual for
public timeservers to disable Mode 6 queries, so this script is
unlikely to be very useful unless you have a collectioon of
specially-configured timeservers on your LAN.
If given no arguments, ntptrace starts with localhost. Here is an
example of the output from ntptrace:
...
...
ntptrace/ntp
0 → 120000
View file @
7226de82
../pylib
\ No newline at end of file
ntptrace/ntptrace
View file @
7226de82
...
...
@@ -17,7 +17,7 @@ import re
import
socket
import
subprocess
import
sys
import
ntp.util
def
get_info
(
host
):
info
=
ntp_read_vars
(
0
,
[],
host
)
...
...
@@ -84,21 +84,6 @@ def ntp_read_vars(peer, vars, host):
return
outvars
def
do_dns
(
hostname
):
try
:
ai
=
socket
.
getaddrinfo
(
hostname
,
None
,
0
,
0
,
0
,
socket
.
AI_CANONNAME
)
except
socket
.
gaierror
as
e
:
print
(
'getaddrinfo failed: %s'
%
e
.
strerr
,
file
=
sys
.
stderr
)
raise
SystemExit
(
1
)
(
family
,
socktype
,
proto
,
canonname
,
sockaddr
)
=
ai
[
0
]
try
:
name
=
socket
.
getnameinfo
(
sockaddr
,
socket
.
NI_NAMEREQD
)
except
socket
.
gaierror
:
return
canonname
.
lower
()
return
name
[
0
].
lower
()
usage
=
r
"""ntptrace - Trace peers of an NTP server.
USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
...
...
@@ -148,7 +133,7 @@ while True:
break
if
not
numeric
:
host
=
do
_dns
(
host
)
host
=
ntp
.
util
.
canonicalize
_dns
(
host
)
print
(
"%s: stratum %d, offset %f, synch distance %f"
%
(
host
,
int
(
info
[
'stratum'
]),
info
[
'offset'
],
info
[
'syncdistance'
]),
end
=
''
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment