├── .gitattributes
├── Gemfile
├── README.md
├── assets
├── fonts
│ ├── fontawesome-webfont.eot
│ ├── fontawesome-webfont.svg
│ ├── fontawesome-webfont.ttf
│ └── fontawesome-webfont.woff
├── images
│ ├── cat.png
│ ├── catjpg
│ └── logo.png
├── javascripts
│ ├── application.coffee
│ ├── d3-3.2.8.js
│ ├── d3.v2.min.js
│ ├── dashing.gridster.coffee
│ ├── gridster
│ │ ├── jquery.gridster.js
│ │ └── jquery.leanModal.min.js
│ ├── highcharts.js
│ ├── jquery.easing.min.js
│ ├── jquery.knob.js
│ ├── modules
│ │ └── exporting.js
│ ├── rickshaw-1.4.3.min.js
│ └── rickshaw.min.js
└── stylesheets
│ ├── application.scss
│ ├── climacons-font.css
│ ├── font-awesome.css
│ └── jquery.gridster.css
├── config.ru
├── dashboard scrn.jpg
├── dashboards
├── layout.erb
├── left.erb
├── local-storage.erb
└── right.erb
├── jobs
├── LBAL-TCP.rb
├── alpha.rb
├── bravo.rb
├── charlie.rb
├── delta.rb
├── echo.rb
├── foxtrot.rb
├── golf.rb
├── hotel.rb
├── india1.rb
├── india2.rb
├── india3.rb
├── india4.rb
├── india5.rb
├── india6.rb
├── india7.rb
├── india8.rb
├── int-cpu.rb
├── int-disk.rb
├── juliet.rb
├── kilo.rb
├── lima.rb
├── mike.rb
├── november.rb
├── oscar.rb
├── papa.rb
├── prod-cpu.rb
├── prod-disk.rb
├── quebec.rb
└── romeo.rb
├── log
└── thin.log
├── public
├── 404.html
└── favicon.ico
├── tmp
└── pids
│ └── thin.pid
└── widgets
├── comments
├── comments.coffee
├── comments.html
└── comments.scss
├── graph
├── graph.coffee
├── graph.html
└── graph.scss
├── horizonbarstack
├── horizonbarstack.coffee
├── horizonbarstack.coffee~
├── horizonbarstack.html
├── horizonbarstack.html~
└── horizonbarstack.scss
├── hotness
├── hotness.coffee
├── hotness.html
└── hotness.scss
├── hotness1
├── hotness1.coffee
├── hotness1.coffee~
├── hotness1.html
├── hotness1.html~
├── hotness1.scss
└── hotness1.scss~
├── hotness2
├── hotness2.coffee
├── hotness2.html
└── hotness2.scss
├── image
├── image.coffee
├── image.html
└── image.scss
├── list
├── list.coffee
├── list.html
└── list.scss
├── meter
├── meter.coffee
├── meter.html
└── meter.scss
├── number
├── number.coffee
├── number.html
└── number.scss
├── progress_bars
├── progress_bars.coffee
├── progress_bars.html
├── progress_bars.scss
└── progress_bars.scss~
├── progress_bars1
├── progress_bars.coffee~
├── progress_bars.scss~
├── progress_bars1.coffee
├── progress_bars1.coffee~
├── progress_bars1.html
└── progress_bars1.scss
├── progress_bars2
├── progress_bars.coffee~
├── progress_bars.scss~
├── progress_bars1.coffee~
├── progress_bars2.coffee
├── progress_bars2.html
└── progress_bars2.scss
├── rickshawgraph
├── rickshawgraph.coffee
├── rickshawgraph.coffee~
├── rickshawgraph.html
└── rickshawgraph.scss
├── server_status
├── server_status.coffee
├── server_status.html
└── server_status.scss
└── text
├── text.coffee
├── text.html
└── text.scss
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 | gem 'sinatra_cyclist'
3 | gem 'rest-client'
4 | gem 'dashing'
5 | gem 'httparty'
6 | gem 'curb'
7 | gem 'csv-mapper'
8 | gem 'nokogiri'
9 | gem 'xpath'
10 | gem 'certified'
11 | gem 'activesupport'
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Dashboard for use with Check_MK built using Dashing
2 |
3 | Simple dashboard which is used in conjunction with a Check_MK instance
4 |
5 | Check out http://shopify.github.com/dashing for more information.
6 |
7 | 
8 |
9 | guide to install required items in order to run dashing on a new installation of debian 7
10 |
11 | log on as root and add user to the sudoers files using adduser ##### sudo
12 | remove cdrom from sources list at /etc/apt/sources.list
13 | apt-get install sudo
14 | sudo apt-get update
15 | check ruby version remove 1.8 if neccessary
16 | apt-get install build-essential
17 | apt-get install ruby1.9.1 ruby-dev
18 | apt-get remove libruby1.8 ruby1.8 ruby1.8-dev rubygems1.8
19 | apt-get install libcurl3 libcurl3-gnutls libcurl3-gnutls-dev libcurl-ocaml
20 | apt-get install rubygems
21 | apt-get install ruby-dev
22 |
23 | ########################################################################
24 | run this as root!!
25 | echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
26 | apt-get update
27 | apt-get install nodejs
28 | ########################################################################
29 |
30 | apt-get install curl
31 | apt-get install liblzma-dev zlib1g-dev
32 | apt-get install liblzma-dev zlib1g-dev
33 | apt-get install NodeJS
34 | gem install zlib
35 | gem install nokogiri
36 | gem install execjs
37 | gem install bundler
38 | gem install execjs
39 | gem install curb
40 | gem install httparty -v '0.12.0'
41 | gem install tzinfo-data
42 | gem install dashing
43 |
44 | #################################################################################
45 | When adding a hosts' service to a job, refer to the link you would use from the main check_mk dashboard when viewing the pnp4nagios data. You will need a valid username and password for check_mk (it does not have to be at admin level,as it is only viewing the page)
46 | ##################################################################################
47 | navigate into the relevant nagios-check_mk-dashing folder, open a terminal and run "bundle
48 | install" then "bundle" and finally dashing start
49 | #####################################################################################
50 |
--------------------------------------------------------------------------------
/assets/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/assets/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/assets/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/assets/images/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/images/cat.png
--------------------------------------------------------------------------------
/assets/images/catjpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/images/catjpg
--------------------------------------------------------------------------------
/assets/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/assets/images/logo.png
--------------------------------------------------------------------------------
/assets/javascripts/application.coffee:
--------------------------------------------------------------------------------
1 | # dashing.js is located in the dashing framework
2 | # It includes jquery & batman for you.
3 | #= require dashing.js
4 |
5 | #= require_directory .
6 | #= require modules/exporting
7 | #= require_tree ../../widgets
8 |
9 | console.log("Yeah! The dashboard has started!")
10 |
11 | Dashing.on 'ready', ->
12 | Dashing.widget_margins ||= [5, 5]
13 | Dashing.widget_base_dimensions ||= [300, 360]
14 | Dashing.numColumns ||= 4
15 |
16 | contentWidth = (Dashing.widget_base_dimensions[0] + Dashing.widget_margins[0] * 2) * Dashing.numColumns
17 |
18 | Batman.setImmediate ->
19 | $('.gridster').width(contentWidth)
20 | $('.gridster ul:first').gridster
21 | widget_margins: Dashing.widget_margins
22 | widget_base_dimensions: Dashing.widget_base_dimensions
23 | avoid_overlapped_widgets: !Dashing.customGridsterLayout
24 | draggable:
25 | stop: Dashing.showGridsterInstructions
26 | start: -> Dashing.currentWidgetPositions = Dashing.getWidgetPositions()
27 |
--------------------------------------------------------------------------------
/assets/javascripts/dashing.gridster.coffee:
--------------------------------------------------------------------------------
1 | #= require_directory ./gridster
2 |
3 | # This file enables gridster integration (http://gridster.net/)
4 | # Delete it if you'd rather handle the layout yourself.
5 | # You'll miss out on a lot if you do, but we won't hold it against you.
6 |
7 | Dashing.gridsterLayout = (positions) ->
8 | Dashing.customGridsterLayout = true
9 | positions = positions.replace(/^"|"$/g, '')
10 | positions = $.parseJSON(positions)
11 | widgets = $("[data-row^=]")
12 | for widget, index in widgets
13 | $(widget).attr('data-row', positions[index].row)
14 | $(widget).attr('data-col', positions[index].col)
15 |
16 | Dashing.getWidgetPositions = ->
17 | $(".gridster ul:first").gridster().data('gridster').serialize()
18 |
19 | Dashing.showGridsterInstructions = ->
20 | newWidgetPositions = Dashing.getWidgetPositions()
21 |
22 | unless JSON.stringify(newWidgetPositions) == JSON.stringify(Dashing.currentWidgetPositions)
23 | Dashing.currentWidgetPositions = newWidgetPositions
24 | $('#save-gridster').slideDown()
25 | $('#gridster-code').text("
26 |
31 | ")
32 |
33 | $ ->
34 | $('#save-gridster').leanModal()
35 |
36 | $('#save-gridster').click ->
37 | $('#save-gridster').slideUp()
38 |
--------------------------------------------------------------------------------
/assets/javascripts/gridster/jquery.leanModal.min.js:
--------------------------------------------------------------------------------
1 | // leanModal v1.1 by Ray Stone - http://finelysliced.com.au
2 | // Dual licensed under the MIT and GPL
3 |
4 | (function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null};var overlay=$("
");$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");$("#lean_overlay").click(function(){close_modal(modal_id)});$(o.closeButton).click(function(){close_modal(modal_id)});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();
5 | $("#lean_overlay").css({"display":"block",opacity:0});$("#lean_overlay").fadeTo(200,o.overlay);$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault()})});function close_modal(modal_id){$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})}}})})(jQuery);
6 |
--------------------------------------------------------------------------------
/assets/javascripts/jquery.easing.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3 | *
4 | * Uses the built in easing capabilities added In jQuery 1.1
5 | * to offer multiple easing options
6 | *
7 | * TERMS OF USE - EASING EQUATIONS
8 | *
9 | * Open source under the BSD License.
10 | *
11 | * Copyright © 2001 Robert Penner
12 | * All rights reserved.
13 | *
14 | * TERMS OF USE - jQuery Easing
15 | *
16 | * Open source under the BSD License.
17 | *
18 | * Copyright © 2008 George McGinley Smith
19 | * All rights reserved.
20 | *
21 | * Redistribution and use in source and binary forms, with or without modification,
22 | * are permitted provided that the following conditions are met:
23 | *
24 | * Redistributions of source code must retain the above copyright notice, this list of
25 | * conditions and the following disclaimer.
26 | * Redistributions in binary form must reproduce the above copyright notice, this list
27 | * of conditions and the following disclaimer in the documentation and/or other materials
28 | * provided with the distribution.
29 | *
30 | * Neither the name of the author nor the names of contributors may be used to endorse
31 | * or promote products derived from this software without specific prior written permission.
32 | *
33 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
34 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
36 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
39 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41 | * OF THE POSSIBILITY OF SUCH DAMAGE.
42 | *
43 | */
44 | jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g.*?$/,"").replace(/ /g,"Â ").replace(//g,"Â").replace(/
/g,
15 | 'xlink:href="$1"/>').replace(/id=([^" >]+)/g,'id="$1"').replace(/class=([^" ]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(a){return a.toLowerCase()});d=d.replace(/(url\(#highcharts-[0-9]+)"/g,"$1").replace(/"/g,"'");d.match(/ xmlns="/g).length===2&&(d=d.replace(/xmlns="[^"]+"/,""));return d},exportChart:function(a,b){var a=a||{},c=this.options.exporting,c=this.getSVG(k({chart:{borderRadius:0}},c,b,{exporting:{sourceWidth:a.sourceWidth||
16 | c.sourceWidth,sourceHeight:a.sourceHeight||c.sourceHeight}})),a=k(this.options.exporting,a);e.post(a.url,{filename:a.filename||"chart",type:a.type,width:a.width||0,scale:a.scale||2,svg:c})},print:function(){var a=this,b=a.container,c=[],d=b.parentNode,e=i.body,g=e.childNodes;if(!a.isPrinting)a.isPrinting=!0,r(g,function(a,b){if(a.nodeType===1)c[b]=a.style.display,a.style.display="none"}),e.appendChild(b),z.focus(),z.print(),setTimeout(function(){d.appendChild(b);r(g,function(a,b){if(a.nodeType===
17 | 1)a.style.display=c[b]});a.isPrinting=!1},1E3)},contextMenu:function(a,b,c,d,e,g,f){var h=this,q=h.options.navigation,n=q.menuItemStyle,o=h.chartWidth,i=h.chartHeight,A="cache-"+a,l=h[A],k=C(e,g),u,j,s;if(!l)h[A]=l=m("div",{className:"highcharts-"+a},{position:"absolute",zIndex:1E3,padding:k+"px"},h.container),u=m("div",null,p({MozBoxShadow:"3px 3px 10px #888",WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},q.menuStyle),l),j=function(){t(l,{display:"none"});f&&f.setState(0)},v(l,
18 | "mouseleave",function(){s=setTimeout(j,500)}),v(l,"mouseenter",function(){clearTimeout(s)}),r(b,function(a){if(a){var b=a.separator?m("hr",null,null,u):m("div",{onmouseover:function(){t(this,q.menuItemHoverStyle)},onmouseout:function(){t(this,n)},onclick:function(){j();a.onclick.apply(h,arguments)},innerHTML:a.text||h.options.lang[a.textKey]},p({cursor:"pointer"},n),u);h.exportDivElements.push(b)}}),h.exportDivElements.push(u,l),h.exportMenuWidth=l.offsetWidth,h.exportMenuHeight=l.offsetHeight;a=
19 | {display:"block"};c+h.exportMenuWidth>o?a.right=o-c-e-k+"px":a.left=c-k+"px";d+g+h.exportMenuHeight>i?a.bottom=i-d-k+"px":a.top=d+g-k+"px";t(l,a)},addButton:function(a){var b=this,c=b.renderer,a=k(b.options.navigation.buttonOptions,a),d=a.onclick,i=a.menuItems,g,f,h={stroke:a.symbolStroke,fill:a.symbolFill},q=a.symbolSize||12;if(!b.btnCount)b.btnCount=0;b.btnCount++;if(!b.exportDivElements)b.exportDivElements=[],b.exportSVGElements=[];if(a.enabled!==!1){var n=a.theme,o=n.states,m=o&&o.hover,o=o&&
20 | o.select,j;delete n.states;d?j=function(){d.apply(b,arguments)}:i&&(j=function(){b.contextMenu("contextmenu",i,f.translateX,f.translateY,f.width,f.height,f);f.setState(2)});a.text&&a.symbol?n.paddingLeft=e.pick(n.paddingLeft,25):a.text||p(n,{width:a.width,height:a.height,padding:0});f=c.button(a.text,0,0,j,n,m,o).attr({title:b.options.lang[a._titleKey],"stroke-linecap":"round"});a.symbol&&(g=c.symbol(a.symbol,a.symbolX-q/2,a.symbolY-q/2,q,q).attr(p(h,{"stroke-width":a.symbolStrokeWidth||1,zIndex:1})).add(f));
21 | f.add().align(p(a,{width:f.width,x:e.pick(a.x,w)}),!0,"spacingBox");w+=(f.width+a.buttonSpacing)*(a.align==="right"?-1:1);b.exportSVGElements.push(f,g)}},destroyExport:function(a){var a=a.target,b,c;for(b=0;b * {
10 | margin: 0 auto;
11 | -webkit-transition: height .4s;
12 | -moz-transition: height .4s;
13 | -o-transition: height .4s;
14 | -ms-transition: height .4s;
15 | transition: height .4s;
16 | }
17 |
18 | .gridster .gs_w{
19 | z-index: 2;
20 | position: absolute;
21 | }
22 |
23 | .ready .gs_w:not(.preview-holder) {
24 | -webkit-transition: opacity .3s, left .3s, top .3s;
25 | -moz-transition: opacity .3s, left .3s, top .3s;
26 | -o-transition: opacity .3s, left .3s, top .3s;
27 | transition: opacity .3s, left .3s, top .3s;
28 | }
29 |
30 | .gridster .preview-holder {
31 | z-index: 1;
32 | position: absolute;
33 | background-color: #fff;
34 | border-color: #fff;
35 | opacity: 0.3;
36 | }
37 |
38 | .gridster .player-revert {
39 | z-index: 10!important;
40 | -webkit-transition: left .3s, top .3s!important;
41 | -moz-transition: left .3s, top .3s!important;
42 | -o-transition: left .3s, top .3s!important;
43 | transition: left .3s, top .3s!important;
44 | }
45 |
46 | .gridster .dragging {
47 | z-index: 10!important;
48 | -webkit-transition: all 0s !important;
49 | -moz-transition: all 0s !important;
50 | -o-transition: all 0s !important;
51 | transition: all 0s !important;
52 | }
53 |
54 | /* Uncomment this if you set helper : "clone" in draggable options */
55 | /*.gridster .player {
56 | opacity:0;
57 | }*/
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | require 'sinatra/cyclist'
2 | require 'dashing'
3 |
4 | configure do
5 | set :auth_token, 'YOUR_AUTH_TOKEN'
6 | set :protection, :except => :frame_options
7 |
8 | helpers do
9 | def protected!
10 | # Put any authentication code you want in here.
11 | # This method is run before accessing any resource.
12 | end
13 | end
14 | end
15 |
16 | map Sinatra::Application.assets_prefix do
17 | run Sinatra::Application.sprockets
18 | end
19 | set :routes_to_cycle_through, [:sample, :monitor]
20 | set :cycle_duration, 60
21 | run Sinatra::Application
22 |
--------------------------------------------------------------------------------
/dashboard scrn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/dashboard scrn.jpg
--------------------------------------------------------------------------------
/dashboards/layout.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | <%= yield_content(:title) %>
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | <%= yield %>
22 |
23 |
24 | <% if development? %>
25 |
26 |
Paste the following at the top of <%= params[:dashboard] %>.erb
27 |
28 |
29 | Save this layout
30 | <% end %>
31 |
32 |
--------------------------------------------------------------------------------
/dashboards/left.erb:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 | -
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/dashboards/local-storage.erb:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 | -
16 |
17 |
18 |
19 | -
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 | -
28 |
29 |
30 |
31 | -
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 | -
40 |
41 |
42 |
43 | -
44 |
45 |
46 |
47 | -
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 | -
56 |
57 |
58 |
59 | -
60 |
61 |
62 |
63 | -
64 |
65 |
66 |
67 | -
68 |
69 |
70 |
71 | -
72 |
73 |
74 |
75 | -
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/dashboards/right.erb:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 | -
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/jobs/LBAL-TCP.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '30s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=RS-LBAL&srv=TCP_Connections", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("/NAGIOS/DATASOURCE[6]/ACT")# search for tags that match "act" there is only one set
12 | cpu = cpu.to_s() #convert the nodeset to a string
13 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
14 | metervalue = cpu2.to_f / 1500 * 100 #convert to a float and as a percentage of 1500
15 |
16 | servers = Array.new
17 | servers << {name: "RS-LBAL - TCP", progress: metervalue}
18 |
19 |
20 | send_event('LBAL-TCP', {title: "Load Balancer Conections", progress_items: servers})
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/jobs/alpha.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.alphaspm.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 | # print statuses to dashboard
26 | send_event('alpha', {value: result})
27 | end
28 |
--------------------------------------------------------------------------------
/jobs/bravo.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.bravospm.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 | # print statuses to dashboard
26 | send_event('bravo', {value: result})
27 | end
28 |
--------------------------------------------------------------------------------
/jobs/charlie.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://charliespm.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 | # print statuses to dashboard
25 | send_event('charlie', {value: result})
26 | end
27 |
--------------------------------------------------------------------------------
/jobs/delta.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('http://delta/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 | # print statuses to dashboard
25 | send_event('delta', {value: result})
26 | end
27 |
--------------------------------------------------------------------------------
/jobs/echo.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.echoenergyspm.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 | # print statuses to dashboard
26 | send_event('echo', {value: result})
27 | end
28 |
--------------------------------------------------------------------------------
/jobs/foxtrot.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.foxtrotspm.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 | # print statuses to dashboard
26 | send_event('foxtrotspm', {value: result})
27 | end
28 |
--------------------------------------------------------------------------------
/jobs/golf.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '30s', :first_in => 0 do |job|
7 | # Grab the raw XML
8 |
9 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=SQL2008R2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
10 | root = doc.root #mark the top of the xml data
11 |
12 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
13 |
14 | cpu = cpu.to_s() #convert the nodeset to a string
15 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
16 | metervalue = cpu2.to_f #convert to a float
17 |
18 | send_event('golf', value: metervalue)
19 | end
20 |
--------------------------------------------------------------------------------
/jobs/hotel.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://hotel.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 |
26 | # print statuses to dashboard
27 | send_event('hotel', {value: result})
28 | end
29 |
--------------------------------------------------------------------------------
/jobs/india1.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=quebec&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph1', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india2.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=juliet1&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 | if data[-1].values_at("y") == "0"
48 |
49 | data3 = data[0..-2]
50 |
51 | elseif data[-2].values_at("y") == "0"
52 |
53 | data3 = data[0..-3]
54 | else
55 |
56 | data3 = data[0..-1]
57 |
58 |
59 | send_event('graph2', points: data3)
60 |
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/jobs/india3.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=papa&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph3', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india4.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=juliet&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph4', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india5.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=juliet3&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph5', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india6.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=kilo&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph6', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india7.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=juliet2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph7', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/india8.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 | require 'nokogiri'
3 |
4 | SCHEDULER.every '90s' do
5 |
6 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/xport/xml?host=SQL2008R2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
7 | root = doc.root #mark the top of the xml data
8 | cpu = root.xpath("//row/v[1]")# search for tags that match "act" there is only one set
9 | cpu = cpu.to_a()
10 | times = root.xpath("//row/t")# search for tags that match "act" there is only one set
11 | times = times.to_a()
12 |
13 | data = [
14 | { "x" => times[-34].inner_text().to_f .round(1), "y" => cpu[-34].inner_text().to_f .round(1) },
15 | { "x" => times[-33].inner_text().to_f .round(1), "y" => cpu[-33].inner_text().to_f .round(1) },
16 | { "x" => times[-32].inner_text().to_f .round(1), "y" => cpu[-32].inner_text().to_f .round(1) },
17 | { "x" => times[-31].inner_text().to_f .round(1), "y" => cpu[-31].inner_text().to_f .round(1) },
18 | { "x" => times[-30].inner_text().to_f .round(1), "y" => cpu[-30].inner_text().to_f .round(1) },
19 | { "x" => times[-29].inner_text().to_f .round(1), "y" => cpu[-39].inner_text().to_f .round(1) },
20 | { "x" => times[-28].inner_text().to_f .round(1), "y" => cpu[-28].inner_text().to_f .round(1) },
21 | { "x" => times[-27].inner_text().to_f .round(1), "y" => cpu[-27].inner_text().to_f .round(1) },
22 | { "x" => times[-26].inner_text().to_f .round(1), "y" => cpu[-26].inner_text().to_f .round(1) },
23 | { "x" => times[-25].inner_text().to_f .round(1), "y" => cpu[-25].inner_text().to_f .round(1) },
24 | { "x" => times[-24].inner_text().to_f .round(1), "y" => cpu[-24].inner_text().to_f .round(1) },
25 | { "x" => times[-23].inner_text().to_f .round(1), "y" => cpu[-23].inner_text().to_f .round(1) },
26 | { "x" => times[-22].inner_text().to_f .round(1), "y" => cpu[-22].inner_text().to_f .round(1) },
27 | { "x" => times[-21].inner_text().to_f .round(1), "y" => cpu[-21].inner_text().to_f .round(1) },
28 | { "x" => times[-20].inner_text().to_f .round(1), "y" => cpu[-20].inner_text().to_f .round(1) },
29 | { "x" => times[-19].inner_text().to_f .round(1), "y" => cpu[-19].inner_text().to_f .round(1) },
30 | { "x" => times[-18].inner_text().to_f .round(1), "y" => cpu[-18].inner_text().to_f .round(1) },
31 | { "x" => times[-17].inner_text().to_f .round(1), "y" => cpu[-17].inner_text().to_f .round(1) },
32 | { "x" => times[-16].inner_text().to_f .round(1), "y" => cpu[-16].inner_text().to_f .round(1) },
33 | { "x" => times[-15].inner_text().to_f .round(1), "y" => cpu[-15].inner_text().to_f .round(1) },
34 | { "x" => times[-14].inner_text().to_f .round(1), "y" => cpu[-14].inner_text().to_f .round(1) },
35 | { "x" => times[-13].inner_text().to_f .round(1), "y" => cpu[-13].inner_text().to_f .round(1) },
36 | { "x" => times[-12].inner_text().to_f .round(1), "y" => cpu[-12].inner_text().to_f .round(1) },
37 | { "x" => times[-11].inner_text().to_f .round(1), "y" => cpu[-11].inner_text().to_f .round(1) },
38 | { "x" => times[-10].inner_text().to_f .round(1), "y" => cpu[-10].inner_text().to_f .round(1) },
39 | { "x" => times[-9].inner_text().to_f .round(1), "y" => cpu[-9].inner_text().to_f .round(1) },
40 | { "x" => times[-8].inner_text().to_f .round(1), "y" => cpu[-8].inner_text().to_f .round(1) },
41 | { "x" => times[-7].inner_text().to_f .round(1), "y" => cpu[-7].inner_text().to_f .round(1) },
42 | { "x" => times[-6].inner_text().to_f .round(1), "y" => cpu[-6].inner_text().to_f .round(1) },
43 | { "x" => times[-5].inner_text().to_f .round(1), "y" => cpu[-5].inner_text().to_f .round(1) },
44 | { "x" => times[-4].inner_text().to_f .round(1), "y" => cpu[-4].inner_text().to_f .round(1) }
45 | ]
46 |
47 |
48 | if data[-1].values_at("y") == "0"
49 |
50 | data3 = data[0..-2]
51 |
52 | elseif data[-2].values_at("y") == "0"
53 |
54 | data3 = data[0..-3]
55 | else
56 |
57 | data3 = data[0..-1]
58 |
59 |
60 | send_event('graph8', points: data3)
61 |
62 | end
63 | end
64 |
--------------------------------------------------------------------------------
/jobs/int-cpu.rb:
--------------------------------------------------------------------------------
1 | ### TOP 10 INSTRUMENTS
2 | require 'curb'
3 | require 'httparty'
4 | require 'open-uri'
5 | require 'nokogiri'
6 | require 'json'
7 |
8 | SCHEDULER.every '30s', :first_in => 0 do |job|
9 |
10 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=papa&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
11 | roota = doc.root #mark the top of the xml data
12 | cpu1 = roota.xpath("//ACT")# search for tags that match "act" there is only one set
13 | metervalue = cpu1.to_s()[5...-6].to_i #convert the nodeset to a readable value
14 |
15 | docb = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=quebec&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
16 | rootb = docb.root #mark the top of the xml data
17 | cpu2 = rootb.xpath("//ACT")# search for tags that match "act" there is only one set
18 | metervalue2 = cpu2.to_s()[5...-6].to_f #convert the nodeset to a readable value
19 |
20 | docc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=SQL2008R2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
21 | rootc = docc.root #mark the top of the xml data
22 | cpu3 = rootc.xpath("//ACT")# search for tags that match "act" there is only one set
23 | metervalue3 = cpu3.to_s()[5...-6].to_f #convert the nodeset to a readable value
24 |
25 | docd = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=EXCH01&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
26 | rootd = docd.root #mark the top of the xml data
27 | cpu4 = rootd.xpath("//ACT")# search for tags that match "act" there is only one set
28 | metervalue4 = cpu4.to_s()[5...-6].to_f #convert the nodeset to a readable value
29 |
30 | docf = Nokogiri::XML(open("http://+++pnp4nagios/index.php/xml?host=VCS01&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
31 | rootf = docf.root #mark the top of the xml data
32 | cpu6 = rootf.xpath("//ACT")# search for tags that match "act" there is only one set
33 | metervalue6 = cpu6.to_s()[5...-6].to_f #convert the nodeset to a readable value
34 |
35 | docg = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=VNODE1&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
36 | rootg = docg.root #mark the top of the xml data
37 | cpu7 = rootg.xpath("//ACT")# search for tags that match "act" there is only one set
38 | metervalue7 = cpu7.to_s()[5...-6].to_f #convert the nodeset to a readable value
39 |
40 | servers = Array.new
41 | servers << {name: "TESTING-SRV1", progress: metervalue}
42 | servers << {name: "TESTING-SRV2", progress: metervalue2}
43 | servers << {name: "SQL-TEST", progress: metervalue3}
44 | servers << {name: "EXCHANGE", progress: metervalue4}
45 | servers << {name: "SUBVERSION", progress: metervalue6}
46 | servers << {name: "VNODE 1", progress: metervalue7}
47 |
48 |
49 | #servers = [["TESTING-SRV1", metervalue], ["TESTING-SRV2", metervalue2], ["SQL-TEST", metervalue3], ["EXCHANGE ", metervalue4], ["SUBVERSION", metervalue6]]
50 |
51 | #servers = servers.sort_by{|k|k[1]}
52 | #servers.reverse!
53 |
54 | #ti_cats = servers.map { |list| list[0] }
55 | #ti_data = servers.map { |list| list[1] }
56 |
57 | #send_event('internal-cpu', { series: [{ name: 'servers', data: ti_data }], categories: ti_cats, color: '#2c3e50' })
58 | send_event('internal-cpu', {title: "INTERNAL CPU USAGE", progress_items: servers})
59 | end
60 |
--------------------------------------------------------------------------------
/jobs/int-disk.rb:
--------------------------------------------------------------------------------
1 |
2 | require 'curb'
3 | require 'httparty'
4 | require 'open-uri'
5 | require 'nokogiri'
6 | require 'json'
7 |
8 | SCHEDULER.every '600s', :first_in => 0 do |job|
9 |
10 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=***&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
11 | root = doc.root #mark the top of the xml data
12 | max = root.xpath("//MAX").first# search for tags that match "act" there is only one set
13 | max = max.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
14 | acpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
15 | acpu = acpu.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
16 |
17 | used = acpu.fdiv(max)*100
18 | free = used.round #convert difference as a percentage
19 |
20 | docb = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=***&srv=fs_/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
21 | rootb = docb.root #mark the top of the xml data
22 | maxb = rootb.xpath("//MAX").first# search for tags that match "act" there is only one set
23 | maxb = maxb.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
24 | acpub = rootb.xpath("//ACT")# search for tags that match "act" there is only one set
25 | acpub = acpub.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
26 |
27 | usedb = acpub.fdiv(maxb)*100
28 | free2 = usedb.round #convert difference as a percentage
29 |
30 | docc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=***&srv=fs_D:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
31 | rootc = docc.root #mark the top of the xml data
32 | maxc = rootc.xpath("//MAX").first# search for tags that match "act" there is only one set
33 | maxc = maxc.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
34 | acpuc = rootc.xpath("//ACT")# search for tags that match "act" there is only one set
35 | acpuc = acpuc.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
36 |
37 | usedc = acpuc.fdiv(maxc)*100
38 | free3 = usedc.round #convert difference as a percentage
39 |
40 | docd = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=***&srv=fs_C:/ClusterStorage/Volume1/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
41 | rootd = docd.root #mark the top of the xml data
42 | maxd = rootd.xpath("//MAX").first# search for tags that match "act" there is only one set
43 | maxd = maxd.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
44 | acpud = rootd.xpath("//ACT")# search for tags that match "act" there is only one set
45 | acpud = acpud.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
46 |
47 | usedd = acpud.fdiv(maxd)*100
48 | free4 = usedd.round #convert difference as a percentage
49 |
50 |
51 |
52 | servers = Array.new
53 | servers << {name: "SQL 2008R2", progress: free}
54 | servers << {name: "VCS-01", progress: free2}
55 | servers << {name: "FILES", progress: free3}
56 | servers << {name: "CLUSTER 1", progress: free4}
57 |
58 | #send_event('servers', { series: [{ name: 'servers', data: ti_data }], categories: ti_cats, color: '#2c3e50' })
59 | send_event('int-disk', {title: "INTERNAL DISK SPACE (USED)", progress_items: servers})
60 | end
61 |
--------------------------------------------------------------------------------
/jobs/juliet.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '60s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
12 |
13 | cpu = cpu.to_s() #convert the nodeset to a string
14 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
15 | metervalue = cpu2.to_f #convert to a float
16 |
17 | send_event('juliet', value: metervalue) #send to dashboard
18 | end
19 |
--------------------------------------------------------------------------------
/jobs/kilo.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '60s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=kilo&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
12 |
13 | cpu = cpu.to_s() #convert the nodeset to a string
14 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
15 | metervalue = cpu2.to_f #convert to a float
16 |
17 | send_event('kilo', value: metervalue) #send to dashboard
18 | end
19 |
--------------------------------------------------------------------------------
/jobs/lima.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '60s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
12 |
13 | cpu = cpu.to_s() #convert the nodeset to a string
14 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
15 | metervalue = cpu2.to_f #convert to a float
16 |
17 | send_event('juliet2', value: metervalue) #send to dashboard
18 | end
19 |
--------------------------------------------------------------------------------
/jobs/mike.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '60s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet3&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read
9 | ) # load it into the nokogiri gem
10 | root = doc.root #mark the top of the xml data
11 |
12 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
13 |
14 | cpu = cpu.to_s() #convert the nodeset to a string
15 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
16 | metervalue = cpu2.to_f #convert to a float
17 |
18 | send_event('juliet3', value: metervalue) #send to dashboard
19 | end
20 |
--------------------------------------------------------------------------------
/jobs/november.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.november.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 | # print statuses to dashboard
26 | send_event('november', {value: result})
27 | end
28 |
--------------------------------------------------------------------------------
/jobs/oscar.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://oscar.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 |
26 | # print statuses to dashboard
27 | send_event('oscar', {value: result})
28 | end
29 |
--------------------------------------------------------------------------------
/jobs/papa.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '45s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=papa&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
12 |
13 | cpu = cpu.to_s() #convert the nodeset to a string
14 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
15 | metervalue = cpu2.to_f #convert to a float
16 |
17 | send_event('papa', value: metervalue) #send to dashboard
18 | end
19 |
--------------------------------------------------------------------------------
/jobs/prod-cpu.rb:
--------------------------------------------------------------------------------
1 |
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '60s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | roota = doc.root #mark the top of the xml data
10 | cpu1 = roota.xpath("//ACT")# search for tags that match "act" there is only one set
11 | metervalue7 = cpu1.to_s()[5...-6].to_f #convert the nodeset to a readable value
12 |
13 | docb = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet2&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
14 | rootb = docb.root #mark the top of the xml data
15 | cpu2 = rootb.xpath("//ACT")# search for tags that match "act" there is only one set
16 | metervalue8 = cpu2.to_s()[5...-6].to_f #convert the nodeset to a readable value
17 |
18 | docc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet3&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
19 | rootc = docc.root #mark the top of the xml data
20 | cpu3 = rootc.xpath("//ACT")# search for tags that match "act" there is only one set
21 | metervalue9 = cpu3.to_s()[5...-6].to_f #convert the nodeset to a readable value
22 |
23 | docd = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=RS-WEB4&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
24 | rootd = docd.root #mark the top of the xml data
25 | cpu4 = rootd.xpath("//ACT")# search for tags that match "act" there is only one set
26 | metervalue10 = cpu4.to_s()[5...-6].to_f #convert the nodeset to a readable value
27 |
28 | doce = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=kilo&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
29 | roote = doce.root #mark the top of the xml data
30 | cpu5 = roote.xpath("//ACT")# search for tags that match "act" there is only one set
31 | metervalue11 = cpu5.to_s()[5...-6].to_f #convert the nodeset to a readable value
32 |
33 | docf = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet1&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
34 | rootf = docf.root #mark the top of the xml data
35 | cpu6 = rootf.xpath("//ACT")# search for tags that match "act" there is only one set
36 | metervalue12 = cpu6.to_s()[5...-6].to_f #convert the nodeset to a readable value
37 |
38 | serversprodcpu = Array.new
39 | serversprodcpu << {name: "STAGING", progress: metervalue7}
40 | serversprodcpu << {name: "PRODUCTION", progress: metervalue8}
41 | serversprodcpu << {name: "STAGING2", progress: metervalue12}
42 | serversprodcpu << {name: "PRODUCTION2", progress: metervalue9}
43 | serversprodcpu << {name: "NON CORE", progress: metervalue10}
44 | serversprodcpu << {name: "MS SQL", progress: metervalue11}
45 |
46 | send_event('production-servers', {title: "PRODUCTION CPU USAGE", progress_items: serversprodcpu})
47 | end
48 |
--------------------------------------------------------------------------------
/jobs/prod-disk.rb:
--------------------------------------------------------------------------------
1 |
2 | require 'curb'
3 | require 'httparty'
4 | require 'open-uri'
5 | require 'nokogiri'
6 | require 'json'
7 |
8 | SCHEDULER.every '600s', :first_in => 0 do |job|
9 |
10 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
11 | root = doc.root #mark the top of the xml data
12 | max = root.xpath("//MAX").first# search for tags that match "act" there is only one set
13 | max = max.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
14 | acpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
15 | acpu = acpu.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
16 |
17 | used = acpu.fdiv(max)*100
18 | free = used.round #convert difference as a percentage
19 |
20 | docb = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet2&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
21 | rootb = docb.root #mark the top of the xml data
22 | maxb = rootb.xpath("//MAX").first# search for tags that match "act" there is only one set
23 | maxb = maxb.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
24 | acpub = rootb.xpath("//ACT")# search for tags that match "act" there is only one set
25 | acpub = acpub.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
26 |
27 | usedb = acpub.fdiv(maxb)*100
28 | free2 = usedb.round #convert difference as a percentage
29 |
30 | docc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet1&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
31 | rootc = docc.root #mark the top of the xml data
32 | maxc = rootc.xpath("//MAX").first# search for tags that match "act" there is only one set
33 | maxc = maxc.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
34 | acpuc = rootc.xpath("//ACT")# search for tags that match "act" there is only one set
35 | acpuc = acpuc.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
36 |
37 | usedc = acpuc.fdiv(max)*100
38 | free3 = usedc.round #convert difference as a percentage
39 |
40 | docd = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=kilo&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
41 | rootd = docd.root #mark the top of the xml data
42 | maxd = rootd.xpath("//MAX").first# search for tags that match "act" there is only one set
43 | maxd = maxd.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
44 | acpud = rootd.xpath("//ACT")# search for tags that match "act" there is only one set
45 | acpud = acpud.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
46 |
47 | usedd = acpud.fdiv(maxd)*100
48 | free4 = usedd.round #convert difference as a percentage
49 |
50 |
51 | docm = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=juliet3&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
52 | rootm = docm.root #mark the top of the xml data
53 | maxm = rootm.xpath("//MAX").first# search for tags that match "act" there is only one set
54 | maxm = maxm.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
55 | acpum = rootm.xpath("//ACT")# search for tags that match "act" there is only one set
56 | acpum = acpum.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
57 |
58 | usedm = acpum.fdiv(maxd)*100
59 | free15 = usedm.round #convert difference as a percentage
60 |
61 | docn = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=RS-WEB4&srv=fs_C:/", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
62 | rootn = docn.root #mark the top of the xml data
63 | maxn = rootn.xpath("//MAX").first# search for tags that match "act" there is only one set
64 | maxn = maxn.to_s()[5...-6].to_f / 1000 .round(3) #convert the nodeset to a string
65 | acpun = rootn.xpath("//ACT")# search for tags that match "act" there is only one set
66 | acpun = acpun.to_s()[5...-6].to_f / 1000 .round(3)#convert the nodeset to a string
67 |
68 | usedn = acpun.fdiv(maxd)*100
69 | free16 = usedn.round #convert difference as a percentage
70 |
71 | servers = Array.new
72 | servers << {name: "STAGING", progress: free}
73 | servers << {name: "PRODUCTION", progress: free2}
74 | servers << {name: "STAGING2", progress: free3}
75 | servers << {name: "PRODUCTION2", progress: free15}
76 | servers << {name: "MS SQL", progress: free4}
77 | servers << {name: "NON CORE", progress: free16}
78 |
79 | #send_event('servers', { series: [{ name: 'servers', data: ti_data }], categories: ti_cats, color: '#2c3e50' })
80 | send_event('prod-disk', {title: "PRODUCTION DISK SPACE (USED)", progress_items: servers})
81 | end
82 |
--------------------------------------------------------------------------------
/jobs/quebec.rb:
--------------------------------------------------------------------------------
1 | require 'curb'
2 | require 'httparty'
3 | require 'open-uri'
4 | require 'nokogiri'
5 |
6 | SCHEDULER.every '45s', :first_in => 0 do |job|
7 |
8 | doc = Nokogiri::XML(open("http://+++/pnp4nagios/index.php/xml?host=quebec&srv=CPU_utilization", http_basic_authentication: ["login", "pwd"]).read) # load it into the nokogiri gem
9 | root = doc.root #mark the top of the xml data
10 |
11 | cpu = root.xpath("//ACT")# search for tags that match "act" there is only one set
12 |
13 | cpu = cpu.to_s() #convert the nodeset to a string
14 | cpu2 = cpu[5...-6] #strip the tag identifiers from each side of the value
15 | metervalue = cpu2.to_f #convert to a float
16 |
17 | send_event('quebec', value: metervalue) #send to dashboard
18 | end
19 |
--------------------------------------------------------------------------------
/jobs/romeo.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'net/http'
3 | #require 'csv'
4 | require 'httparty'
5 | require 'open-uri'
6 | # Check whether a server is responding
7 | #
8 |
9 | SCHEDULER.every '30s', :first_in => 0 do |job|
10 |
11 |
12 | # check status for server
13 | s = HTTParty.get('https://www.romeo.com/md5 hash check.cfm')
14 |
15 | siteMd5 = '******'
16 | strcomp = s.strip <=> siteMd5.strip
17 | comparison = s + ' against ' + siteMd5
18 | if strcomp == 0
19 | result = '1(site is up)'
20 | else
21 | result = '4 ( DOH! ) '
22 | end
23 |
24 |
25 |
26 | # print statuses to dashboard
27 | send_event('romeo', {value: result})
28 | end
29 |
--------------------------------------------------------------------------------
/log/thin.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/log/thin.log
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | This Dashboard doesn't exist.
5 |
17 |
18 |
19 |
20 |
21 |
22 |
Drats! That Dashboard doesn't exist.
23 |
You may have mistyped the address or the page may have moved.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/public/favicon.ico
--------------------------------------------------------------------------------
/tmp/pids/thin.pid:
--------------------------------------------------------------------------------
1 | 4400
--------------------------------------------------------------------------------
/widgets/comments/comments.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Comments extends Dashing.Widget
2 |
3 | @accessor 'quote', ->
4 | "“#{@get('current_comment')?.body}”"
5 |
6 | ready: ->
7 | @currentIndex = 0
8 | @commentElem = $(@node).find('.comment-container')
9 | @nextComment()
10 | @startCarousel()
11 |
12 | onData: (data) ->
13 | @currentIndex = 0
14 |
15 | startCarousel: ->
16 | setInterval(@nextComment, 8000)
17 |
18 | nextComment: =>
19 | comments = @get('comments')
20 | if comments
21 | @commentElem.fadeOut =>
22 | @currentIndex = (@currentIndex + 1) % comments.length
23 | @set 'current_comment', comments[@currentIndex]
24 | @commentElem.fadeIn()
25 |
--------------------------------------------------------------------------------
/widgets/comments/comments.html:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/widgets/comments/comments.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #eb9c3c;
5 |
6 | $title-color: rgba(255, 255, 255, 0.7);
7 | $moreinfo-color: rgba(255, 255, 255, 0.7);
8 |
9 | // ----------------------------------------------------------------------------
10 | // Widget-comment styles
11 | // ----------------------------------------------------------------------------
12 | .widget-comments {
13 |
14 | background-color: $background-color;
15 |
16 | .title {
17 | color: $title-color;
18 | margin-bottom: 15px;
19 | }
20 |
21 | .name {
22 | padding-left: 5px;
23 | }
24 |
25 | .comment-container {
26 | display: none;
27 | }
28 |
29 | .more-info {
30 | color: $moreinfo-color;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/widgets/graph/graph.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Graph extends Dashing.Widget
2 |
3 | @accessor 'current', ->
4 | return @get('displayedValue') if @get('displayedValue')
5 | points = @get('points')
6 | if points
7 | points[points.length - 1].y
8 |
9 | ready: ->
10 | container = $(@node).parent()
11 | # Gross hacks. Let's fix this.
12 | width = (Dashing.widget_base_dimensions[0] * container.data("sizex")) + Dashing.widget_margins[0] * 2 * (container.data("sizex") - 1)
13 | height = (Dashing.widget_base_dimensions[1] * container.data("sizey"))
14 | @graph = new Rickshaw.Graph(
15 | element: @node
16 | width: width
17 | height: height
18 | renderer: @get("graphtype")
19 | series: [
20 | {
21 | color: "#fff",
22 | data: [{x:0, y:0}]
23 | }
24 | ]
25 | )
26 |
27 | @graph.series[0].data = @get('points') if @get('points')
28 |
29 | x_axis = new Rickshaw.Graph.Axis.Time(graph: @graph)
30 | y_axis = new Rickshaw.Graph.Axis.Y(graph: @graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT)
31 | @graph.render()
32 |
33 | onData: (data) ->
34 | if @graph
35 | @graph.series[0].data = data.points
36 | @graph.render()
37 |
--------------------------------------------------------------------------------
/widgets/graph/graph.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/widgets/graph/graph.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #dc5945;
5 |
6 | $title-color: rgba(255, 255, 255, 0.7);
7 | $moreinfo-color: rgba(255, 255, 255, 0.3);
8 | $tick-color: rgba(0, 0, 0, 0.4);
9 |
10 |
11 | // ----------------------------------------------------------------------------
12 | // Widget-graph styles
13 | // ----------------------------------------------------------------------------
14 | .widget-graph {
15 |
16 | background-color: $background-color;
17 | position: relative;
18 |
19 |
20 | svg {
21 | position: absolute;
22 | opacity: 0.4;
23 | fill-opacity: 0.4;
24 | left: 0px;
25 | top: 0px;
26 | }
27 |
28 | .title, .value {
29 | position: relative;
30 | z-index: 99;
31 | }
32 |
33 | .title {
34 | color: $title-color;
35 | }
36 |
37 | .more-info {
38 | color: $moreinfo-color;
39 | font-weight: 600;
40 | font-size: 20px;
41 | margin-top: 0;
42 | }
43 |
44 | .x_tick {
45 | position: absolute;
46 | bottom: 0;
47 | .title {
48 | font-size: 20px;
49 | color: $tick-color;
50 | opacity: 0.5;
51 | padding-bottom: 3px;
52 | }
53 | }
54 |
55 | .y_ticks {
56 | font-size: 20px;
57 | fill: $tick-color;
58 | fill-opacity: 1;
59 | }
60 |
61 | .domain {
62 | display: none;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/widgets/horizonbarstack/horizonbarstack.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Horizonbarstack extends Dashing.Widget
2 |
3 | ready: ->
4 |
5 | Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, (color) ->
6 | Highcharts.Color(color).setOpacity(0.82).get "rgba"
7 | )
8 |
9 | createChart: (series, categories, color) ->
10 | container = $(@node).find('.horizon-container')
11 | if $(container)[0]
12 | @chart = new Highcharts.Chart(
13 |
14 | chart:
15 | renderTo: $(container)[0]
16 | type: "bar"
17 | backgroundColor: null
18 | marginTop: 0
19 | marginRight: 15
20 |
21 | title:
22 | text: ''
23 |
24 | legend:
25 | enabled: false
26 | reversed: true
27 | borderColor: 'white'
28 | borderWidth: 2
29 |
30 | xAxis:
31 | categories: categories
32 | labels:
33 | enabled: false
34 | minorGridLineWidth: 0
35 | minorTickLength: 0
36 | tickLength: 0
37 |
38 | yAxis:
39 | gridLineColor: 'gray'
40 | stackLabels:
41 | style:
42 | color: 'white'
43 | enabled: false
44 | verticalAlign: 'middle'
45 | align: 'left'
46 | #formatter: ->
47 | # categories[@x]
48 |
49 | title:
50 | text: ""
51 |
52 | tooltip:
53 | formatter: ->
54 | "" + @series.name + "
" + " Transactions: " + @y + "
"
55 |
56 | plotOptions:
57 | series:
58 | stacking: 'normal'
59 | borderWidth: 0
60 | pointPadding: 0
61 | groupPadding: 0
62 | bar:
63 | colorByPoint: false
64 | cursor: "pointer"
65 | animation:
66 | duration: 2000
67 | easing: 'easeOutBounce'
68 | showInLegend: false
69 | dataLabels:
70 | enabled: true
71 | format: '{x}' + ': {y}'
72 | color: "white"
73 | align: 'left'
74 | verticalAlign: 'middle'
75 | style:
76 | fontSize: '20 px'
77 | connectorColor: "#000000"
78 |
79 |
80 | navigation:
81 | buttonOptions:
82 | verticalAlign: 'top'
83 | y: -7
84 | x: -9
85 | theme:
86 | 'stroke-width': 1
87 | stroke: color
88 | r: 0
89 | fill: color
90 | states:
91 | hover:
92 | fill: color
93 | select:
94 | fill: color
95 |
96 | series: series
97 | )
98 |
99 | onData: (data) ->
100 | @createChart(data.series, data.categories, data.color)
--------------------------------------------------------------------------------
/widgets/horizonbarstack/horizonbarstack.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.Horizonbarstack extends Dashing.Widget
2 |
3 | ready: ->
4 |
5 | Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, (color) ->
6 | Highcharts.Color(color).setOpacity(0.82).get "rgba"
7 | )
8 |
9 | createChart: (series, categories, color) ->
10 | container = $(@node).find('.horizon-container')
11 | if $(container)[0]
12 | @chart = new Highcharts.Chart(
13 |
14 | chart:
15 | renderTo: $(container)[0]
16 | type: "bar"
17 | backgroundColor: null
18 | marginTop: 0
19 | marginRight: 15
20 |
21 | title:
22 | text: ''
23 |
24 | legend:
25 | enabled: false
26 | reversed: true
27 | borderColor: 'white'
28 | borderWidth: 2
29 |
30 | xAxis:
31 | categories: categories
32 | labels:
33 | enabled: false
34 | minorGridLineWidth: 0
35 | minorTickLength: 0
36 | tickLength: 0
37 |
38 | yAxis:
39 | gridLineColor: 'gray'
40 | stackLabels:
41 | style:
42 | color: 'white'
43 | enabled: false
44 | verticalAlign: 'middle'
45 | align: 'left'
46 | #formatter: ->
47 | # categories[@x]
48 |
49 | title:
50 | text: "Total Number of Transactions"
51 |
52 | tooltip:
53 | formatter: ->
54 | "" + @series.name + "
" + " Transactions: " + @y + "
"
55 |
56 | plotOptions:
57 | series:
58 | stacking: 'normal'
59 | borderWidth: 1
60 | pointPadding: 0
61 | groupPadding: 0
62 | bar:
63 | colorByPoint: false
64 | cursor: "pointer"
65 | animation:
66 | duration: 2000
67 | easing: 'easeOutBounce'
68 | showInLegend: false
69 | dataLabels:
70 | enabled: true
71 | format: '{x}' + ': {y}'
72 | color: "white"
73 | align: 'left'
74 | verticalAlign: 'middle'
75 | style:
76 | fontSize: '20 px'
77 | connectorColor: "#000000"
78 |
79 |
80 | navigation:
81 | buttonOptions:
82 | verticalAlign: 'top'
83 | y: -7
84 | x: -9
85 | theme:
86 | 'stroke-width': 1
87 | stroke: color
88 | r: 0
89 | fill: color
90 | states:
91 | hover:
92 | fill: color
93 | select:
94 | fill: color
95 |
96 | series: series
97 | )
98 |
99 | onData: (data) ->
100 | @createChart(data.series, data.categories, data.color)
--------------------------------------------------------------------------------
/widgets/horizonbarstack/horizonbarstack.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/widgets/horizonbarstack/horizonbarstack.html~:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/horizonbarstack/horizonbarstack.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derrybarry/nagios-check_mk-dashing/a7517aa7640f14427084fa128be4ea0c423cef69/widgets/horizonbarstack/horizonbarstack.scss
--------------------------------------------------------------------------------
/widgets/hotness/hotness.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Hotness extends Dashing.Widget
2 |
3 | @accessor 'value', Dashing.AnimatedValue
4 |
5 | constructor: ->
6 | super
7 |
8 | onData: (data) ->
9 | node = $(@node)
10 | value = parseInt data.value
11 | cool = parseInt node.data "cool"
12 | warm = parseInt node.data "warm"
13 | level = switch
14 | when value <= cool then 0
15 | when value >= warm then 4
16 | else
17 | bucketSize = (warm - cool) / 3 # Total # of colours in middle
18 | Math.ceil (value - cool) / bucketSize
19 |
20 | backgroundClass = "hotness#{level}"
21 | lastClass = @get "lastClass"
22 | node.toggleClass "#{lastClass} #{backgroundClass}"
23 | @set "lastClass", backgroundClass
24 |
--------------------------------------------------------------------------------
/widgets/hotness/hotness.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/widgets/hotness/hotness.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Mixins
3 | // ----------------------------------------------------------------------------
4 | @mixin transition($transition-property, $transition-time, $method) {
5 | -webkit-transition: $transition-property $transition-time $method;
6 | -moz-transition: $transition-property $transition-time $method;
7 | -o-transition: $transition-property $transition-time $method;
8 | transition: $transition-property $transition-time $method;
9 | }
10 |
11 | // ----------------------------------------------------------------------------
12 | // Sass declarations
13 | // ----------------------------------------------------------------------------
14 | $background-color: #000000;
15 | $value-color: #FFFFFF;
16 | $title-color: rgba(255, 255, 255, 0.8);
17 | $updated-at-color: rgba(0, 0, 0, 0.3);
18 |
19 |
20 | // ----------------------------------------------------------------------------
21 | // Widget-hotness styles
22 | // ----------------------------------------------------------------------------
23 | .widget-hotness {
24 |
25 | background-color: $background-color;
26 | @include transition(background-color, 1s, linear);
27 |
28 |
29 | h1 {
30 | font-size:+em;
31 | font-weight: bold;
32 | }
33 |
34 | h2 {
35 | font-size:+em;
36 |
37 | }
38 | .title {
39 | color: $title-color;
40 | }
41 |
42 | .value {
43 | color: $value-color;
44 | }
45 |
46 | .updated-at {
47 | color: $updated-at-color;
48 | }
49 |
50 | }
51 |
52 | .hotness0 { background-color: #00C176; }
53 | .hotness1 { background-color: #88C100; }
54 | .hotness2 { background-color: #FABE28; }
55 | .hotness3 { background-color: #FF8A00; }
56 | .hotness4 { background-color: #FF003C; }
57 |
58 | // // More colour-blind friendly palette
59 | // .hotness0 { background-color: #046D8B; }
60 | // .hotness1 { background-color: #309292; }
61 | // .hotness2 { background-color: #2FB8AC; }
62 | // .hotness3 { background-color: #93A42A; }
63 | // .hotness4 { background-color: #ECBE13; }
64 |
65 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Hotness1 extends Dashing.Widget
2 |
3 | #@accessor 'value', Dashing.AnimatedValue
4 |
5 | constructor: ->
6 | super
7 |
8 | onData: (data) ->
9 | debugger
10 | node = $(@node)
11 | value = parseFloat data.value
12 | cool = parseFloat node.data "cool"
13 | warm = parseFloat node.data "warm"
14 | level = switch
15 | when value <= cool then 0
16 | when value >= warm then 4
17 | else
18 | bucketSize = (warm - cool) / 3 # Total # of colours in middle
19 | Math.ceil (value - cool) / bucketSize
20 |
21 | backgroundClass = "hotness#{level}"
22 | lastClass = @get "lastClass"
23 | node.toggleClass "#{lastClass} #{backgroundClass}"
24 | @set "lastClass", backgroundClass
25 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.Hotness1 extends Dashing.Widget
2 |
3 | @accessor 'value', Dashing.AnimatedValue
4 |
5 | constructor: ->
6 | super
7 |
8 | onData: (data) ->
9 | node = $(@node)
10 | value = parseInt data.value
11 | cool = parseInt node.data "cool"
12 | warm = parseInt node.data "warm"
13 | level = switch
14 | when value <= cool then 0
15 | when value >= warm then 4
16 | else
17 | bucketSize = (warm - cool) / 3 # Total # of colours in middle
18 | Math.ceil (value - cool) / bucketSize
19 |
20 | backgroundClass = "hotness#{level}"
21 | lastClass = @get "lastClass"
22 | node.toggleClass "#{lastClass} #{backgroundClass}"
23 | @set "lastClass", backgroundClass
24 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.html~:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Mixins
3 | // ----------------------------------------------------------------------------
4 | @mixin transition($transition-property, $transition-time, $method) {
5 | -webkit-transition: $transition-property $transition-time $method;
6 | -moz-transition: $transition-property $transition-time $method;
7 | -o-transition: $transition-property $transition-time $method;
8 | transition: $transition-property $transition-time $method;
9 | }
10 |
11 | // ----------------------------------------------------------------------------
12 | // Sass declarations
13 | // ----------------------------------------------------------------------------
14 | $background-color: #000000;
15 | $value-color: #FFFFFF;
16 | $title-color: rgba(255, 255, 255, 0.8);
17 | $updated-at-color: rgba(0, 0, 0, 0.3);
18 |
19 |
20 | // ----------------------------------------------------------------------------
21 | // Widget-hotness styles
22 | // ----------------------------------------------------------------------------
23 | .widget-hotness1 {
24 |
25 | background-color: $background-color;
26 | @include transition(background-color, 1s, linear);
27 |
28 |
29 |
30 | h1 {
31 | font-size:42px;
32 | font-weight: bold;
33 |
34 | }
35 |
36 | h2 {
37 | font-size:52px;
38 | font-weight: bold;
39 |
40 | }
41 | .title {
42 | color: $title-color;
43 | }
44 |
45 | .value {
46 | color: $value-color;
47 | }
48 |
49 | .updated-at {
50 | color: $updated-at-color;
51 | }
52 |
53 | }
54 |
55 | .hotness0 { background-color: #00C176; }
56 | .hotness1 { background-color: #88C100; }
57 | .hotness2 { background-color: #FABE28; }
58 | .hotness3 { background-color: #FF8A00; }
59 | .hotness4 { background-color: #FF003C; }
60 |
61 | // // More colour-blind friendly palette
62 | // .hotness0 { background-color: #046D8B; }
63 | // .hotness1 { background-color: #309292; }
64 | // .hotness2 { background-color: #2FB8AC; }
65 | // .hotness3 { background-color: #93A42A; }
66 | // .hotness4 { background-color: #ECBE13; }
67 |
68 |
--------------------------------------------------------------------------------
/widgets/hotness1/hotness1.scss~:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Mixins
3 | // ----------------------------------------------------------------------------
4 | @mixin transition($transition-property, $transition-time, $method) {
5 | -webkit-transition: $transition-property $transition-time $method;
6 | -moz-transition: $transition-property $transition-time $method;
7 | -o-transition: $transition-property $transition-time $method;
8 | transition: $transition-property $transition-time $method;
9 | }
10 |
11 | // ----------------------------------------------------------------------------
12 | // Sass declarations
13 | // ----------------------------------------------------------------------------
14 | $background-color: #000000;
15 | $value-color: #FFFFFF;
16 | $title-color: rgba(255, 255, 255, 0.8);
17 | $updated-at-color: rgba(0, 0, 0, 0.3);
18 |
19 |
20 | // ----------------------------------------------------------------------------
21 | // Widget-hotness styles
22 | // ----------------------------------------------------------------------------
23 | .widget-hotness1 {
24 |
25 | background-color: $background-color;
26 | @include transition(background-color, 1s, linear);
27 |
28 |
29 |
30 | h1 {
31 | font-size:+1em;
32 |
33 | }
34 |
35 | h2 {
36 | font-size:+em;
37 |
38 | }
39 | .title {
40 | color: $title-color;
41 | }
42 |
43 | .value {
44 | color: $value-color;
45 | }
46 |
47 | .updated-at {
48 | color: $updated-at-color;
49 | }
50 |
51 | }
52 |
53 | .hotness0 { background-color: #00C176; }
54 | .hotness1 { background-color: #88C100; }
55 | .hotness2 { background-color: #FABE28; }
56 | .hotness3 { background-color: #FF8A00; }
57 | .hotness4 { background-color: #FF003C; }
58 |
59 | // // More colour-blind friendly palette
60 | // .hotness0 { background-color: #046D8B; }
61 | // .hotness1 { background-color: #309292; }
62 | // .hotness2 { background-color: #2FB8AC; }
63 | // .hotness3 { background-color: #93A42A; }
64 | // .hotness4 { background-color: #ECBE13; }
65 |
66 |
--------------------------------------------------------------------------------
/widgets/hotness2/hotness2.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Hotness2 extends Dashing.Widget
2 |
3 | #@accessor 'value', Dashing.AnimatedValue
4 |
5 | constructor: ->
6 | super
7 |
8 | onData: (data) ->
9 | node = $(@node)
10 | value = parseFloat data.value
11 | cool = parseFloat node.data "cool"
12 | warm = parseFloat node.data "warm"
13 | level = switch
14 | when value <= cool then 0
15 | when value >= warm then 4
16 | else
17 | bucketSize = (warm - cool) / 3 # Total # of colours in middle
18 | Math.ceil (value - cool) / bucketSize
19 |
20 | backgroundClass = "hotness#{level}"
21 | lastClass = @get "lastClass"
22 | node.toggleClass "#{lastClass} #{backgroundClass}"
23 | @set "lastClass", backgroundClass
24 |
--------------------------------------------------------------------------------
/widgets/hotness2/hotness2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/widgets/hotness2/hotness2.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Mixins
3 | // ----------------------------------------------------------------------------
4 | @mixin transition($transition-property, $transition-time, $method) {
5 | -webkit-transition: $transition-property $transition-time $method;
6 | -moz-transition: $transition-property $transition-time $method;
7 | -o-transition: $transition-property $transition-time $method;
8 | transition: $transition-property $transition-time $method;
9 | }
10 |
11 | // ----------------------------------------------------------------------------
12 | // Sass declarations
13 | // ----------------------------------------------------------------------------
14 | $background-color: #000000;
15 | $value-color: #FFFFFF;
16 | $title-color: rgba(255, 255, 255, 0.8);
17 | $updated-at-color: rgba(0, 0, 0, 0.3);
18 |
19 |
20 | // ----------------------------------------------------------------------------
21 | // Widget-hotness styles
22 | // ----------------------------------------------------------------------------
23 | .widget-hotness2 {
24 |
25 | background-color: $background-color;
26 | @include transition(background-color, 1s, linear);
27 |
28 |
29 |
30 | h1 {
31 | font-size:32px;
32 | font-weight: bold;
33 |
34 | }
35 |
36 | h2 {
37 | font-size:35px;
38 | font-weight: bold;
39 |
40 | }
41 | .title {
42 | color: $title-color;
43 | }
44 |
45 | .value {
46 | color: $value-color;
47 | }
48 |
49 | .updated-at {
50 | color: $updated-at-color;
51 | }
52 |
53 | }
54 |
55 | .hotness0 { background-color: #00C176; }
56 | .hotness1 { background-color: #88C100; }
57 | .hotness2 { background-color: #FABE28; }
58 | .hotness3 { background-color: #FF8A00; }
59 | .hotness4 { background-color: #FF003C; }
60 |
61 | // // More colour-blind friendly palette
62 | // .hotness0 { background-color: #046D8B; }
63 | // .hotness1 { background-color: #309292; }
64 | // .hotness2 { background-color: #2FB8AC; }
65 | // .hotness3 { background-color: #93A42A; }
66 | // .hotness4 { background-color: #ECBE13; }
67 |
68 |
--------------------------------------------------------------------------------
/widgets/image/image.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Image extends Dashing.Widget
2 |
3 | ready: ->
4 | # This is fired when the widget is done being rendered
5 |
6 | onData: (data) ->
7 | # Handle incoming data
8 | # You can access the html node of this widget with `@node`
9 | # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in.
10 |
--------------------------------------------------------------------------------
/widgets/image/image.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/widgets/image/image.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #4b4b4b;
5 |
6 | // ----------------------------------------------------------------------------
7 | // Widget-image styles
8 | // ----------------------------------------------------------------------------
9 | .widget-image {
10 |
11 | background-color: $background-color;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/widgets/list/list.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.List extends Dashing.Widget
2 | ready: ->
3 | if @get('unordered')
4 | $(@node).find('ol').remove()
5 | else
6 | $(@node).find('ul').remove()
7 |
--------------------------------------------------------------------------------
/widgets/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/widgets/list/list.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #12b0c5;
5 | $value-color: #fff;
6 |
7 | $title-color: rgba(255, 255, 255, 0.7);
8 | $label-color: rgba(255, 255, 255, 0.7);
9 | $moreinfo-color: rgba(255, 255, 255, 0.7);
10 |
11 | // ----------------------------------------------------------------------------
12 | // Widget-list styles
13 | // ----------------------------------------------------------------------------
14 | .widget-list {
15 |
16 | background-color: $background-color;
17 | vertical-align: top;
18 |
19 | .title {
20 | color: $title-color;
21 | }
22 |
23 | ol, ul {
24 | margin: 0 15px;
25 | text-align: left;
26 | color: $label-color;
27 | }
28 |
29 | ol {
30 | list-style-position: inside;
31 | }
32 |
33 | li {
34 | margin-bottom: 5px;
35 | }
36 |
37 | .list-nostyle {
38 | list-style: none;
39 | }
40 |
41 | .label {
42 | color: $label-color;
43 | }
44 |
45 | .value {
46 | float: right;
47 | margin-left: 12px;
48 | font-weight: 600;
49 | color: $value-color;
50 | }
51 |
52 | .updated-at {
53 | color: rgba(0, 0, 0, 0.3);
54 | }
55 |
56 | .more-info {
57 | color: $moreinfo-color;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/widgets/meter/meter.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Meter extends Dashing.Widget
2 |
3 | @accessor 'value', Dashing.AnimatedValue
4 |
5 | constructor: ->
6 | super
7 | @observe 'value', (value) ->
8 | $(@node).find(".meter").val(value).trigger('change')
9 |
10 | ready: ->
11 | meter = $(@node).find(".meter")
12 | meter.attr("data-bgcolor", meter.css("background-color"))
13 | meter.attr("data-fgcolor", meter.css("color"))
14 | meter.knob()
15 |
--------------------------------------------------------------------------------
/widgets/meter/meter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/widgets/meter/meter.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #08b5fc;
5 |
6 | $title-color: rgba(255, 255, 255, 0.99);
7 | $moreinfo-color: rgba(255, 255, 255, 0.3);
8 |
9 | $meter-background: darken($background-color, 15%);
10 |
11 | // ----------------------------------------------------------------------------
12 | // Widget-meter styles
13 | // ----------------------------------------------------------------------------
14 | .widget-meter {
15 |
16 | background-color: $background-color;
17 |
18 | input.meter {
19 | background-color: $meter-background;
20 | color: #fff;
21 | }
22 |
23 | .title {
24 | color: $title-color;
25 | }
26 |
27 | .more-info {
28 | color: $moreinfo-color;
29 | }
30 |
31 | .updated-at {
32 | color: rgba(0, 0, 0, 0.3);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/widgets/number/number.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Number extends Dashing.Widget
2 | @accessor 'current', Dashing.AnimatedValue
3 |
4 | @accessor 'difference', ->
5 | if @get('last')
6 | last = parseInt(@get('last'))
7 | current = parseInt(@get('current'))
8 | if last != 0
9 | diff = Math.abs(Math.round((current - last) / last * 100))
10 | "#{diff}%"
11 | else
12 | ""
13 |
14 | @accessor 'arrow', ->
15 | if @get('last')
16 | if parseInt(@get('current')) > parseInt(@get('last')) then 'icon-arrow-up' else 'icon-arrow-down'
17 |
18 | onData: (data) ->
19 | if data.status
20 | # clear existing "status-*" classes
21 | $(@get('node')).attr 'class', (i,c) ->
22 | c.replace /\bstatus-\S+/g, ''
23 | # add new class
24 | $(@get('node')).addClass "status-#{data.status}"
25 |
--------------------------------------------------------------------------------
/widgets/number/number.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/widgets/number/number.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #47bbb3;
5 | $value-color: #fff;
6 |
7 | $title-color: rgba(255, 255, 255, 0.7);
8 | $moreinfo-color: rgba(255, 255, 255, 0.7);
9 |
10 | // ----------------------------------------------------------------------------
11 | // Widget-number styles
12 | // ----------------------------------------------------------------------------
13 | .widget-number {
14 |
15 | background-color: $background-color;
16 |
17 | .title {
18 | color: $title-color;
19 | }
20 |
21 | .value {
22 | color: $value-color;
23 | }
24 |
25 | .change-rate {
26 | font-weight: 500;
27 | font-size: 30px;
28 | color: $value-color;
29 | }
30 |
31 | .more-info {
32 | color: $moreinfo-color;
33 | }
34 |
35 | .updated-at {
36 | color: rgba(0, 0, 0, 0.3);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/widgets/progress_bars/progress_bars.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 100)
150 | value = 100
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
--------------------------------------------------------------------------------
/widgets/progress_bars/progress_bars.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/progress_bars/progress_bars.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 1.0em;
9 |
10 | $blue: #2db4d4;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
--------------------------------------------------------------------------------
/widgets/progress_bars/progress_bars.scss~:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 0.5em;
9 |
10 | $blue: #9C4274;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 100)
150 | value = 100
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars.scss~:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 1.0em;
9 |
10 | $blue: #2db4d4;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars1.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars1 extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 100)
150 | value = 100
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
201 |
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars1.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars1 extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 500)
150 | value = 500
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
201 |
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/progress_bars1/progress_bars1.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 1.0em;
9 |
10 | $blue: #2db4d4;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars1 {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 100)
150 | value = 100
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars.scss~:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 1.0em;
9 |
10 | $blue: #2db4d4;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars1.coffee~:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars1 extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 500)
150 | value = 500
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
201 |
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars2.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.ProgressBars2 extends Dashing.Widget
2 |
3 | @accessor 'title'
4 |
5 | ready: ->
6 | @drawWidget( @get('progress_items') )
7 |
8 | onData: (eventData) ->
9 | @drawWidget(eventData.progress_items)
10 |
11 | drawWidget: (progress_items) ->
12 | container = $(@node)
13 | rowsContainer = container.find('.rows-container')
14 |
15 | if progress_items.length == 0
16 | rowsContainer.empty()
17 | else
18 | # Float value used to scale the rows to use the entire space of the widget
19 | rowHeight = 100 / progress_items.length
20 | counter = 0
21 | @clearIntervals()
22 |
23 | # Add or move rows for each project. Checks first if the row already exists.
24 | progress_items.forEach (item) =>
25 | normalizedItemName = item.name.replace(/\W+/g, "_")
26 | referenceRow = rowsContainer.children().eq(counter)
27 | existingRow = rowsContainer.find("."+normalizedItemName)
28 |
29 | if existingRow.length
30 | if referenceRow.attr("class").indexOf(normalizedItemName) == -1
31 | existingRow.detach().insertBefore(referenceRow)
32 | existingRow.hide().fadeIn(1200)
33 | else
34 | row = createRow(item)
35 | if referenceRow.length
36 | row.insertBefore(referenceRow)
37 | else
38 | rowsContainer.append(row)
39 | row.hide().fadeIn(1200)
40 |
41 | elem = rowsContainer.find("."+normalizedItemName+" .inner-progress-bar")
42 | if elem.length
43 | @animateProgressBarContent(elem[0], parseFloat(elem[0].style.width),
44 | parseFloat(item.progress), 1000)
45 | ++counter
46 |
47 | # Remove any nodes that were not in the new data, these will be the rows
48 | # at the end of the widget.
49 | currentNode = rowsContainer.children().eq(counter-1)
50 | while currentNode.next().length
51 | currentNode = currentNode.next()
52 | currentNode.fadeOut(100, -> $(this).remove() )
53 |
54 | # Set the height after rows were added/removed.
55 | rows = rowsContainer.children()
56 | percentageOfTotalHeight = 100 / progress_items.length
57 | applyCorrectedRowHeight(rows, percentageOfTotalHeight)
58 |
59 | #applyZebraStriping(rows)
60 |
61 |
62 | #***/
63 | # Create a JQuery row object with the proper structure and base
64 | # settings for the item passed in.
65 | #
66 | # The Row DOM Hierarchy:
67 | # Row
68 | # Row Content (here so we can use vertical alignment)
69 | # Project Name
70 | # Outer Bar Container (The border and background)
71 | # Inner Bar Container (The progress and text)
72 | #
73 | # @item - object representing an item and it's progress
74 | # /
75 | createRow = (item) ->
76 |
77 | row = ( $("")
78 | .attr("class", "row " + item.name.replace(/\W+/g, "_") ) )
79 |
80 | rowContent = ( $("")
81 | .attr("class", "row-content") )
82 |
83 | projectName = ( $("")
84 | .attr("class", "project-name")
85 | .text(item.name)
86 | .attr("title", item.name) )
87 |
88 | outerProgressBar = ( $("")
89 | .attr("class", "outer-progress-bar") )
90 |
91 | innerProgressBar = $("")
92 | .attr("class", "inner-progress-bar")
93 | .text("0%")
94 | innerProgressBar.css("width", "0%")
95 |
96 | # Put it all together.
97 | outerProgressBar.append(innerProgressBar)
98 | rowContent.append(projectName)
99 | rowContent.append(outerProgressBar)
100 | row.append(rowContent)
101 |
102 | return row
103 |
104 |
105 | #***/
106 | # Does calculations for the animation and sets up the javascript
107 | # interval to perform the animation.
108 | #
109 | # @element - element that is going to be animated.
110 | # @from - the value that the element starts at.
111 | # @to - the value that the element is going to.
112 | # @baseDuration - the minimum time the animation will perform.
113 | # /
114 | animateProgressBarContent: (element, from, to, baseDuration) ->
115 | endpointDifference = (to-from)
116 |
117 | if endpointDifference != 0
118 | currentValue = from
119 |
120 | # Every x milliseconds, the function should run.
121 | stepInterval = 16.667
122 |
123 | # Change the duration based on the distance between points.
124 | duration = baseDuration + Math.abs(endpointDifference) * 25
125 |
126 | numberOfSteps = duration / stepInterval
127 | valueIncrement = endpointDifference / numberOfSteps
128 |
129 | interval = setInterval(
130 | ->
131 | currentValue += valueIncrement
132 | if Math.abs(currentValue - from) >= Math.abs(endpointDifference)
133 | setProgressBarValue(element, to)
134 | clearInterval(interval)
135 | else
136 | setProgressBarValue(element, currentValue)
137 | stepInterval)
138 |
139 | @addInterval(interval)
140 |
141 | #***/
142 | # Sets the text and width of the element in question to the specified value
143 | # after making sure it is bounded between [0-100]
144 | #
145 | # @element - element to be set
146 | # @value - the numeric value to set the element to. This can be a float.
147 | # /
148 | setProgressBarValue = (element, value) ->
149 | if (value > 100)
150 | value = 100
151 | else if (value < 0)
152 | value = 0
153 | element.textContent = Math.floor(value) + "%"
154 | element.style.width = value + "%"
155 |
156 | #***/
157 | # Applies a percentage-based row height to the list of rows passed in.
158 | #
159 | # @rows - the elements to apply this height value to
160 | # @percentageOfTotalHeight - The height to be applied to each row.
161 | # /
162 | applyCorrectedRowHeight = (rows, percentageOfTotalHeight) ->
163 | height = percentageOfTotalHeight + "%"
164 | for row in rows
165 | row.style.height = height
166 |
167 | #***/
168 | # Adds a class to every other row to change the background color. This
169 | # was done mainly for readability.
170 | #
171 | # @rows - list of elements to run zebra-striping on
172 | # /
173 | applyZebraStriping = (rows) ->
174 | isZebraStripe = false
175 | for row in rows
176 | # In case elements are moved around, we don't want them to retain this.
177 | row.classList.remove("zebra-stripe")
178 | if isZebraStripe
179 | row.classList.add("zebra-stripe")
180 | isZebraStripe = !isZebraStripe
181 |
182 | #***/
183 | # Stops all javascript intervals from running and clears the list.
184 | #/
185 | clearIntervals: ->
186 | if @intervalList
187 | for interval in @intervalList
188 | clearInterval(interval)
189 | @intervalList = []
190 |
191 | #***/
192 | # Adds a javascript interval to a list so that it can be tracked and cleared
193 | # ahead of time if the need arises.
194 | #
195 | # @interval - the javascript interval to add
196 | #/
197 | addInterval: (interval) ->
198 | if !@intervalList
199 | @intervalList = []
200 | @intervalList.push(interval)
201 |
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/progress_bars2/progress_bars2.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 |
5 | // row-size is a magic number used for scaling. It will make things bigger
6 | // or smaller but always in proportion with each other. Feel free to change
7 | // this to reflect your personal needs.
8 | $row-size: 1.0em;
9 |
10 | $blue: #2db4d4;
11 | $white: #ffffff;
12 | $base-color: $blue;
13 |
14 | $base-color-dark: darken($base-color, 10%);
15 | $base-color-light: lighten($base-color, 10%);
16 | $base-color-lighter: lighten($base-color, 25%);
17 | $base-color-lightest: lighten($base-color, 35%);
18 |
19 | $text-color: $base-color-lightest;
20 |
21 | // ----------------------------------------------------------------------------
22 | // Widget-project-completion styles
23 | // ----------------------------------------------------------------------------
24 | .widget.widget-progress-bars2 {
25 | height: 100%;
26 | width: 100%;
27 | padding: 5px;
28 | position:relative;
29 | background-color: $base-color;
30 | vertical-align: baseline;
31 |
32 | * {
33 | -webkit-box-sizing: border-box;
34 | -moz-box-sizing: border-box;
35 | box-sizing:border-box;
36 | }
37 |
38 | .title {
39 | color: $text-color;
40 | margin-bottom: 5px;
41 | }
42 |
43 | .rows-container {
44 | height: 85%;
45 | width:100%;
46 | color: $text-color;
47 | font-size: $row-size;
48 | text-align:center;
49 | }
50 |
51 | .row {
52 | height:0%;
53 | width:100%;
54 | vertical-align: middle;
55 | display:table;
56 | transition-property: height;
57 | transition-duration: 0.3s;
58 | transition-timing-function: linear;
59 | }
60 |
61 | .row-content {
62 | padding-left: 5px;
63 | display:table-cell;
64 | vertical-align: middle;
65 | }
66 |
67 | .project-name {
68 | display:inline-block;
69 | width:35%;
70 | padding-right: $row-size;
71 | text-align: left;
72 | vertical-align: middle;
73 | text-overflow: ellipsis;
74 | overflow:hidden;
75 | white-space: nowrap;
76 | }
77 |
78 | .outer-progress-bar {
79 | display:inline-block;
80 | width: 65%;
81 | vertical-align: middle;
82 | border: ($row-size / 3) solid $base-color-dark;
83 | border-radius: 2 * $row-size;
84 | background-color: $base-color-lighter;
85 |
86 | .inner-progress-bar {
87 | background-color: $base-color-dark;
88 | border-radius: $row-size / 2;
89 | color: $white;
90 | }
91 | }
92 |
93 | .zebra-stripe {
94 | background-color: $base-color-light;
95 | }
96 |
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/widgets/rickshawgraph/rickshawgraph.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/rickshawgraph/rickshawgraph.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #dc5945;
5 |
6 | $title-color: rgba(255, 255, 255, 0.7);
7 | $moreinfo-color: rgba(255, 255, 255, 0.5);
8 | $tick-color: rgba(255, 255, 255, 0.5);
9 |
10 |
11 | // ----------------------------------------------------------------------------
12 | // Widget-graph styles
13 | // ----------------------------------------------------------------------------
14 | .widget-rickshawgraph {
15 |
16 | background-color: $background-color;
17 | position: relative;
18 |
19 | .rickshaw_graph {
20 | position: absolute;
21 | left: 0px;
22 | top: 0px;
23 | }
24 |
25 | svg {
26 | position: absolute;
27 | left: 0px;
28 | top: 0px;
29 | }
30 |
31 | .title, .value {
32 | position: relative;
33 | z-index: 99;
34 | }
35 |
36 | .title {
37 | color: $title-color;
38 | }
39 |
40 | .more-info {
41 | color: $moreinfo-color;
42 | font-weight: 600;
43 | font-size: 20px;
44 | margin-top: 0;
45 | }
46 |
47 | .x_tick {
48 | position: absolute;
49 | bottom: 0;
50 | .title {
51 | font-size: 12px;
52 | color: rgba(255, 255, 255, 0.5);
53 | opacity: 0.75;
54 | padding-bottom: 3px;
55 | }
56 | }
57 |
58 | .y_ticks {
59 | max: 100;
60 | font-size: 20px;
61 | fill: $tick-color;
62 | text {
63 | opacity: 0.5;
64 | }
65 | }
66 |
67 | .domain {
68 | display: none;
69 | }
70 |
71 | .rickshaw_legend {
72 | position: absolute;
73 | left: 0px;
74 | bottom: 0px;
75 | white-space: nowrap;
76 | overflow-x: hidden;
77 | font-size: 15px;
78 | height: 20px;
79 |
80 | ul {
81 | margin: 0;
82 | padding: 0;
83 | list-style-type: none;
84 | text-align: center;
85 | }
86 |
87 | ul li {
88 | display: inline;
89 | }
90 |
91 | .swatch {
92 | display: inline-block;
93 | width: 14px;
94 | height: 14px;
95 | margin-left: 5px;
96 | }
97 |
98 | .label {
99 | display: inline-block;
100 | margin-left: 5px;
101 | }
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/widgets/server_status/server_status.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.ServerStatus extends Dashing.Widget
2 |
--------------------------------------------------------------------------------
/widgets/server_status/server_status.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/widgets/server_status/server_status.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #12b0c5;
5 | $value-color: #fff;
6 |
7 | $title-color: rgba(255, 255, 255, 0.7);
8 | $label-color: rgba(255, 255, 255, 0.7);
9 | $moreinfo-color: rgba(255, 255, 255, 0.7);
10 |
11 | // ----------------------------------------------------------------------------
12 | // Widget-list styles
13 | // ----------------------------------------------------------------------------
14 | .widget-server-status {
15 |
16 | background-color: $background-color;
17 | vertical-align: top;
18 |
19 | .title {
20 | color: $title-color;
21 | }
22 |
23 | ol, ul {
24 | margin: 0 15px;
25 | text-align: left;
26 | color: $label-color;
27 | }
28 |
29 | ol {
30 | list-style-position: inside;
31 | }
32 |
33 | li {
34 | margin-bottom: 5px;
35 | }
36 |
37 | .list-nostyle {
38 | list-style: none;
39 | }
40 |
41 | .label {
42 | color: $label-color;
43 | }
44 |
45 | .value {
46 | float: right;
47 | margin-left: 12px;
48 | font-weight: 600;
49 | color: $value-color;
50 | }
51 |
52 | .updated-at {
53 | color: rgba(0, 0, 0, 0.3);
54 | }
55 |
56 | .more-info {
57 | color: $moreinfo-color;
58 | }
59 |
60 | .red {
61 | color: red;
62 | }
63 |
64 | .green {
65 | color: green;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/widgets/text/text.coffee:
--------------------------------------------------------------------------------
1 | class Dashing.Text extends Dashing.Widget
2 |
3 |
4 |
--------------------------------------------------------------------------------
/widgets/text/text.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/widgets/text/text.scss:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // Sass declarations
3 | // ----------------------------------------------------------------------------
4 | $background-color: #08b5fc;
5 |
6 | $title-color: rgba(255, 255, 255, 0.9);
7 | $moreinfo-color: rgba(255, 255, 255, 0.7);
8 |
9 | // ----------------------------------------------------------------------------
10 | // Widget-text styles
11 | // ----------------------------------------------------------------------------
12 | .widget-text {
13 |
14 | background-color: $background-color;
15 |
16 | .title {
17 | color: $title-color;
18 | }
19 |
20 | .more-info {
21 | color: $moreinfo-color;
22 | }
23 |
24 | .updated-at {
25 | color: rgba(255, 255, 255, 0.3);
26 | }
27 |
28 |
29 | &.large h3 {
30 | font-size: 65px;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
![]()
4 | 5 |