Skip to content

Commit

Permalink
Switch from slackbot to email from desi cluster.
Browse files Browse the repository at this point in the history
  • Loading branch information
Segev BenZvi committed Sep 25, 2024
1 parent 44b1a08 commit 4a6953a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
19 changes: 6 additions & 13 deletions etc/desimodel_sync_kpno_cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,14 @@ END
fi
fi

# Send notifications.
# Send notifications. Mail out result.
slack_email=${DESI_SLACK_MAIL_DESIMODEL_SYNC}

# Get our webhook address from the environment
slack_web_hook=${DESI_SLACKBOT_DESIMODEL_SYNC}

if [ "x${slack_web_hook}" = "x" ]; then
echo "Environment variable DESI_SLACKBOT_DESIMODEL_SYNC not set- skipping notifications" >> "${logfile}"
if [ "x${slack_email}" = "x" ]; then
echo "Environment variable DESI_SLACK_MAIL_DESIMODEL_SYNC not set- skipping notifications" >> "${logfile}"
else
# Create the JSON payload.
slackjson="${logfile}_slack.json"
headtail=15
echo -e "{\"text\":\"Focalplane DB sync (log at \`${logfile}\`):\n\`\`\`$(head -n ${headtail} ${logfile} | sed -e "s|'|\\\'|g")\`\`\`\n(Snip)\n\`\`\`$(tail -n ${headtail} ${logfile} | sed -e "s|'|\\\'|g")\`\`\`\"}" > "${slackjson}"
# Post it.
slackerror=$(curl -X POST -H 'Content-type: application/json' --data "$(cat ${slackjson})" ${slack_web_hook})
echo "Slack API post ${slackerror}" >> "${logfile}"
cat ${logfile} | mailx -s "Focalplane sync: ${logdate}" ${slack_email}
echo "Sent log to slack" >> ${logfile}
fi

echo "Sync script finished at $(date -u --iso-8601=seconds)" >> "${logfile}"
Expand Down
19 changes: 6 additions & 13 deletions etc/desimodel_sync_kpno_force.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,14 @@ END
fi
fi

# Send notifications.
# Send notifications. Mail out result.
slack_email=${DESI_SLACK_MAIL_DESIMODEL_SYNC}

# Get our webhook address from the environment
slack_web_hook=${DESI_SLACKBOT_DESIMODEL_SYNC}

if [ "x${slack_web_hook}" = "x" ]; then
echo "Environment variable DESI_SLACKBOT_DESIMODEL_SYNC not set- skipping notifications" >> "${logfile}"
if [ "x${slack_email}" = "x" ]; then
echo "Environment variable DESI_SLACK_MAIL_DESIMODEL_SYNC not set- skipping notifications" >> "${logfile}"
else
# Create the JSON payload.
slackjson="${logfile}_slack.json"
headtail=15
echo -e "{\"text\":\"Focalplane DB sync (log at \`${logfile}\`):\n\`\`\`$(head -n ${headtail} ${logfile} | sed -e "s|'|\\\'|g")\`\`\`\n(Snip)\n\`\`\`$(tail -n ${headtail} ${logfile} | sed -e "s|'|\\\'|g")\`\`\`\"}" > "${slackjson}"
# Post it.
slackerror=$(curl -X POST -H 'Content-type: application/json' --data "$(cat ${slackjson})" ${slack_web_hook})
echo "Slack API post ${slackerror}" >> "${logfile}"
cat ${logfile} | mailx -s "Focalplane sync: ${logdate}" ${slack_email}
echo "Sent log to slack" >> ${logfile}
fi

echo "Sync script finished at $(date -u --iso-8601=seconds)" >> "${logfile}"
Expand Down

0 comments on commit 4a6953a

Please sign in to comment.