Skip to content

Instantly share code, notes, and snippets.

@alexshd
Last active August 29, 2015 14:17
Show Gist options
  • Save alexshd/682bd7e9a3d764659422 to your computer and use it in GitHub Desktop.
Save alexshd/682bd7e9a3d764659422 to your computer and use it in GitHub Desktop.
slack ruby notifier
#! /opt/chef/embedded/bin/ruby
require 'slack-notifier'
require 'trollop'
host = ENV['HOSTNAME']
opts = Trollop.options do
opt :message, 'message to send', type: :string, default: 'OK'
opt :channel, 'slack channel to use', type: :string, default: '#shd-test'
opt :user, 'user name to use in the message', type: :string, default: host
opt :web_huk, 'the URL of the Web Huk', type: :string
opt :icon, 'icon to use, as specified in slack', type: :string, default: ':+1:'
end
notifier = Slack::Notifier.new opts.web_huk
notifier.channel = opts.channel
notifier.username = opts.user
notifier.ping opts.message, icon_emoji: opts.icon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment