diff --git a/playbooks/roles/cloud-launcher-cron/tasks/main.yaml b/playbooks/roles/cloud-launcher-cron/tasks/main.yaml index 628d032f5f..a0edcc0544 100644 --- a/playbooks/roles/cloud-launcher-cron/tasks/main.yaml +++ b/playbooks/roles/cloud-launcher-cron/tasks/main.yaml @@ -7,7 +7,7 @@ cron: name: run_cloud_launcher.sh state: present - job: '/usr/bin/flock -n /var/run/ansible/run_cloud_launcher.lock /bin/bash /opt/system-config/run_cloud_launcher.sh >> /var/log/ansible/run_cloud_launcher_cron.log 2>&1' + job: '/usr/bin/flock -n /var/run/ansible/run_cloud_launcher.lock /bin/bash /opt/system-config/run_cloud_launcher.sh -c >> /var/log/ansible/run_cloud_launcher_cron.log 2>&1' minute: "{{ cloud_launcher_cron_interval.minute }}" hour: "{{ cloud_launcher_cron_interval.hour }}" day: "{{ cloud_launcher_cron_interval.day }}" diff --git a/run_cloud_launcher.sh b/run_cloud_launcher.sh index b3fcaf7f0b..caf21c31a4 100755 --- a/run_cloud_launcher.sh +++ b/run_cloud_launcher.sh @@ -27,6 +27,21 @@ ANSIBLE_PLAYBOOKS=$SYSTEM_CONFIG/playbooks # errexit set +e +# We only send stats if running under cron +UNDER_CRON=0 + +while getopts ":c" arg; do + case $arg in + c) + UNDER_CRON=1 + ;; + esac +done + +_START_TIME=$(date '+%s') + +echo "--- begin run @ $(date -Is) ---" + # We need access to all-clouds export OS_CLIENT_CONFIG_FILE=/etc/openstack/all-clouds.yaml @@ -35,3 +50,15 @@ export OS_CLIENT_CONFIG_FILE=/etc/openstack/all-clouds.yaml /usr/bin/timeout -k 2m 120m /usr/local/bin/ansible-playbook -i /dev/null -f 1 \ ${ANSIBLE_PLAYBOOKS}/run_cloud_launcher.yaml \ -e@${ANSIBLE_PLAYBOOKS}/clouds_layouts.yml + +echo "--- end run @ $(date -Is) ---" + +# Only send stats under cron conditions +if [[ ${UNDER_CRON} != 1 ]]; then + return +fi + +_CURRENT_TIME=$(date '+%s') +_ELAPSED_MS=$(( (_CURRENT_TIME - _START_TIME) * 1000 )) +echo "bridge.ansible.run_cloud_launcher:${_ELAPSED_MS}|ms" | \ + nc -w 1 -u graphite.openstack.org 8125