Permalink
Browse files

Add items over time and convert memory from bytes to megabytes

  • Loading branch information...
1 parent b6c0288 commit d750598eaa108c92ba58b0d5a07fdac3510adeb4 @bryckbost committed Apr 25, 2012
Showing with 44 additions and 5 deletions.
  1. +3 −2 lib/memdash/server.rb
  2. +40 −3 lib/memdash/server/public/charts.js
  3. +1 −0 lib/memdash/server/views/overview.erb
View
@@ -41,8 +41,9 @@ def miss_ratio_percentage(hits, misses)
@sets = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["cmd_set"].to_i]}}
@hits = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["get_hits"].to_i]}}
@misses = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["get_misses"].to_i]}}
- @limit_maxbytes = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["limit_maxbytes"].to_i]}}
- @bytes = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["bytes"].to_i]}}
+ @limit_maxbytes = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), (v["limit_maxbytes"].to_i / 1024.0 / 1024.0).round(2)]}}
+ @bytes = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), (v["bytes"].to_i / 1024.0 / 1024.0).round(2)]}}
+ @current_items = past_day.flat_map{|report| report.stats.map{|_, v| [report.created_at.strftime("%m-%d-%Y %I:%M%p"), v["curr_items"].to_i]}}
erb :overview, :layout => :application
end
end
@@ -47,7 +47,11 @@ $(document).ready(function(){
min: $("#hits-misses").data("hits")[0][0],
max: $("#hits-misses").data("hits")[$("#hits-misses").data("hits").length - 1][0],
tickInterval: "2 hours",
+ },
+ yaxis: {
+ rendererOptions: { forceTickAt0: true, forceTickAt100: true }
}
+
},
seriesDefaults: {
rendererOptions: {
@@ -87,13 +91,46 @@ $(document).ready(function(){
}
},
series: [
- {label: 'Max Size', showMarker: false},
- {label: 'Used', showMarker: false}
+ {label: 'Max Size (MB)', showMarker: false},
+ {label: 'Used (MB)', showMarker: false}
],
legend: {
show: true
},
seriesColors: ["rgb(227, 193, 36)", "rgb(36, 173, 227)"]
});
-
+ $.jqplot('current-items', [$("#current-items").data("current-items")], {
+ title: 'Items over the Past Day',
+ grid: {
+ drawBorder: false,
+ shadow: false,
+ background: '#fefefe'
+ },
+ axes:{
+ xaxis:{
+ renderer: $.jqplot.DateAxisRenderer,
+ tickOptions: {
+ formatString:'%#I %p'
+ },
+ min: $("#current-items").data("current-items")[0][0],
+ max: $("#current-items").data("current-items")[$("#current-items").data("current-items").length - 1][0],
+ tickInterval: "2 hours",
+ },
+ yaxis: {
+ rendererOptions: { forceTickAt0: true, forceTickAt100: true }
+ }
+ },
+ seriesDefaults: {
+ rendererOptions: {
+ smooth: true,
+ }
+ },
+ series: [
+ {label: 'Items', showMarker: false},
+ ],
+ legend: {
+ show: true
+ },
+ seriesColors: ["rgb(227, 193, 36)"]
+ });
});
@@ -14,5 +14,6 @@
<div class="row">
<div id="memory-usage" class="span6" data-limit-maxbytes='<%= @limit_maxbytes %>' data-bytes='<%= @bytes %>'></div>
+ <div id="current-items" class="span6" data-current-items='<%= @current_items %>'></div>
</div>
</section>

0 comments on commit d750598

Please sign in to comment.