[pkg-nagios-changes] [Git][nagios-team/nagios-plugins-contrib][master] check_libs_ng: catch FileNotFoundErrors when trying to read the map files

Jan Wagner (@waja) gitlab at salsa.debian.org
Mon May 6 15:35:31 BST 2024



Jan Wagner pushed to branch master at Debian Nagios Maintainer Group / nagios-plugins-contrib


Commits:
8a9233bf by Evgeni Golov at 2024-04-30T13:50:46+02:00
check_libs_ng: catch FileNotFoundErrors when trying to read the map files

Closes: #1070073

- - - - -


1 changed file:

- check_libs_ng/check_libs_ng


Changes:

=====================================
check_libs_ng/check_libs_ng
=====================================
@@ -56,20 +56,23 @@ def main():
     for proc in glob('/proc/[0-9]*'):  # numbers to avoid e.g. /proc/self
         exe = os.path.join(proc, 'exe')
         if os.path.exists(exe):
-            proc_pid = os.path.basename(proc)
-            proc_name = os.path.basename(os.path.realpath(exe))
-            logger.debug('checking process %s', proc_name)
-            os.chdir(os.path.join(proc, 'map_files'))
-            for map_file in os.listdir('.'):
-                # all files in /map_files/ are absolute symlinks, so we don't need abspath()
-                real_map_file_path = os.path.realpath(map_file)
-                if not '/lib/' in real_map_file_path:
-                    logger.debug('skipping non-lib path %s', real_map_file_path)
-                    continue
-                else:
-                    logger.debug('checking lib %s', real_map_file_path)
-                if os.stat(map_file).st_nlink == 0:
-                    needs_reload.setdefault(proc_name, set()).add(proc_pid)
+            try:
+                proc_pid = os.path.basename(proc)
+                proc_name = os.path.basename(os.path.realpath(exe))
+                logger.debug('checking process %s', proc_name)
+                os.chdir(os.path.join(proc, 'map_files'))
+                for map_file in os.listdir('.'):
+                    # all files in /map_files/ are absolute symlinks, so we don't need abspath()
+                    real_map_file_path = os.path.realpath(map_file)
+                    if not '/lib/' in real_map_file_path:
+                        logger.debug('skipping non-lib path %s', real_map_file_path)
+                        continue
+                    else:
+                        logger.debug('checking lib %s', real_map_file_path)
+                    if os.stat(map_file).st_nlink == 0:
+                        needs_reload.setdefault(proc_name, set()).add(proc_pid)
+            except FileNotFoundError:
+                pass
         else:
             logger.debug('skipping kernel process %s', os.path.basename(proc))
 



View it on GitLab: https://salsa.debian.org/nagios-team/nagios-plugins-contrib/-/commit/8a9233bff1aca03cc0bd507a34fcb08170f0260f

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/nagios-plugins-contrib/-/commit/8a9233bff1aca03cc0bd507a34fcb08170f0260f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20240506/cf64ccb8/attachment-0001.htm>


More information about the pkg-nagios-changes mailing list