Skip to content

Commit

Permalink
Fix variable name "ceph_dfcmdline" and add % cluster used
Browse files Browse the repository at this point in the history
Fix variable name "ceph_dfcmdline" and add % cluster used

Signed-off-by: anmolbabu <[email protected]>
  • Loading branch information
anmolbabu committed Mar 7, 2017
1 parent 74c567d commit 831586a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def dispatch_value(self, plugin, plugin_instance, type, type_instance, value):
else:
val.type_instance=type
val.values=[value]
val.host=self.cluster
val.interval = self.interval
val.dispatch()
self.logdebug("sent metric %s.%s.%s.%s.%s"
Expand Down
19 changes: 18 additions & 1 deletion plugins/ceph_pool_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import base


class CephPoolPlugin(base.Base):

def __init__(self):
Expand All @@ -54,7 +55,7 @@ def get_stats(self):
osd_pool_cmdline='ceph osd pool stats -f json --cluster ' + self.cluster
stats_output = subprocess.check_output(osd_pool_cmdline, shell=True)
cephdf_cmdline='ceph df -f json --cluster ' + self.cluster
df_output = subprocess.check_output(ceph_dfcmdline, shell=True)
df_output = subprocess.check_output(cephdf_cmdline, shell=True)
except Exception as exc:
collectd.error("ceph-pool: failed to ceph pool stats :: %s :: %s"
% (exc, traceback.format_exc()))
Expand Down Expand Up @@ -90,11 +91,27 @@ def get_stats(self):
data[ceph_cluster]['cluster']['total_space'] = int(json_df_data['stats']['total_bytes'])
data[ceph_cluster]['cluster']['total_used'] = int(json_df_data['stats']['total_used_bytes'])
data[ceph_cluster]['cluster']['total_avail'] = int(json_df_data['stats']['total_avail_bytes'])
data[ceph_cluster]['cluster']['percent-used'] = (
int(
json_df_data['stats']['total_used_bytes']
) * 100 / (
int(json_df_data['stats']['total_bytes'])
* 1.0
)
)
else:
# ceph < 0.84
data[ceph_cluster]['cluster']['total_space'] = int(json_df_data['stats']['total_space']) * 1024.0
data[ceph_cluster]['cluster']['total_used'] = int(json_df_data['stats']['total_used']) * 1024.0
data[ceph_cluster]['cluster']['total_avail'] = int(json_df_data['stats']['total_avail']) * 1024.0
data[ceph_cluster]['cluster']['percent-used'] = (
int(
json_df_data['stats']['total_used_bytes']
) * 100 / (
int(json_df_data['stats']['total_bytes'])
* 1.0
)
)

return data

Expand Down

0 comments on commit 831586a

Please sign in to comment.