Skip to content

Commit

Permalink
Fix: (reported by descrepes) encoding errors from passive actions. Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
naparuba committed Jan 8, 2015
1 parent cc4ac86 commit 3bcffa7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions shinken/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,19 @@ def get_actions_from_passives_satellites(self):
# Before ask a call that can be long, do a simple ping to be sure it is alive
con.get('ping')
results = con.get('get_returns', {'sched_id':self.instance_id}, wait='long')
results = cPickle.loads(str(results))
try:
results = str(results)
except UnicodeEncodeError: # ascii not working, switch to utf8 so
results = results.encode("utf8", 'ignore') # if not eally utf8 will be a real problem
# and data will be invalid, socatch by the pickle.

# now go the cpickle pass, and catch possible errors from it
try:
results = cPickle.loads(results)
except Exception, exp:
logger.error('Cannot load passive results from satellite %s : %s' % (p['name'], str(exp)))
continue

nb_received = len(results)
self.nb_check_received += nb_received
logger.debug("Received %d passive results", nb_received)
Expand All @@ -857,11 +869,11 @@ def get_actions_from_passives_satellites(self):
except HTTPExceptions, exp:
logger.warning("Connection problem to the %s %s: %s", type, p['name'], str(exp))
p['con'] = None
return
continue
except KeyError, exp:
logger.warning("The %s '%s' is not initialized: %s", type, p['name'], str(exp))
p['con'] = None
return
continue
else: # no connection, try reinit
self.pynag_con_init(p['instance_id'], type='poller')

Expand Down

0 comments on commit 3bcffa7

Please sign in to comment.