Python API mon_comand()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am trying to get some statistics via the Python API but fail to run the equivalent of "ceph df detail".

One the command line I get:

# ceph -f json df |jq .pools[0]
{
  "name": "rbd",
  "id": 1,
  "stats": {
    "stored": 27410520278,
    "objects": 6781,
    "kb_used": 80382849,
    "bytes_used": 82312036566,
    "percent_used": 0.1416085809469223,
    "max_avail": 166317473792
  }
}
# ceph -f json df detail |jq .pools[0]
{
  "name": "rbd",
  "id": 1,
  "stats": {
    "stored": 27410520278,
    "objects": 6781,
    "kb_used": 80382849,
    "bytes_used": 82312036566,
    "percent_used": 0.1416085809469223,
    "max_avail": 166317473792,
    "quota_objects": 0,
    "quota_bytes": 0,
    "dirty": 6781,
    "rd": 309130743,
    "rd_bytes": 327278814208,
    "wr": 155492443,
    "wr_bytes": 155528225792,
    "compress_bytes_used": 0,
    "compress_under_bytes": 0,
    "stored_raw": 82231558358,
    "avail_raw": 498952444191
  }
}

In Python I just get an error:

# python
Python 2.7.16 (default, Oct 10 2019, 22:02:15) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> import rados
>>> cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
>>> cluster.connect()
>>> cluster.mon_command(json.dumps({'prefix': 'df', 'format': 'json'}), b'')
(0, '{"stats":{"total_bytes":643914731520,"total_avail_bytes":550794231808,"total_used_bytes":86678048768,"total_used_raw_bytes":93120499712,"total_used_raw_ratio":0.14461618661880493,"num_osds":6,"num_per_pool_osds":6},"stats_by_class":{"hdd":{"total_bytes":643914731520,"total_avail_bytes":550794231808,"total_used_bytes":86678048768,"total_used_raw_bytes":93120499712,"total_used_raw_ratio":0.14461618661880493}},"pools":[{"name":"rbd","id":1,"stats":{"stored":27410520278,"objects":6781,"kb_used":80382849,"bytes_used":82312036566,"percent_used":0.1416085809469223,"max_avail":166317473792}},{"name":"cephfs_data","id":3,"stats":{"stored":1282414464,"objects":307,"kb_used":3757248,"bytes_used":3847421952,"percent_used":0.0076519949361681938,"max_avail":166317473792}},{"name":"cephfs_metadata","id":4,"stats":{"stored":458803,"objects":22,"kb_used":2693,"bytes_used":2757248,"percent_used":5.5260434237425216e-06,"max_avail":166317473792}}]}\n', u'')
>>> cluster.mon_command(json.dumps({'prefix': 'df detail', 'format': 'json'}), b'')
(-22, '', u'command not known')
>>> 

Anything I can do to get the output of "ceph df detail" via Python API?
I would like to have the stats fields "rd", "wr", "rd_bytes" and "wr_bytes" per pool.

Regards
-- 
Robert Sander
Heinlein Support GmbH
Schwedter Str. 8/9b, 10119 Berlin

http://www.heinlein-support.de

Tel: 030 / 405051-43
Fax: 030 / 405051-19

Zwangsangaben lt. §35a GmbHG: 
HRB 93818 B / Amtsgericht Berlin-Charlottenburg,
Geschäftsführer: Peer Heinlein -- Sitz: Berlin

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
ceph-users mailing list -- ceph-users@xxxxxxx
To unsubscribe send an email to ceph-users-leave@xxxxxxx

[Index of Archives]     [Information on CEPH]     [Linux Filesystem Development]     [Ceph Development]     [Ceph Large]     [Ceph Dev]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [xfs]


  Powered by Linux