The contents of this wiki are no longer actively maintained. The most current documentation is available at http://ceph.com/docs.

Perfomance counters

From Ceph wiki

Revision as of 08:12, 16 December 2011 by Szymon (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Performance counters protocol

Performance counters are described briefly on doc page, but connection protocol is not. For some people example implementation of collectd plugin might be hard to understand, I've don't use c/c++ at day to day basis so it took while to understand that, but protocol is fair easy to use. If you want to develop own code which interacts with sockets, you have to remember about few things:

  • performance counters are provided only for osd deamons, you can connect to mds socket but you won't get anything useful
  • always use "network" bit order when connecting to ceph socket
  • there are four types of request:
    • 0 - version
    • 1 - data
    • 2 - schema
    • 1000 - none
  • response for request version contains only a 4 byte number, for other request it's 4 byte response length and rest of response with tailing 0 (0 is for end of string in c/c++)

Connecting to performance socket in ruby

Below is described basic example - getting version from socket

 #!/usr/bin/env ruby
 require 'rubygems'
 require 'socket'
 
 # path to socket
 socket = UNIXSocket.new("/var/run/ceph/osd.0.asok")
 
 # send request 0 (version) in network byte order
 socket.send([0].pack("N"), 0)
 
 # receive 4 byte response, unpack
 response = socket.recv(4).unpack("N")
 
 # it is always nice to close socket
 socket.close
 
 puts response

Now something more usefull - getting performance counters json file

 #!/usr/bin/env ruby
 require 'rubygems'
 require 'socket'
 require 'json'
 
   # path to socket
 socket = UNIXSocket.new("/var/run/ceph/osd.0.asok")
 
 # send request 1 (data) in network byte order
 socket.send([1].pack("N"), 0)
 
 # receive payload size
 payload_size = socket.recv(4).unpack("N")[0]
 
 # if our payload size > 0
 if payload_size > 0
   # receive data without tailing 0
   payload = socket.recv(payload_size -= 1)
   # data variable contains json with all performance counters
   data = JSON.parse(payload)
 end
 
 socket.close


Munin plugin

There is also munin plugin chef template (updated to ceph 0.39), you have to fill @label, @id and @counters variables. @counters is comma separated string with counter names which should be shown at single graph. Available counters are listed in lines 9-72. It will be moved to munin exchange, when someone fix site.

Personal tools