Przeglądaj źródła

Merge branch 'master' of http://git.cc-lotus.info/count/webnew-count

lrf402788946 4 lat temu
rodzic
commit
39c6a08c75

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .DS_Store
 node_modules
 /dist
+package-lock.json
 
 # local env files
 .env.local

Plik diff jest za duży
+ 0 - 12110
package-lock.json


+ 3 - 1
package.json

@@ -8,6 +8,7 @@
     "lint": "vue-cli-service lint"
   },
   "dependencies": {
+    "@stomp/stompjs": "^5.4.4",
     "@tinymce/tinymce-vue": "^3.2.2",
     "axios": "^0.19.2",
     "core-js": "^3.6.4",
@@ -17,7 +18,8 @@
     "lodash": "^4.17.15",
     "moment": "^2.27.0",
     "naf-core": "^0.1.2",
-    "tinymce": "5.2.2",
+    "stomp": "^0.1.1",
+    "tinymce": "^5.4.0",
     "vue": "^2.6.11",
     "vue-meta": "^2.4.0",
     "vue-route": "^1.5.1",

+ 1 - 1
public/index.html

@@ -5,7 +5,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
-    <title><%= htmlWebpackPlugin.options.title %></title>
+    <title>吉林省计算中心</title>
   </head>
   <body>
     <noscript>

+ 42 - 12
src/layout/index/top-right.vue

@@ -15,7 +15,7 @@ import 'echarts/lib/component/toolbox';
 import 'echarts/lib/component/markPoint';
 import 'echarts/lib/component/tooltip';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: news } = createNamespacedHelpers('news');
