go-ceph icon indicating copy to clipboard operation
go-ceph copied to clipboard

question: rbd du

Open sajal opened this issue 9 years ago • 14 comments

I am new to ceph, and am looking at this library to list image information in a dashboard.

How do I get the equivalent of rbd du myrbd or rbd diff myrbd | awk '{ SUM += $2 } END { print SUM/1024/1024 " MB" }' cli command? the Size in rbd.ImageInfo is the total allocated size.

My code so far: https://gist.github.com/sajal/4e7e0bd77d3deced0d450e8f9af7775a

sajal avatar Mar 27 '17 11:03 sajal

Is there a timeline for when rbd diff is going to be implemented? I see a TODO item on the code which may be related to what the poster needs. Ever got how to do this @sajal ?

kfajardo-agsx avatar Jan 29 '18 02:01 kfajardo-agsx

@kfajardo I did not.

I gave up on my grand plans of running on bare-metal and no longer need to manage storage.

sajal avatar Jan 29 '18 10:01 sajal

Awts. Thanks. I also need the go-ceph support for calculating actual usage on what I'm currently working on. @_@ I guess I need to find another way.

kfajardo-agsx avatar Jan 29 '18 12:01 kfajardo-agsx

Any news about this issue? I can't find a method that calculates a du in the C library. But if someone helps me, I'll try to make a PR, huh

objque avatar Aug 10 '18 06:08 objque

Hi @objque is there a specific C API or set of C APIs that you'd like a wrapper for?

dotnwat avatar Aug 10 '18 14:08 dotnwat

@noahdesu - I guess they are referring to an equivalent to this stat call: http://docs.ceph.com/docs/master/rbd/api/librbdpy/#rbd.Image.stat

Which is already available: https://github.com/ceph/go-ceph/blob/master/rbd/rbd.go#L297

Maybe they didn't find this yet?

mulbc avatar Aug 15 '18 07:08 mulbc

Thanks @zeichenanonym that does seem like it might be what's being discussed.

dotnwat avatar Aug 15 '18 14:08 dotnwat

Hey ,

Does it answer the issue here ?

I'm trying to acheive the same goal. Trying to get image use with this go library.

Trying to get same output as rbd du -p POOL_NAME

SebastienTolron avatar Oct 29 '19 15:10 SebastienTolron

New permalink: https://github.com/ceph/go-ceph/blob/e32f9f0f2e941422937c0a6c4f0a61b8f0c82995/rbd/rbd.go#L348

Please try if this works for what you want to do ;)

mulbc avatar Oct 29 '19 16:10 mulbc

I Might miss something.

This stat function allow me to get the size of image, the block number etc..

But I don't have the usage ? the disk utilization ?

Did i Miss something ?

SebastienTolron avatar Oct 30 '19 07:10 SebastienTolron

Copying from the documentation:

dict - contains the following keys:

  • size (int) - the size of the image in bytes
  • obj_size (int) - the size of each object that comprises the image
  • num_objs (int) - the number of objects in the image
  • order (int) - log_2(object_size)
  • block_name_prefix (str) - the prefix of the RADOS objects used to store the image
  • parent_pool (int) - deprecated
  • parent_name (str) - deprecated

So you could figure out the disk utilisation by multiplying the num_objs with the obj_size...

mulbc avatar Oct 30 '19 08:10 mulbc

There is also rados.IOContext.GetPoolStats() that fills a struct with details about the pool. See

nixpanic avatar Dec 16 '19 13:12 nixpanic

Closing as there have been no follow-up questions for almost 2 months.

nixpanic avatar Feb 13 '20 07:02 nixpanic

hello, I was working with

o you could figure out the disk utilisation by multiplying the num_objs with the obj_siz

Hello, @mulbc I have tried this way but doesn't provide me the appropriate output. I have also tried using 'image.DiffIterate' but that doesn't help me either.

shaekhhasanshoron avatar Sep 20 '20 20:09 shaekhhasanshoron