add ceph checks (from https://github.com/valerytschopp/ceph-nagios-plugins)
diff --git a/sensu/files/checks/check_ceph_df b/sensu/files/checks/check_ceph_df
new file mode 100755
index 0000000..f841b55
--- /dev/null
+++ b/sensu/files/checks/check_ceph_df
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+#
+#  Copyright (c) 2013 SWITCH http://www.switch.ch
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+import argparse
+import os
+import subprocess
+import sys
+
+__version__ = '1.0.1'
+
+# default ceph values
+CEPH_COMMAND = '/usr/bin/ceph'
+
+# nagios exit code
+STATUS_OK = 0
+STATUS_WARNING = 1
+STATUS_ERROR = 2
+STATUS_UNKNOWN = 3
+
+def main():
+
+    # parse args
+    parser = argparse.ArgumentParser(description="'ceph df' nagios plugin.")
+    parser.add_argument('-e','--exe', help='ceph executable [%s]' % CEPH_COMMAND)
+    parser.add_argument('-c','--conf', help='alternative ceph conf file')
+    parser.add_argument('-m','--monaddress', help='ceph monitor address[:port]')    
+    parser.add_argument('-i','--id', help='ceph client id')
+    parser.add_argument('-n','--name', help='ceph client name')
+    parser.add_argument('-k','--keyring', help='ceph client keyring file')
+    parser.add_argument('-d','--detail', help="show pool details on warn and critical", action='store_true')
+    parser.add_argument('-W','--warn', help="warn above this percent RAW USED")
+    parser.add_argument('-C','--critical', help="critical alert above this percent RAW USED")
+    parser.add_argument('-V','--version', help='show version and exit', action='store_true')
+    args = parser.parse_args()
+   
+    # validate args
+    ceph_exec = args.exe if args.exe else CEPH_COMMAND
+    if not os.path.exists(ceph_exec):
+        print "ERROR: ceph executable '%s' doesn't exist" % ceph_exec
+        return STATUS_UNKNOWN
+    
+    if args.version:
+        print 'version %s' % __version__
+        return STATUS_OK
+
+    if args.conf and not os.path.exists(args.conf):
+        print "ERROR: ceph conf file '%s' doesn't exist" % args.conf
+        return STATUS_UNKNOWN
+    
+    if args.keyring and not os.path.exists(args.keyring):
+        print "ERROR: keyring file '%s' doesn't exist" % args.keyring
+        return STATUS_UNKNOWN
+
+    if args.warn > args.critical or not args.warn or not args.critical:
+        print "ERROR: warn and critical level must be set and critical must be greater than warn"
+        return STATUS_UNKNOWN
+    
+    # build command
+    ceph_df = [ceph_exec]
+    if args.monaddress:
+        ceph_df.append('-m')
+        ceph_df.append(args.monaddress)
+    if args.conf:
+        ceph_df.append('-c')
+        ceph_df.append(args.conf)
+    if args.id:
+        ceph_df.append('--id')
+        ceph_df.append(args.id)
+    if args.name:
+        ceph_df.append('--name')
+        ceph_df.append(args.name)
+    if args.keyring:
+        ceph_df.append('--keyring')
+        ceph_df.append(args.keyring)
+    ceph_df.append('df')
+
+    #print ceph_df
+    
+    # exec command
+    p = subprocess.Popen(ceph_df,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+    output, err = p.communicate()
+    
+    # parse output
+    # print "DEBUG: output:", output
+    # print "DEBUG: err:", err
+    if output:
+        # parse output
+        # if detail switch was not set only show global values and compare to warning and critical
+        # otherwise show space for pools too
+        result=output.splitlines()
+        # values for GLOBAL are in 3rd line of output
+        globalline = result[2]
+        globalvals = globalline.split(' ')
+        # strip all empty values from list
+        globalvals = [x for x in globalvals if x != '']
+
+        # prepare pool values
+        # pool output starts in line 4 with the bare word POOLS: followed by the output
+        poolline = result[3:]
+        # print 'DEBUG:', globalvals
+        # finally 4th element contains percentual value
+        # print 'DEBUG USAGE:', globalvals[3]
+        global_usage_percent = globalvals[3]
+        global_available_space = globalvals[1]
+        global_total_space = globalvals[0]
+        # print 'DEBUG WARNLEVEL:', args.warn
+        # print 'DEBUG CRITICALLEVEL:', args.critical
+        if global_usage_percent > args.critical:
+            if args.detail:
+                    poolline.insert(0, '\n')
+                    poolout = '\n '.join(poolline)
+            else:
+                    poolout = ''
+            print 'CRITICAL: global RAW usage of %s%% is above %s%% (%s of %s free)%s' % (global_usage_percent, args.critical, global_available_space, global_total_space, poolout)
+            return STATUS_ERROR
+        elif global_usage_percent > args.warn:
+            if args.detail:
+                    poolline.insert(0, '\n')
+                    poolout = '\n '.join(poolline)
+            else:
+                    poolout = ''
+            print 'WARNING: global RAW usage of %s%% is above %s%% (%s of %s free)%s' % (global_usage_percent, args.warn, global_available_space, global_total_space, poolout)
+            return STATUS_WARNING 
+        else:
+            print 'RAW usage %s%%' % global_usage_percent
+            return STATUS_OK
+    elif err:
+        # read only first line of error
+        one_line = err.split('\n')[0]
+        if '-1 ' in one_line:
+            idx = one_line.rfind('-1 ')
+            print 'ERROR: %s: %s' % (ceph_exec, one_line[idx+len('-1 '):])
+        else:
+            print one_line
+    
+    return STATUS_UNKNOWN
+
+
+if __name__ == "__main__":
+    sys.exit(main())
+
diff --git a/sensu/files/checks/check_ceph_health b/sensu/files/checks/check_ceph_health
new file mode 100755
index 0000000..b164e45
--- /dev/null
+++ b/sensu/files/checks/check_ceph_health
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+#
+#  Copyright (c) 2013 SWITCH http://www.switch.ch
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+import argparse
+import os
+import subprocess
+import sys
+
+__version__ = '1.0.1'
+
+# default ceph values
+CEPH_COMMAND = '/usr/bin/ceph'
+
+# nagios exit code
+STATUS_OK = 0
+STATUS_WARNING = 1
+STATUS_ERROR = 2
+STATUS_UNKNOWN = 3
+
+def main():
+
+    # parse args
+    parser = argparse.ArgumentParser(description="'ceph health' nagios plugin.")
+    parser.add_argument('-e','--exe', help='ceph executable [%s]' % CEPH_COMMAND)
+    parser.add_argument('-c','--conf', help='alternative ceph conf file')
+    parser.add_argument('-m','--monaddress', help='ceph monitor address[:port]')    
+    parser.add_argument('-i','--id', help='ceph client id')
+    parser.add_argument('-n','--name', help='ceph client name')
+    parser.add_argument('-k','--keyring', help='ceph client keyring file')
+    parser.add_argument('-d','--detail', help="exec 'ceph health detail'", action='store_true')
+    parser.add_argument('-V','--version', help='show version and exit', action='store_true')
+    args = parser.parse_args()
+   
+    # validate args
+    ceph_exec = args.exe if args.exe else CEPH_COMMAND
+    if not os.path.exists(ceph_exec):
+        print "ERROR: ceph executable '%s' doesn't exist" % ceph_exec
+        return STATUS_UNKNOWN
+    
+    if args.version:
+        print 'version %s' % __version__
+        return STATUS_OK
+
+    if args.conf and not os.path.exists(args.conf):
+        print "ERROR: ceph conf file '%s' doesn't exist" % args.conf
+        return STATUS_UNKNOWN
+    
+    if args.keyring and not os.path.exists(args.keyring):
+        print "ERROR: keyring file '%s' doesn't exist" % args.keyring
+        return STATUS_UNKNOWN
+    
+    # build command
+    ceph_health = [ceph_exec]
+    if args.monaddress:
+        ceph_health.append('-m')
+        ceph_health.append(args.monaddress)
+    if args.conf:
+        ceph_health.append('-c')
+        ceph_health.append(args.conf)
+    if args.id:
+        ceph_health.append('--id')
+        ceph_health.append(args.id)
+    if args.name:
+        ceph_health.append('--name')
+        ceph_health.append(args.name)
+    if args.keyring:
+        ceph_health.append('--keyring')
+        ceph_health.append(args.keyring)
+    ceph_health.append('health')
+    if args.detail:
+        ceph_health.append('detail')
+
+    #print ceph_health
+    
+    # exec command
+    p = subprocess.Popen(ceph_health,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+    output, err = p.communicate()
+    
+    # parse output
+    #print "output:", output
+    #print "err:", err
+    if output:
+        # merge multi-lines of output in one line
+        one_line = output.replace('\n','; ')
+        if one_line.startswith('HEALTH_OK'):
+            #print 'HEALTH OK:', one_line[len('HEALTH_OK')+1:]
+            one_line= one_line[len('HEALTH_OK')+1:].strip()
+            if one_line:
+                print 'HEALTH OK:', one_line
+            else:
+                print 'HEALTH OK'
+            return STATUS_OK
+        elif one_line.startswith('HEALTH_WARN'):
+            print 'HEALTH WARNING:', one_line[len('HEALTH_WARN')+1:]
+            return STATUS_WARNING
+        elif one_line.startswith('HEALTH_ERR'):
+            print 'HEALTH ERROR:', one_line[len('HEALTH_ERR')+1:]
+            return STATUS_ERROR
+        else:
+            print one_line
+        
+    elif err:
+        # read only first line of error
+        one_line = err.split('\n')[0]
+        if '-1 ' in one_line:
+            idx = one_line.rfind('-1 ')
+            print 'ERROR: %s: %s' % (ceph_exec, one_line[idx+len('-1 '):])
+        else:
+            print one_line
+    
+    return STATUS_UNKNOWN
+
+
+if __name__ == "__main__":
+    sys.exit(main())
+
diff --git a/sensu/files/checks/check_ceph_mon b/sensu/files/checks/check_ceph_mon
new file mode 100755
index 0000000..e00f0eb
--- /dev/null
+++ b/sensu/files/checks/check_ceph_mon
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+#
+#  Copyright (c) 2013 Catalyst IT http://www.catalyst.net.nz
+#  Copyright (c) 2015 SWITCH http://www.switch.ch
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+import argparse
+import socket
+import os
+import re
+import subprocess
+import sys
+import json
+
+__version__ = '1.1.0'
+
+# default ceph values
+CEPH_EXEC = '/usr/bin/ceph'
+CEPH_COMMAND = 'quorum_status'
+
+# nagios exit code
+STATUS_OK = 0
+STATUS_WARNING = 1
+STATUS_ERROR = 2
+STATUS_UNKNOWN = 3
+
+##
+# ceph quorum_status output example
+##
+ceph_quorum_status_output_example = '''{
+   "quorum_leader_name" : "s0001",
+   "monmap" : {
+      "mons" : [
+         {
+            "name" : "s0001",
+            "addr" : "[2001:620:5ca1:8000::1001]:6789/0",
+            "rank" : 0
+         },
+         {
+            "name" : "s0003",
+            "addr" : "[2001:620:5ca1:8000::1003]:6789/0",
+            "rank" : 1
+         }
+      ],
+      "created" : "2014-12-15 08:28:35.153650",
+      "epoch" : 2,
+      "modified" : "2014-12-15 08:28:40.371878",
+      "fsid" : "22348d2b-b69d-46cc-9a79-ca93cd6bae84"
+   },
+   "quorum_names" : [
+      "s0001",
+      "s0003"
+   ],
+   "quorum" : [
+      0,
+      1
+   ],
+   "election_epoch" : 24
+}'''
+
+def main():
+
+  # parse args
+  parser = argparse.ArgumentParser(description="'ceph quorum_status' nagios plugin.")
+  parser.add_argument('-e','--exe', help='ceph executable [%s]' % CEPH_EXEC)
+  parser.add_argument('-c','--conf', help='alternative ceph conf file')
+  parser.add_argument('-m','--monaddress', help='ceph monitor to use for queries (address[:port])')    
+  parser.add_argument('-i','--id', help='ceph client id')
+  parser.add_argument('-k','--keyring', help='ceph client keyring file')
+  parser.add_argument('-V','--version', help='show version and exit', action='store_true')
+  parser.add_argument('-I','--monid', help='mon ID to be checked for availability')
+  args = parser.parse_args()
+ 
+  if args.version:
+    print 'version %s' % __version__
+    return STATUS_OK
+
+  # validate args
+  ceph_exec = args.exe if args.exe else CEPH_EXEC
+  if not os.path.exists(ceph_exec):
+    print "MON ERROR: ceph executable '%s' doesn't exist" % ceph_exec
+    return STATUS_UNKNOWN
+  
+  if args.conf and not os.path.exists(args.conf):
+    print "MON ERROR: ceph conf file '%s' doesn't exist" % args.conf
+    return STATUS_UNKNOWN
+  
+  if args.keyring and not os.path.exists(args.keyring):
+    print "MON ERROR: keyring file '%s' doesn't exist" % args.keyring
+    return STATUS_UNKNOWN
+  
+  if not args.monid:
+    print "MON ERROR: no MON ID given, use -I/--monid parameter"
+    return STATUS_UNKNOWN
+
+  # build command
+  ceph_cmd = [ceph_exec]
+  if args.monaddress:
+    ceph_cmd.append('-m')
+    ceph_cmd.append(args.monaddress)
+  if args.conf:
+    ceph_cmd.append('-c')
+    ceph_cmd.append(args.conf)
+  if args.id:
+    ceph_cmd.append('--id')
+    ceph_cmd.append(args.id)
+  if args.keyring:
+    ceph_cmd.append('--keyring')
+    ceph_cmd.append(args.keyring)
+  ceph_cmd.append(CEPH_COMMAND)
+
+  # exec command
+  p = subprocess.Popen(ceph_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+  output, err = p.communicate()
+
+  if p.returncode != 0 or not output:
+    print "MON ERROR: %s" % err
+    return STATUS_ERROR
+
+  # load json output and parse
+  quorum_status = False
+  try:
+    quorum_status = json.loads(output)
+  except Exception as e:
+    print "MON ERROR: could not parse '%s' output: %s: %s" % (CEPH_COMMAND,output,e)
+    return STATUS_UNKNOWN
+
+  #print "XXX: quorum_status['quorum_names']:", quorum_status['quorum_names']
+
+  # do our checks
+  is_monitor = False
+  for mon in quorum_status['monmap']['mons']:
+    if mon['name'] == args.monid:
+      is_monitor = True
+  if not is_monitor:
+    print "MON WARN: mon '%s' is not in monmap: %s" % (args.monid,quorum_status['monmap']['mons'])
+    return STATUS_WARNING
+
+  in_quorum = args.monid in quorum_status['quorum_names']
+  if in_quorum:
+    print "MON OK"
+    return STATUS_OK
+  else:
+    print "MON WARN: no MON '%s' found in quorum" % args.monid
+    return STATUS_WARNING
+
+# main
+if __name__ == "__main__":
+  sys.exit(main())
+
diff --git a/sensu/files/checks/check_ceph_osd b/sensu/files/checks/check_ceph_osd
new file mode 100755
index 0000000..64f13e3
--- /dev/null
+++ b/sensu/files/checks/check_ceph_osd
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+#
+#  Copyright (c) 2013 Catalyst IT http://www.catalyst.net.nz
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import socket
+
+__version__ = '1.1.0'
+
+# default ceph values
+CEPH_COMMAND = '/usr/bin/ceph'
+
+# nagios exit code
+STATUS_OK = 0
+STATUS_WARNING = 1
+STATUS_ERROR = 2
+STATUS_UNKNOWN = 3
+
+def main():
+
+  # parse args
+  parser = argparse.ArgumentParser(description="'ceph osd' nagios plugin.")
+  parser.add_argument('-e','--exe', help='ceph executable [%s]' % CEPH_COMMAND)
+  parser.add_argument('-c','--conf', help='alternative ceph conf file')
+  parser.add_argument('-m','--monaddress', help='ceph monitor address[:port]')    
+  parser.add_argument('-i','--id', help='ceph client id')
+  parser.add_argument('-k','--keyring', help='ceph client keyring file')
+  parser.add_argument('-V','--version', help='show version and exit', action='store_true')
+  parser.add_argument('-H','--host', help='osd host', required=True)
+  parser.add_argument('-I','--osdid', help='osd id', required=False)
+  parser.add_argument('-o','--out', help='check osds that are set OUT', default=False, action='store_true', required=False)
+  args = parser.parse_args()
+ 
+  # validate args
+  ceph_exec = args.exe if args.exe else CEPH_COMMAND
+  if not os.path.exists(ceph_exec):
+    print "OSD ERROR: ceph executable '%s' doesn't exist" % ceph_exec
+    return STATUS_UNKNOWN
+  
+  if args.version:
+    print 'version %s' % __version__
+    return STATUS_OK
+
+  if args.conf and not os.path.exists(args.conf):
+    print "OSD ERROR: ceph conf file '%s' doesn't exist" % args.conf
+    return STATUS_UNKNOWN
+  
+  if args.keyring and not os.path.exists(args.keyring):
+    print "OSD ERROR: keyring file '%s' doesn't exist" % args.keyring
+    return STATUS_UNKNOWN
+  
+  if not args.osdid:
+    args.osdid = '[^ ]*'
+
+  if not args.host:
+    print "OSD ERROR: no OSD hostname given"
+    return STATUS_UNKNOWN
+
+  try:
+    args.host = socket.gethostbyname(args.host)
+  except socket.gaierror:
+    print 'OSD ERROR: could not resolve %s' % args.host
+    return STATUS_UNKNOWN
+
+
+  # build command
+  ceph_cmd = [ceph_exec]
+  if args.monaddress:
+      ceph_cmd.append('-m')
+      ceph_cmd.append(args.monaddress)
+  if args.conf:
+      ceph_cmd.append('-c')
+      ceph_cmd.append(args.conf)
+  if args.id:
+      ceph_cmd.append('--id')
+      ceph_cmd.append(args.id)
+  if args.keyring:
+      ceph_cmd.append('--keyring')
+      ceph_cmd.append(args.keyring)
+  ceph_cmd.append('osd')
+  ceph_cmd.append('dump')
+
+  # exec command
+  p = subprocess.Popen(ceph_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+  output, err = p.communicate()
+  
+  if err or not output:
+    print "OSD ERROR: %s" % err
+    return STATUS_ERROR
+
+  # escape IPv4 host address
+  osd_host = args.host.replace('.', '\.')
+  # escape IPv6 host address
+  osd_host = osd_host.replace('[', '\[')
+  osd_host = osd_host.replace(']', '\]')
+  up = re.findall(r"^(osd\.%s) up.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+  if args.out:
+    down = re.findall(r"^(osd\.%s) down.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+    down_in = re.findall(r"^(osd\.%s) down[ ]+in.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+    down_out = re.findall(r"^(osd\.%s) down[ ]+out.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+  else:
+    down = re.findall(r"^(osd\.%s) down[ ]+in.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+    down_in = down
+    down_out = re.findall(r"^(osd\.%s) down[ ]+out.* %s:" % (args.osdid, osd_host), output, re.MULTILINE)
+
+  if down:
+    print "OSD WARN: Down OSD%s on %s: %s" % ('s' if len(down)>1 else '', args.host, " ".join(down))
+    print "Up OSDs: " + " ".join(up)
+    print "Down+In OSDs: " + " ".join(down_in)
+    print "Down+Out OSDs: " + " ".join(down_out)
+    return STATUS_WARNING
+
+  if up:
+    print "OSD OK"
+    print "Up OSDs: " + " ".join(up)
+    print "Down+In OSDs: " + " ".join(down_in)
+    print "Down+Out OSDs: " + " ".join(down_out)
+    return STATUS_OK
+
+  print "OSD WARN: no OSD.%s found on host %s" % (args.osdid, args.host)
+  return STATUS_WARNING
+
+if __name__ == "__main__":
+    sys.exit(main())
+
diff --git a/sensu/files/checks/check_ceph_rgw b/sensu/files/checks/check_ceph_rgw
new file mode 100755
index 0000000..87c214f
--- /dev/null
+++ b/sensu/files/checks/check_ceph_rgw
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+#
+#  Copyright (c) 2014 Catalyst IT http://www.catalyst.net.nz
+#  Copyright (c) 2015 SWITCH http://www.switch.ch
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+import json
+
+__version__ = '1.3.0'
+
+# default ceph values
+RGW_COMMAND = '/usr/bin/radosgw-admin'
+
+# nagios exit code
+STATUS_OK = 0
+STATUS_WARNING = 1
+STATUS_ERROR = 2
+STATUS_UNKNOWN = 3
+
+def main():
+
+  # parse args
+  parser = argparse.ArgumentParser(description="'radosgw-admin bucket stats' nagios plugin.")
+  parser.add_argument('-d','--detail', help='output perf data for all buckets', action='store_true')
+  parser.add_argument('-B','--byte', help='output perf data in Byte instead of KB', action='store_true')
+  parser.add_argument('-e','--exe', help='radosgw-admin executable [%s]' % RGW_COMMAND)
+  parser.add_argument('-c','--conf', help='alternative ceph conf file')
+  parser.add_argument('-i','--id', help='ceph client id')
+  parser.add_argument('-V','--version', help='show version and exit', action='store_true')
+  args = parser.parse_args()
+ 
+  # validate args
+  rgw_exec = args.exe if args.exe else RGW_COMMAND
+  if not os.path.exists(rgw_exec):
+    print "RGW ERROR: radosgw-admin executable '%s' doesn't exist" % rgw_exec
+    return STATUS_UNKNOWN
+  
+  if args.version:
+    print 'version %s' % __version__
+    return STATUS_OK
+
+  if args.conf and not os.path.exists(args.conf):
+    print "RGW ERROR: ceph conf file '%s' doesn't exist" % args.conf
+    return STATUS_UNKNOWN
+  
+  # build command
+  rgw_cmd = [rgw_exec]
+  if args.conf:
+    rgw_cmd.append('-c')
+    rgw_cmd.append(args.conf)
+  if args.id:
+    rgw_cmd.append('-i')
+    rgw_cmd.append(args.id)
+  rgw_cmd.append('bucket')
+  rgw_cmd.append('stats')
+
+  # exec command
+  p = subprocess.Popen(rgw_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+  output, err = p.communicate()
+
+  if p.returncode != 0 or not output:
+    print "RGW ERROR: %s :: %s" % (output, err)
+    return STATUS_ERROR
+
+  bucket_stats = json.loads(output)
+  #print bucket_stats
+  buckets = []
+  for i in bucket_stats:
+    if type(i) is dict:
+      bucket_name = i['bucket']
+      usage_dict = i['usage']
+      if not usage_dict:
+        bucket_usage_kb = 0
+      else:
+        bucket_usage_kb = usage_dict['rgw.main']['size_kb_actual']
+      buckets.append((bucket_name, bucket_usage_kb))
+  buckets_total_kb =  sum([b[1] for b in buckets])
+  if args.byte:
+    status = "RGW OK: {} buckets, {} KB total | /={}B ".format(len(buckets),buckets_total_kb,buckets_total_kb*1024)
+  else:
+    status = "RGW OK: {} buckets, {} KB total | /={}KB ".format(len(buckets),buckets_total_kb,buckets_total_kb)
+  #print buckets
+  if buckets and args.detail:
+    if args.byte:
+      status = status + " ".join(["{}={}B".format(b[0],b[1]*1024) for b in buckets])
+    else:
+      status = status + " ".join(["{}={}KB".format(b[0],b[1]) for b in buckets])
+
+  print status
+  return STATUS_OK
+
+if __name__ == "__main__":
+  sys.exit(main())
+