运维架构图之用前端简易实现集群框架图
前言:
今个群里有个哥们问我怎么实现一个集群的架构图,一说架构图,大家肯定想到的是用visio或者是亿图,但是动态的咋办?甚至说高端了点,不仅可以看到架构图,而且可以看到流量及负载的信息。 现在运维平台这么火热,大家恨不得把平台做全面点。 我以前做过一个机房展现图,有兴趣的朋友可以再以前的博客中找到。
运维平台化之IDC机柜拓扑及数据展现实现思路
http://rfyiamcool.blog.51cto.com/1030776/1346389
用的是 jquery.jOrgChart.css js库,实现提来还算简单。大家只需要做个模板,然后各种if判断就行了。你懂的。 个人觉得大家要在cmdb资产系统里面要做好位置的标记,不然后期做架构图展现的时候,会发现 没法动态。。。。。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
原文: < script src = "http://libs.baidu.com/jquery/1.9.0/jquery.js" ></ script >
< script src = "http://libs.baidu.com/jqueryui/1.8.22/jquery-ui.min.js " ></ script >
< script src = "jquery.jOrgChart.js" ></ script >
< script >
jQuery(document).ready(function() {
$("#org").jOrgChart({
chartElement : '#chart',
dragAndDrop : true
});
});
</ script >
</ head >
< body onload = "prettyPrint();" >
< div class = "topbar" >
< div class = "topbar-inner" >
< div class = "container" >
< a class = "brand" href = "#" >jQuery Organisation Chart</ a >
< ul class = "nav" >
< li >< a href = "http://github.com/wesnolte" >Github</ a ></ li >
< li >< a href = "http://twitter.com/wesnolte" >Twitter</ a ></ li >
< li >< a href = "http://th3silverlining.com" >Blog</ a ></ li >
</ ul >
< div class = "pull-right" >
< div class = "alert-message info" id = "show-list" >Show underlying list.</ div >
< pre class = "prettyprint lang-html" id = "list-html" style = "display:none" ></ pre >
</ div >
</ div >
</ div >
</ div >
< ul id = "org" style = "display:none" >
< li >< br >< font size = "4" >Balance</ font >
< ul >
< li id = "beer" >< br >redis 192.168.1.10</ li >
< li >< br >nginx2 192.168.1.13
< ul >
< li >mongodb 192.168.1.16</ li >
< li >mongodb 192.168.1.19</ li >
</ ul >
</ li >
< li class = "fruit" >nginx3 192.168.1.24
< ul >
< li >php 192.168.1.28
< ul >
< li >mysql 192.168.1.33</ li >
< li >mysql 192.168.1.37</ li >
</ ul >
</ li >
</ ul >
</ li >
< li >spider 192.168.1.41</ li >
< li class = "collapsed" >nginx5 192.168.1.44
< ul >
< li >Topdeck</ li >
< li >Reese's Cups</ li >
</ ul >
</ li >
</ ul >
</ li >
</ ul >
< div id = "chart" class = "orgChart" ></ div >
< script >
jQuery(document).ready(function() {
/* Custom jQuery for the example */
$("#show-list").click(function(e){
e.preventDefault();
$('#list-html').toggle('fast', function(){
if($(this).is(':visible')){
$('#show-list').text('Hide underlying list.');
$(".topbar").fadeTo('fast',0.9);
}else{
$('#show-list').text('Show underlying list.');
$(".topbar").fadeTo('fast',1);
}
});
});
$('#list-html').text($('#org').html());
$("#org").bind("DOMSubtreeModified", function() {
$('#list-html').text('');
$('#list-html').text($('#org').html());
prettyPrint();
});
});
</ script >
|
这里实现的方法有些简单,大家自己举一反三的做成模板,也可以换成自己服务器的图标。
好了,不多说了 !
本文转自 rfyiamcool 51CTO博客,原文链接:http://blog.51cto.com/rfyiamcool/1559137,如需转载请自行联系原作者