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

Added checkmk json parser

parent f80eb474
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -8,9 +8,9 @@ gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
#gem 'uglifier', '>= 1.3.0'
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
#gem 'coffee-rails', '~> 4.1.0'
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
 
Loading
Loading
@@ -23,6 +23,8 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
 
gem 'bootstrap3-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
 
Loading
Loading
Loading
Loading
@@ -39,6 +39,8 @@ GEM
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap3-rails (3.2.0)
rails (>= 4.0.0)
builder (3.2.2)
byebug (6.0.2)
coffee-rails (4.1.0)
Loading
Loading
@@ -127,6 +129,9 @@ GEM
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
Loading
Loading
@@ -137,7 +142,9 @@ PLATFORMS
ruby
 
DEPENDENCIES
bootstrap3-rails
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.4)
Loading
Loading
@@ -146,4 +153,5 @@ DEPENDENCIES
spring
sqlite3
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
Loading
Loading
@@ -14,3 +14,4 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
Loading
Loading
@@ -12,4 +12,5 @@
*
*= require_tree .
*= require_self
*= require bootstrap
*/
// Place all the styles related to the status controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
body {
padding-top: 20px;
padding-bottom: 20px;
}
.header,
.footer {
padding-right: 15px;
padding-left: 15px;
}
/* Custom page header */
.header {
padding-bottom: 20px;
border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
}
/* Custom page footer */
.footer {
padding-top: 19px;
color: #777;
border-top: 1px solid #e5e5e5;
}
require 'checkmk'
class StatusController < ApplicationController
include CheckMk
def index
@stats = get_stats
end
end
<!DOCTYPE html>
<html>
<head>
<title>StatusGitlabCom</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<title>GitLab Status</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted">GitLab Status</h3>
</div>
 
<%= yield %>
<div>
<%= yield %>
</div>
 
<div class="tweeter-feed">
<a class="twitter-timeline" href="https://twitter.com/git_lab" data-widget-id="293671753740324864">Tweets by @git_lab</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<footer class="footer">
<p>&copy; GitLab B.V. 2015</p>
</footer>
</div>
</body>
</html>
<h1>Status#index</h1>
<p>Find me in app/views/status/index.html.erb</p>
<br/>
<% @stats.each do |stat| %>
<h3><%= stat['value'] %></h3>
<h5><%= stat['name'] %></h5>
<% end %>
<br/>
Loading
Loading
@@ -5,7 +5,7 @@ Rails.application.routes.draw do
# See how all your routes lay out with "rake routes".
 
# You can have the root of your site routed with "root"
# root 'welcome#index'
root 'status#index'
 
# Example of regular route:
# get 'products/:id' => 'catalog#view'
Loading
Loading
module CheckMk
require 'json'
require 'open-uri'
def get_stats
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
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