diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2020-02-06 09:30:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 09:30:23 +0300 |
commit | a90838e628e1adcea59bcac97c9d018f7643165d (patch) | |
tree | 0bcbf34a1710d89ca7bc711e6bf33d07e46fbdb6 /collectors | |
parent | 9d6c9219baae97bb50050b1a3c3a80326cbc0c74 (diff) |
/collectors/python.d.plugin/third_party: patch monotonic synolo… (#7980)
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/python.d.plugin/python_modules/third_party/monotonic.py | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/collectors/python.d.plugin/python_modules/third_party/monotonic.py b/collectors/python.d.plugin/python_modules/third_party/monotonic.py index da04bb857a..4ebd556c3a 100644 --- a/collectors/python.d.plugin/python_modules/third_party/monotonic.py +++ b/collectors/python.d.plugin/python_modules/third_party/monotonic.py @@ -54,6 +54,41 @@ except AttributeError: import os import sys import threading + + + def clock_clock_gettime_c_library(): + return ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True).clock_gettime + + + def clock_clock_gettime_rt_library(): + return ctypes.CDLL(ctypes.util.find_library('rt'), use_errno=True).clock_gettime + + + def clock_clock_gettime_c_library_synology6(): + return ctypes.CDLL('/usr/lib/libc.so.6', use_errno=True).clock_gettime + + + def clock_clock_gettime_rt_library_synology6(): + return ctypes.CDLL('/usr/lib/librt.so.1', use_errno=True).clock_gettime + + + def clock_gettime_linux(): + # see https://github.com/netdata/netdata/issues/7976 + order = [ + clock_clock_gettime_c_library, + clock_clock_gettime_rt_library, + clock_clock_gettime_c_library_synology6, + clock_clock_gettime_rt_library_synology6, + ] + + for gettime in order: + try: + return gettime() + except (RuntimeError, AttributeError, OSError): + continue + raise RuntimeError('can not find c and rt libraries') + + try: if sys.platform == 'darwin': # OS X, iOS # See Technical Q&A QA1398 of the Mac Developer Library: @@ -132,12 +167,7 @@ except AttributeError: return final_milliseconds / 1000.0 else: - try: - clock_gettime = ctypes.CDLL(ctypes.util.find_library('c'), - use_errno=True).clock_gettime - except Exception: - clock_gettime = ctypes.CDLL(ctypes.util.find_library('rt'), - use_errno=True).clock_gettime + clock_gettime = clock_gettime_linux() class timespec(ctypes.Structure): """Time specification, as described in clock_gettime(3).""" |