Skip to content

Instantly share code, notes, and snippets.

@mattyjones
Created December 13, 2015 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyjones/79e018a65ee8d81a8d41 to your computer and use it in GitHub Desktop.
Save mattyjones/79e018a65ee8d81a8d41 to your computer and use it in GitHub Desktop.
#!/bin/bash +e
#
# DevOps - Auto-generated by Chef for XXX
#
# /etc/init.d/sensu-graceful-shutdown
# Subsystem for notifying the sensu server that a graceful shutdown has been initiated
#
# chkconfig: 12345 05 05
# description: Notify the sensu server that a graceful shutdown has been initiated
#
# processname: sensu-graceful-shutdown
#
# Copyright 2014 Yieldbot, Inc <devops@yieldbot.com>
#
prog="sensu-graceful-shutdown"
touch /var/lock/subsys/$prog
stop() {
echo -n $"Stopping $prog"
# Trigger the initial Unknown event for the shutdown
for i in `seq 1 3`;
do
/opt/sensu/embedded/bin/ruby /sensu-yieldbot-plugins/sensu/sensu-socket-client.rb --handler "graceful-shutdown" --name "graceful-shutdown" --output "Graceful shutdown initiated" --status 3 > /dev/null 2>&1 || true
done
# Sleep to give the message time to prop
sleep 1s
# Trigger the Ok Event
/opt/sensu/embedded/bin/ruby /sensu-yieldbot-plugins/sensu/sensu-socket-client.rb --handler "graceful-shutdown" --name "graceful-shutdown" --output "Graceful shutdown initiated" --status 0 > /dev/null 2>&1 || true
# Remove the subsystem lock
rm -f /var/lock/subsys/$prog
echo
}
case "$1" in
stop)
stop
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment