aboutsummaryrefslogtreecommitdiff
path: root/utils/supportbot-mauve
diff options
context:
space:
mode:
authorJames Carter <james.carter@bytemark.co.uk>2017-08-01 15:56:35 +0100
committerJames Carter <james.carter@bytemark.co.uk>2017-08-01 15:56:35 +0100
commit4eff930c3f01414bb454d7bcb5501827cb60289b (patch)
treea398edd68c7fd30cf3987538e41e9b4df9f561b8 /utils/supportbot-mauve
parent0be1fa0ebadf9435a760582d17f47ff96dc0851c (diff)
parent814ed65fd415cc62b2f6f661a7f6d1629562544b (diff)
Merge branch '27-package-and-publish-in-gitlab-ci-retire-maker2-job' into 'develop'
Added CI Closes #27 See merge request !2
Diffstat (limited to 'utils/supportbot-mauve')
-rwxr-xr-xutils/supportbot-mauve73
1 files changed, 0 insertions, 73 deletions
diff --git a/utils/supportbot-mauve b/utils/supportbot-mauve
deleted file mode 100755
index 614c5f5..0000000
--- a/utils/supportbot-mauve
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/ruby
-require 'fileutils'
-require 'yaml'
-require 'timeout'
-require 'rubygems'
-require 'cgi'
-
-class RT
- class Ticket < Struct.new(:id, :subject, :content)
- end
-
- def initialize(cli, ticket_query)
- @cli = cli
- @ticket_query = ticket_query
- end
-
- def query(args)
- IO.popen("#{@cli} #{args}", "r") do |io|
- io.read
- end
- end
-
- def tickets
- query(@ticket_query).split("\n").map do |line|
- if /^(\d+): (.*)$/.match(line)
- t = Ticket.new($1.to_i, $2, "")
- query("show ticket/#{t.id}/attachments").split("\n")[-5..-1].each do |line2|
- next unless /\s(\d+):\s+\(text\/(plain|html)/.match(line2)
- is_html = $2 == "html"
-
- attachment = query("show -f Content ticket/#{t.id}/attachments/#{$1}").
- split("Content: ")[1].
- split("\n").
- map { |line3| line3.gsub(/^\s+/,"") }.
- join("\n")
- next unless attachment.match(/Action=Take/)
- if is_html
- t.content += attachment + "<hr/>"
- else
- t.content += "<pre>"+attachment+"</pre><hr/>"
- end
- end
- t
- else
- nil
- end
- end.compact
- end
-end
-
-class String; def escape; gsub(/[^A-Za-z0-9]/) { |x| "\\#{x}" }; end end
-
-config = File.open("supportbot.config") { |fh|
- YAML::parse(fh.read).transform }
-
-system("mauvesend -o supportbot -i heartbeat -r +10m -c now -s \"heartbeat not received\" -d \"Headtbeat send from supportbot-mauve code. It maybe down.\"")
-
-rt = RT.new(config['rt']['bin'], config['rt']['ticket_query2'])
-
-if 0 < rt.tickets.size
- args = %w( mauvesend alert.bytemark.co.uk -o supportbot )
- args += rt.tickets.map do |ticket|
- ["-i", ticket.id.to_s,
- "-u", ticket.id.to_s,
- "-s", ticket.subject,
- "-d", ticket.content
- ]
- end.flatten
- exec(*args)
-else
- args = %w( mauvesend alert.bytemark.co.uk --id supportbot -o supportbot -p -c now )
- exec(*args)
-end