Skip to content
Snippets Groups Projects
Commit 90ef573a authored by Florent Thiery's avatar Florent Thiery
Browse files

support timedatectl for ntp test

parent 65fedeb6
No related branches found
No related tags found
No related merge requests found
......@@ -11,10 +11,17 @@ import subprocess
import imp
# Check that ntpd is synced
print('Running ntpq -pd')
ntpd_status = subprocess.getoutput('LANG=C ntpq -pd')
if 'remote' not in ntpd_status:
print('NTP not working, ntpq -p output:\n%s' % ntpd_status)
if os.path.isfile('/usr/bin/ntpq'):
cmd = "LANG=C ntpq -pd"
expected = "remote"
else:
cmd = "LANG=C timedatectl"
expected = 'NTP synchronized'
print("Running %s" % cmd)
status = subprocess.getoutput(cmd)
if expected not in status:
print('NTP not working: %s' % status)
sys.exit(1)
else:
print('System is NTP synchronized')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment