Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
3312a769
Commit
3312a769
authored
Mar 16, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10461 from cblument/fact_ansible_uptime
Adding uptime_seconds fact for linux and darwin platforms
parents
caf2a96e
7813ffd7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
lib/ansible/module_utils/facts.py
+11
-0
No files found.
lib/ansible/module_utils/facts.py
View file @
3312a769
...
...
@@ -652,6 +652,7 @@ class LinuxHardware(Hardware):
self
.
get_memory_facts
()
self
.
get_dmi_facts
()
self
.
get_device_facts
()
self
.
get_uptime_facts
()
try
:
self
.
get_mount_facts
()
except
TimeoutError
:
...
...
@@ -990,6 +991,9 @@ class LinuxHardware(Hardware):
self
.
facts
[
'devices'
][
diskname
]
=
d
def
get_uptime_facts
(
self
):
uptime_seconds_string
=
get_file_content
(
'/proc/uptime'
)
.
split
(
' '
)[
0
]
self
.
facts
[
'uptime_seconds'
]
=
int
(
float
(
uptime_seconds_string
))
class
SunOSHardware
(
Hardware
):
"""
...
...
@@ -1588,6 +1592,7 @@ class Darwin(Hardware):
self
.
get_mac_facts
()
self
.
get_cpu_facts
()
self
.
get_memory_facts
()
self
.
get_uptime_facts
()
return
self
.
facts
def
get_sysctl
(
self
):
...
...
@@ -1635,6 +1640,12 @@ class Darwin(Hardware):
if
rc
==
0
:
self
.
facts
[
'memfree_mb'
]
=
long
(
out
.
splitlines
()[
-
1
]
.
split
()[
1
])
/
1024
/
1024
def
get_uptime_facts
(
self
):
kern_boottime
=
self
.
sysctl
[
'kern.boottime'
]
boottime
=
datetime
.
datetime
.
strptime
(
kern_boottime
,
"
%
a
%
b
%
d
%
H:
%
M:
%
S
%
Y"
)
delta
=
datetime
.
datetime
.
now
()
-
boottime
self
.
facts
[
'uptime_seconds'
]
=
int
(
delta
.
total_seconds
())
class
Network
(
Facts
):
"""
This is a generic Network subclass of Facts. This should be further
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment