Created
November 11, 2021 20:35
-
-
Save alivx/4de31bafad43e5e60b81bf4a5fb6ab0f to your computer and use it in GitHub Desktop.
Monit slack ruby script
This file contains hidden or 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
"ruby -e "" | |
require 'net/https' | |
require 'json' | |
uri = URI.parse('https://hooks.slack.com/services/xx/xx/xx') | |
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