Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Commit

Permalink
check_ceph_libs_mk: Handle some failures
Browse files Browse the repository at this point in the history
There are cases where this check fails. Let's take care of them:
* KeyError: 'getpwuid(): uid not found: XXXXX'
 This seems to be caused by a bug in grnet/nss-uidpool.

* IOError: 'No such file or directory: '/proc/XXXXX/maps'
  This case happens when the check queries for a PID that does not
  exist anymore.
  • Loading branch information
Nikos Kormpakis committed Apr 23, 2018
1 parent c75ef46 commit a1063fa
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions monitoring/checkmk/check_ceph_libs_mk
Expand Up @@ -114,12 +114,15 @@ def fetch_procs(procs_to_check):
"""
procs = []
for p in psutil.process_iter():
# It is possible that a process found by process_iter() has died.
# Catch that exception and ignore it.
# It is possible that:
# * a process found by process_iter() has died
# * a UID cannot be found (see libnss-uidpool bug, T1934)
# Catch these exceptions and ignore them.
try:
_pinfo = p.as_dict()
except psutil.NoSuchProcess:
except (psutil.NoSuchProcess, KeyError):
continue

if check_process(_pinfo, procs_to_check):
procs.append(_pinfo)

Expand Down Expand Up @@ -155,12 +158,18 @@ def find_procs_old_libs(procs, libs_to_check):
# Since psutil 4.0.0, '(deleted)' string gets deleted.
# There is no way in psutil to find out if the library has
# been deleted, other than reading the /proc/[pid]/maps file.
mapfile = '/proc/{}/maps'.format(proc['pid'])
with open(mapfile, 'r') as f:
for line in f:
if any(lib in line for lib in libs_to_check):
if '(deleted)' in line:
oldmaps.append(' '.join(line.split()[-2:]))
try:
mapfile = '/proc/{}/maps'.format(proc['pid'])
with open(mapfile, 'r') as f:
for line in f:
if any(lib in line for lib in libs_to_check):
if '(deleted)' in line:
oldmaps.append(' '.join(line.split()[-2:]))
# In case a process found by fetch_procs() has died, its mapfile in
# procfs won't be available. We do not want the check to fail, so
# handle that exception accordingly.
except IOError:
continue

# If oldmaps contains at least one element, we have to show it.
# Append a dict with all proc information and stale mappings. We pass
Expand Down

0 comments on commit a1063fa

Please sign in to comment.