Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
977465d6
authored
Feb 24, 2014
by
Gregory Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixtures
parent
ec91e24f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
manage.py
+6
-6
src/client.py
+21
-16
No files found.
manage.py
View file @
977465d6
import
sys
from
src
import
cnfparse
,
client
,
collectables
from
src
import
cnfparse
from
src
import
client
from
src.collectables
import
collectables
def
main
():
if
len
(
sys
.
argv
)
<
2
:
print
(
"usage: manage.py run [options]"
)
if
len
(
sys
.
argv
)
is
not
2
and
sys
.
argv
[
1
]
is
not
"run"
:
print
(
"[ERROR] Command cannot be parsed. Exiting..."
)
return
configuration
,
metrics
=
cnfparse
.
importConf
(
"config/client.conf"
)
configuration
,
metrics
=
cnfparse
.
import_conf
(
"config/client.conf"
)
cli
=
client
.
Client
(
configuration
)
cli
.
startReporting
(
metricCollectors
=
collectables
.
collectables
.
provide
(
metrics
)
)
metricCollectors
=
collectables
.
provide
(
metrics
)
cli
.
run
(
metricCollectors
)
if
__name__
==
"__main__"
:
...
...
src/client.py
View file @
977465d6
...
...
@@ -46,34 +46,38 @@ class Client:
self
.
amqp_pass
=
str
(
os
.
getenv
(
self
.
env_config
[
'amqp_pass'
]))
self
.
amqp_queue
=
str
(
os
.
getenv
(
self
.
env_config
[
'amqp_queue'
]))
self
.
amqp_vhost
=
str
(
os
.
getenv
(
self
.
env_config
[
'amqp_vhost'
]))
if
self
.
server_address
is
""
:
host_check
=
self
.
__check_envvar
(
self
.
server_address
)
port_check
=
self
.
__check_envvar
(
self
.
server_port
)
amqp_pass_check
=
self
.
__check_envvar
(
self
.
amqp_pass
)
amqp_user_check
=
self
.
__check_envvar
(
self
.
amqp_user
)
amqp_queue_check
=
self
.
__check_envvar
(
self
.
amqp_queue
)
amqp_vhost_check
=
self
.
__check_envvar
(
self
.
amqp_vhost
)
if
host_check
:
print
((
'
%(host)
s cannot be found in environmental variables.'
)
%
{
'host'
:
self
.
env_config
[
'host'
]}
)
self
.
valid
=
False
return
if
self
.
server_port
is
""
:
raise
RuntimeError
if
port_check
:
print
((
'
%(port)
s cannot be found in environmental variables. '
)
%
{
'port'
:
self
.
env_config
[
'port'
]}
)
self
.
valid
=
False
return
if
self
.
amqp_user
is
""
or
self
.
amqp_pass
is
""
:
raise
RuntimeError
if
amqp_user_check
or
amqp_pass_check
:
print
((
'
%(user)
s or
%(pass)
s cannot be '
'found in environmental variables.'
)
%
{
'user'
:
self
.
env_config
[
'amqp_user'
],
'pass'
:
self
.
env_config
[
'amqp_pass'
]}
)
self
.
valid
=
False
return
if
self
.
amqp_queue
is
""
or
self
.
amqp_vhost
is
""
:
raise
RuntimeError
amqp_pass_check
=
self
.
__check_envvar
(
self
.
amqp_pass
)
amqp_user_check
=
self
.
__check_envvar
(
self
.
amqp_user
)
if
amqp_vhost_check
or
amqp_queue_check
:
print
((
'
%(queue)
s or
%(vhost)
s cannot be '
'found in environmental variables.'
)
%
{
'queue'
:
self
.
env_config
[
'amqp_queue'
],
'vhost'
:
self
.
env_config
[
'amqp_vhost'
]}
)
self
.
valid
=
False
return
raise
RuntimeError
self
.
debugMode
=
config
[
"debugMode"
]
self
.
kvmCPU
=
int
(
config
[
"kvmCpuUsage"
])
self
.
kvmMem
=
int
(
config
[
"kvmMemoryUsage"
])
...
...
@@ -81,6 +85,9 @@ class Client:
self
.
beat
=
1
self
.
valid
=
True
def
__check_envvar
(
variable
):
return
variable
==
"None"
or
variable
==
""
def
connect
(
self
):
"""
This method creates the connection to the queue of the graphite
...
...
@@ -258,14 +265,12 @@ class Client:
metricCollectors parameter that should be provided by the collectables
modul to work properly.
"""
if
self
.
valid
is
False
:
print
(
"[ERROR] The client cannot be started."
)
raise
RuntimeError
if
self
.
connect
()
is
False
:
hostdata
=
self
.
server_address
+
':'
+
s
elf
.
server_port
hostdata
=
self
.
server_address
+
':'
+
s
tr
(
self
.
server_port
)
print
(
"[ERROR] An error has occured while connecting to the "
"server on
%(host)
s."
%
{
'host'
:
hostdata
})
return
else
:
print
(
'[SUCCESS] Connection established to
%(host)
s:
%(port)
s.'
%
{
'host'
:
self
.
server_address
,
...
...
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