PageSourceSearch

https://www.damodel.com/3.8.18/MonitorSystem-DvQanYXa.js

js damodel.com collected 2026-10-06 03:05:29 UTC 28,456 bytes, 1 lines download raw bytes

1import{r as e,p as t,j as s,a0 as a,am as n,an as r,v as i,S as l,aE as o,ai as c,R as d,aq as p,b0 as u,F as x,w as m,a9 as g,bk as h}from"./vendor-ic2EBoqS.js";import{E as f}from"./echarts-BYvPqWVN.js";import{d as y,e as b,c as v,f as _}from"./instance-apis-D516cLuV.js";import{F as j}from"./FormTimePicker-BExNJHxA.js";import{P as w}from"./PageHeader-BNLY62aG.js";import{M as S}from"./MonitorChart-1kHRPjIW.js";import{e as $,v as k,D as N,W as M,C as E}from"./index-DFEDUUSj.js";import{F as A}from"./TimeUtils-Cxh6byDf.js";import{S as T,a as F,D as R,b as C,C as P,t as L,f as W,g as z,c as G,d as I,e as O,h as D,i as B,j as H}from"./ServiceMonitorMetricCharts-DyYaoMMJ.js";import{Q as Y}from"./image-apis-9uWh2RmQ.js";import{b as U}from"./file-storage-apis-CddwGFPV.js";import"./zrender-zsY48kmo.js";import"./FormatUtils-Bu6RTZwc.js";import"./axios-BrNB3knv.js";const q=["primary","blue","purple","warning_extend_2","primary_extend_5","danger","text_extend_1","primary_extend_6","blue_extend_2"],K=e=>{const t=(e.values||[]).filter((e=>e&&Number.isFinite(e.timestamp))).sort(((e,t)=>e.timestamp-t.timestamp));return{...e,values:t}},Q=async(e,t,s)=>{const a={};for(let n=0;n<e.length;n+=F){const r=e.slice(n,n+F),i=await Promise.allSettled(r.map((e=>y({end_time:s,interval:"",metric_name:e.metricName,quantile:"histogram"===(null==e?void 0:e.metricType)?e.quantile||R:"",start_time:t}))));r.forEach(((e,t)=>{var s,n;const r=i[t],l="fulfilled"===r.status&&(null==(n=null==(s=r.value)?void 0:s.result)?void 0:n.jobs)||[];a[e.metricName]=l.map(K).filter((e=>e.job&&e.values.length>0))}))}return a},V=({monitorType:o,timeRange:c,refreshSignal:d=0})=>{const p=$(k),u=N(p),x=C[o],m=e.useMemo((()=>T[o]||[]),[o]),{data:g={},run:h,loading:y}=t(Q,{manual:!0,defaultParams:[m,0,0],debounceWait:300}),b=e.useCallback(((e,t)=>{if(!(null==e?void 0:e.length)||!t)return;const[s,a]=t;s&&a&&h(e,s,a)}),[h]);e.useEffect((()=>{b(m,c)}),[b,d,m,c]);const v=e.useRef({}),_=e.useCallback(((e,t)=>{t&&(v.current[e]=t)}),[]),j=e.useRef({});e.useEffect((()=>{j.current={}}),[g]);const w=e.useCallback(((e,t)=>{const s=null==t?void 0:t.name;if(!s)return;const a=g[e]||[],n=j.current[e]===s,r=a.reduce(((e,t)=>(e[t.job]=n||t.job===s,e)),{});n?delete j.current[e]:j.current[e]=s;const i=v.current[e];i&&i.setOption({legend:{selected:r}})}),[g]),S=e.useMemo((()=>m.reduce(((e,t)=>(e[t.metricName]={legendselectchanged:e=>w(t.metricName,e)},e)),{})),[w,m]),M=(e,t)=>{const s=new Set;e.forEach((e=>e.values.forEach((e=>s.add(e.timestamp)))));const a=Array.from(s).sort(((e,t)=>e-t)),n=a[0]||0,r=a[a.length-1]||0,i=n&&r&&r>n?r-n:0,l=q.map((e=>u[e])).filter(Boolean);0===l.length&&l.push(u.primary);const o=e.map(((e,t)=>{const s=l[t%l.length],n=new Map;return e.values.forEach((e=>n.set(e.timestamp,e.value))),{name:e.job,type:"line",smooth:!1,connectNulls:!1,lineStyle:{color:s,width:2},itemStyle:{color:s},symbol:"circle",symbolSize:4,areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:L(s,"dark"===p?.28:.18)},{offset:1,color:L(s,"dark"===p?.06:.02)}],global:!1}},data:a.map((e=>{const t=n.get(e);return void 0===t?null:t}))}}));return{color:l,tooltip:{trigger:"axis",confine:!0,backgroundColor:u.bg,textStyle:{color:u.text},formatter(e){if(!Array.isArray(e)||0===e.length)return"";const[s]=e,a=A(Number(s.name)),n=e.map((e=>{const{value:s}=e,a=e.seriesName.length>26?"margin-right:8px;display:inline-block;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom;":"margin-right:8px;",n=null==s?"--":W(Number(s),t.unit);return`<p style="margin:0;">\n\t\t\t\t\t\t\t\t${e.marker}\n\t\t\t\t\t\t\t\t<span style="${a}">${J(e.seriesName)}</span>\n\t\t\t\t\t\t\t\t<span style="float:right;">${n}</span>\n\t\t\t\t\t\t\t</p>`})).join("");return`<p style="margin-bottom:4px;font-weight:600;">${t.title}</p>\n\t\t\t\t\t\t<p style="margin:0 0 6px;color:${u.text_extend_2};">${a}</p>\n\t\t\t\t\t\t<div>${n}</div>`}},legend:{type:"plain",bottom:0,icon:"roundRect",textStyle:{color:u.text_extend_1},inactiveColor:u.text_extend_2,pageTextStyle:{color:u.text_extend_2}}
1,grid:{right:8,left:8,top:16,bottom:40,containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:a,axisLabel:{show:!0,interval:z(a.length),hideOverlap:!0,margin:12,color:u.text_extend_2,formatter:e=>G(Number(e),i)},axisTick:{show:!1},axisLine:{lineStyle:{color:u.split}}},yAxis:{type:"value",min:0,..."percent"===t.unit?{max:100}:{},axisLabel:{formatter:e=>W(e,t.unit),color:u.text_extend_2},splitLine:{lineStyle:{color:u.split,type:[4,3],dashOffset:5}}},series:o}},E=(e,t)=>y?s.jsx("div",{className:"flex items-center justify-center",style:{height:P},children:s.jsx(l,{})}):0===t.length?s.jsx("div",{className:"flex items-center justify-center",style:{height:P},children:s.jsx(a,{description:"暂无监控数据",image:a.PRESENTED_IMAGE_SIMPLE})}):s.jsx(f,{option:M(t,e),notMerge:!0,style:{height:P},onChartReady:t=>_(e.metricName,t),onEvents:S[e.metricName]});return 0===m.length?s.jsx("div",{className:"mt-6 flex h-48 items-center justify-center",children:s.jsx(a,{description:`暂不支持${x}服务监控类型`})}):s.jsx(n,{gutter:[16,16],children:m.map((e=>{const t=g[e.metricName]||[];return s.jsx(r,{lg:12,md:24,sm:24,xs:24,children:s.jsxs(i,{title:e.title,extra:s.jsxs("span",{className:"text-sm font-semibold text-font-extend-2",children:[t.length," 个服务"]}),children:[s.jsx("div",{className:"pb-1 pt-1 text-center text-xs text-font-extend-2",children:e.metricName}),E(e,t)]})},e.metricName)}))})},J=e=>(e||"--").replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll(/'/g,"&#039;"),X="/api/monitor",Z=e=>M({url:`${X}/image_usage`,method:"GET",data:e,silentError:!0}),ee=e=>M({url:`${X}/storage_usage`,method:"GET",data:e,silentError:!0}),te=async()=>{var e,t,s;const a=await U();return{total_usage:(null==(e=null==a?void 0:a.result)?void 0:e.total_usage)||0,peek_usage_today:(null==(t=null==a?void 0:a.result)?void 0:t.peek_usage_today)||0,expected_deduction:(null==(s=null==a?void 0:a.result)?void 0:s.expected_deduction)||0}},se=async()=>{var e,t,s;const a=await Y();return{used_space:((null==(e=null==a?void 0:a.result)?void 0:e.used_space)||0)/1024,peek_space:((null==(t=null==a?void 0:a.result)?void 0:t.peek_space)||0)/1024,pay_cost:(null==(s=null==a?void 0:a.result)?void 0:s.pay_cost)||0}},ae=(e,t)=>{if(Number.isFinite(e.value))return Number(e.value);if("storage"===t){if(Number.isFinite(e.storage_used_space))return Number(e.storage_used_space);if(Number.isFinite(e.net_disk_used_space))return Number(e.net_disk_used_space)}return Number.isFinite(e.image_used_space)?Number(e.image_used_space):Number.isFinite(e.total_used_space)?Number(e.total_used_space):0},ne=e=>e.hour_str?e.hour_str:e.timestamp?A(e.timestamp,"YYYY/MM/DD HH:mm:ss"):"--",re=async(e,t,s)=>{const a="storage"===e?ee:Z,n=await a({start_time:t,end_time:s});return((e,t)=>e?Array.isArray(e)?e.map((e=>({label:ne(e),value:ae(e,t)}))):Array.isArray(e.values)?e.values.map((e=>({label:A(e.timestamp,"YYYY/MM/DD HH:mm:ss"),value:Number.isFinite(e.value)?Number(e.value):0}))):Object.values(e).filter((e=>Boolean(e)&&!Array.isArray(e))).map((e=>({label:ne(e),value:ae(e,t)}))):[])(null==n?void 0:n.result,e)},ie=({type:c,timeRange:d,refreshSignal:p})=>{const u=$(k),x=N(u),m="storage"===c,g=m?"存储用量":"镜像用量",h=m?"文件存储使用量趋势":"镜像使用量趋势",y=m?x.blue:x.primary,{data:b={total_usage:0,peek_usage_today:0,expected_deduction:0},loading:v,run:_}=t(te,{manual:!m,ready:m}),{data:j={used_space:0,peek_space:0,pay_cost:0},loading:w,run:S}=t(se,{manual:m,ready:!m}),{data:M=[],loading:A,run:T}=t(re,{manual:!0}),F=e=>{const t=e.map((e=>e.label)),s=e.map((e=>e.value));return{color:[y],tooltip:{trigger:"axis",formatter(e){const[t]=Array.isArray(e)?e:[e];if(!t)return"";const s=Number(t.value),a=Number.isFinite(s)?s.toFixed(2):"0.00";return`<p class="mb-2">${t.name}</p>\n\t\t\t\t\t\t<p class="mb-1 flex justify-between items-center"><span class="mr-10">${t.marker}${t.seriesName}</span><span>${a} GB</span></p>`},backgroundColor:x.bg,textStyle:{color:x.text}},grid:{right:4,left:0,top:32,bottom:16,containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:t,axisLabel:{show:!0,hideOverlap:!0,margin:12,color:x.text_extend_2},axisTick:{show:!1}
1,axisLine:{lineStyle:{color:x.split}}},yAxis:{type:"value",axisLabel:{formatter:"{value} G",color:x.text_extend_2},splitLine:{lineStyle:{color:x.split,type:[4,3],dashOffset:5}}},series:[{name:m?"文件存储":"镜像",type:"line",smooth:!0,symbol:"circle",symbolSize:4,lineStyle:{width:2},itemStyle:{color:y},areaStyle:(a=y,n=u,{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:a},{offset:1,color:"light"===n?"#ffffff":"rgba(0,0,0,0)"}],global:!1},opacity:"light"===n?.8:.12}),data:s}]};var a,n};return e.useEffect((()=>{if(!d)return;const[e,t]=d;e&&t&&T(c,e,t)}),[T,d,c]),e.useEffect((()=>{p<=0||(m?_():S())}),[m,S,p,_]),m?s.jsxs(i,{title:g,children:[s.jsx(l,{spinning:v,children:s.jsxs(n,{gutter:[16,16],children:[s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"文件存储总使用量",value:b.total_usage.toFixed(2),valueStyle:{fontWeight:600},suffix:s.jsx("span",{className:"text-sm font-normal",children:"GB"})})}),s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"今日峰值使用量",value:b.peek_usage_today.toFixed(2),valueStyle:{fontWeight:600},suffix:s.jsx("span",{className:"text-sm font-normal",children:"GB"})})}),s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"预计扣费",value:b.expected_deduction.toFixed(2),valueStyle:{fontWeight:600},prefix:s.jsx(E,{name:"dollor-unit",size:14,className:"align-[initial]"})})})]})}),s.jsx("p",{className:"text-font-extend-2 text-xs mt-8 mb-3",children:h}),s.jsx(l,{spinning:A,children:s.jsx("div",{className:"w-full h-80",children:M.length>0?s.jsx(f,{option:F(M)}):s.jsx(a,{className:"flex h-full flex-col items-center justify-center",description:"暂无用量数据",image:a.PRESENTED_IMAGE_SIMPLE})})})]}):s.jsxs(i,{title:g,children:[s.jsx(l,{spinning:w,children:s.jsxs(n,{gutter:[16,16],children:[s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"镜像总使用量",value:j.used_space.toFixed(2),valueStyle:{fontWeight:600},suffix:s.jsx("span",{className:"text-sm font-normal",children:"GB"})})}),s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"今日峰值使用量",value:j.peek_space.toFixed(2),valueStyle:{fontWeight:600},suffix:s.jsx("span",{className:"text-sm font-normal",children:"GB"})})}),s.jsx(r,{xs:24,sm:12,lg:8,children:s.jsx(o,{title:"预计扣费",value:j.pay_cost.toFixed(2),valueStyle:{fontWeight:600},prefix:s.jsx(E,{name:"dollor-unit",size:14,className:"align-[initial]"})})})]})}),s.jsx("p",{className:"text-font-extend-2 text-xs mt-8 mb-3",children:h}),s.jsx(l,{spinning:A,children:s.jsx("div",{className:"w-full h-80",children:M.length>0?s.jsx(f,{option:F(M)}):s.jsx(a,{className:"flex h-full flex-col items-center justify-center",description:"暂无用量数据",image:a.PRESENTED_IMAGE_SIMPLE})})})]})},le="global",oe="global-storage-usage",ce="global-image-usage",de="instance:",pe="service:",ue="namespace-service:",xe={dot:"#52c41a",text:"采集中"},me={dot:"#52c41a",text:"运行中"},ge=[{value:.5,label:"近半小时"},{value:1,label:"近1小时"},{value:6,label:"近6小时"},{value:24,label:"近1日"}],he=[{resourceType:"gpu_compute_usage",title:"GPU利用率",colorKey:"primary"},{resourceType:"gpu_mem_usage",title:"GPU显存利用率",colorKey:"blue"},{resourceType:"cpu_usage",title:"CPU使用率",colorKey:"purple"},{resourceType:"mem_usage",title:"内存使用率",colorKey:"warning_extend_2"}],fe=he.map((e=>e.resourceType)),ye=e=>`${(e=>Number.isFinite(e)?Number.isInteger(e)?`${e}`:Math.abs(e)>=100?e.toFixed(0):Math.abs(e)>=10?e.toFixed(1):e.toFixed(2):"--")(e)} %`,be=e=>(e||"--").replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll(/'/g,"&#039;"),ve=(e,t)=>
1`/console/instance/details?uid=${encodeURIComponent(e)}&type=${t}`,_e=e=>`${pe}${B(e)}`,je=e=>e.instance_uid||e.exported_pod.split("-")[0]||e.exported_pod,we=e=>e.instance_alias||je(e),Se={dot:"#52c41a",text:"#237804"},$e={dot:"#ff4d4f",text:"#cf1322"},ke={dot:"#faad14",text:"#ad6800"},Ne={dot:"#fa8c16",text:"#ad4e00"},Me={dot:"#8c8c8c",text:"#595959"},Ee=e=>{const t=(e||"").toLowerCase();return/(running|active|succeed|succeeded|ready|ok|up)/.test(t)?Se:/(released|terminated|expired)/.test(t)||!e?Ne:/(fail|error|err|down|dead|crash|lost)/.test(t)?$e:/(pend|wait|init|creat|build|start)/.test(t)?ke:Me},Ae=async(e,t,s)=>{const a=await Promise.allSettled(e.map((e=>b({end_time:s,resource_type:e,start_time:t}))));return e.reduce(((e,t,s)=>{var n,r;const i=a[s],l="fulfilled"===i.status&&(null==(r=null==(n=i.value)?void 0:n.result)?void 0:r.pods)||[];return e[t]=(e=>e.map((e=>({...e,values:(e.values||[]).filter((e=>Number.isFinite(e.timestamp)&&Number.isFinite(e.value))).sort(((e,t)=>e.timestamp-t.timestamp))}))).filter((e=>e.exported_pod&&e.values.length>0)))(l),e}),{})},Te=async()=>{var e;const t=await v({page:1,page_size:1e3});return(null==(e=null==t?void 0:t.result)?void 0:e.data)||[]},Fe=async()=>{const e=await _();return(null==e?void 0:e.result)||[]},Re=e=>e.instance_alias||e.instance_uid,Ce=e=>{switch(e){case"Running":return{dot:"#52c41a",text:"运行中"};case"Creating":return{dot:"#1677ff",text:"创建中"};case"Pending":return{dot:"#1677ff",text:"启动中"};case"Changing":return{dot:"#faad14",text:"变更中"};case"StoppedForNonPayment":return{dot:"#ff4d4f",text:"已欠费"};case"Stopped":return{dot:"#8c8c8c",text:"已停止"};case"Released":case"Terminated":return{dot:"#fa8c16",text:"已释放"};case"Failed":case"Succeeded":case"Unknown":return{dot:"#ff4d4f",text:"异常"};default:return{dot:"#8c8c8c",text:"未知"}}},Pe=()=>{const l=$(k),o=N(l),[y]=c.useForm(),[b,v]=d.useState(1),[_,M]=d.useState(0),[E,T]=d.useState(0),[F,R]=d.useState(le),[P,L]=d.useState(0),[W,z]=d.useState(0),[G,Y]=d.useState(0),[U,q]=d.useState(0),{data:K=[]}=t(Te),{data:Q=[]}=t(Fe),J=e.useMemo((()=>new Map(K.map((e=>[e.instance_uid,e])))),[K]),X=e.useMemo((()=>Q.filter((e=>I.includes(e.monitor_type)&&O(e)))),[Q]),Z=F.startsWith(de)?F.slice(9):void 0,ee=X.find((e=>_e(e)===F)),te=F===le,se=(ae=F)===oe?"storage":ae===ce?"image":void 0;var ae;const ne=F.startsWith(ue)?F.slice(18):void 0;e.useEffect((()=>{F.startsWith(pe)&&!X.some((e=>_e(e)===F))&&R(le)}),[F,X]);const re=d.useRef({}),Se=e.useCallback(((e,t)=>{t&&(re.current[e]=t)}),[]),$e=c.useWatch("timeRanger",y),{data:ke={},run:Ne,loading:Me}=t(Ae,{manual:!0,defaultParams:[fe,0,0],debounceWait:300}),Pe=d.useRef(ke);Pe.current=ke;const Le=d.useRef({});e.useEffect((()=>{Le.current={}}),[ke]);const We=e.useCallback(((e,t)=>{const s=null==t?void 0:t.name;if(!s)return;const a=Pe.current[e]||[],n=Le.current[e]===s,r=a.reduce(((e,t)=>{const a=we(t);return e[a]=n||a===s,e}),{});n?delete Le.current[e]:Le.current[e]=s;const i=re.current[e];i&&i.setOption({legend:{selected:r}})}),[]),ze=d.useMemo((()=>fe.reduce(((e,t)=>(e[t]={legendselectchanged:e=>We(t,e)},e)),{})),[We]),Ge=e.useCallback((e=>{if(!e)return;const[t,s]=e;t&&s&&Ne(fe,t,s)}),[Ne]);e.useEffect((()=>{Ge($e)}),[Ge,$e]),e.useEffect((()=>{if(E<=0)return;const e=window.setTimeout((()=>{T((e=>e-1))}),1e3);return()=>{window.clearTimeout(e)}}),[E]);const Ie=(e,t)=>{const s=(e=>{const t=new Set;return e.forEach((e=>{e.values.forEach((e=>{t.add(e.timestamp)}))})),Array.from(t).sort(((e,t)=>e-t))})(e),a=s[0]||0,n=s[s.length-1]||0,r=a&&n&&n>a?n-a:0,i=e=>{if(!e){const{dot:e,text:t}=Ee(void 0);return`<span style="display:inline-flex; align-items:center; gap:4px; padding:1px 7px; border-radius:9px; background:${e}1a; color:${t}; font-size:12px; line-height:18px; white-space:nowrap;">\n\t\t\t\t\t<span style="display:inline-block; width:6px; height:6px; border-radius:50%; background:${e};"></span>已释放\n\t\t\t\t</span>`}const{dot:t,text:s}=Ee(e);return`<span style="display:inline-flex; align-items:center; gap:4px; padding:1px 7px; border-radius:9px; background:${t}1a; color:${s}; font-size:12px; line-height:18px; white-space:nowrap;">\n\t\t\t\t<span style="display:inline-block; width:6px; height:6px; border-radius:50%; background:${t};"></span>${be(e)}\n\t\t\t</span>`},c=[t,o.blue,o.purple,o.warning_extend_2,o.primary_extend_5,o.danger,o.text_extend_1,o.primary_extend_6].filter(
1Boolean);return{color:c,tooltip:{trigger:"axis",confine:!0,enterable:!0,hideDelay:200,padding:[10,12],axisPointer:{type:"line",axis:"x",lineStyle:{color:o.primary,type:"dashed"}},backgroundColor:o.bg,textStyle:{color:o.text},formatter(t){const a=Array.isArray(t)?t:[t];if(0===a.length)return"";const[n]=a,{dataIndex:r}=n,l=s[r]||0,c=a.map((t=>{const{seriesIndex:s,value:a,marker:n}=t,r=e[s];if(!r)return"";const l=Number(a),c=null!==a&&Number.isFinite(l),d=we(r),p=c?ye(l):"--";return`<span style="display:inline-flex; flex-shrink:0;">${n}</span>\n\t\t\t\t\t\t\t\t<span style="max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">${be(d)}</span>\n\t\t\t\t\t\t\t\t<span style="display:inline-flex; align-items:center; justify-self:start;">${i(r.instance_status)}</span>\n\t\t\t\t\t\t\t\t<span style="justify-self:end; color:${c?o.text:o.text_extend_2}; font-variant-numeric:tabular-nums;">${p}</span>`})).filter(Boolean);return 0===c.length?"":`<div style="user-select:text; -webkit-user-select:text;">\n\t\t\t\t\t\t<div style="margin-bottom:8px; padding-bottom:6px; border-bottom:1px solid ${o.split}; font-size:13px; color:${o.text_extend_2};">${A(l)}</div>\n\t\t\t\t\t\t<div style="display:grid; grid-template-columns:14px fit-content(260px) max-content max-content; align-items:center; column-gap:4px; row-gap:2px; line-height:22px;">${c.join("")}</div>\n\t\t\t\t\t</div>`}},legend:{type:"plain",orient:"horizontal",bottom:0,left:"center",itemGap:12,tooltip:{show:!0,enterable:!0,hideDelay:300,padding:[10,12],confine:!0,formatter(t){const s=e.findIndex((e=>we(e)===t.name));return((e,t,s)=>{if(!e)return"";const a=je(e),n=s?`<span style="display:inline-block; width:9px; height:9px; border-radius:50%; background:${s}; margin-right:8px; vertical-align:middle;"></span>`:"",r=ve(a,"details"),c=ve(a,"monitor"),d=!e.instance_status,p="dark"===l?o.primary_text:o.primary,u=d?`padding: 4px 10px; color: ${o.text_extend_2}; cursor: not-allowed; pointer-events: none; opacity: 0.5;`:`padding: 4px 10px; color: ${p};`,x=d?`padding: 4px 10px; color: ${o.text_extend_2}; background: ${o.split}; border-radius: 4px; cursor: not-allowed; pointer-events: none; opacity: 0.5;`:`padding: 4px 10px; color: #fff; background: ${o.primary}; border-radius: 4px;`,m=d?`<span style="${u}">实例详情</span>`:`<a ${d?"":`href="${r}" target="_blank" rel="noopener noreferrer"`} style="${u}">实例详情</a>`,g=d?`<span style="${x}">主机监控</span>`:`<a ${d?"":`href="${c}" target="_blank" rel="noopener noreferrer"`} style="${x}">主机监控</a>`;return`<div style="min-width: 280px; user-select:text; -webkit-user-select:text;">\n\t\t\t\t\t<div style="margin-bottom: 10px; font-size: 15px; font-weight: 600;">${n}${be(a)}</div>\n\t\t\t\t\t<div style="display: grid; grid-template-columns: 64px 1fr; gap: 6px 12px; line-height: 22px;">\n\t\t\t\t\t\t<span style="color: ${o.text_extend_2};">实例名</span>\n\t\t\t\t\t\t<span>${be(e.instance_alias)}</span>\n\t\t\t\t\t\t<span style="color: ${o.text_extend_2};">状态</span>\n\t\t\t\t\t\t<span style="display:inline-flex; align-items:center;">${i(e.instance_status)}</span>\n\t\t\t\t\t\t<span style="color: ${o.text_extend_2};">Pod</span>\n\t\t\t\t\t\t<span>${be(e.exported_pod)}</span>\n\t\t\t\t\t\t\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style="display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid ${o.split};">\n\t\t\t\t\t\t${m}\n\t\t\t\t\t\t${g}\n\t\t\t\t\t</div>\n\t\t\t\t</div>`})(e[s],0,c[s%c.length])},backgroundColor:o.bg,textStyle:{color:o.text}},formatter:e=>e.length>22?`${e.slice(0,19)}...`:e,textStyle:{color:o.text_extend_2}},grid:{right:16,left:8,top:16,bottom:88,containLabel:!0},xAxis:{type:"category",data:s,axisLabel:{show:!0,interval:(d=s.length,d<=5?0:Math.ceil(d/5)-1),hideOverlap:!0,margin:12,color:o.text_extend_2,formatter:e=>((e,t)=>e?t<=86400?h(1e3*e).format("HH:mm"):t<=604800?h(1e3*e).format("MM-DD HH:mm"):h(1e3*e).format("MM-DD"):"")(Number(e),r)},axisTick:{show:!1},axisLine:{lineStyle:{color:o.split}}},yAxis:{type:"value",min:0,max:100,axisLabel:{formatter:e=>ye(e),color:o.text_extend_2},splitLine:{lineStyle:{color:o.split,type:[4,3],dashOffset:5}}},series:e.map(((e,a)=>{const n=new Map(e.values.map((e=>[e.timestamp,e.value]))),r=c[a%c.length]||t;return{name:we(e),type:"line",lineStyle:{color:r,width:2},itemStyle:{color:r},symbol:"circle",symbolSize:4,connectNulls:!1,data:s.map((e=>n.get(e)??null))}}))};var d},Oe=d.useMemo((()=>{const e={};return he.forEach((t=>{const s=ke[t.resourceType]||[];if(0===s.length)return;const a=o[t.colorKey]||o.primary;e[t.resourceType]=Ie(s,a)})),e}),[ke,l]);return s.jsx(s.Fragment,{children:s.jsx(p,{type:["right","left"],ease:["easeOutQuart","easeInOutQuart"],children:s.jsxs("div",{className:"min-w-[420px] sm:min-w-0",children:[s.jsx(w,{content:"监控系统"}),s.jsxs("div",{className:"mb-4 grid grid-cols-1 items-center gap-2 lg:grid-cols-[280px_minmax(0,1fr)]",children:[s.jsx(u,{showSearch:!0,allowClear:!0,placeholder:"选择监控对象",value:F,onChange:e=>R(e||le),className:"h-9 w-full [&_.ant-select-selection-item]:!leading-[36px] [&_.ant-select-selection-
1placeholder]:!leading-[36px] [&_.ant-select-selector]:!h-9",optionFilterProp:"searchText",options:[{label:"全局视图",options:[{label:"全局(全部实例)",value:le,searchText:"全局 全部实例",monitorMode:"global"},{label:"存储用量",value:oe,searchText:"全局 存储用量 文件存储 storage",monitorMode:"storage-usage"},{label:"镜像用量",value:ce,searchText:"全局 镜像用量 image",monitorMode:"storage-usage"}]},...(()=>{const e=I.filter((e=>X.some((t=>t.monitor_type===e))));return 0===e.length?[]:[{label:"服务监控总览",options:e.map((e=>({label:`${C[e]}(全部服务)`,value:`${ue}${e}`,searchText:`服务监控总览 ${e} ${C[e]} 全部服务 namespace`,monitorType:e,monitorMode:"namespace-service"})))}]})(),{label:"实例主机监控",options:K.map((e=>{return{label:Re(e),value:(t=e.instance_uid,`${de}${t}`),searchText:`${Re(e)} ${e.instance_uid}`,status:e.status,monitorMode:"instance"};var t}))},...I.map((e=>{const t=X.filter((t=>t.monitor_type===e));return{label:`服务监控 ${e}`,options:t.map((e=>{const t=J.get(e.instance_uid),s=O(e),a=D(e),n=t?Re(t):e.instance_uid;return{label:a,value:_e(e),searchText:`${a} ${s} ${n} ${e.instance_uid}`,instanceName:n,monitor:e,monitorMode:"service"}}))}})).filter((e=>e.options.length>0))],optionRender:e=>{if("global"===e.data.monitorMode){const{dot:t,text:a}=me;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t,flexShrink:0}}),s.jsx("span",{style:{flex:1,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),s.jsx("span",{style:{width:48,color:t,fontSize:12,flexShrink:0,textAlign:"right"},children:a})]})}
1if("storage-usage"===e.data.monitorMode){const{dot:t,text:a}=me;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t,flexShrink:0}}),s.jsx("span",{style:{flex:1,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),s.jsx("span",{style:{width:48,color:t,fontSize:12,flexShrink:0,textAlign:"right"},children:a})]})}if("namespace-service"===e.data.monitorMode){const{dot:t,text:a}=xe;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t,flexShrink:0}}),s.jsx("span",{style:{flex:1,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),s.jsx("span",{style:{width:48,color:t,fontSize:12,flexShrink:0,textAlign:"right"},children:a})]})}if("service"===e.data.monitorMode){const{dot:t,text:a}=xe;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t,flexShrink:0}}),s.jsx("span",{style:{maxWidth:112,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0},children:e.label}),s.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:o.text_extend_2,fontSize:12,flex:1},children:e.data.instanceName}),s.jsx("span",{style:{width:48,color:t,fontSize:12,flexShrink:0,textAlign:"right"},children:a})]})}const{dot:t,text:a}=Ce(e.data.status);return s.jsxs(x,{align:"center",gap:8,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t,flexShrink:0}}),s.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:e.label}),s.jsx("span",{style:{width:48,color:t,fontSize:12,flexShrink:0,textAlign:"right"},children:a})]})},labelRender:e=>{if(e.value===le||void 0===e.value)return s.jsx("span",{children:"全局(全部实例)"});if(e.value===oe)return s.jsx("span",{children:"存储用量"});if(e.value===ce)return s.jsx("span",{children:"镜像用量"});if(String(e.value).startsWith(ue)){const{dot:t}=xe;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:t}}),s.jsx("span",{children:e.label})]})}if(String(e.value).startsWith(pe)){const t=X.find((t=>_e(t)===e.value)),{dot:a}=xe;return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:a}}),s.jsx("span",{children:t?D(t):e.label})]})}const t=String(e.value).slice(9),a=J.get(t),{dot:n}=Ce(null==a?void 0:a.status);return s.jsxs(x,{align:"center",gap:6,children:[s.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:n}}),s.jsx("span",{children:a?Re(a):e.label})]})}}),s.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-5",children:[s.jsx(c,{form:y,className:"min-w-0 flex-1",children:s.jsx(c.Item,{name:"timeRanger",className:"mb-0",children:s.jsx(j,{initialValue:b,options:ge,allowClear:!1},_)})}),s.jsx(m,{loading:!se&&te&&Me,disabled:E>0,onClick:()=>{if(E>0)return;const[e,t]=$e||[];if(!e||!t)return;const s=(t-e)/3600;s<=0||(T(5),se?(q((e=>e+1)),v(s),M((e=>e+1))):Z?L((e=>e+1)):ee?z((e=>e+1)):ne?Y((e=>e+1)):(v(s),M((e=>e+1))))},className:"h-9 min-w-[104px] shrink-0 self-center px-4",children:E>0?`${E}s后刷新`:"刷新"})]})]}),(()=>{if(se)return s.jsx(ie,{type:se,timeRange:$e,refreshSignal:U},se);if(Z)return s.jsx(S,{instanceId:Z,hideToolbar:!0,timeRange:$e,refreshSignal:P});if(ee){const e=J.get(ee.instance_uid);return s.jsxs(s.Fragment,{children:[s.jsxs(x,{align:"center",gap:8,wrap:"wrap",className:"mb-4",children:[s.jsx(g,{bordered:!1,children:C[ee.monitor_type]}),s.jsx("span",{className:"text-sm font-semibold text-font-extend-1",children:O(ee)}),s.jsxs("span",{className:"text-xs text-font-extend-2",children:["实例:",e?Re(e):ee.instance_uid]})]}),s.jsx(H,{instanceId:ee.instance_uid,monitor:ee,timeRange:$e,refreshSignal:W},B(ee))]})}return ne?s.jsxs(s.Fragment,{children:[s.jsxs(x,{align:"center",gap:8,wrap:"wrap",className:"mb-4",children:[s.jsx(g,{bordered:!1,children:C[ne]}),s.jsx("span",{className:"text-sm font-semibold text-font-extend-1",children:"全部服务(namespace 总览)"}),s.jsx("span",{className:"text-xs text-font-extend-2",children:"按服务(job)聚合, 点击图例可切换单个/全部服务"})]}),s.jsx(V,{monitorType:ne,timeRange:$e,refreshSignal:G},ne)]}):s.jsx(n,{gutter:[16,16],children:he.map((e=>{const t=ke[e.resourceType]||[],n=Oe[e.resourceType];return s.jsx(r,{lg:12,md:24,sm:24,xs:24,children:s.jsx(i,{title:e.title,extra:s.jsxs("span",{className:"text-sm font-semibold text-font-extend-2",children:[t.length," 个Pod"]}),children:t.length>0&&n?s.jsx(f,{option:n,notMerge:!0,onChartReady:t=>Se(e.resourceType,t),onEvents:ze[e.resourceType]}):s.jsx(a,{className:"flex h-[300px] flex-col items-center justify-center",description:"暂无监控数据",image:a.PRESENTED_IMAGE_SIMPLE})})},e.resourceType)}))})})()]},"monitor-system")})})};export{Pe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.