Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
864e044c
Commit
864e044c
authored
Mar 20, 2019
by
Дмитрий Никулин
Committed by
Никита Ефремов
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Statistics: partially switch to psutil
parent
2e2c2fbf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
fmod_statistics.py
plugins/functions/fmod_statistics.py
+28
-8
No files found.
plugins/functions/fmod_statistics.py
View file @
864e044c
...
...
@@ -8,6 +8,8 @@ from settingsd import shared
import
settingsd.tools
as
tools
import
settingsd.tools.dbus
import
psutil
from
os
import
getloadavg
##### Private constants #####
...
...
@@ -53,21 +55,22 @@ class Memory(service.FunctionObject) :
### DBus methods ###
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
i
"
)
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
t
"
)
def
memoryFull
(
self
)
:
return
self
.
meminfoSum
(
"MemTotal"
)
return
psutil
.
virtual_memory
()
.
total
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
i
"
)
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
t
"
)
def
memoryFree
(
self
)
:
return
self
.
meminfoSum
(
"MemFree"
,
"Buffers"
,
"Cached"
)
return
psutil
.
virtual_memory
()
.
available
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
i
"
)
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
t
"
)
def
swapFull
(
self
)
:
return
self
.
meminfoSum
(
"SwapTotal"
)
return
psutil
.
swap_memory
()
.
total
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
i
"
)
@service.functionMethod
(
MEMORY_METHODS_NAMESPACE
,
out_signature
=
"
t
"
)
def
swapFree
(
self
)
:
return
self
.
meminfoSum
(
"SwapFree"
,
"SwapCached"
)
swap
=
psutil
.
swap_memory
()
return
swap
.
total
-
swap
.
used
### Private ###
...
...
@@ -132,6 +135,23 @@ class Cpu(service.FunctionObject) :
return
-
1
###
@service.functionMethod
(
CPU_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
cpuCount
(
self
):
return
psutil
.
cpu_count
()
@service.functionMethod
(
CPU_METHODS_NAMESPACE
,
out_signature
=
"a{sd}"
)
def
cpuTimes
(
self
):
times
=
psutil
.
cpu_times_percent
()
return
{
'iowait'
:
times
.
iowait
,
'softirq'
:
times
.
softirq
,
'sys'
:
times
.
system
,
'user'
:
times
.
user
}
@service.functionMethod
(
CPU_METHODS_NAMESPACE
,
out_signature
=
"ad"
)
def
loadAverage
(
self
):
return
getloadavg
()
@service.functionMethod
(
CPU_METHODS_NAMESPACE
,
out_signature
=
"d"
)
def
loadPercent
(
self
)
:
...
...
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