host_detail.html 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. @media (min-width: 768px) {
  6. .form-horizontal .control-label {
  7. text-align: left;
  8. }
  9. }
  10. label>span {
  11. color: deepskyblue;
  12. }
  13. .btn,
  14. .form-group>div>div,
  15. .form-control {
  16. border-radius: 0;
  17. }
  18. .table {
  19. font-size: 12px;
  20. border-width: 1px;
  21. line-height: 22px;
  22. }
  23. .table > tbody > tr > td {
  24. color: #424547;
  25. }
  26. .table-bordered > tbody > tr {
  27. padding-top: 10px;
  28. padding-bottom: 10px;
  29. }
  30. .table-bordered > thead > tr > th,
  31. .table-bordered > tbody > tr > th,
  32. .table-bordered > tfoot > tr > th,
  33. .table-bordered > thead > tr > td,
  34. .table-bordered > tbody > tr > td,
  35. .table-bordered > tfoot > tr > td {
  36. border-style: solid;
  37. border-width: 1px 0 0 0;
  38. }
  39. .guest-label {
  40. color: #999999;
  41. }
  42. .guest-desc {
  43. color: #333333;
  44. }
  45. </style>
  46. {% endblock head %}
  47. {% block body %}
  48. <script>
  49. var resource_path = window.location.pathname;
  50. var resource_path_array = resource_path.split('/');
  51. var node_id = resource_path_array[resource_path_array.length - 1];
  52. var cpu_chart = null;
  53. var memory_chart = null;
  54. var host_info = null;
  55. var datetime_format_type = 'time';
  56. function format_time(timestamp, i) {
  57. if (datetime_format_type === 'time') {
  58. return new Date(timestamp).format('HH:MM');
  59. } else {
  60. return new Date(timestamp).format('mm-dd');
  61. }
  62. }
  63. function render_cpu_chart(granularity) {
  64. var url = '/api/host_performance/cpu_memory/last_hour/' + node_id;
  65. if (granularity === 'hour') {
  66. url = '/api/host_performance/cpu_memory/last_hour/' + node_id
  67. } else if (granularity === 'six_hours') {
  68. url = '/api/host_performance/cpu_memory/last_six_hours/' + node_id
  69. } else if (granularity === 'day') {
  70. url = '/api/host_performance/cpu_memory/last_day/' + node_id
  71. } else {
  72. url = '/api/host_performance/cpu_memory/last_seven_days/' + node_id
  73. }
  74. $.ajax({
  75. url : url,
  76. type : 'GET',
  77. contentType: "application/json; charset=utf-8",
  78. dataType: 'json',
  79. error : function() {
  80. alter_danger('获取图表数据失败失败!');
  81. },
  82. success : function(data, textStatus, xhr) {
  83. if (data.data.length > 1) {
  84. if ((data.data[data.data.length - 1]['timestamp'] - data.data[0]['timestamp']) >= 86400) {
  85. datetime_format_type = 'date';
  86. } else {
  87. datetime_format_type = 'time';
  88. }
  89. }
  90. var option = {
  91. color: ['#3BC0FF'],
  92. title: {
  93. text: 'CPU'
  94. },
  95. legend: {
  96. data:['CPU使用率(%)'],
  97. bottom: 5
  98. },
  99. toolbox: {
  100. feature: {
  101. dataZoom: {
  102. yAxisIndex: 'none'
  103. },
  104. magicType: {type: ['line', 'bar']},
  105. saveAsImage: {
  106. show: true,
  107. pixelRatio: 4
  108. }
  109. }
  110. },
  111. tooltip: {
  112. show: true,
  113. trigger: 'axis',
  114. formatter: (function (params, ticket, callback) {
  115. var cpu_load = params[0].data[1];
  116. var seriesName = params[0].seriesName;
  117. var marker = params[0].marker;
  118. var datetime = new Date(params[0].data[0]).format('yyyy-mm-dd HH:MM:ss');
  119. if (cpu_load === null) {
  120. cpu_load = '无数据';
  121. }
  122. return datetime + '<br />' + [marker, seriesName, cpu_load].join(' ')
  123. })
  124. },
  125. xAxis: {
  126. type: 'time',
  127. axisTick: {
  128. show: false
  129. },
  130. axisLine: {
  131. lineStyle: {
  132. opacity: 0.1,
  133. color: '#3d4245'
  134. }
  135. },
  136. splitLine: {
  137. show: false
  138. },
  139. axisLabel: {
  140. formatter: format_time
  141. }
  142. },
  143. yAxis: {
  144. min: 0,
  145. max: 'dataMax',
  146. minInterval: 2,
  147. axisTick: {
  148. show: false
  149. },
  150. axisLine: {
  151. lineStyle: {
  152. opacity: 0,
  153. color: '#8c8f91'
  154. }
  155. },
  156. splitLine: {
  157. show: true,
  158. lineStyle: {
  159. width: 1,
  160. opacity: 0.5
  161. }
  162. }
  163. },
  164. series: [{
  165. name: 'CPU使用率(%)',
  166. type: 'line',
  167. showSymbol: false,
  168. smooth: true,
  169. lineStyle: {
  170. normal: {
  171. width: 1
  172. }
  173. },
  174. data: (function () {
  175. var d = [];
  176. $.each(data.data, function(i, ele) {
  177. d.push([
  178. ele['timestamp'] * 1000,
  179. ele['cpu_load']
  180. ])
  181. });
  182. return d;
  183. })()
  184. }]
  185. };
  186. cpu_chart.setOption(option);
  187. }
  188. });
  189. }
  190. function render_traffic_chart(nic_name, granularity) {
  191. var url = '/api/host_performance/traffic/last_hour/' + node_id + '/' + nic_name;
  192. if (granularity === 'hour') {
  193. url = '/api/host_performance/traffic/last_hour/' + node_id + '/' + nic_name
  194. } else if (granularity === 'six_hours') {
  195. url = '/api/host_performance/traffic/last_six_hours/' + node_id + '/' + nic_name
  196. } else if (granularity === 'day') {
  197. url = '/api/host_performance/traffic/last_day/' + node_id + '/' + nic_name
  198. } else {
  199. url = '/api/host_performance/traffic/last_seven_days/' + node_id + '/' + nic_name
  200. }
  201. $.ajax({
  202. url : url,
  203. type : 'GET',
  204. contentType: "application/json; charset=utf-8",
  205. dataType: 'json',
  206. error : function() {
  207. alter_danger('获取图表数据失败失败!');
  208. },
  209. success : function(data, textStatus, xhr) {
  210. if (data.data.length > 1) {
  211. if ((data.data[data.data.length - 1]['timestamp'] - data.data[0]['timestamp']) >= 86400) {
  212. datetime_format_type = 'date';
  213. } else {
  214. datetime_format_type = 'time';
  215. }
  216. }
  217. var option = {
  218. color: ['#3BC0FF', '#FAB406'],
  219. title: {
  220. text: '网络(' + nic_name + ')'
  221. },
  222. legend: {
  223. data:['流入(kbps)', '流出(kbps)'],
  224. bottom: 5
  225. },
  226. toolbox: {
  227. feature: {
  228. dataZoom: {
  229. yAxisIndex: 'none'
  230. },
  231. magicType: {type: ['line', 'bar']},
  232. saveAsImage: {
  233. show: true,
  234. pixelRatio: 4
  235. }
  236. }
  237. },
  238. tooltip: {
  239. show: true,
  240. trigger: 'axis',
  241. formatter: (function (params, ticket, callback) {
  242. var inflowSeriesName = params[0].seriesName;
  243. var outflowSeriesName = params[1].seriesName;
  244. var inflow = params[0].data[1];
  245. var outflow = params[1].data[1];
  246. var inflowMarker = params[0].marker;
  247. var outflowMarker = params[1].marker;
  248. var datetime = new Date(params[0].data[0]).format('yyyy-mm-dd HH:MM:ss');
  249. if (inflow === null) {
  250. inflow = '无数据';
  251. }
  252. if (outflow === null) {
  253. outflow = '无数据';
  254. }
  255. return datetime + '<br />' + [inflowMarker, inflowSeriesName, inflow].join(' ') +
  256. '<br />' + [outflowMarker, outflowSeriesName, outflow].join(' ')
  257. })
  258. },
  259. xAxis: {
  260. type: 'time',
  261. axisTick: {
  262. show: false
  263. },
  264. axisLine: {
  265. lineStyle: {
  266. opacity: 0.1,
  267. color: '#3d4245'
  268. }
  269. },
  270. splitLine: {
  271. show: false
  272. },
  273. axisLabel: {
  274. formatter: format_time
  275. }
  276. },
  277. yAxis: {
  278. min: 0,
  279. max: 'dataMax',
  280. minInterval: 2,
  281. axisTick: {
  282. show: false
  283. },
  284. axisLine: {
  285. lineStyle: {
  286. opacity: 0,
  287. color: '#8c8f91'
  288. }
  289. },
  290. splitLine: {
  291. show: true,
  292. lineStyle: {
  293. width: 1,
  294. opacity: 0.5
  295. }
  296. }
  297. },
  298. series: [{
  299. name: '流入(kbps)',
  300. type: 'line',
  301. showSymbol: false,
  302. smooth: true,
  303. lineStyle: {
  304. normal: {
  305. width: 1
  306. }
  307. },
  308. data: (function () {
  309. var d = [];
  310. $.each(data.data, function(i, ele) {
  311. d.push([
  312. ele['timestamp'] * 1000,
  313. ele['rx_bytes'] !== null ? Math.floor(ele['rx_bytes'] * 8 / 1000) : null
  314. ])
  315. });
  316. return d;
  317. })()
  318. },{
  319. name: '流出(kbps)',
  320. type: 'line',
  321. showSymbol: false,
  322. smooth: true,
  323. lineStyle: {
  324. normal: {
  325. width: 1
  326. }
  327. },
  328. data: (function () {
  329. var d = [];
  330. $.each(data.data, function(i, ele) {
  331. d.push([
  332. ele['timestamp'] * 1000,
  333. ele['tx_bytes'] !== null ? Math.floor(ele['tx_bytes'] * 8 / 1000) : null
  334. ])
  335. });
  336. return d;
  337. })()
  338. }]
  339. };
  340. var traffic_chart = echarts.init(document.getElementById(nic_name));
  341. traffic_chart.setOption(option);
  342. }
  343. });
  344. }
  345. function render_memory_chart(granularity) {
  346. var url = '/api/host_performance/cpu_memory/last_hour/' + node_id;
  347. if (granularity === 'hour') {
  348. url = '/api/host_performance/cpu_memory/last_hour/' + node_id
  349. } else if (granularity === 'six_hours') {
  350. url = '/api/host_performance/cpu_memory/last_six_hours/' + node_id
  351. } else if (granularity === 'day') {
  352. url = '/api/host_performance/cpu_memory/last_day/' + node_id
  353. } else {
  354. url = '/api/host_performance/cpu_memory/last_seven_days/' + node_id
  355. }
  356. $.ajax({
  357. url: url,
  358. type: 'GET',
  359. contentType: "application/json; charset=utf-8",
  360. dataType: 'json',
  361. error: function () {
  362. alter_danger('获取图表数据失败失败!');
  363. },
  364. success: function (data, textStatus, xhr) {
  365. if (data.data.length > 1) {
  366. if ((data.data[data.data.length - 1]['timestamp'] - data.data[0]['timestamp']) >= 86400) {
  367. datetime_format_type = 'date';
  368. } else {
  369. datetime_format_type = 'time';
  370. }
  371. }
  372. var option = {
  373. color: ['#35CD03'],
  374. title: {
  375. text: '内存'
  376. },
  377. legend: {
  378. data: ['可用量'],
  379. bottom: 5
  380. },
  381. toolbox: {
  382. feature: {
  383. dataZoom: {
  384. yAxisIndex: 'none'
  385. },
  386. magicType: {type: ['line', 'bar']},
  387. saveAsImage: {
  388. show: true,
  389. pixelRatio: 4
  390. }
  391. }
  392. },
  393. tooltip: {
  394. show: true,
  395. trigger: 'axis',
  396. formatter: (function (params, ticket, callback) {
  397. var seriesName = params[0].seriesName;
  398. var free = params[0].data[1];
  399. var marker = params[0].marker;
  400. var datetime = new Date(params[0].data[0]).format('yyyy-mm-dd HH:MM:ss');
  401. if (free === null) {
  402. free = '无数据';
  403. }
  404. return datetime + '<br />' + [marker, seriesName, free].join(' ')
  405. })
  406. },
  407. xAxis: {
  408. type: 'time',
  409. axisTick: {
  410. show: false
  411. },
  412. axisLine: {
  413. lineStyle: {
  414. opacity: 0.1,
  415. color: '#3d4245'
  416. }
  417. },
  418. splitLine: {
  419. show: false
  420. },
  421. axisLabel: {
  422. formatter: format_time
  423. }
  424. },
  425. yAxis: {
  426. min: 0,
  427. max: Math.floor(host_info['memory'] / 1024 / 1024 / 1024),
  428. minInterval: 2,
  429. axisTick: {
  430. show: false
  431. },
  432. axisLine: {
  433. lineStyle: {
  434. opacity: 0,
  435. color: '#8c8f91'
  436. }
  437. },
  438. splitLine: {
  439. show: true,
  440. lineStyle: {
  441. width: 1,
  442. opacity: 0.5
  443. }
  444. }
  445. },
  446. series: [{
  447. name: '可用量(GB)',
  448. type: 'line',
  449. showSymbol: false,
  450. smooth: true,
  451. lineStyle: {
  452. normal: {
  453. width: 1
  454. }
  455. },
  456. areaStyle: {normal: {}},
  457. data: (function () {
  458. var d = [];
  459. $.each(data.data, function (i, ele) {
  460. d.push([
  461. ele['timestamp'] * 1000,
  462. // 保留一位小数
  463. ele['memory_available'] !== null ? Math.floor(ele['memory_available'] / 1024 / 1024 / 102.4) / 10 : null
  464. ])
  465. });
  466. return d;
  467. })()
  468. }]
  469. };
  470. memory_chart.setOption(option);
  471. }
  472. });
  473. }
  474. function render_disk_throughput_chart(granularity, dev_id, mountpoint) {
  475. mountpoint = window.btoa(mountpoint);
  476. var url = '/api/host_performance/disk_io/last_hour/' + node_id + '/' + mountpoint;
  477. if (granularity === 'hour') {
  478. url = '/api/host_performance/disk_io/last_hour/' + node_id + '/' + mountpoint
  479. } else if (granularity === 'six_hours') {
  480. url = '/api/host_performance/disk_io/last_six_hours/' + node_id + '/' + mountpoint
  481. } else if (granularity === 'day') {
  482. url = '/api/host_performance/disk_io/last_day/' + node_id + '/' + mountpoint
  483. } else {
  484. url = '/api/host_performance/disk_io/last_seven_days/' + node_id + '/' + mountpoint
  485. }
  486. mountpoint = window.atob(mountpoint);
  487. $.ajax({
  488. url : url,
  489. type : 'GET',
  490. contentType: "application/json; charset=utf-8",
  491. dataType: 'json',
  492. error : function() {
  493. alter_danger('获取图表数据失败失败!');
  494. },
  495. success : function(data, textStatus, xhr) {
  496. if (data.data.length > 1) {
  497. if ((data.data[data.data.length - 1]['timestamp'] - data.data[0]['timestamp']) >= 86400) {
  498. datetime_format_type = 'date';
  499. } else {
  500. datetime_format_type = 'time';
  501. }
  502. }
  503. var option = {
  504. color: ['#3BC0FF', '#FAB406'],
  505. title: {
  506. text: '磁盘吞吐量 - ' + host_info['disks'][mountpoint]['device']
  507. },
  508. legend: {
  509. data:['读(MBps)', '写(MBps)'],
  510. bottom: 5
  511. },
  512. toolbox: {
  513. feature: {
  514. dataZoom: {
  515. yAxisIndex: 'none'
  516. },
  517. magicType: {type: ['line', 'bar']},
  518. saveAsImage: {
  519. show: true,
  520. pixelRatio: 4
  521. }
  522. }
  523. },
  524. tooltip: {
  525. show: true,
  526. trigger: 'axis',
  527. formatter: (function (params, ticket, callback) {
  528. var readSeriesName = params[0].seriesName;
  529. var writeSeriesName = params[1].seriesName;
  530. var read = params[0].data[1];
  531. var write = params[1].data[1];
  532. var readMarker = params[0].marker;
  533. var writeMarker = params[1].marker;
  534. var datetime = new Date(params[0].data[0]).format('yyyy-mm-dd HH:MM:ss');
  535. if (read === null) {
  536. read = '无数据';
  537. }
  538. if (write === null) {
  539. write = '无数据';
  540. }
  541. return datetime + '<br />' + [readMarker, readSeriesName, read].join(' ') +
  542. '<br />' + [writeMarker, writeSeriesName, write].join(' ')
  543. })
  544. },
  545. xAxis: {
  546. type: 'time',
  547. axisTick: {
  548. show: false
  549. },
  550. axisLine: {
  551. lineStyle: {
  552. opacity: 0.1,
  553. color: '#3d4245'
  554. }
  555. },
  556. splitLine: {
  557. show: false
  558. },
  559. axisLabel: {
  560. formatter: format_time
  561. }
  562. },
  563. yAxis: {
  564. min: 0,
  565. max: 'dataMax',
  566. minInterval: 2,
  567. axisTick: {
  568. show: false
  569. },
  570. axisLine: {
  571. lineStyle: {
  572. opacity: 0,
  573. color: '#8c8f91'
  574. }
  575. },
  576. splitLine: {
  577. show: true,
  578. lineStyle: {
  579. width: 1,
  580. opacity: 0.5
  581. }
  582. }
  583. },
  584. series: [{
  585. name: '读(MBps)',
  586. type: 'line',
  587. showSymbol: false,
  588. smooth: true,
  589. lineStyle: {
  590. normal: {
  591. width: 1
  592. }
  593. },
  594. data: (function () {
  595. var d = [];
  596. $.each(data.data, function(i, ele) {
  597. d.push([
  598. ele['timestamp'] * 1000,
  599. ele['rd_bytes'] !== null ? Math.floor(ele['rd_bytes'] / 1024 / 1024 * 1000) / 1000 : null
  600. ])
  601. });
  602. return d;
  603. })()
  604. },{
  605. name: '写(MBps)',
  606. type: 'line',
  607. showSymbol: false,
  608. smooth: true,
  609. lineStyle: {
  610. normal: {
  611. width: 1
  612. }
  613. },
  614. data: (function () {
  615. var d = [];
  616. $.each(data.data, function(i, ele) {
  617. d.push([
  618. ele['timestamp'] * 1000,
  619. ele['wr_bytes'] !== null ? Math.floor(ele['wr_bytes'] / 1024 / 1024 * 1000) / 1000 : null
  620. ])
  621. });
  622. return d;
  623. })()
  624. }]
  625. };
  626. var disk_chart = echarts.init(document.getElementById(dev_id));
  627. disk_chart.setOption(option);
  628. }
  629. });
  630. }
  631. function render_disk_iops_chart(granularity, dev_id, mountpoint) {
  632. mountpoint = window.btoa(mountpoint);
  633. var url = '/api/host_performance/disk_io/last_hour/' + node_id + '/' + mountpoint;
  634. if (granularity === 'hour') {
  635. url = '/api/host_performance/disk_io/last_hour/' + node_id + '/' + mountpoint
  636. } else if (granularity === 'six_hours') {
  637. url = '/api/host_performance/disk_io/last_six_hours/' + node_id + '/' + mountpoint
  638. } else if (granularity === 'day') {
  639. url = '/api/host_performance/disk_io/last_day/' + node_id + '/' + mountpoint
  640. } else {
  641. url = '/api/host_performance/disk_io/last_seven_days/' + node_id + '/' + mountpoint
  642. }
  643. mountpoint = window.atob(mountpoint);
  644. $.ajax({
  645. url : url,
  646. type : 'GET',
  647. contentType: "application/json; charset=utf-8",
  648. dataType: 'json',
  649. error : function() {
  650. alter_danger('获取图表数据失败失败!');
  651. },
  652. success : function(data, textStatus, xhr) {
  653. if (data.data.length > 1) {
  654. if ((data.data[data.data.length - 1]['timestamp'] - data.data[0]['timestamp']) >= 86400) {
  655. datetime_format_type = 'date';
  656. } else {
  657. datetime_format_type = 'time';
  658. }
  659. }
  660. var option = {
  661. color: ['#3BC0FF', '#FAB406'],
  662. title: {
  663. text: '磁盘IOPS - ' + host_info['disks'][mountpoint]['device']
  664. },
  665. legend: {
  666. data:['读(IOPS)', '写(IOPS)'],
  667. bottom: 5
  668. },
  669. toolbox: {
  670. feature: {
  671. dataZoom: {
  672. yAxisIndex: 'none'
  673. },
  674. magicType: {type: ['line', 'bar']},
  675. saveAsImage: {
  676. show: true,
  677. pixelRatio: 4
  678. }
  679. }
  680. },
  681. tooltip: {
  682. show: true,
  683. trigger: 'axis',
  684. formatter: (function (params, ticket, callback) {
  685. var readSeriesName = params[0].seriesName;
  686. var writeSeriesName = params[1].seriesName;
  687. var read = params[0].data[1];
  688. var write = params[1].data[1];
  689. var readMarker = params[0].marker;
  690. var writeMarker = params[1].marker;
  691. var datetime = new Date(params[0].data[0]).format('yyyy-mm-dd HH:MM:ss');
  692. if (read === null) {
  693. read = '无数据';
  694. }
  695. if (write === null) {
  696. write = '无数据';
  697. }
  698. return datetime + '<br />' + [readMarker, readSeriesName, read].join(' ') +
  699. '<br />' + [writeMarker, writeSeriesName, write].join(' ')
  700. })
  701. },
  702. xAxis: {
  703. type: 'time',
  704. axisTick: {
  705. show: false
  706. },
  707. axisLine: {
  708. lineStyle: {
  709. opacity: 0.1,
  710. color: '#3d4245'
  711. }
  712. },
  713. splitLine: {
  714. show: false
  715. },
  716. axisLabel: {
  717. formatter: format_time
  718. }
  719. },
  720. yAxis: {
  721. min: 0,
  722. max: 'dataMax',
  723. minInterval: 2,
  724. axisTick: {
  725. show: false
  726. },
  727. axisLine: {
  728. lineStyle: {
  729. opacity: 0,
  730. color: '#8c8f91'
  731. }
  732. },
  733. splitLine: {
  734. show: true,
  735. lineStyle: {
  736. width: 1,
  737. opacity: 0.5
  738. }
  739. }
  740. },
  741. series: [{
  742. name: '读(IOPS)',
  743. type: 'line',
  744. showSymbol: false,
  745. smooth: true,
  746. lineStyle: {
  747. normal: {
  748. width: 1
  749. }
  750. },
  751. data: (function () {
  752. var d = [];
  753. $.each(data.data, function(i, ele) {
  754. d.push([
  755. ele['timestamp'] * 1000,
  756. ele['rd_req'] !== null ? ele['rd_req'] : null
  757. ])
  758. });
  759. return d;
  760. })()
  761. },{
  762. name: '写(IOPS)',
  763. type: 'line',
  764. showSymbol: false,
  765. smooth: true,
  766. lineStyle: {
  767. normal: {
  768. width: 1
  769. }
  770. },
  771. data: (function () {
  772. var d = [];
  773. $.each(data.data, function(i, ele) {
  774. d.push([
  775. ele['timestamp'] * 1000,
  776. ele['wr_req'] !== null ? ele['wr_req'] : null
  777. ])
  778. });
  779. return d;
  780. })()
  781. }]
  782. };
  783. var disk_chart = echarts.init(document.getElementById(dev_id));
  784. disk_chart.setOption(option);
  785. }
  786. });
  787. }
  788. function render_traffics_chart(granularity) {
  789. $('#traffics_chart').empty();
  790. $.each(host_info['interfaces'], function(key, ele) {
  791. $('#traffics_chart').append($('<div id=' + key +' style="width: 800px;height:280px;"></div>'));
  792. render_traffic_chart(key,granularity);
  793. });
  794. }
  795. function render_disks_chart(granularity) {
  796. $('#disks_chart').empty();
  797. $.each(host_info['disks'], function(key, ele) {
  798. var mountpoint = key;
  799. var dev_id_throughput = 'throughput_' + key;
  800. var dev_id_iops = 'iops_' + key;
  801. $('#disks_chart').append($('<div id=' + dev_id_throughput +' style="width: 800px;height:280px;"></div>'));
  802. render_disk_throughput_chart(granularity, dev_id_throughput, mountpoint);
  803. $('#disks_chart').append($('<div id=' + dev_id_iops +' style="width: 800px;height:280px;"></div>'));
  804. render_disk_iops_chart(granularity, dev_id_iops, mountpoint);
  805. });
  806. }
  807. $(document).ready(function() {
  808. $('body').addClass('add-transition');
  809. $('.add-page-transition').on('click', function(){
  810. var transAttr = $(this).attr('data-transition');
  811. $('.add-transition').attr('class', 'add-transition');
  812. $('.add-transition').addClass(transAttr);
  813. });
  814. var url = '/api/hosts/' + node_id;
  815. $.ajax({
  816. url: url,
  817. type: 'GET',
  818. async: false,
  819. contentType: "application/json; charset=utf-8",
  820. dataType: 'json',
  821. error: function () {
  822. alter_danger('获取计算节点数据失败失败!');
  823. },
  824. success: function (data, textStatus, xhr) {
  825. host_info = data.data;
  826. }
  827. });
  828. cpu_chart = echarts.init(document.getElementById('cpu_chart'));
  829. memory_chart = echarts.init(document.getElementById('memory_chart'));
  830. render_cpu_chart('hour');
  831. render_memory_chart('hour');
  832. render_traffics_chart('hour');
  833. render_disks_chart('hour')
  834. });
  835. function refresh_render_with_specify_granularity(granularity) {
  836. render_cpu_chart(granularity);
  837. render_memory_chart(granularity);
  838. render_traffics_chart(granularity);
  839. render_disks_chart(granularity)
  840. }
  841. </script>
  842. <div class="container" style="padding-top: 100px; width: 90%; max-width: 100%;">
  843. <div class="panel">
  844. <div class="panel-body">
  845. <a href="javascript:history.go(-1)" class="btn btn-xs btn-default add-page-transition" data-transition="pt-page-moveFromLeft-init" style="margin-bottom: 4px; margin-left: 10px;">
  846. <span class="glyph-icon icon-separator" style="transform: rotateY(-180deg);">
  847. <i class="glyph-icon icon-level-up"></i>
  848. </span>
  849. <span class="button-content">
  850. 返回
  851. </span>
  852. </a>
  853. <div class="row" style="margin-top: 10px;">
  854. <div class="col-xs-4">
  855. <div style="background: #F5f6FA; border: 1px solid #e1e6eb; padding: 10px; font-size: 14px; width: 100%;">
  856. <span>
  857. {{ host_ret.data.hostname }}
  858. </span>
  859. </div>
  860. <table class="table table-bordered">
  861. <tbody>
  862. <tr>
  863. <td>
  864. <span class="guest-label">NODE ID:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  865. <span class="guest-desc">
  866. {{ host_ret.data.node_id }}
  867. </span>
  868. </td>
  869. </tr>
  870. <tr>
  871. <td style="padding: 0;">
  872. <table style="width: 100%;">
  873. <tr>
  874. <td>
  875. <span class="guest-label">节点健康状况:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  876. <span class="guest-desc">
  877. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  878. </span>
  879. </td>
  880. <td>
  881. <span class="guest-label">节点性能收集引擎:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  882. <span class="guest-desc">
  883. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.host_performance_collection_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  884. </span>
  885. </td>
  886. </tr>
  887. <tr>
  888. <td>
  889. <span class="guest-label">状态汇送引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  890. <span class="guest-desc">
  891. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.host_state_report_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  892. </span>
  893. </td>
  894. <td>
  895. <span class="guest-label">虚拟机性能收集引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  896. <span class="guest-desc">
  897. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.guest_performance_collection_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  898. </span>
  899. </td>
  900. </tr>
  901. <tr>
  902. <td>
  903. <span class="guest-label">指令处理引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  904. <span class="guest-desc">
  905. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.instruction_process_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  906. </span>
  907. </td>
  908. <td>
  909. <span class="guest-label">虚拟机创建进度引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  910. <span class="guest-desc">
  911. <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.guest_creating_progress_report_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
  912. </span>
  913. </td>
  914. </tr>
  915. </table>
  916. </td>
  917. </tr>
  918. <tr>
  919. <td>
  920. <span class="guest-label">CPU:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  921. <span class="guest-desc">
  922. {{ host_ret.data.cpu }} 核
  923. </span>
  924. </td>
  925. </tr>
  926. <tr>
  927. <td>
  928. <span class="guest-label">内存:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  929. <span class="guest-desc">
  930. {{ (host_ret.data.memory / 1024 / 1024 / 1024)|int }} GB
  931. </span>
  932. </td>
  933. </tr>
  934. {% for nic_name, nic in host_ret.data.interfaces.iteritems() %}
  935. <tr>
  936. <td style="padding: 0;">
  937. <table style="width: 100%;">
  938. <tr class="guest-label"><th>网络接口</th><th width="30%">IP</th><th width="30%">MAC</th></tr>
  939. <tr><th>{{ nic_name }}</th><th>{{ nic.ip }}</th><th>{{ nic.mac }}</th></tr>
  940. </table>
  941. </td>
  942. </tr>
  943. {% endfor %}
  944. {% for mountpoint, disk in host_ret.data.disks.iteritems() %}
  945. <tr>
  946. <td style="padding: 0;">
  947. <table style="width: 100%;">
  948. <tr class="guest-label"><th>挂载点</th><th width="20%">设备路径</th><th width="20%">磁盘大小</th><th width="20%">使用率</th></tr>
  949. <tr class="guest-desc"><th>{{ mountpoint }}</th><th>{{ disk.device }}</th><th>{{ (disk.total / 1024 / 1024 / 1024) | int }} GB</th><th>{{ disk.percent }}</th></tr>
  950. </table>
  951. </td>
  952. </tr>
  953. {% endfor %}
  954. <tr>
  955. <td>
  956. <span class="guest-label">启动时间:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  957. <span class="guest-desc">
  958. {{ format_datetime_by_tus(host_ret.data.boot_time * 1000 * 1000) }}
  959. </span>
  960. </td>
  961. </tr>
  962. <tr>
  963. <td>
  964. <span class="guest-label">更新时间:&nbsp;&nbsp;&nbsp;&nbsp;</span>
  965. <span class="guest-desc">
  966. {{ format_datetime_by_tus(host_ret.data.timestamp * 1000 * 1000) }}
  967. </span>
  968. </td>
  969. </tr>
  970. </tbody>
  971. </table>
  972. </div>
  973. <div class="col-xs-8">
  974. <div class="row" style="margin-bottom: 20px;">
  975. <div class="col-xs-8"></div>
  976. <div class="col-xs-4">
  977. <div class="btn-group btn-group-justified btn-group-xs">
  978. <a class="btn btn-default" role="button" onclick="refresh_render_with_specify_granularity('hour');">1小时</a>
  979. <a class="btn btn-default" role="button" onclick="refresh_render_with_specify_granularity('six_hours');">6小时</a>
  980. <a class="btn btn-default" role="button" onclick="refresh_render_with_specify_granularity('day');">1天</a>
  981. <a class="btn btn-default" role="button" onclick="refresh_render_with_specify_granularity('seven_days');">7天</a>
  982. </div>
  983. </div>
  984. </div>
  985. <div>
  986. <div id="cpu_chart" style="width: 800px;height:280px;"></div>
  987. <div id="memory_chart" style="width: 800px;height:280px;"></div>
  988. </div>
  989. <div id="traffics_chart"></div>
  990. <div id="disks_chart"></div>
  991. </div>
  992. </div>
  993. </div>
  994. </div>
  995. </div>
  996. {% endblock body %}