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
f97c6e09
Commit
f97c6e09
authored
Feb 28, 2019
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for network statistics
parent
654d94e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
fmod_network.py
plugins/functions/fmod_network.py
+21
-1
No files found.
plugins/functions/fmod_network.py
View file @
f97c6e09
...
...
@@ -29,7 +29,7 @@ NETWORK_SERVICES = {
##### Private classes #####
class
Network
(
service
.
FunctionObject
)
:
class
Network
(
service
.
FunctionObject
)
:
### DBus methods ###
@service.functionMethod
(
NETWORK_METHODS_NAMESPACE
,
in_signature
=
"s"
)
def
dumpCurrentSettings
(
self
,
filename
):
...
...
@@ -40,6 +40,26 @@ class Network(service.FunctionObject) :
with
open
(
filename
,
'w+'
)
as
network_config
:
network_config
.
write
(
dump
(
settings
))
@service.functionMethod
(
NETWORK_METHODS_NAMESPACE
,
out_signature
=
'a{sa{si}}'
)
def
getStatistics
(
self
):
with
IPDB
()
as
ipdb
:
interfaces
=
[
i
.
ifname
for
i
in
ipdb
.
interfaces
.
values
()]
stats
=
{}
for
interface_name
in
interfaces
:
with
open
(
'/sys/class/net/'
+
interface_name
+
'/statistics/rx_bytes'
,
'r'
)
as
file
:
rx
=
int
(
file
.
read
())
with
open
(
'/sys/class/net/'
+
interface_name
+
'/statistics/tx_bytes'
,
'r'
)
as
file
:
tx
=
int
(
file
.
read
())
stats
[
interface_name
]
=
{
'rx'
:
rx
,
'tx'
:
tx
}
return
stats
@service.functionMethod
(
NETWORK_METHODS_NAMESPACE
,
in_signature
=
"s"
)
def
reloadNetworkConfig
(
self
,
filename
):
with
open
(
filename
,
'r'
)
as
network_config
:
...
...
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