Last active
May 5, 2020 18:00
-
-
Save g3rhard/e8ca8adff63601aa6c18d81473fe0699 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'net/https' | |
require 'json' | |
uri = URI.parse("https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'}) | |
request.body = { | |
"channel" => "#general", | |
"username" => "mmonit", | |
"text" => "[#{ENV['MONIT_HOST']}] #{ENV['MONIT_SERVICE']} - #{ENV['MONIT_DESCRIPTION']}" | |
}.to_json | |
response = http.request(request) | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment