Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
monitor-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
ec91e24f
authored
Feb 24, 2014
by
Gregory Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8 conventions
parent
3faa2b8f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
src/client.py
+0
-0
src/cnfparse.py
+18
-5
src/collectables.py
+4
-5
No files found.
src/client.py
View file @
ec91e24f
This diff is collapsed.
Click to expand it.
src/cnfparse.py
View file @
ec91e24f
import
ConfigParser
as
configparser
import
sys
if
sys
.
version_info
<
(
3
,
0
):
import
ConfigParser
as
configparser
else
:
import
configparser
def
import
C
onf
(
path_to_file
):
def
import
_c
onf
(
path_to_file
):
config
=
configparser
.
RawConfigParser
(
allow_no_value
=
False
)
config
=
configparser
.
RawConfigParser
(
allow_no_value
=
False
)
try
:
try
:
config
.
read
(
path_to_file
)
config
.
read
(
path_to_file
)
params
=
{}
params
=
{}
metrics
=
{}
metrics
=
{}
params
[
"debugMode"
]
=
config
.
get
(
"Client"
,
"Debug"
)
params
[
"debugMode"
]
=
config
.
get
(
"Client"
,
"Debug"
)
##
## Metrics
##
metrics
[
"cpu.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuUsage"
))
metrics
[
"cpu.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuUsage"
))
metrics
[
"cpu.times"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuTimes"
))
metrics
[
"cpu.times"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuTimes"
))
metrics
[
"memory.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"memoryUsage"
))
metrics
[
"memory.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"memoryUsage"
))
...
@@ -16,17 +23,23 @@ def importConf(path_to_file):
...
@@ -16,17 +23,23 @@ def importConf(path_to_file):
metrics
[
"system.boot_time"
]
=
int
(
config
.
get
(
"Metrics"
,
metrics
[
"system.boot_time"
]
=
int
(
config
.
get
(
"Metrics"
,
"systemBootTime"
))
"systemBootTime"
))
metrics
[
"network"
]
=
int
(
config
.
get
(
"Metrics"
,
"dataTraffic"
))
metrics
[
"network"
]
=
int
(
config
.
get
(
"Metrics"
,
"dataTraffic"
))
##
## Params
##
params
[
"kvmCpuUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"cpuUsage"
))
params
[
"kvmCpuUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"cpuUsage"
))
params
[
"kvmMemoryUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"memoryUsage"
))
params
[
"kvmMemoryUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"memoryUsage"
))
params
[
"kvmNetworkUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"networkUsage"
))
params
[
"kvmNetworkUsage"
]
=
int
(
config
.
get
(
"KVM"
,
"networkUsage"
))
except
configparser
.
NoSectionError
:
except
configparser
.
NoSectionError
:
print
(
"Config file contains error! Reason: Missing section."
)
print
(
"[ERROR] Config file contains error! "
"Reason: Missing section."
)
raise
raise
except
configparser
.
ParsingError
:
except
configparser
.
ParsingError
:
print
(
"Config file contains error! Reason: Cannot parse."
)
print
(
"[ERROR] Config file contains error! "
"Reason: Cannot parse."
)
raise
raise
except
configparser
.
MissingSectionHeaderError
:
except
configparser
.
MissingSectionHeaderError
:
print
(
"Config file contains error! Reason: Missing section-header."
)
print
(
"[ERROR] Config file contains error! "
"Reason: Missing section-header."
)
raise
raise
return
params
,
metrics
return
params
,
metrics
src/collectables.py
View file @
ec91e24f
...
@@ -18,20 +18,19 @@ class collectables:
...
@@ -18,20 +18,19 @@ class collectables:
}
}
@staticmethod
@staticmethod
def
list
K
eys
():
def
list
_k
eys
():
return
list
(
collectables
.
__collectables
.
keys
())
return
list
(
collectables
.
__collectables
.
keys
())
@staticmethod
@staticmethod
def
list
MetricsToK
ey
(
key
):
def
list
_metrics_to_k
ey
(
key
):
return
collectables
.
__collectables
[
key
]
return
collectables
.
__collectables
[
key
]
@staticmethod
@staticmethod
def
list
MetricsNameToK
ey
(
key
):
def
list
_metrics_name_to_k
ey
(
key
):
return
[
x
.
name
for
x
in
collectables
.
__collectables
[
key
]]
return
[
x
.
name
for
x
in
collectables
.
__collectables
[
key
]]
@staticmethod
@staticmethod
def
provide
(
requests
=
[]):
def
provide
(
requests
=
[]):
#valid_keys = collectables.listKeys()
reqs
=
[]
reqs
=
[]
for
requests
,
value
in
requests
.
items
():
for
requests
,
value
in
requests
.
items
():
if
value
>
0
:
if
value
>
0
:
...
@@ -44,4 +43,4 @@ class collectables:
...
@@ -44,4 +43,4 @@ class collectables:
@staticmethod
@staticmethod
def
provideAll
():
def
provideAll
():
return
collectables
.
provide
(
collectables
.
list
K
eys
())
return
collectables
.
provide
(
collectables
.
list
_k
eys
())
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