Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
repl_graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vaclab
repl_graph
Commits
3117b512
Commit
3117b512
authored
5 years ago
by
Thomas Bock
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
48f6a59b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
repl/__pycache__/utils.cpython-36.pyc
+0
-0
0 additions, 0 deletions
repl/__pycache__/utils.cpython-36.pyc
repl/utils.py
+37
-8
37 additions, 8 deletions
repl/utils.py
server.py
+4
-4
4 additions, 4 deletions
server.py
templates/html/all.html
+33
-31
33 additions, 31 deletions
templates/html/all.html
with
74 additions
and
43 deletions
repl/__pycache__/utils.cpython-36.pyc
+
0
−
0
View file @
3117b512
No preview for this file type
This diff is collapsed.
Click to expand it.
repl/utils.py
+
37
−
8
View file @
3117b512
...
...
@@ -26,11 +26,18 @@ def get_current_date(short=False):
def
get_jobs
(
server
,
port
):
try
:
req
=
requests
.
get
(
"
http://{}:{}/_scheduler/jobs
"
.
format
(
server
,
port
))
req
=
requests
.
get
(
"
http://{}:{}/_scheduler/jobs
"
.
format
(
server
,
port
)
,
verify
=
False
,
timeout
=
0.1
)
return
req
.
json
().
get
(
"
jobs
"
,
[])
except
:
return
[]
def
get_server
():
try
:
req
=
requests
.
get
(
"
http://localhost:5984/vl_db/000_SERVERS
"
)
return
req
.
json
().
get
(
"
Servers
"
,
[])
except
:
return
[]
def
gen_count
():
i
=
0
while
True
:
...
...
@@ -50,12 +57,21 @@ def get_info(url, srv):
def
gen_ext_name
(
d
,
h
):
return
"
{}@{}
"
.
format
(
d
,
h
)
def
make_label
(
job
):
hist
=
job
.
get
(
"
history
"
)
l
=
""
for
h
in
hist
:
s
=
h
.
get
(
"
type
"
)[
0
]
l
=
"
{s} {l}
"
.
format
(
l
=
l
,
s
=
s
)
return
l
def
get_nodes_and_edges
(
jobs
,
gen
,
hosts
,
dbs
,
nodes
,
edges
,
srv
):
for
job
in
jobs
:
s
=
job
.
get
(
"
source
"
)
t
=
job
.
get
(
"
target
"
)
e_label
=
make_label
(
job
)
if
s
and
t
:
s_db
,
s_host
=
get_info
(
s
,
srv
)
t_db
,
t_host
=
get_info
(
t
,
srv
)
...
...
@@ -64,22 +80,35 @@ def get_nodes_and_edges(jobs, gen, hosts, dbs, nodes, edges, srv):
if
s_host
not
in
hosts
:
hosts
[
s_host
]
=
gen
.
__next__
()
nodes
.
append
({
"
id
"
:
hosts
[
s_host
],
"
label
"
:
s_host
,
"
group
"
:
"
server
"
})
nodes
.
append
({
"
id
"
:
hosts
[
s_host
],
"
label
"
:
s_host
,
"
group
"
:
"
server
"
})
if
t_host
not
in
hosts
:
hosts
[
t_host
]
=
gen
.
__next__
()
nodes
.
append
({
"
id
"
:
hosts
[
t_host
],
"
label
"
:
t_host
,
"
group
"
:
"
server
"
})
nodes
.
append
({
"
id
"
:
hosts
[
t_host
],
"
label
"
:
t_host
,
"
group
"
:
"
server
"
})
if
s_db_name
not
in
dbs
:
dbs
[
s_db_name
]
=
gen
.
__next__
()
nodes
.
append
({
"
id
"
:
dbs
[
s_db_name
],
"
label
"
:
s_db
,
"
group
"
:
"
db
"
})
nodes
.
append
({
"
id
"
:
dbs
[
s_db_name
],
"
label
"
:
s_db
,
"
group
"
:
"
db
"
})
if
t_db_name
not
in
dbs
:
dbs
[
t_db_name
]
=
gen
.
__next__
()
nodes
.
append
({
"
id
"
:
dbs
[
t_db_name
],
"
label
"
:
t_db
,
"
group
"
:
"
db
"
})
edges
.
append
({
"
from
"
:
dbs
[
s_db_name
]
,
"
to
"
:
dbs
[
t_db_name
]
,
"
arrow_type
"
:
"
to
"
})
edges
.
append
({
"
from
"
:
hosts
[
s_host
]
,
"
to
"
:
dbs
[
s_db_name
],
"
arrow_type
"
:
"
box
"
})
edges
.
append
({
"
from
"
:
hosts
[
t_host
]
,
"
to
"
:
dbs
[
t_db_name
],
"
arrow_type
"
:
"
box
"
})
edges
.
append
({
"
from
"
:
dbs
[
s_db_name
]
,
"
to
"
:
dbs
[
t_db_name
]
,
"
arrow_type
"
:
"
to
"
,
"
label
"
:
e_label
})
edges
.
append
({
"
from
"
:
hosts
[
s_host
]
,
"
to
"
:
dbs
[
s_db_name
],
"
arrow_type
"
:
"
to
"
})
edges
.
append
({
"
from
"
:
hosts
[
t_host
]
,
"
to
"
:
dbs
[
t_db_name
],
"
arrow_type
"
:
"
from
"
})
return
nodes
,
edges
This diff is collapsed.
Click to expand it.
server.py
+
4
−
4
View file @
3117b512
...
...
@@ -17,10 +17,10 @@ def repl_all():
dbs
=
{}
nodes
=
[]
edges
=
[]
for
srv
in
(
"
a73434
"
,
"
a73435
"
,
"
i75422
"
,
"
i75464
"
,
"
e75455
"
,
"
i75415
"
)
:
jobs
=
utils
.
get_jobs
(
srv
,
5984
)
nodes
,
edges
=
utils
.
get_nodes_and_edges
(
jobs
,
gen
,
hosts
,
dbs
,
nodes
,
edges
,
srv
)
srvs
=
utils
.
get_server
()
for
srv
in
srvs
:
jobs
=
utils
.
get_jobs
(
srv
.
get
(
"
name
"
),
srv
.
get
(
"
port
"
)
)
nodes
,
edges
=
utils
.
get_nodes_and_edges
(
jobs
,
gen
,
hosts
,
dbs
,
nodes
,
edges
,
srv
.
get
(
"
name
"
)
)
template
=
utils
.
path_file
(
path
=
config
[
'
templates
'
][
'
html
'
],
file
=
'
all.html
'
)
return
render_template
(
template
,
nodes
=
nodes
,
edges
=
edges
)
...
...
This diff is collapsed.
Click to expand it.
templates/html/all.html
+
33
−
31
View file @
3117b512
...
...
@@ -40,7 +40,7 @@
<footer
class=
"footer mt-auto py-3"
>
<div
class=
"container"
>
<span
class=
"text-muted"
>
.
</span>
<span
class=
"text-muted"
>
<b>
a
</b>
: added,
<b>
s
</b>
: started,
<b>
c:
</b>
crasched
</span>
</div>
</footer>
...
...
@@ -49,38 +49,40 @@
<script
type=
"text/javascript"
charset=
"utf8"
src=
"../js/bootstrap.min.js"
></script>
<script
type=
"text/javascript"
charset=
"utf8"
src=
"../js/vis-network.min.js"
></script>
<script
type=
"text/javascript"
charset=
"utf8"
>
var
nodes
=
new
vis
.
DataSet
([
{
%
for
node
in
nodes
%
}
{
id
:
{{
node
.
id
}},
label
:
"
{{node.label}}
"
,
group
:
"
{{node.group}}
"
},
{
%
endfor
%
}
]);
var
nodes
=
new
vis
.
DataSet
([
{
%
for
node
in
nodes
%
}
{
id
:
{{
node
.
id
}},
label
:
"
{{node.label}}
"
,
group
:
"
{{node.group}}
"
},
{
%
endfor
%
}
]);
var
edges
=
new
vis
.
DataSet
([
{
%
for
edge
in
edges
%
}
{
from
:
{{
edge
.
from
}},
to
:
{{
edge
.
to
}}
,
arrows
:
"
{{edge.arrow_type}}
"
,
shadow
:
{
color
:
"
#FF9900
"
}},
{
%
endfor
%
}
]);
{
%
for
edge
in
edges
%
}
{
from
:
{{
edge
.
from
}},
to
:
{{
edge
.
to
}}
,
arrows
:
"
{{edge.arrow_type}}
"
,
label
:
"
{{edge.label|safe}}
"
,
font
:
{
multi
:
"
md
"
}},
{
%
endfor
%
}
]);
var
container
=
document
.
getElementById
(
'
net
'
);
var
data
=
{
nodes
:
nodes
,
edges
:
edges
};
nodes
:
nodes
,
edges
:
edges
};
var
options
=
{
edges
:
{
smooth
:
false
},
groups
:
{
server
:
{
shape
:
"
box
"
,
color
:
"
#FF9900
"
},
db
:
{
shape
:
"
box
"
}}}
// initialize your network!
var
network
=
new
vis
.
Network
(
container
,
data
,
options
);
</script>
</body>
var
options
=
{
edges
:
{
smooth
:
true
},
groups
:
{
server
:
{
shape
:
"
box
"
,
color
:
"
#FF9900
"
},
db
:
{
shape
:
"
database
"
}}}
var
network
=
new
vis
.
Network
(
container
,
data
,
options
);
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment