peep 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+
2
+ v0.5. First release.
data/LICENSE ADDED
@@ -0,0 +1,184 @@
1
+ Academic Free License (AFL) v. 3.0
2
+
3
+ This Academic Free License (the "License") applies to any original work
4
+ of authorship (the "Original Work") whose owner (the "Licensor") has
5
+ placed the following licensing notice adjacent to the copyright notice
6
+ for the Original Work:
7
+
8
+ Licensed under the Academic Free License version 3.0
9
+
10
+ 1) Grant of Copyright License. Licensor grants You a worldwide,
11
+ royalty-free, non-exclusive, sublicensable license, for the duration of
12
+ the copyright, to do the following:
13
+
14
+ a) to reproduce the Original Work in copies, either alone or as part of
15
+ a collective work;
16
+
17
+ b) to translate, adapt, alter, transform, modify, or arrange the
18
+ Original Work, thereby creating derivative works ("Derivative Works")
19
+ based upon the Original Work;
20
+
21
+ c) to distribute or communicate copies of the Original Work and
22
+ Derivative Works to the public, under any license of your choice that
23
+ does not contradict the terms and conditions, including Licensor's
24
+ reserved rights and remedies, in this Academic Free License;
25
+
26
+ d) to perform the Original Work publicly; and
27
+
28
+ e) to display the Original Work publicly.
29
+
30
+ 2) Grant of Patent License. Licensor grants You a worldwide,
31
+ royalty-free, non-exclusive, sublicensable license, under patent claims
32
+ owned or controlled by the Licensor that are embodied in the Original
33
+ Work as furnished by the Licensor, for the duration of the patents, to
34
+ make, use, sell, offer for sale, have made, and import the Original Work
35
+ and Derivative Works.
36
+
37
+ 3) Grant of Source Code License. The term "Source Code" means the
38
+ preferred form of the Original Work for making modifications to it and
39
+ all available documentation describing how to modify the Original Work.
40
+ Licensor agrees to provide a machine-readable copy of the Source Code of
41
+ the Original Work along with each copy of the Original Work that
42
+ Licensor distributes. Licensor reserves the right to satisfy this
43
+ obligation by placing a machine-readable copy of the Source Code in an
44
+ information repository reasonably calculated to permit inexpensive and
45
+ convenient access by You for as long as Licensor continues to distribute
46
+ the Original Work.
47
+
48
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the
49
+ names of any contributors to the Original Work, nor any of their
50
+ trademarks or service marks, may be used to endorse or promote products
51
+ derived from this Original Work without express prior permission of the
52
+ Licensor. Except as expressly stated herein, nothing in this License
53
+ grants any license to Licensor's trademarks, copyrights, patents, trade
54
+ secrets or any other intellectual property. No patent license is granted
55
+ to make, use, sell, offer for sale, have made, or import embodiments of
56
+ any patent claims other than the licensed claims defined in Section 2.
57
+ No license is granted to the trademarks of Licensor even if such marks
58
+ are included in the Original Work. Nothing in this License shall be
59
+ interpreted to prohibit Licensor from licensing under terms different
60
+ from this License any Original Work that Licensor otherwise would have a
61
+ right to license.
62
+
63
+ 5) External Deployment. The term "External Deployment" means the use,
64
+ distribution, or communication of the Original Work or Derivative Works
65
+ in any way such that the Original Work or Derivative Works may be used
66
+ by anyone other than You, whether those works are distributed or
67
+ communicated to those persons or made available as an application
68
+ intended for use over a network. As an express condition for the grants
69
+ of license hereunder, You must treat any External Deployment by You of
70
+ the Original Work or a Derivative Work as a distribution under section
71
+ 1(c).
72
+
73
+ 6) Attribution Rights. You must retain, in the Source Code of any
74
+ Derivative Works that You create, all copyright, patent, or trademark
75
+ notices from the Source Code of the Original Work, as well as any
76
+ notices of licensing and any descriptive text identified therein as an
77
+ "Attribution Notice." You must cause the Source Code for any Derivative
78
+ Works that You create to carry a prominent Attribution Notice reasonably
79
+ calculated to inform recipients that You have modified the Original
80
+ Work.
81
+
82
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants
83
+ that the copyright in and to the Original Work and the patent rights
84
+ granted herein by Licensor are owned by the Licensor or are sublicensed
85
+ to You under the terms of this License with the permission of the
86
+ contributor(s) of those copyrights and patent rights. Except as
87
+ expressly stated in the immediately preceding sentence, the Original
88
+ Work is provided under this License on an "AS IS" BASIS and WITHOUT
89
+ WARRANTY, either express or implied, including, without limitation, the
90
+ warranties of non-infringement, merchantability or fitness for a
91
+ particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
92
+ WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
93
+ part of this License. No license to the Original Work is granted by this
94
+ License except under this disclaimer.
95
+
96
+ 8) Limitation of Liability. Under no circumstances and under no legal
97
+ theory, whether in tort (including negligence), contract, or otherwise,
98
+ shall the Licensor be liable to anyone for any indirect, special,
99
+ incidental, or consequential damages of any character arising as a
100
+ result of this License or the use of the Original Work including,
101
+ without limitation, damages for loss of goodwill, work stoppage,
102
+ computer failure or malfunction, or any and all other commercial damages
103
+ or losses. This limitation of liability shall not apply to the extent
104
+ applicable law prohibits such limitation.
105
+
106
+ 9) Acceptance and Termination. If, at any time, You expressly assented
107
+ to this License, that assent indicates your clear and irrevocable
108
+ acceptance of this License and all of its terms and conditions. If You
109
+ distribute or communicate copies of the Original Work or a Derivative
110
+ Work, You must make a reasonable effort under the circumstances to
111
+ obtain the express assent of recipients to the terms of this License.
112
+ This License conditions your rights to undertake the activities listed
113
+ in Section 1, including your right to create Derivative Works based upon
114
+ the Original Work, and doing so without honoring these terms and
115
+ conditions is prohibited by copyright law and international treaty.
116
+ Nothing in this License is intended to affect copyright exceptions and
117
+ limitations (including "fair use" or "fair dealing"). This License shall
118
+ terminate immediately and You may no longer exercise any of the rights
119
+ granted to You by this License upon your failure to honor the conditions
120
+ in Section 1(c).
121
+
122
+ 10) Termination for Patent Action. This License shall terminate
123
+ automatically and You may no longer exercise any of the rights granted
124
+ to You by this License as of the date You commence an action, including
125
+ a cross-claim or counterclaim, against Licensor or any licensee alleging
126
+ that the Original Work infringes a patent. This termination provision
127
+ shall not apply for an action alleging patent infringement by
128
+ combinations of the Original Work with other software or hardware.
129
+
130
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating
131
+ to this License may be brought only in the courts of a jurisdiction
132
+ wherein the Licensor resides or in which Licensor conducts its primary
133
+ business, and under the laws of that jurisdiction excluding its
134
+ conflict-of-law provisions. The application of the United Nations
135
+ Convention on Contracts for the International Sale of Goods is expressly
136
+ excluded. Any use of the Original Work outside the scope of this License
137
+ or after its termination shall be subject to the requirements and
138
+ penalties of copyright or patent law in the appropriate jurisdiction.
139
+ This section shall survive the termination of this License.
140
+
141
+ 12) Attorneys' Fees. In any action to enforce the terms of this License
142
+ or seeking damages relating thereto, the prevailing party shall be
143
+ entitled to recover its costs and expenses, including, without
144
+ limitation, reasonable attorneys' fees and costs incurred in connection
145
+ with such action, including any appeal of such action. This section
146
+ shall survive the termination of this License.
147
+
148
+ 13) Miscellaneous. If any provision of this License is held to be
149
+ unenforceable, such provision shall be reformed only to the extent
150
+ necessary to make it enforceable.
151
+
152
+ 14) Definition of "You" in This License. "You" throughout this License,
153
+ whether in upper or lower case, means an individual or a legal entity
154
+ exercising rights under, and complying with all of the terms of, this
155
+ License. For legal entities, "You" includes any entity that controls, is
156
+ controlled by, or is under common control with you. For purposes of this
157
+ definition, "control" means (i) the power, direct or indirect, to cause
158
+ the direction or management of such entity, whether by contract or
159
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
160
+ outstanding shares, or (iii) beneficial ownership of such entity.
161
+
162
+ 15) Right to Use. You may use the Original Work in all ways not
163
+ otherwise restricted or conditioned by this License or by law, and
164
+ Licensor promises not to interfere with or be responsible for such uses
165
+ by You.
166
+
167
+ 16) Modification of This License. This License is Copyright (c) 2005
168
+ Lawrence Rosen. Permission is granted to copy, distribute, or
169
+ communicate this License without modification. Nothing in this License
170
+ permits You to modify this License as applied to the Original Work or to
171
+ Derivative Works. However, You may modify the text of this License and
172
+ copy, distribute or communicate your modified version (the "Modified
173
+ License") and apply it to other original works of authorship subject to
174
+ the following conditions: (i) You may not indicate in any way that your
175
+ Modified License is the "Academic Free License" or "AFL" and you may not
176
+ use those names in the name of your Modified License; (ii) You must
177
+ replace the notice specified in the first paragraph above with the
178
+ notice "Licensed under <insert your license name here>" or with a notice
179
+ of your own that is not confusingly similar to the notice in this
180
+ License; and (iii) You may not claim that your original works are open
181
+ source software unless your Modified License has been approved by Open
182
+ Source Initiative (OSI) and You comply with its license review and
183
+ certification process.
184
+
data/Manifest ADDED
@@ -0,0 +1,10 @@
1
+ bin/peep
2
+ CHANGELOG
3
+ ext/extconf.rb
4
+ ext/ptrace.c
5
+ lib/peep/peep.rb
6
+ lib/peep.rb
7
+ LICENSE
8
+ Manifest
9
+ Rakefile
10
+ README
data/README ADDED
@@ -0,0 +1,55 @@
1
+
2
+ peep
3
+
4
+ A heap inspector for live memcached instances.
5
+
6
+ == License
7
+
8
+ Copyright 2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file.
9
+
10
+ == Features
11
+
12
+ * it works
13
+
14
+ == Installation
15
+
16
+ x86 Linux is required.
17
+
18
+ You need {memcached}[http://www.danga.com/memcached/] compiled with debugging symbols:
19
+
20
+ CFLAGS='-g' ./configure --with-debug --enable-threads
21
+ make
22
+ sudo make install
23
+
24
+ Now install the gem:
25
+ sudo gem install peep -- --with-memcached-include=/path/to/memcached/source
26
+
27
+ == Usage
28
+
29
+ Find the pid of a live memcached server. Then run:
30
+
31
+ peep --pretty $pid
32
+
33
+ or
34
+
35
+ peep --ugly $pid
36
+
37
+ Please note that memcached is fully blocked while peep is running.
38
+
39
+ Peep is also usable as a library, for statistics gathering or deeper inspection.
40
+
41
+ == Sample output
42
+
43
+ eweaver@ubuntu:~$ peep 32589
44
+ time | exptime | nbytes | nsuffix | it_f | clsid | nkey | key | exprd | flushd
45
+ 8658 | 613458 | 272 | 8 | link | 5 | 31 | "element2-benchmark:c3RhdH:171:5" | false | false
46
+ 8658 | 0 | 6 | 6 | link | 1 | 35 | "element2-benchmark:current_c3RhdH:3" | false | false
47
+ 8658 | 613458 | 281 | 8 | link | 5 | 32 | "element2-benchmark:c3RhdH:171:26" | false | false
48
+ 8678 | 95078 | 6 | 6 | link | 1 | 35 | "element2-benchmark:User:1:auth:m4Uq" | false | false
49
+ 8658 | 0 | 8 | 6 | link | 2 | 34 | "element2-benchmark:user_dGltZWxp:4" | false | false
50
+ 8686 | 613486 | 1278 | 9 | link | 9 | 27 | "element2-benchmark:User:1:6" | false | false
51
+ 8658 | 613458 | 1286 | 9 | link | 9 | 27 | "element2-benchmark:User:1:4" | false | false
52
+ 8658 | 613458 | 283 | 8 | link | 5 | 32 | "element2-benchmark:c3RhdH:171:28" | false | false
53
+ 8658 | 613458 | 277 | 8 | link | 5 | 32 | "element2-benchmark:c3RhdH:171:30" | false | false
54
+ ...
55
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+
2
+ require 'echoe'
3
+
4
+ Echoe.new("peep") do |p|
5
+ p.author = "Evan Weaver"
6
+ p.project = "fauna"
7
+ p.summary = "A heap inspector for live memcached instances."
8
+ p.url = "http://blog.evanweaver.com/files/doc/fauna/peep/"
9
+ p.docs_host = 'blog.evanweaver.com:~/www/bax/public/files/doc/'
10
+ p.require_signed = true
11
+ p.rdoc_pattern = /^ext.*\.c|lib.*|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
12
+ end
data/bin/peep ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
4
+ require "rubygems"
5
+ require "peep"
6
+
7
+ pretty = true
8
+ format = "%10s |%10s |%8s |%8s |%5s |%6s |%5s |%75s |%6s |%7s\n"
9
+
10
+ if ARGV.first == '--ugly'
11
+ pretty = false
12
+ format = "%s | %s | %s | %s | %s | %s | %s | %s | %s | %s\n"
13
+ end
14
+
15
+ pid = ARGV.last.to_i
16
+
17
+ if pid.zero?
18
+ puts "peep [--pretty|--ugly] $pid"
19
+ exit!
20
+ end
21
+
22
+ peeper = Peep::Analysis.new(pid)
23
+ printf format, *peeper.class::HEADER if pretty
24
+ peeper.items do |*item|
25
+ item[7] = item[7].inspect[0,73] if pretty
26
+ printf format, *item
27
+ end
data/ext/extconf.rb ADDED
@@ -0,0 +1,9 @@
1
+
2
+ require 'mkmf'
3
+
4
+ find_header "memcached.h", dir_config("memcached").first
5
+ have_header "sys/ptrace.h"
6
+ have_header "sys/ptrace.h"
7
+ have_header "sys/user.h"
8
+
9
+ create_makefile "ptrace"
data/ext/ptrace.c ADDED
@@ -0,0 +1,139 @@
1
+ #include <unistd.h>
2
+ #include <stdio.h>
3
+ #include <errno.h>
4
+ #include <string.h>
5
+ #include <sys/user.h>
6
+ #include <sys/ptrace.h>
7
+ #include <linux/ptrace.h>
8
+
9
+ #include "ruby.h"
10
+ #include "rubyio.h"
11
+ #include "intern.h"
12
+ #include "memcached.h"
13
+
14
+ static VALUE p_module;
15
+ static VALUE p_error;
16
+
17
+ static VALUE sizes () {
18
+ VALUE p_hash = rb_hash_new();
19
+
20
+ unsigned short s = 0x0001;
21
+ rb_hash_aset(p_hash, rb_str_new2("little_endian"), ((*(unsigned char*)&s) ? Qtrue : Qfalse));
22
+ rb_hash_aset(p_hash, rb_str_new2("address"), INT2NUM(sizeof(void *)));
23
+ rb_hash_aset(p_hash, rb_str_new2("time_t"), INT2NUM(sizeof(time_t)));
24
+ rb_hash_aset(p_hash, rb_str_new2("double"), INT2NUM(sizeof(double)));
25
+ rb_hash_freeze(p_hash);
26
+ return p_hash;
27
+ }
28
+
29
+ static VALUE item_offsets () {
30
+ VALUE p_hash = rb_hash_new();
31
+
32
+ #define OFFSET_(EL) rb_hash_aset(p_hash, rb_str_new2(#EL), INT2NUM(offsetof(struct _stritem, EL)))
33
+ OFFSET_(h_next);
34
+ OFFSET_(nbytes);
35
+ OFFSET_(time);
36
+ OFFSET_(exptime);
37
+ OFFSET_(refcount);
38
+ OFFSET_(nsuffix);
39
+ OFFSET_(nkey);
40
+ OFFSET_(it_flags);
41
+ OFFSET_(slabs_clsid);
42
+ OFFSET_(end);
43
+
44
+ rb_hash_freeze(p_hash);
45
+ return p_hash;
46
+ }
47
+
48
+ static VALUE stats_offsets () {
49
+ VALUE p_hash = rb_hash_new();
50
+
51
+ #define STATS_(EL) rb_hash_aset(p_hash, rb_str_new2(#EL), INT2NUM(offsetof(struct stats, EL)))
52
+ STATS_(curr_items);
53
+ STATS_(total_items);
54
+ STATS_(curr_bytes);
55
+ STATS_(curr_conns);
56
+ STATS_(total_conns);
57
+ STATS_(conn_structs);
58
+ STATS_(get_cmds);
59
+ STATS_(set_cmds);
60
+ STATS_(get_hits);
61
+ STATS_(get_misses);
62
+ STATS_(started);
63
+ STATS_(bytes_read);
64
+ STATS_(bytes_written);
65
+
66
+ rb_hash_freeze(p_hash);
67
+ return p_hash;
68
+ }
69
+
70
+ static VALUE settings_offsets () {
71
+ VALUE p_hash = rb_hash_new();
72
+
73
+ #define SETTINGS_(EL) rb_hash_aset(p_hash, rb_str_new2(#EL), INT2NUM(offsetof(struct settings, EL)))
74
+ SETTINGS_(maxbytes);
75
+ SETTINGS_(maxconns);
76
+ SETTINGS_(port);
77
+ SETTINGS_(udpport);
78
+ // SETTINGS_(inter);
79
+ SETTINGS_(verbose);
80
+ SETTINGS_(oldest_live);
81
+ SETTINGS_(managed);
82
+ SETTINGS_(evict_to_free);
83
+ // SETTINGS_(socketpath);
84
+ SETTINGS_(access);
85
+ SETTINGS_(factor);
86
+ SETTINGS_(chunk_size);
87
+ SETTINGS_(num_threads);
88
+ SETTINGS_(prefix_delimiter);
89
+ SETTINGS_(detail_enabled);
90
+
91
+ rb_hash_freeze(p_hash);
92
+ return p_hash;
93
+ }
94
+
95
+ static void fail(int pid) {
96
+ char buffer[16];
97
+ sprintf(buffer, "%d", pid);
98
+ rb_sys_fail(buffer);
99
+ }
100
+
101
+ static VALUE attach (VALUE self, VALUE pid_)
102
+ {
103
+ pid_t pid = NUM2INT(pid_);
104
+ if (ptrace (PTRACE_ATTACH, pid, 0, 0))
105
+ fail(pid);
106
+ return Qtrue;
107
+ }
108
+
109
+ static VALUE detach (VALUE self, VALUE pid_)
110
+ {
111
+ pid_t pid = NUM2INT(pid_);
112
+ if (ptrace (PTRACE_DETACH, pid, 0, 0))
113
+ fail(pid);
114
+ return Qtrue;
115
+ }
116
+
117
+ static VALUE peek (VALUE self, VALUE pid_, VALUE address)
118
+ {
119
+ pid_t pid = NUM2INT(pid_);
120
+ long byte = ptrace (PTRACE_PEEKDATA, pid, (void *) NUM2ULONG(address), 0);
121
+ if (byte == -1 && errno)
122
+ fail(pid);
123
+ return ULONG2NUM((unsigned long) byte);
124
+ }
125
+
126
+ void
127
+ Init_ptrace (void)
128
+ {
129
+ p_module = rb_define_module ("Peep");
130
+
131
+ rb_define_const(p_module, "SIZES", sizes());
132
+ rb_define_const(p_module, "ITEM_OFFSETS", item_offsets());
133
+ rb_define_const(p_module, "STATS_OFFSETS", stats_offsets());
134
+ rb_define_const(p_module, "SETTINGS_OFFSETS", settings_offsets());
135
+
136
+ rb_define_module_function (p_module, "attach", attach, 1);
137
+ rb_define_module_function (p_module, "detach", detach, 1);
138
+ rb_define_module_function (p_module, "peek", peek, 2);
139
+ }
data/lib/peep/peep.rb ADDED
@@ -0,0 +1,156 @@
1
+
2
+ module Peep
3
+
4
+ class Analysis
5
+ attr_reader :pid
6
+ attr_reader :addresses
7
+ attr_reader :pack_format
8
+
9
+ def read_long(addr)
10
+ Peep.peek(pid, addr)
11
+ end
12
+
13
+ def read_int(addr)
14
+ n = Peep.peek(pid, addr)
15
+ SIZES['little_endian'] ? n & 0xffffffff : (n >> 32) & 0xffffffff
16
+ end
17
+
18
+ def read_uint8(addr)
19
+ offset = addr % SIZES['address']
20
+ word = read_long(addr - offset)
21
+ [word].pack(pack_format)[offset]
22
+ end
23
+
24
+ def read_bytes(addr, nbytes)
25
+ buffer = ""
26
+ (nbytes / SIZES['address'].to_f).ceil.times do |offset|
27
+ buffer << [read_long(addr + offset * SIZES['address'])].pack(pack_format)
28
+ end
29
+ buffer[0, nbytes]
30
+ end
31
+
32
+ def read_double(addr)
33
+ read_bytes(addr, SIZES['double']).unpack('d')
34
+ end
35
+
36
+ def init_addresses
37
+ @addresses = {}
38
+ IO.popen("gdb -q memcached #{pid}", "w+") do |gdb|
39
+ %w(primary_hashtable hash_items hashpower stats settings).each do | key|
40
+ gdb.puts "p &#{key}"
41
+ 1 while (line = gdb.gets) !~ /\(gdb\)/
42
+ @addresses[key] = line.split.last.hex
43
+ end
44
+ gdb.puts "detach"
45
+ gdb.puts "quit"
46
+ end
47
+ end
48
+
49
+ def initialize(pid, options = {})
50
+ raise TypeError unless pid.is_a? Integer
51
+ @pack_format = SIZES['address'] == 4 ? "l" : "q"
52
+ @pid = pid
53
+ init_addresses
54
+ end
55
+
56
+ def attached
57
+ GC.disable
58
+ Peep.attach pid
59
+ sleep 0.5
60
+ value = yield
61
+ Peep.detach pid
62
+ GC.enable
63
+ value
64
+ ensure
65
+ Process.kill("CONT", pid)
66
+ end
67
+
68
+ def basics
69
+ @basics ||= attached do
70
+ {
71
+ 'hashtable' => read_long(addresses['primary_hashtable']),
72
+ 'hash_items' => read_long(addresses['hash_items']),
73
+ 'hashpower' => read_int(addresses['hashpower'])
74
+ }
75
+ end
76
+ end
77
+
78
+ def stats
79
+ @stats ||= attached do
80
+ # Static
81
+ Hash[*
82
+ STATS_OFFSETS.map do |key, offset|
83
+ [key, read_long(addresses['stats'] + offset)]
84
+ end.flatten
85
+ ]
86
+ end
87
+ end
88
+
89
+ def settings
90
+ @settings ||= attached do
91
+ # Static
92
+ Hash[*
93
+ SETTINGS_OFFSETS.map do |key, offset|
94
+ [key, case key
95
+ when 'prefix_delimiter'
96
+ read_int(addresses['settings'] + offset).chr
97
+ when 'factor'
98
+ read_double(addresses['settings'] + offset)
99
+ else
100
+ read_long(addresses['settings'] + offset)
101
+ end]
102
+ end.flatten
103
+ ]
104
+ end
105
+ end
106
+
107
+ IT_FLAGS = {
108
+ 1 => "link",
109
+ 2 => "del",
110
+ 4 => "slab"
111
+ }
112
+
113
+ HEADER = ['time', 'exptime', 'nbytes', 'nsuffix', 'it_f', 'clsid', 'nkey', 'key', 'exprd', 'flushd']
114
+
115
+ def items
116
+ basics
117
+
118
+ now = Time.now.to_i - stats['started']
119
+ flushed = settings['oldest_live']
120
+ items = []
121
+
122
+ hashtable = basics['hashtable']
123
+
124
+ attached do
125
+ (2**basics['hashpower']).times do
126
+ bucket = read_long(hashtable)
127
+
128
+ while !bucket.zero?
129
+ item = [
130
+ time = read_int(bucket + ITEM_OFFSETS['time']),
131
+ exptime = read_int(bucket + ITEM_OFFSETS['exptime']),
132
+ read_int(bucket + ITEM_OFFSETS['nbytes']),
133
+ read_uint8(bucket + ITEM_OFFSETS['nsuffix']),
134
+ IT_FLAGS[read_uint8(bucket + ITEM_OFFSETS['it_flags'])],
135
+ read_uint8(bucket + ITEM_OFFSETS['slabs_clsid']),
136
+ nkey = read_uint8(bucket + ITEM_OFFSETS['nkey']),
137
+ read_bytes(bucket + ITEM_OFFSETS['end'], nkey),
138
+
139
+ !(exptime.zero? or now < exptime), # expired?
140
+ !(flushed.zero? or flushed < time) # flushed?
141
+ ]
142
+
143
+ block_given? ? yield(*item) : items << item
144
+
145
+ bucket = read_long(bucket + ITEM_OFFSETS['h_next'])
146
+ end
147
+
148
+ hashtable += SIZES['address']
149
+ end
150
+ end
151
+
152
+ items unless block_given?
153
+ end
154
+
155
+ end
156
+ end
data/lib/peep.rb ADDED
@@ -0,0 +1,4 @@
1
+
2
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../ext"
3
+ require 'ptrace'
4
+ require 'peep/peep'
data/peep.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{peep}
5
+ s.version = "0.5"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Evan Weaver"]
9
+ s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
+ s.date = %q{2008-11-10}
11
+ s.default_executable = %q{peep}
12
+ s.description = %q{A heap inspector for live memcached instances.}
13
+ s.email = %q{}
14
+ s.executables = ["peep"]
15
+ s.extensions = ["ext/extconf.rb"]
16
+ s.extra_rdoc_files = ["CHANGELOG", "ext/ptrace.c", "lib/peep/peep.rb", "lib/peep.rb", "LICENSE", "README"]
17
+ s.files = ["bin/peep", "CHANGELOG", "ext/extconf.rb", "ext/ptrace.c", "lib/peep/peep.rb", "lib/peep.rb", "LICENSE", "Manifest", "Rakefile", "README", "peep.gemspec"]
18
+ s.has_rdoc = true
19
+ s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/peep/}
20
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Peep", "--main", "README"]
21
+ s.require_paths = ["lib", "ext"]
22
+ s.rubyforge_project = %q{fauna}
23
+ s.rubygems_version = %q{1.3.1}
24
+ s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
25
+ s.summary = %q{A heap inspector for live memcached instances.}
26
+
27
+ if s.respond_to? :specification_version then
28
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
+ s.specification_version = 2
30
+
31
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
32
+ s.add_development_dependency(%q<echoe>, [">= 0"])
33
+ else
34
+ s.add_dependency(%q<echoe>, [">= 0"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<echoe>, [">= 0"])
38
+ end
39
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peep
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.5"
5
+ platform: ruby
6
+ authors:
7
+ - Evan Weaver
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu
14
+ MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe
15
+ Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x
16
+ GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB
17
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs
18
+ yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A
19
+ Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj
20
+ R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46
21
+ QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT
22
+ QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID
23
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ
24
+ XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt
25
+ JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1
26
+ XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h
27
+ MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5
28
+ hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
29
+ x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
30
+ yZ0=
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2008-11-10 00:00:00 -08:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: echoe
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ description: A heap inspector for live memcached instances.
47
+ email: ""
48
+ executables:
49
+ - peep
50
+ extensions:
51
+ - ext/extconf.rb
52
+ extra_rdoc_files:
53
+ - CHANGELOG
54
+ - ext/ptrace.c
55
+ - lib/peep/peep.rb
56
+ - lib/peep.rb
57
+ - LICENSE
58
+ - README
59
+ files:
60
+ - bin/peep
61
+ - CHANGELOG
62
+ - ext/extconf.rb
63
+ - ext/ptrace.c
64
+ - lib/peep/peep.rb
65
+ - lib/peep.rb
66
+ - LICENSE
67
+ - Manifest
68
+ - Rakefile
69
+ - README
70
+ - peep.gemspec
71
+ has_rdoc: true
72
+ homepage: http://blog.evanweaver.com/files/doc/fauna/peep/
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --line-numbers
76
+ - --inline-source
77
+ - --title
78
+ - Peep
79
+ - --main
80
+ - README
81
+ require_paths:
82
+ - lib
83
+ - ext
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "1.2"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project: fauna
99
+ rubygems_version: 1.3.1
100
+ signing_key:
101
+ specification_version: 2
102
+ summary: A heap inspector for live memcached instances.
103
+ test_files: []
104
+
metadata.gz.sig ADDED
Binary file