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
Commit
c9e70b85
authored
Oct 10, 2013
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3.2 python
parent
dc85b3c1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
17 additions
and
18 deletions
+17
-18
config/client.conf
+2
-2
src/__init__.pyc
+0
-0
src/client.py
+4
-6
src/client.pyc
+0
-0
src/cnfparse.py
+1
-1
src/cnfparse.pyc
+0
-0
src/collectables.pyc
+0
-0
src/metrics.py
+10
-9
src/metrics.pyc
+0
-0
No files found.
config/client.conf
View file @
c9e70b85
...
...
@@ -14,8 +14,8 @@ Pass = guest
[
Metrics
]
cpuUsage
=
True
memoryUsage
=
True
userCount
=
Tru
e
swapUsage
=
Tru
e
userCount
=
Fals
e
swapUsage
=
Fals
e
systemBootTime
=
False
packageTraffic
=
False
dataTraffic
=
False
src/__init__.pyc
View file @
c9e70b85
No preview for this file type
src/client.py
View file @
c9e70b85
...
...
@@ -12,8 +12,8 @@ class Client:
modul. It is a dictionary: {server_address, server_port, frequency,
debugMode, amqp_user, amqp_pass, amqp_queue}.
"""
hostname
=
socket
.
gethostname
()
.
split
(
'.'
)
hostname
.
reverse
()
hostname
=
socket
.
gethostname
()
.
split
(
'.'
)
hostname
.
reverse
()
self
.
name
=
"circle."
+
"."
.
join
(
hostname
)
self
.
server_address
=
str
(
config
[
"server_address"
])
self
.
server_port
=
int
(
config
[
"server_port"
])
...
...
@@ -30,7 +30,7 @@ class Client:
"""
try
:
credentials
=
pika
.
PlainCredentials
(
self
.
amqp_user
,
self
.
amqp_pass
)
self
.
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
self
.
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
self
.
server_address
,
port
=
self
.
server_port
,
credentials
=
credentials
...
...
@@ -39,7 +39,7 @@ class Client:
self
.
channel
=
self
.
connection
.
channel
()
return
True
except
:
raise
raise
def
__disconnect
(
self
):
"""
...
...
@@ -95,5 +95,3 @@ class Client:
print
(
"Reporting has stopped by the user. Exiting..."
)
finally
:
self
.
__disconnect
()
src/client.pyc
View file @
c9e70b85
No preview for this file type
src/cnfparse.py
View file @
c9e70b85
import
ConfigParser
as
configparser
import
configparser
def
importConf
(
path_to_file
):
config
=
configparser
.
RawConfigParser
(
allow_no_value
=
False
)
...
...
src/cnfparse.pyc
View file @
c9e70b85
No preview for this file type
src/collectables.pyc
View file @
c9e70b85
No preview for this file type
src/metrics.py
View file @
c9e70b85
...
...
@@ -16,16 +16,17 @@ class Collection (object):
@classmethod
def
harvest
(
cls
):
print
(
cls
.
collector_function_arguments
)
query
=
cls
.
collector_function
(
**
cls
.
collector_function_arguments
)
if
((
isinstance
(
query
,
list
))
or
(
isinstance
(
query
,
dict
))):
return
Metrics
(
cls
.
name
,
query
[
cls
.
collector_function_result_attr
])
return
Metrics
(
name
,
query
[
cls
.
collector_function_result_attr
])
elif
(
isinstance
(
query
,
tuple
)):
return
Metrics
(
cls
.
name
,
query
.
__getattribute__
(
cls
.
collector_function_result_attr
))
return
Metrics
(
name
,
query
.
__getattribute__
(
cls
.
collector_function_result_attr
))
else
:
return
Metrics
(
cls
.
name
,
query
)
query
)
####################################################################################
...
...
@@ -36,7 +37,7 @@ class std (Collection):
class
usage
(
Collection
.
Group
.
Metric
):
collector_function
=
ps
.
cpu_percent
collector_function_arguments
=
{
'interval'
:
0
,
'interval'
:
0
.0
,
}
name
=
"cpu.usage"
...
...
@@ -52,9 +53,9 @@ class std (Collection):
class
count
(
Collection
.
Group
.
Metric
):
name
=
"user.count"
@
static
method
def
harvest
():
return
Metrics
(
std
.
user
.
count
.
name
,
len
(
ps
.
get_users
()))
@
class
method
def
harvest
(
cls
):
return
Metrics
(
cls
.
name
,
len
(
ps
.
get_users
()))
class
network
(
Collection
.
Group
):
...
...
src/metrics.pyc
View file @
c9e70b85
No preview for this file type
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