[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 04/24: check_libs_ng: small performance improvement

Jan Wagner waja at moszumanska.debian.org
Wed Dec 13 22:07:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

waja pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.

commit 273f7a0fe4b60729361f46c342ee6d21184dde4f
Author: Leo Antunes <leo at costela.net>
Date:   Tue Mar 14 11:58:13 2017 +0100

    check_libs_ng: small performance improvement
---
 check_libs_ng/check_libs_ng | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/check_libs_ng/check_libs_ng b/check_libs_ng/check_libs_ng
index 92d2544..e0053e0 100644
--- a/check_libs_ng/check_libs_ng
+++ b/check_libs_ng/check_libs_ng
@@ -59,15 +59,16 @@ def main():
             proc_pid = os.path.basename(proc)
             proc_name = os.path.basename(os.path.realpath(exe))
             logger.debug('checking process %s', proc_name)
-            for map_file in os.listdir(os.path.join(proc, 'map_files')):
-                full_map_file_path = os.path.join(proc, 'map_files', map_file)
-                real_map_file_path = os.path.realpath(full_map_file_path)
+            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(full_map_file_path).st_nlink == 0:
+                if os.stat(map_file).st_nlink == 0:
                     needs_reload.setdefault(proc_name, set()).add(proc_pid)
         else:
             logger.debug('skipping kernel process %s', os.path.basename(proc))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git



More information about the Pkg-nagios-changes mailing list