Package: monitoring-plugins-contrib Version: 42.20230308+deb12u1+b1 Tags: patch
Ohai, on systems with many short-lived processes (like a monitoring server, spawning many check_* commands), I regularly see check_libs_ng return UNKNOWN Exception: [Errno 2] No such file or directory: <some map file> This is because the process might have already ended between calling os.listdir() and os.stat(). Attached is a patch that catches the exception and pretends the process does not need restarting. (FileNotFoundError is Python 3.3+, if you for some arcane reason need support for older Pythons, catch OSError instead.) Thanks Evgeni
diff --git a/check_libs_ng/check_libs_ng b/check_libs_ng/check_libs_ng index f260491..44ad0f1 100644 --- a/check_libs_ng/check_libs_ng +++ b/check_libs_ng/check_libs_ng @@ -68,8 +68,11 @@ def main(): 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: + 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))