运维架构图之用前端简易实现集群框架图

前言:

    今个群里有个哥们问我怎么实现一个集群的架构图,一说架构图,大家肯定想到的是用visio或者是亿图,但是动态的咋办?甚至说高端了点,不仅可以看到架构图,而且可以看到流量及负载的信息。 现在运维平台这么火热,大家恨不得把平台做全面点。 我以前做过一个机房展现图,有兴趣的朋友可以再以前的博客中找到。 

运维平台化之IDC机柜拓扑及数据展现实现思路

http://rfyiamcool.blog.51cto.com/1030776/1346389


wKiom1Qn1rThOaX4AANwufEHeY4204.jpg


用的是 jquery.jOrgChart.css  js库,实现提来还算简单。大家只需要做个模板,然后各种if判断就行了。你懂的。     个人觉得大家要在cmdb资产系统里面要做好位置的标记,不然后期做架构图展现的时候,会发现 没法动态。。。。。 


原文: 
 
	<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 οnlοad="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>


这里实现的方法有些简单,大家自己举一反三的做成模板,也可以换成自己服务器的图标。


好了,不多说了 ! 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值