Browse Source

服务器指标采集保存模式修改2

demon 8 years ago
parent
commit
5771707e73

+ 5 - 4
hos-broker/src/main/java/com/yihu/hos/common/scheduler/MonitorScheduler.java

@ -139,10 +139,11 @@ public class MonitorScheduler {
    /**
     * 服务器列表保存
     */
    @Scheduled(initialDelay=3000,cron = "0 0 12 * * ?") //每天中午12点触发
//    @Scheduled(cron = "0 0 12 * * ?") //每天中午12点触发
    @Scheduled(fixedDelay = 3600*24*1000,initialDelay=3000) //每天中午12点触发
    public void checkHost() {
        MongodbUtil monoEnv = new MongodbUtil("monitor");
        mongoOperations = new MongoTemplate(mongo, "monitor");
        MongodbUtil monoEnv = new MongodbUtil(MonitorConstant.MONITOR);
        mongoOperations = new MongoTemplate(mongo, MonitorConstant.MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(MonitorConstant.HOST);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
@ -151,7 +152,7 @@ public class MonitorScheduler {
        DBCursor cursor = envCollection.find(queryObject);
        if (cursor.size() < 1) {
            try {
                org.json.JSONObject result = new org.json.JSONObject();
                Document result = new Document();
                InetAddress addr = null;
                addr = InetAddress.getLocalHost();
                result.put("name",  addr.getHostName());

+ 1 - 1
hos-broker/src/main/java/com/yihu/hos/common/util/SigarUtil.java

@ -315,7 +315,7 @@ public class SigarUtil {
                InetAddress inet = InetAddress.getLocalHost();
                // 没有出现异常而正常当取到的IP时,如果取到的不是网卡循回地址时就返回
                // 否则再通过Sigar工具包中的方法来获取
                if (!NetFlags.LOOPBACK_ADDRESS.equals(address)) {
                if (NetFlags.LOOPBACK_ADDRESS.equals(address)) {
                    address = netConfig.getAddress();
                }
            } catch (UnknownHostException e) {

+ 2 - 2
src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

@ -121,9 +121,9 @@ public class ServerMonitorService {
        while(cursor.hasNext()) {
            DBObject dbObject = cursor.next();
            TreeView rootTree = new TreeView();
            rootTree.setId("host" + dbObject.get("host"));
            rootTree.setId(dbObject.get("host").toString());
            rootTree.setPid("-1");
            rootTree.setText(dbObject.get("host").toString());
            rootTree.setText(dbObject.get("name").toString()+"/"+dbObject.get("host").toString());
            treeList.add(rootTree);
        }

+ 3 - 3
src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManage.jsp

@ -16,7 +16,7 @@
    .div-item{width:40%;float: left;}
    .d-item{font-size: 12px;display: inline-block;width: 100px;}
    .c-content{font-size: 16px;display: inline-block;width: 100px;font-weight: bold;}
    .div-right-item{font-size: 12px;width: 150px;}
    .div-right-item{font-size: 12px;width: 200px;}
</style>
<!-- ####### 页面部分 ####### -->
<div id="div_wrapper">
@ -24,7 +24,7 @@
    <div position="left"  style="margin-left:10px;margin-top:10px;">
        <input type="hidden" id="nowHost">
        <ul    style="margin-left:30px;margin-top:10px;font-size: 17px;">服务器列表</ul>
        <ul id="div_wrapper_left_ul_resourcetree" class="m-snav"  style="margin-left:20px;margin-top:40px;"></ul>
        <ul id="div_wrapper_left_ul_resourcetree" class="m-snav"  style="margin-top:40px;"></ul>
    </div>
    <div position="center" style="margin-left:10px;margin-top:10px;margin-right:10px;">
        <!-- ####### 查询条件部分 ####### -->
@ -55,7 +55,7 @@
            <div class="c-item" data-item="net">网络</div>
        </div>
            <%-- echarts 数据--%>
        <div id="main" style="width: 80%;height:400px;"></div>
        <div id="main" style="width: 60%;height:400px;"></div>
            <%-- 详细数据 --%>
            <div id="detail" class="ml50 mt20">

+ 5 - 5
src/main/webapp/WEB-INF/ehr/jsp/monitor/server/sEnvManageJs.jsp

@ -87,7 +87,7 @@
            async: false,
            success: function (msg) {
                var data = JSON.parse(msg.message);
                host = data[0].text;
                host = data[0].id;
                if (msg.successFlg) {
                    // 初始化树形菜单
                    serviceTree = serviceTree.ligerTree({
@ -98,7 +98,7 @@
                        isExpand: false,
                        onClick: function (obj) {
                            //初始化图表
                            host = obj.data.text;
                            host = obj.data.id;
                            var beginTime = $("#repeatStartTime").ligerDateEditor("getValue");
                            var endTime = $("#repeatEndTime").ligerDateEditor("getValue");
                            if(beginTime=="" && $endTime=="")
@ -122,7 +122,7 @@
                        },
                        onSuccess: function (data) {
                            alert(2222);
                            host = data[0].text;
                            host = data[0].id;
                        }
                    });
                }
@ -656,13 +656,13 @@
                "                        <div class=\"d-item\">发送</div>" +
                "                    </div>" +
                "                    <div class=\"mb20\">\n" +
                "                        <div class=\"c-content\">"+envData.txbps+"kbps</div>" +
                "                        <div class=\"c-content\">"+envData.txbps+" kbps</div>" +
                "                    </div>\n" +
                "                    <div>\n" +
                "                        <div class=\"d-item\">接收</div>\n" +
                "                    </div>\n" +
                "                    <div class=\"mb20\">\n" +
                "                        <div class=\"c-content\">"+envData.rxbps+"kbps</div>\n" +
                "                        <div class=\"c-content\">"+envData.rxbps+" kbps</div>\n" +
                "                    </div>\n" +
                "                </div>\n" +
                "                <div class=\"div-item\">\n" +