Created
November 24, 2017 15:46
-
-
Save np422/e748aa22d23b6a62acc632933b8889f8 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
log = Syslog::Logger.new 'app-epr-dashboard' | |
date_sent_perfdata = Date.today - 1.day | |
n_logmsg_sent = 0 | |
N_LOGMESSAGES_PER_DAY = 20 | |
SCHEDULER.every '300s' do | |
url1 = "https://issue.admin.conextrade.com/" | |
board_id = 3 | |
c = JSONClient.new | |
c.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
c.set_auth( url1, DashApp.config.default_username, DashApp.config.default_password ) | |
c.force_basic_auth = true | |
c.set_cookie_store('/tmp/cookie.dat') | |
url = url1 + "rest/agile/1.0/board/3/sprint" | |
r = c.get( url ) | |
if !r.nil? && r.status == 200 | |
sprint_id = r.body["values"].select { |s| s["state"] == "active" }.first["id"] | |
url = url1 + "rest/greenhopper/1.0/gadgets/sprints/remainingdays?rapidViewId=3&sprintId=#{sprint_id}" | |
days_left = c.get(url).body["days"] | |
#url = url1 + "rest/agile/1.0/board/3/sprint/#{sprint_id}/issue" | |
url = url1 + "rest/api/2/search?jql=project=CL4CXT%26Sprint=#{sprint_id}%26status!=Done" | |
r = c.get(url) | |
open_issues = r.body["total"] | |
if date_sent_perfdata.past? | |
remaining_tickets_per_sprint_day = (open_issues.to_f / days_left.to_f ).round(2) | |
log.info("remaining_tickets_per_sprint_day=#{remaining_tickets_per_sprint_day}") | |
n_logmsg_sent += 1 | |
if n_logmsg_sent > N_LOGMESSAGES_PER_DAY | |
n_logmsg_sent = 0 | |
date_sent_perfdata = Date.today | |
end | |
end | |
send_event('sprint', { daysleft: days_left , open: open_issues } ) | |
else | |
puts "Problem accesing url = #{url}" | |
puts "HTTP-status code = #{r.status}" | |
puts "HTTP-body = #{r.body}" unless r.body.nil? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment