Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
507267b5
authored
Nov 11, 2013
by
Nagy Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formating fixed.
parent
ed351d66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
circle/monitor/calvin/src/calvin.py
+14
-11
No files found.
circle/monitor/calvin/src/calvin.py
View file @
507267b5
import
json
,
requests
import
requests
class
GraphiteHandler
:
def
__init__
(
self
,
server_name
=
"localhost"
,
server_port
=
"8080"
):
def
__init__
(
self
,
server_name
=
"localhost"
,
server_port
=
"8080"
):
self
.
__server_name
=
server_name
self
.
__server_port
=
server_port
self
.
__queries
=
[]
...
...
@@ -34,11 +35,12 @@ class GraphiteHandler:
Important: After sending queries to the server the fifo will lost its
content.
"""
url_base
=
"http://
%
s:
%
s/render?"
%
(
self
.
__server_name
,
self
.
__server_port
)
url_base
=
"http://
%
s:
%
s/render?"
%
(
self
.
__server_name
,
self
.
__server_port
)
for
query
in
self
.
__queries
:
response
=
requests
.
get
(
url_base
+
query
.
getGenerated
())
if
query
.
getFormat
()
is
"json"
:
self
.
__responses
.
append
(
response
.
json
()
[
0
])
#
DICT
self
.
__responses
.
append
(
response
.
json
()
)
#
DICT
else
:
self
.
__responses
.
append
(
response
)
self
.
cleanUpQueries
()
...
...
@@ -48,10 +50,11 @@ class GraphiteHandler:
Pop the first query has got from the server.
"""
try
:
return
self
.
__responses
.
pop
(
0
)
# Transform to dictionary
return
self
.
__responses
.
pop
(
0
)
# Transform to dictionary
except
:
print
(
"There is no more responses."
)
class
Query
:
def
__init__
(
self
):
...
...
@@ -90,7 +93,7 @@ class Query:
"""
Function for setting the time you want to get the reports from.
"""
if
(
len
(
year
)
>
4
or
len
(
year
)
<
2
):
if
(
len
(
year
)
>
4
or
len
(
year
)
<
2
):
raise
self
.
__start
=
hour
+
":"
+
minute
+
"_"
+
year
+
month
+
day
...
...
@@ -98,7 +101,8 @@ class Query:
"""
Function for setting the time you want to get the reports from.
"""
if
scale
not
in
[
"years"
,
"months"
,
"days"
,
"hours"
,
"minutes"
,
"seconds"
]:
if
(
scale
not
in
[
"years"
,
"months"
,
"days"
,
"hours"
,
"minutes"
,
"seconds"
]):
raise
self
.
__start
=
"-"
+
str
(
value
)
+
scale
...
...
@@ -109,7 +113,7 @@ class Query:
"""
Function for setting the time until you want to get the reports from.
"""
if
(
len
(
year
)
>
4
or
len
(
year
)
<
2
):
if
(
len
(
year
)
>
4
or
len
(
year
)
<
2
):
raise
self
.
__end
=
hour
+
":"
+
minute
+
"_"
+
year
+
month
+
day
...
...
@@ -117,7 +121,8 @@ class Query:
"""
Function for setting the time until you want to get the reports from.
"""
if
scale
not
in
[
"years"
,
"months"
,
"days"
,
"hours"
,
"minutes"
,
"seconds"
]:
if
(
scale
not
in
[
"years"
,
"months"
,
"days"
,
"hours"
,
"minutes"
,
"seconds"
]):
raise
self
.
__end
=
"-"
+
str
(
value
)
+
scale
...
...
@@ -160,5 +165,3 @@ class Query:
if
len
(
self
.
__generated
)
is
0
:
raise
return
self
.
__generated
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