+const { mapActions: topmessage } = createNamespacedHelpers('topmessage');
 export default {
   name: 'top-right',
   props: {},
@@ -23,23 +23,29 @@ export default {
   data: () => {
     return {
       myChart: null,
+      // 结点
+      hyjdTotal: 0,
+      serveTime: true,
     };
   },
-  created() {
-    this.init();
+  async created() {
+    await this.init();
+  },
+  mounted() {
+    this.channel();
+    if (this.serveTime) {
+      this.searchNode();
+      this.searchNode = false;
+    }
   },
   methods: {
-    ...news(['query']),
+    ...topmessage(['query', 'querytwo']),
     async init() {
       let res = await this.query();
       if (this.$checkRes(res)) {
-        let s1 = [{ name: '1' }];
-        let s2 = [{ name: '1' }, { name: '2' }];
-        let s3 = [{ name: '1' }, { name: '2' }, { name: '3' }];
         this.myChart = echarts.init(document.getElementById('chart'));
         const option = {
           title: { text: '运行动态', left: 'center' },
-
           tooltip: { trigger: 'axis' },
           legend: {
             data: ['活跃用户', '活跃节点', '活跃应用'],
@@ -58,21 +64,45 @@ export default {
               },
               type: 'bar',
               data: [
-                { name: '活跃用户', value: s3.length, itemStyle: { color: '#7cb5ec' } },
-                { name: '活跃节点', value: s1.length, itemStyle: { color: '#ffa94b' } },
-                { name: '活跃应用', value: s2.length, itemStyle: { color: '#346da4' } },
+                { name: '活跃用户', value: res.total, itemStyle: { color: '#7cb5ec' } },
+                { name: '活跃节点', value: this.hyjdTotal, itemStyle: { color: '#ffa94b' } },
+                { name: '活跃应用', value: res.total, itemStyle: { color: '#346da4' } },
               ],
               animationType: 'scale',
             },
           ],
         };
         this.myChart.setOption(option);
-
         this.myChart.on('click', function(params) {
           self.location.href = '/service/detail?title=运行动态';
         });
       }
     },
+    // 页面一次性请求
+    async searchNode() {
+      let res = await this.querytwo();
+    },
+    channel() {
+      this.$stomp({
+        [`/exchange/service_count/nodes`]: this.onMessage,
+      });
+    },
+    onMessage(message) {
+      let data = JSON.parse(message.body).filter(i => i.node != 'gpu01');
+      console.log(data.length);
+      this.$set(this, 'hyjdTotal', data.length);
+    },
+  },
+  watch: {
+    hyjdTotal: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (val) {
+          this.init();
+        }
+      },
+    },
   },
   computed: {
     ...mapState(['']),

+ 2 - 0
src/main.js

@@ -11,12 +11,14 @@ import '@/plugins/loading';
 import '@/plugins/var';
 import '@/plugins/methods';
 import '@/plugins/setting';
+import InitStomp from '@/plugins/stomp';
 
 new Vue({
   router,
   store,
   render: h => h(App),
 }).$mount('#app');
+InitStomp();
 window.vm = new Vue({
   router,
 });

+ 3 - 3
src/plugins/setting.js

@@ -9,9 +9,9 @@ Vue.config.stomp = {
   // brokerURL: 'ws://192.168.1.190:15674/ws',
   brokerURL: '/ws', // ws://${location.host}/ws
   connectHeaders: {
-    host: 'smart',
-    login: 'web',
-    passcode: 'web123',
+    host: 'visit',
+    login: 'visit',
+    passcode: 'visit',
   },
   // debug: true,
   reconnectDelay: 5000,

+ 2 - 0
src/store/index.js

@@ -13,6 +13,7 @@ import news from './news';
 import demand from './demand';
 import comment from './comment';
 import links from './links';
+import topmessage from './topmessage';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -31,5 +32,6 @@ export default new Vuex.Store({
     demand,
     comment,
     links,
+    topmessage,
   },
 });

+ 46 - 0
src/store/topmessage.js

@@ -0,0 +1,46 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  topInfo: `/api/count/top`,
+  servenodeInfo: `/api/count/servenode`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = 15, ...info } = {}) {
+    const res = await this.$axios.$get(api.topInfo, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.topInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.topInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.topInfo}/update/${id}`, {
+      ...info,
+    });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+  async querytwo({ commit }, { skip = 0, limit = 15, ...info } = {}) {
+    const res = await this.$axios.$get(api.servenodeInfo, { ...info });
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 4 - 1
src/views/communication/parts/demand.vue

@@ -44,7 +44,10 @@ export default {
     xuqiu(item) {
       // this.$router.push({ path: '/demand/index', query: { id: item.id } });
       let id = item.id;
-      window.open('/demand/index?id' + id);
+      // window.open('/count/demand/index?id=' + id);
+      let routeData = this.$router.push({ path: '/demand/index', query: { id: item.id } });
+      window.open(routeData.href, '_blank');
+      // $window.open('/bdfence/bdfence-division/bdfence.html?vehicleId=' + id);
     },
     async onclick() {
       if (this.user) {

+ 105 - 20
src/views/service/parts/sign.vue

@@ -10,22 +10,58 @@
           <el-col :span="24" class="top">
             <el-col :span="6" class="left"> 当前状态</el-col>
             <el-col :span="10" class="under">
-              <el-radio v-model="radio" label="1">活跃用户</el-radio>
-              <el-radio v-model="radio" label="2">活跃节点</el-radio>
-              <el-radio v-model="radio" label="3">活跃应用</el-radio>
+              <el-radio-group v-model="radio" @change="changeType">
+                <el-radio label="1">活跃用户</el-radio>
+                <el-radio label="2">活跃节点</el-radio>
+                <el-radio label="3">活跃应用</el-radio>
+              </el-radio-group>
             </el-col>
-            <el-col :span="8" class="right">更新时间:2020-5-19_00:00:00</el-col>
+            <el-col :span="8" class="right">更新时间:{{ toDay }}</el-col>
           </el-col>
           <el-col :span="24" class="table">
-            <el-table :data="tableData" border style="width: 100%">
-              <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
-              <el-table-column prop="name" label="用户" align="center"> </el-table-column>
-              <el-table-column prop="yingxing" label="运行作业" align="center"> </el-table-column>
-              <el-table-column prop="paidui" label="排队作业" align="center"> </el-table-column>
-              <el-table-column prop="heshu" label="运行核数" align="center"> </el-table-column>
-              <el-table-column prop="diaduiheshu" label="排队核数" align="center"> </el-table-column>
-              <el-table-column prop="huoyue" label="活跃结点" align="center"> </el-table-column>
-            </el-table>
+            <span v-if="radio == '1'">
+              <el-table :data="hyyh" border style="width: 100%">
+                <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+                <el-table-column prop="user" label="用户" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="pr" label="进程调度" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="ni" label="进程nice值" align="center" show-overflow-tooltip> </el-table-column>
+                <!-- <el-table-column prop="virt" label="虚拟内存" align="center" show-overflow-tooltip> </el-table-column> -->
+                <el-table-column prop="res" label="驻留内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="shr" label="共享内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="s" label="进程状态" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="cpu" label="CPU时间" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="mem" label="物理内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="command" label="进程指令" align="center" show-overflow-tooltip> </el-table-column>
+                <!-- <el-table-column prop="time" label="全部CPU时间" align="center" show-overflow-tooltip> </el-table-column> -->
+              </el-table>
+            </span>
+            <span v-else-if="radio == '2'">
+              <el-table :data="hyjd" border style="width: 100%">
+                <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+                <el-table-column prop="uname" label="用户" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="jobs" label="运行作业" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="physmem" label="作业占用内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="np" label="可用核数" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="ncpus" label="运行核数" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="node" label="活跃结点" align="center" show-overflow-tooltip> </el-table-column>
+              </el-table>
+            </span>
+            <span v-else-if="radio == '3'">
+              <el-table :data="hyyy" border style="width: 100%">
+                <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+                <el-table-column prop="user" label="应用" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="pr" label="进程调度" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="ni" label="进程nice值" align="center" show-overflow-tooltip> </el-table-column>
+                <!-- <el-table-column prop="virt" label="虚拟内存" align="center" show-overflow-tooltip> </el-table-column> -->
+                <el-table-column prop="res" label="驻留内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="shr" label="共享内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="s" label="进程状态" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="cpu" label="CPU时间" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="mem" label="物理内存" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="command" label="进程指令" align="center" show-overflow-tooltip> </el-table-column>
+                <!-- <el-table-column prop="time" label="全部CPU时间" align="center" show-overflow-tooltip> </el-table-column> -->
+              </el-table>
+            </span>
           </el-col>
         </el-col>
       </el-col>
@@ -35,6 +71,8 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: topmessage } = createNamespacedHelpers('topmessage');
+import moment from 'moment';
 export default {
   name: 'sign',
   props: {
@@ -43,15 +81,58 @@ export default {
   components: {},
   data: function() {
     return {
+      // 显示类型
       radio: '1',
-      tableData: [
-        { name: '测试', yingxing: '0', heshu: '0', paidui: '0', diaduiheshu: '230', huoyue: 'era' },
-        { name: '测试', yingxing: '0', heshu: '0', paidui: '0', diaduiheshu: '230', huoyue: 'era' },
-      ],
+      // 活跃用户
+      hyyh: [],
+      // 活跃结点
+      hyjd: [],
+      // 活跃应用
+      hyyy: [],
+      toDay: '',
+      serveTime: true,
     };
   },
-  created() {},
-  methods: {},
+  async created() {
+    let toDay = moment().format('YYYY-MM-DD HH:mm:ss');
+    this.$set(this, `toDay`, toDay);
+    await this.search();
+  },
+  mounted() {
+    this.channel();
+    if (this.serveTime) {
+      this.searchNode();
+      this.searchNode = false;
+    }
+  },
+  methods: {
+    ...topmessage(['query', 'querytwo']),
+    async search({ skip = 0, limit = 300, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `hyyh`, res.data);
+        this.$set(this, `hyyy`, res.data.reverse());
+      }
+    },
+    // 页面一次性请求
+    async searchNode() {
+      let res = await this.querytwo();
+    },
+    channel() {
+      this.$stomp({
+        [`/exchange/service_count/nodes`]: this.onMessage,
+      });
+    },
+    onMessage(message) {
+      let data = JSON.parse(message.body).filter(i => i.node != 'gpu01');
+      this.$set(this, 'hyjd', data);
+    },
+    // 选择类型
+    changeType(label) {
+      this.$set(this, `radio`, label);
+      console.log(this.radio);
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {
@@ -89,7 +170,7 @@ export default {
 .info {
   border-top: 2px solid #054982;
   background-image: linear-gradient(0deg, #c4e0ec, #f0f7fa);
-  min-height: 700px;
+  min-height: 695px;
   .top {
     height: 50px;
     line-height: 50px;
@@ -110,6 +191,10 @@ export default {
       float: right;
     }
   }
+  .table {
+    height: 641px;
+    overflow: hidden;
+  }
 }
 /deep/.el-radio {
   color: #606266;