mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Merge pull request #1451 from kimheino/master
gluster: "volume status all detail" command fails randomly. Sleep and retry.
This commit is contained in:
commit
a0821117ad
1 changed files with 12 additions and 6 deletions
|
@ -36,17 +36,23 @@ GPLv2
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
|
|
||||||
def run_command(command):
|
def run_command(command):
|
||||||
"""Run gluster command and return it's output as etree."""
|
"""Run gluster command and return it's output as etree."""
|
||||||
try:
|
for _dummy_retry in range(3):
|
||||||
text = subprocess.run(['gluster', '--mode=script', '--xml'] + command,
|
try:
|
||||||
check=False, stdout=subprocess.PIPE,
|
text = subprocess.run(['gluster', '--mode=script', '--xml'] +
|
||||||
stderr=subprocess.PIPE, encoding='utf-8').stdout
|
command, check=False, stdout=subprocess.PIPE,
|
||||||
except FileNotFoundError:
|
stderr=subprocess.PIPE,
|
||||||
return None
|
encoding='utf-8').stdout
|
||||||
|
except FileNotFoundError:
|
||||||
|
return None
|
||||||
|
if text.count('\n') > 10:
|
||||||
|
break
|
||||||
|
time.sleep(2) # Sleep and retry
|
||||||
try:
|
try:
|
||||||
return xml.etree.ElementTree.fromstring(text)
|
return xml.etree.ElementTree.fromstring(text)
|
||||||
except xml.etree.ElementTree.ParseError:
|
except xml.etree.ElementTree.ParseError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue