Skip to content

Commit

Permalink
Wait until the status file becomes available, Nagios might be rewriti…
Browse files Browse the repository at this point in the history
…ng it
  • Loading branch information
Wijnand Modderman-Lenstra committed Nov 22, 2012
1 parent 7a82027 commit 9ae493f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions nagios_cli/nagios.py
Expand Up @@ -40,13 +40,26 @@ def parse(self, filename, limit=None):
if limit is not None:
self.limit = limit

handle = open(filename, 'rb')
retry = 10
handle = None
while handle is None:
try:
handle = open(filename, 'rb')
except:
retry -= 1
if retry:
print '%s is not available, retry %d' % (filename, retry)
time.sleep(0.5)
else:
print '%s is not available' % (filename,)
sys.exit(0)

for line in handle:
line = line.strip()

if not line:
continue

elif self.section is None:
if self.define:
if line[:6] == 'define' and line[-1] == '{':
Expand Down

0 comments on commit 9ae493f

Please sign in to comment.