Skip to content

Commit

Permalink
a tad nicer looking and splits sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Apr 27, 2010
1 parent 69b16dc commit a24e5f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions browser/browser.rb
Expand Up @@ -58,10 +58,10 @@ def get_line(data)
@sessions = [] @sessions = []
sessions = @snifter.current sessions = @snifter.current
sessions.each do |sess| sessions.each do |sess|
req, res = @snifter.session(sess) req, res, time = @snifter.session(sess)
req = get_line(req) req = get_line(req)
res = get_line(res) res = get_line(res)
@sessions << [sess, req, res] @sessions << [sess, req, res, time]
end end
erb :index erb :index
end end
Expand Down
1 change: 1 addition & 0 deletions browser/public/style.css
Expand Up @@ -5,6 +5,7 @@ h1 {


#results { padding: 0 20px; } #results { padding: 0 20px; }
.details { font-size: 80%; } .details { font-size: 80%; }
a.session { color: #363; }


table.headers { table.headers {
font-family: monospace; font-family: monospace;
Expand Down
7 changes: 6 additions & 1 deletion browser/views/index.erb
Expand Up @@ -2,7 +2,12 @@
<tr><td valign="top"> <tr><td valign="top">
<h1>Sessions</h1> <h1>Sessions</h1>
<table> <table>
<% @sessions.each do |sess, req, res| %> <% last_time = 0 %>
<% @sessions.each do |sess, req, res, time| %>
<% if (time - last_time) > 2 %>
<tr><td colspan="2"><hr/></td></tr>
<% end %>
<% last_time = time %>
<tr> <tr>
<td nowrap><a class="session" href="#" rel="/sess/<%= sess %>"><%= req %></a></td> <td nowrap><a class="session" href="#" rel="/sess/<%= sess %>"><%= req %></a></td>
<td nowrap><%= res %></td> <td nowrap><%= res %></td>
Expand Down
6 changes: 4 additions & 2 deletions snifter.rb
Expand Up @@ -14,10 +14,11 @@ def conn_id(conn)


def update_list(id) def update_list(id)
@redis.rpush LIST_ID, id @redis.rpush LIST_ID, id
@redis.ltrim LIST_ID, -10, -1 @redis.ltrim LIST_ID, -50, -1
end end


def log_connect(conn) def log_connect(conn)
add_data(conn, 'time', Time.now.to_i)
update_list(conn_id(conn)) update_list(conn_id(conn))
end end


Expand Down Expand Up @@ -48,7 +49,8 @@ def current
def session(session) def session(session)
req = @redis.get session + 'request' req = @redis.get session + 'request'
res = @redis.get session + 'response' res = @redis.get session + 'response'
[req, res] time = @redis.get session + 'time'
[req, res, time.to_i]
end end


def show_stats def show_stats
Expand Down

0 comments on commit a24e5f8

Please sign in to comment.