Skip to content

Commit cf636a0

Browse files
authored
Merge pull request #6710 from FireLemons/performance_monitoring
create resource monitoring script
2 parents 0621783 + 12fa195 commit cf636a0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
desc "Post gc stats to discord channel"
2+
3+
task post_gc_stat_to_discord: :environment do
4+
stats = GC.stat
5+
6+
unless ENV["DISCORD_WEBHOOK_URL"].nil?
7+
formatted_stats = JSON.pretty_generate(stats)
8+
discord_message = <<~MULTILINE
9+
```json
10+
#{formatted_stats}
11+
```
12+
MULTILINE
13+
14+
payload = {content: discord_message}.to_json
15+
16+
uri = URI.parse(ENV["DISCORD_WEBHOOK_URL"])
17+
http = Net::HTTP.new(uri.host, uri.port)
18+
http.use_ssl = (uri.scheme == "https") # Use SSL for HTTPS
19+
20+
request = Net::HTTP::Post.new(uri.path, {"Content-Type" => "application/json"})
21+
request.body = payload
22+
23+
http.request(request)
24+
end
25+
end

0 commit comments

Comments
 (0)