Last active
August 22, 2019 16:25
-
-
Save junaid18183/dfaa3c84e36c9e5dad42 to your computer and use it in GitHub Desktop.
Dashing Widget For Hadoop DFS Stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This widget creats the dashing dashboard for Hadoop DFS stats. | |
There is Job which parses the hadoop DFS status page and provides the below widget_event_id's | |
#Configured_Capacity | |
#DFS_Used | |
#Non_DFS_Used | |
#DFS_Remaining | |
#DFS_Used% | |
#DFS_Remaining% | |
#Block_Pool_Used | |
#Block_Pool_Used% | |
#Live_Nodes | |
#Dead_Nodes | |
#Decommissioning_Nodes | |
Sample Dashboard is also in this Gist named haddop_dfs_stats.erb | |
Installation : | |
dashing install dfaa3c84e36c9e5dad42 | |
Configuration : | |
Change the Hadoop DFS URL in the hadoop_dfs_stats.rb file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dashing.HaddopDfsStats extends Dashing.Widget | |
@accessor 'current', Dashing.AnimatedValue | |
ready: -> | |
# This is fired when the widget is done being rendered | |
onData: (data) -> | |
# Handle incoming data | |
# You can access the html node of this widget with `@node` | |
# Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in. | |
$(@node).fadeOut().fadeIn() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 class="title" data-bind="title"></h1> | |
<h2 class="value" data-bind="current | shortenedNumber | prepend prefix | append suffix"></h2> | |
<p class="change-rate"> | |
<i data-bind-class="arrow"></i><span data-bind="difference"></span> | |
</p> | |
<p class="more-info" data-bind="moreinfo"></p> | |
<p class="updated-at" data-bind="updatedAtMessage"></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------------------- | |
// Sass declarations | |
// ---------------------------------------------------------------------------- | |
$background-color: #96bf48; | |
$value-color: white; | |
$title-color: rgba(255, 255, 255, 0.7); | |
$moreinfo-color: rgba(255, 255, 255, 0.7); | |
// ---------------------------------------------------------------------------- | |
// Widget-number styles | |
// ---------------------------------------------------------------------------- | |
.widget-haddop-dfs-stats { | |
background-color: $background-color; | |
.title { | |
color: $title-color; | |
} | |
.value { | |
color: $value-color; | |
} | |
.change-rate { | |
font-weight: 500; | |
font-size: 30px; | |
color: $value-color; | |
} | |
.updated-at { | |
color: rgba(0, 0, 0, 0.3); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% content_for :title do %>Hadoop dashboard<% end %> | |
<div class="gridster"> | |
<ul> | |
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1"> | |
<div data-view="Clock"></div> | |
<i class="icon-time icon-background"></i> | |
</li> | |
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1"> | |
<div data-id="Configured_Capacity" data-view="HaddopDfsStats" data-title="Configured HDFS Capacity" ></div> | |
</li> | |
<li data-row="1" data-col="3" data-sizex="1" data-sizey="1"> | |
<div data-id="Live_Nodes" data-view="HaddopDfsStats" data-title="Live Nodes"></div> | |
</li> | |
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"> | |
<div data-id="Dead_Nodes" data-view="HaddopDfsStats" data-title="Dead Nodes"></div> | |
</li> | |
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="DFS_Used" data-view="HaddopDfsStats" data-title="HDFS Used"></div> | |
</li> | |
<li data-row="2" data-col="2" data-sizex="1" data-sizey="1"> | |
<div data-id="DFS_Remaining" data-view="HaddopDfsStats" data-title="HDFS Remaining" ></div> | |
</li> | |
<li data-row="2" data-col="3" data-sizex="1" data-sizey="1"> | |
<div data-id="Non_DFS_Used" data-view="HaddopDfsStats" data-title="Non DFS Used"></div> | |
</li> | |
<li data-row="1" data-col="5" data-sizex="1" data-sizey="1"> | |
<div data-id="Decommissioning_Nodes" data-view="HaddopDfsStats" data-title="Decommissioning Nodes"></div> | |
</li> | |
</ul> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
DFS_URL = 'http://hadoop.tipsntraps.com:50070/dfshealth.jsp' | |
#---------------------------------------------------------------------------------------------------- | |
def get_dfs_stats() | |
dfs_stats=Hash.new | |
name=Array.new | |
value=Array.new | |
i=0 | |
page = Nokogiri::HTML(open("#{DFS_URL}")) | |
page.css('div.dfstable tr td#col1').each do |el| | |
name[i]=el.text.strip.tr(' ','_') # this will also replace space with _ | |
i=i+1 | |
end | |
j=0 | |
page.css('div.dfstable tr td#col3').each do |el| | |
el=el.text.strip | |
el=el.sub(/Decommissioned: \d*/,'') # I am not intrested in Decommissioned number | |
value[j]=el.split | |
j=j+1 | |
end | |
name.zip(value).each do |n,v| | |
dfs_stats[n]=v | |
end | |
dfs_stats.delete("") # Because "DataNodes usages"=>["Min", "%"], ""=>["7.49", "%"] | |
dfs_stats.delete("DataNodes_usages") | |
return dfs_stats | |
end | |
#---------------------------------------------------------------------------------------------------- | |
SCHEDULER.every '1m' do | |
begin | |
dfs_stats=Hash.new | |
dfs_stats=get_dfs_stats() | |
dfs_stats.each do |key,value| | |
send_event( key.to_s, { current: value[0],moreinfo: value[1] }) | |
sleep 2 # this will give nice effect in UI | |
end | |
end | |
end | |
#---------------------------------------------------------------------------------------------------- | |
#Below are the widget_event_id it will send to Dashbord | |
#Configured_Capacity | |
#DFS_Used | |
#Non_DFS_Used | |
#DFS_Remaining | |
#DFS_Used% | |
#DFS_Remaining% | |
#Block_Pool_Used | |
#Block_Pool_Used% | |
#Live_Nodes | |
#Dead_Nodes | |
#Decommissioning_Nodes | |
#---------------------------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment