Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
598db995
Commit
598db995
authored
Aug 12, 2016
by
Bilal Ahmad
Committed by
GitHub
Aug 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3298 from edx/bilalahmad99/ntp_alert
adding logs if ntp is out of sync for [OPS-1395]
parents
5410d5e4
e67c05b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
playbooks/roles/common/tasks/main.yml
+22
-0
playbooks/roles/common/templates/etc/logrotate.d/ntp.j2
+8
-0
playbooks/roles/common/templates/log-ntp-alerts.sh.j2
+16
-0
No files found.
playbooks/roles/common/tasks/main.yml
View file @
598db995
...
...
@@ -158,3 +158,25 @@
state
:
restarted
become
:
True
when
:
config_templates.changed
-
name
:
Add ntp alert script
template
:
src
:
"
log-ntp-alerts.sh.j2"
dest
:
"
{{
COMMON_BIN_DIR
}}/log-ntp-alerts.sh"
owner
:
root
group
:
root
mode
:
"
0755"
-
name
:
Set up a cron job to run the script
cron
:
name
:
"
log-ntp-alerts"
job
:
"
{{
COMMON_BIN_DIR
}}/log-ntp-alerts.sh
>/dev/null
2>&1"
-
name
:
install logrotate configuration
template
:
src
:
etc/logrotate.d/ntp.j2
dest
:
/etc/logrotate.d/ntp
tags
:
-
"
install"
-
"
install:configuration"
-
"
logrotate"
playbooks/roles/common/templates/etc/logrotate.d/ntp.j2
0 → 100644
View file @
598db995
{{ COMMON_LOG_DIR }}/ntp.log {
compress
dateext
dateformat -%Y%m%d-%s
missingok
daily
rotate 3
}
playbooks/roles/common/templates/log-ntp-alerts.sh.j2
0 → 100644
View file @
598db995
#!/bin/bash
log_directory
={{
COMMON_LOG_DIR
}}
reach
=
$(
ntpq
-c
associations | awk
'{print $5}'
|
grep
yes
)
if
[[
${
reach
}
==
*
"no"
*
]]
;
then
echo
$(
date
-u
)
$(
hostname
)
"NTPD not synchronized - Please investigate"
>>
${
log_directory
}
/ntp.log
fi
limit
=
100
# limit in milliseconds
offsets
=
$(
ntpq
-nc
peers | tail
-n
+3 | cut
-c
62-66 | tr
-d
'-'
)
for
offset
in
${
offsets
}
;
do
if
[
${
offset
:-
0
}
-ge
${
limit
:-
100
}
]
;
then
echo
$(
date
-u
)
$(
hostname
)
"An NTPD offset with value
$offset
is excessive - Please investigate"
>>
${
log_directory
}
/ntp.log
exit
1
fi
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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