Use logger consistently
This commit is contained in:
parent
bac1723bb4
commit
46ff5e3f02
@ -70,7 +70,7 @@ class jmx_query():
|
|||||||
jmx = self.query(url)
|
jmx = self.query(url)
|
||||||
|
|
||||||
if (jmx == False):
|
if (jmx == False):
|
||||||
print("Could not read jmx data from: " + url)
|
logging.info("Could not read jmx data from: " + url)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for k, v in jmx.items():
|
for k, v in jmx.items():
|
||||||
@ -91,7 +91,7 @@ class jmx_query():
|
|||||||
try:
|
try:
|
||||||
r = subprocess.run(cmd_hdfs_namenodes, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
r = subprocess.run(cmd_hdfs_namenodes, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("type error: " + str(e))
|
logging.debug("type error: " + str(e))
|
||||||
logging.debug("Failed to get active master")
|
logging.debug("Failed to get active master")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class jmx_query():
|
|||||||
active_namenode = None
|
active_namenode = None
|
||||||
|
|
||||||
if has_ha_element:
|
if has_ha_element:
|
||||||
print("Hadoop High-Availability")
|
logging.info("Hadoop High-Availability")
|
||||||
|
|
||||||
for property in root:
|
for property in root:
|
||||||
if "dfs.ha.namenodes" in property.find("name").text:
|
if "dfs.ha.namenodes" in property.find("name").text:
|
||||||
@ -124,10 +124,10 @@ class jmx_query():
|
|||||||
r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if len(r.stderr.decode("utf-8")) > 0:
|
if len(r.stderr.decode("utf-8")) > 0:
|
||||||
print(r.stderr.decode("utf-8"))
|
logging.debug(r.stderr.decode("utf-8"))
|
||||||
|
|
||||||
if "active" in r.stdout.decode("utf-8").lower():
|
if "active" in r.stdout.decode("utf-8").lower():
|
||||||
print("Active namenode: " + node_address + " (" + node + ")")
|
logging.info("Active namenode: " + node_address + " (" + node + ")")
|
||||||
return node_address
|
return node_address
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@ -136,7 +136,7 @@ class jmx_query():
|
|||||||
try:
|
try:
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Could not connect to: " + url)
|
logging.info("Could not connect to: " + url)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
jmx = json.loads(r.text)
|
jmx = json.loads(r.text)
|
||||||
@ -163,8 +163,8 @@ class hbase_exporter():
|
|||||||
try:
|
try:
|
||||||
r = subprocess.run(cmd_hbase_active_master, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
r = subprocess.run(cmd_hbase_active_master, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("type error: " + str(e))
|
logging.debug("type error: " + str(e))
|
||||||
logging.debug("Failed to get active master")
|
logging.info("Failed to get active master")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return r.stdout.decode('utf-8')
|
return r.stdout.decode('utf-8')
|
||||||
@ -200,7 +200,7 @@ class hbase_exporter():
|
|||||||
msg = '{0} regions stale in transition '\
|
msg = '{0} regions stale in transition '\
|
||||||
.format(nregions_in_transition_stale)
|
.format(nregions_in_transition_stale)
|
||||||
prom_nregions_in_transition_stale.set(nregions_in_transition_stale)
|
prom_nregions_in_transition_stale.set(nregions_in_transition_stale)
|
||||||
print(msg)
|
logging.info(msg)
|
||||||
return nregions_in_transition_stale
|
return nregions_in_transition_stale
|
||||||
|
|
||||||
def hbaseui_parse_output(self, content):
|
def hbaseui_parse_output(self, content):
|
||||||
@ -234,7 +234,7 @@ class hbase_exporter():
|
|||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print("Failed to run hbck (%d)" % (p.returncode))
|
logging.info("Failed to run hbck (%d)" % (p.returncode))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for line in output:
|
for line in output:
|
||||||
@ -253,15 +253,15 @@ class hbase_exporter():
|
|||||||
break
|
break
|
||||||
|
|
||||||
if hbck_status is None:
|
if hbck_status is None:
|
||||||
print('Failed to find hbck status result')
|
logging.info('Failed to find hbck status result')
|
||||||
if ninconsistencies is None:
|
if ninconsistencies is None:
|
||||||
print('Failed to find number of inconsistencies')
|
logging.info('Failed to find number of inconsistencies')
|
||||||
|
|
||||||
if ninconsistencies != None:
|
if ninconsistencies != None:
|
||||||
ninconsistencies = int(ninconsistencies)
|
ninconsistencies = int(ninconsistencies)
|
||||||
|
|
||||||
if not isinstance(ninconsistencies, int):
|
if not isinstance(ninconsistencies, int):
|
||||||
print('Error: Non-integer detected for the number of inconsistencies')
|
logging.info('Error: Non-integer detected for the number of inconsistencies')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def hbaseui_parse_table(table):
|
def hbaseui_parse_table(table):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user