Skip to content

Commit 1d73efd

Browse files
Stop using the uptime library
1 parent 78dea73 commit 1d73efd

File tree

10 files changed

+9
-12
lines changed

10 files changed

+9
-12
lines changed

.ddev/config.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ semver = ['BSD-3-Clause']
9494
simplejson = ['MIT']
9595
# https://github.com/Supervisor/supervisor/blob/master/LICENSES.txt
9696
supervisor = ['BSD-3-Clause-Modification']
97-
# https://github.com/Cairnarvon/uptime/blob/master/COPYING.txt
98-
uptime = ['BSD-2-Clause']
9997

10098
[overrides.dependencies.repo]
10199
PyYAML = 'https://github.com/yaml/pyyaml'

LICENSE-3rdparty.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,5 @@ snowflake-connector-python,PyPI,Apache-2.0,"Copyright (c) 2013-2023 Snowflake Co
8383
supervisor,PyPI,BSD-3-Clause-Modification,"Copyright (c) 2002-2005, Daniel Krech, http://eikeon.com/"
8484
tuf,PyPI,Apache-2.0,Copyright (c) 2010 New York University
8585
tuf,PyPI,MIT,Copyright (c) 2010 New York University
86-
uptime,PyPI,BSD-2-Clause,"Copyright (c) 2012, Koen Crolla"
8786
vertica-python,PyPI,Apache-2.0,"Copyright 2013 Justin Berka, Alex Kim, Siting Ren"
8887
wrapt,PyPI,BSD-3-Clause,"Copyright (c) 2013-2023, Graham Dumpleton"

agent_requirements.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,5 @@ simplejson==3.20.1
6666
snowflake-connector-python==3.13.2
6767
supervisor==4.2.5
6868
tuf==4.0.0
69-
uptime==3.0.1
7069
vertica-python==1.4.0
7170
wrapt==1.17.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop using the `uptime` library.

datadog_checks_base/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ deps = [
4949
"requests-unixsocket2==0.4.2",
5050
"requests==2.32.3",
5151
"simplejson==3.20.1",
52-
"uptime==3.0.1",
5352
"wrapt==1.17.2",
5453
]
5554
http = [
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop using the uptime library

datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/licenses.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
'simplejson': ['MIT'],
6969
# https://github.com/Supervisor/supervisor/blob/master/LICENSES.txt
7070
'supervisor': ['BSD-3-Clause-Modification'],
71-
# https://github.com/Cairnarvon/uptime/blob/master/COPYING.txt
72-
'uptime': ['BSD-2-Clause'],
7371
# https://github.com/hickeroar/win_inet_pton/blob/master/LICENSE
7472
'win-inet-pton': ['Unlicense'],
7573
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop using the `uptime` library.

win32_event_log/datadog_checks/win32_event_log/legacy/win32_event_log.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# All rights reserved
33
# Licensed under Simplified BSD License (see LICENSE)
44
import calendar
5-
from datetime import datetime, timedelta
5+
from datetime import datetime, timedelta, timezone
66

7-
from uptime import uptime
7+
import psutil
88

99
from datadog_checks.base import ConfigurationError, is_affirmative
1010
from datadog_checks.base.checks.win.wmi import WinWMICheck, from_time, to_time
@@ -92,8 +92,9 @@ def check(self, instance):
9292
# Store the last timestamp by instance
9393
if instance_key not in self.last_ts:
9494
# If system boot was within 600s of dd agent start then use boottime as last_ts
95-
if uptime() <= 600:
96-
self.last_ts[instance_key] = datetime.utcnow() - timedelta(seconds=uptime())
95+
uptime = datetime.now(timezone.utc) - datetime.fromtimestamp(psutil.boot_time(), timezone.utc)
96+
if uptime.total_seconds() <= 600:
97+
self.last_ts[instance_key] = datetime.utcnow() - uptime
9798
else:
9899
self.last_ts[instance_key] = datetime.utcnow()
99100
return

win32_event_log/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dynamic = [
3737
[project.optional-dependencies]
3838
deps = [
3939
"pywin32==308; sys_platform == 'win32'",
40-
"uptime==3.0.1",
40+
"psutil==6.0.0",
4141
]
4242

4343
[project.urls]

0 commit comments

Comments
 (0)