Commit bb50bb7a by Bilal Ahmad

addressing comments

parent c9b01e68
......@@ -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"
{{ ecommerce_log_dir }}/*.log {
{{ COMMON_LOG_DIR }}/ntp.log {
compress
dateext
dateformat -%Y%m%d-%s
......
#!/bin/bash
log_directory={{ ecommerce_log_dir }}
log_directory={{ COMMON_LOG_DIR }}
reach=$(ntpq -c associations | awk '{print $5}' | grep yes)
if [[ ${reach} == *"no"* ]]; then
echo "NTPD not synchronized - Please investigate" >> ${log_directory}/ntp.log
echo $(date -u) "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 "An NTPD offset is excessive - Please investigate" >> ${log_directory}/ntp.log
echo $(date -u) "An NTPD offset is excessive - Please investigate" >> ${log_directory}/ntp.log
exit 1
fi
done
......@@ -204,7 +204,6 @@ ECOMMERCE_GUNICORN_WORKER_CLASS: "gevent"
#
ecommerce_service_name: "ecommerce"
ecommerce_user: "{{ ecommerce_service_name }}"
ecommerce_group: "{{ ecommerce_service_name }}"
ecommerce_home: "{{ COMMON_APP_DIR }}/{{ ecommerce_service_name }}"
ecommerce_code_dir: "{{ ecommerce_home }}/{{ ecommerce_service_name }}"
ecommerce_venv_dir: "{{ ecommerce_home }}/venvs/{{ ecommerce_service_name }}"
......
......@@ -226,25 +226,3 @@
tags:
- manage
- manage:start
- name: Add ntp alert script
template:
src: "edx/app/ecommerce/log-ntp-alerts.sh.j2"
dest: "{{ ecommerce_home }}/log-ntp-alerts.sh"
owner: "{{ ecommerce_user }}"
group: "{{ ecommerce_group }}"
mode: "0755"
- name: Set up a cron job to run the script
cron:
name: "log-ntp-alerts"
job: "{{ ecommerce_home }}/log-ntp-alerts.sh >/dev/null 2>&1"
- name: install logrotate configuration
template:
src: etc/logrotate.d/ecommerce.j2
dest: /etc/logrotate.d/ecommerce
tags:
- "install"
- "install:configuration"
- "logrotate"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment