Skip to content
Snippets Groups Projects
Commit 8dca5edd authored by Jeroen Nijhof's avatar Jeroen Nijhof
Browse files

Changed hash to contain timestamps for charts

parent 003bf1fa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,6 +2,6 @@ require 'checkmk'
class StatusController < ApplicationController
include CheckMk
def index
@stats = get_stats
@stats = get_checkmk_json
end
end
<!DOCTYPE html>
<html>
<head>
<title>GitLab Status</title>
<title>GitLab.com Status</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
Loading
Loading
@@ -9,7 +9,7 @@
<body>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted">GitLab Status</h3>
<h2 class="text-muted">GitLab.com Status</h2>
</div>
 
<div>
Loading
Loading
@@ -22,7 +22,7 @@
</div>
 
<footer class="footer">
<p>&copy; GitLab B.V. 2015</p>
<p>&copy; GitLab Inc. 2015</p>
</footer>
</div>
</body>
Loading
Loading
<br/>
<% @stats.each do |stat| %>
<h3><%= stat['value'] %></h3>
<h5><%= stat['name'] %></h5>
<% @stats.keys.each do |key| %>
<% label = "success" %>
<% label_text = "OK" %>
<% label = "warning" if @stats[key].last['state'] != 0 %>
<% label_text = "NOT OK" if @stats[key].last['state'] != 0 %>
<h3><%= @stats[key].last['value'] %></h3>
<h5><span class="label label-<%= label %>"><%= label_text %></span> <%= @stats[key].last['name'] %></h5>
<% end %>
<br/>
Loading
Loading
@@ -38,4 +38,7 @@ Rails.application.configure do
 
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# CheckMK json url
config.checkmk_json_url = 'http://checkmk.gitlap.com/gitlab-checkmk-stats.json'
end
Loading
Loading
@@ -76,4 +76,7 @@ Rails.application.configure do
 
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# CheckMK json url
config.checkmk_json_url = 'http://checkmk.gitlap.com/gitlab-checkmk-stats.json'
end
Loading
Loading
@@ -39,4 +39,7 @@ Rails.application.configure do
 
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# CheckMK json url
config.checkmk_json_url = 'http://checkmk.gitlap.com/gitlab-checkmk-stats.json'
end
Loading
Loading
@@ -2,25 +2,9 @@ module CheckMk
require 'json'
require 'open-uri'
 
def get_stats
def get_checkmk_json
stats = []
json = JSON.parse(open("http://checkmk.gitlap.com/gitlab-checkmk-stats.json").read)
json.each do |stat|
if stat[0].include?("SSH")
value = stat[5].gsub('rta=', '')
value.gsub!(/;.*/, '')
stats.push({"name" => "gitlab.com latency", "state" => "#{stat[4]}", "value" => "#{value}"})
value = stat[2].gsub('time=', '')
value.gsub!(/;.*/, '')
stats.push({"name" => "gitlab.com ssh response time", "state" => "#{stat[1]}", "value" => "#{value}"})
end
if stat[0].include?("HTTP gitlab.com")
value = stat[2].gsub('time=', '')
value.gsub!(/;.*/, '')
stats.push({"name" => "gitlab.com http response time", "state" => "#{stat[1]}", "value" => "#{value}"})
end
end
return stats
json = JSON.parse(open(Rails.configuration.checkmk_json_url).read)
return json
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment