Cephdetail
Cephdetail
fetches Ceph capacity and monitoring data from the Ceph REST API, and returns the responses as
Ruby Hashes to be used in other code.
I initially wrote this to integrate with my LogStash plugin, logstash-input-ceph
.
Installation
Add this line to your application's Gemfile:
gem 'cephdetail'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cephdetail
Usage
Using cephdetail
is very straight forward. First though, you'll need an environment variable called
CEPH_REST_API
so that the gem can find the URL of your WSGI service, such as http://localhost:5000
.
Here's some examples on how to use the gem:
require 'cephdetail'
health = Cephdetail::Health.new
df = health.df
status = health.status
cluster_health = health.cluster_health
osdstat = health.osdstat
osdperf = health.osdperf
What you get back are hashes constructed from the JSON returned by the API. The methods mock the following ceph
client commands:
df
=ceph df
status
=ceph status
cluster_health
=ceph health detail
osdstat
=ceph osd stat
osdperf
=ceph osd perf
Notes on security
By default, when installing the Ceph REST API, there is no security. You use a cephx
authentication key to authenticate
the API against your Ceph cluster, but insofar as the WSGI service is concerned, there's no authentication of
requests. In our environment, the VM that runs the Apache2 service that hosts the API service is buried deep within
our core network and protected by access lists and firewall rules limiting incoming to a handful of addresses. On the
surface, if you've hacked that far into my network, I'm screwed anyway, but figuring out some form of authentication
would definitely be a good idea. I'll also bake in support for using HTTPS and not plain old HTTP in coming versions.
The long and the short of it is this: the gem provides no mechanism for authentication as of 0.2.0
. This will be
baked into the gem in later releases, but for now, be aware that you are communicating with your Ceph API, and thus,
your cluster, using unauthenticated and unencrypted requests, and are encouraged to think and plan accordingly.
I'll only be updating this gem for PUT and POST paths when the above has been completed.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can
also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the
version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version,
push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/xnoder/cephdetail.
License
The gem is available as open source under the terms of the MIT License (MIT)