FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netdata/python.d/python_modules/bases/monotonic.py at master · chih7/netdata · GitHub
chih7
/
netdata
Public
forked from
netdata/netdata
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
netdata
/
python.d
/
python_modules
/
bases
/
monotonic.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (20 loc) · 678 Bytes
Breadcrumbs
netdata
/
python.d
/
python_modules
/
bases
/
monotonic.py
Copy path
File metadata and controls
29 lines (20 loc) · 678 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# thx to https://stackoverflow.com/a/1205762
import
ctypes
# import os
CLOCK_MONOTONIC
=
1
# see <linux/time.h>
class
_Timespec
(
ctypes
.
Structure
):
_fields_
=
[
(
'tv_sec'
,
ctypes
.
c_long
),
(
'tv_nsec'
,
ctypes
.
c_long
)
]
_librt
=
ctypes
.
CDLL
(
'librt.so.1'
,
use_errno
=
True
)
_clock_gettime
=
_librt
.
clock_gettime
_clock_gettime
.
argtypes
=
[
ctypes
.
c_int
,
ctypes
.
POINTER
(
_Timespec
)]
def
time
():
t
=
_Timespec
()
if
_clock_gettime
(
CLOCK_MONOTONIC
,
ctypes
.
pointer
(
t
))
!=
0
:
# errno_ = ctypes.get_errno()
# raise OSError(errno_, os.strerror(errno_))
return
None
return
t
.
tv_sec
+
t
.
tv_nsec
*
1e-9
AVAILABLE
=
bool
(
time
())
Back
|
FazBrowse Home
|
New Git URL