Code cleaning
This commit is contained in:
parent
c3f1fd1e04
commit
7e6ae28c54
1 changed files with 10 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Nagios plugin to check Ceph cluster state
|
# Nagios plugin to check Ceph cluster state
|
||||||
#
|
#
|
||||||
|
@ -40,13 +40,13 @@
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
import subprocess
|
|
||||||
import re
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# default ceph values
|
# default ceph values
|
||||||
CEPH_COMMAND = '/usr/bin/ceph'
|
CEPH_COMMAND = '/usr/bin/ceph'
|
||||||
|
@ -185,8 +185,8 @@ ceph_cmd.append('status')
|
||||||
ceph_cmd.append('--format=json')
|
ceph_cmd.append('--format=json')
|
||||||
|
|
||||||
# exec command
|
# exec command
|
||||||
p = subprocess.Popen(ceph_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
with subprocess.Popen(ceph_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
|
||||||
output, err = p.communicate()
|
output, err = p.communicate()
|
||||||
|
|
||||||
if not output:
|
if not output:
|
||||||
print("UNKNOWN : fail to execute ceph status command")
|
print("UNKNOWN : fail to execute ceph status command")
|
||||||
|
@ -209,7 +209,7 @@ total_mon = data['monmap'].get('num_mons', len(data['monmap'].get('mons', [])))
|
||||||
if not total_mon:
|
if not total_mon:
|
||||||
print("UNKNOWN : fail to retreive total number of monitors")
|
print("UNKNOWN : fail to retreive total number of monitors")
|
||||||
sys.exit(STATUS['UNKNOWN'])
|
sys.exit(STATUS['UNKNOWN'])
|
||||||
total_mon_up = len(data.get('quorum', data['health'].get('timechecks', dict()).get('mons', [])))
|
total_mon_up = len(data.get('quorum', data['health'].get('timechecks', {}).get('mons', [])))
|
||||||
if not total_mon_up:
|
if not total_mon_up:
|
||||||
print("UNKNOWN : fail to retreive total number of UP monitors")
|
print("UNKNOWN : fail to retreive total number of UP monitors")
|
||||||
sys.exit(STATUS['UNKNOWN'])
|
sys.exit(STATUS['UNKNOWN'])
|
||||||
|
|
Loading…
Reference in a new issue