dsh-ops-kit 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +45 -19
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -351,6 +351,8 @@ window.__ModuleLoader__.load({
|
|
|
351
351
|
.ops-dot.warn{background:var(--dsw-alias-warning,#e5b650)}
|
|
352
352
|
.ops-dot.bad{background:var(--dsw-alias-danger,#ff6b6b)}
|
|
353
353
|
.ops-nums{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
|
|
354
|
+
.ops-trends{display:flex;flex-direction:column;gap:2px;margin:8px 0 4px}
|
|
355
|
+
.ops-trend{display:flex;align-items:center;gap:8px;min-height:26px}
|
|
354
356
|
.ops-num{background:var(--dsw-alias-bg,#15181c);border:1px solid var(--dsw-alias-border,#3a3f45);border-radius:8px;padding:8px 10px}
|
|
355
357
|
.ops-num b{display:block;font-size:16px;font-weight:600}
|
|
356
358
|
.ops-num span{font-size:11px;color:var(--dsw-alias-text-secondary,#9aa0a6)}
|
|
@@ -2398,22 +2400,27 @@ window.__ModuleLoader__.load({
|
|
|
2398
2400
|
const title = host.alias || host.name
|
|
2399
2401
|
const toneClass = st.cls === 'ok' ? 'ops-ok' : st.cls === 'warn' ? 'ops-warn' : st.cls === 'bad' ? 'ops-bad' : 'ops-dim'
|
|
2400
2402
|
|
|
2403
|
+
const checkFailing = (simpleMonitors[host.name] || []).filter(item => item.lastOk === false)
|
|
2401
2404
|
const head = h('div', { className: 'ops-card-h' },
|
|
2402
2405
|
h('span', null,
|
|
2403
2406
|
h('i', { className: 'ops-dot ' + st.cls }),
|
|
2404
2407
|
title,
|
|
2405
2408
|
host.alias ? h('span', { className: 'ops-dim', style: { marginLeft: '8px', fontWeight: 400 } }, host.name) : null),
|
|
2406
|
-
h('span', {
|
|
2409
|
+
h('span', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
|
|
2410
|
+
checkFailing.length
|
|
2411
|
+
? h('span', { className: 'ops-warn', style: { fontSize: '12px' } }, L(`${checkFailing.length} 项检查未通过`, `${checkFailing.length} check(s) failed`))
|
|
2412
|
+
: null,
|
|
2413
|
+
h('span', { className: toneClass, style: { fontSize: '12px' } }, st.text)))
|
|
2407
2414
|
|
|
2408
2415
|
const nums = h('div', { className: 'ops-nums' },
|
|
2409
2416
|
metricBox(T.cpu, sample?.cpu, ''),
|
|
2410
2417
|
metricBox(T.mem, sample?.mem, memTone),
|
|
2411
2418
|
metricBox(T.disk, sample?.disk, diskTone))
|
|
2412
2419
|
|
|
2413
|
-
const trends = h('div', {
|
|
2414
|
-
h('span', { className: 'ops-dim' }, T.cpu), h(Spark, { rows: list, field: 'cpu' }),
|
|
2415
|
-
h('span', { className: 'ops-dim' }, T.mem), h(Spark, { rows: list, field: 'mem' }),
|
|
2416
|
-
h('span', { className: 'ops-dim' }, T.disk), h(Spark, { rows: list, field: 'disk' }))
|
|
2420
|
+
const trends = h('div', { className: 'ops-trends' },
|
|
2421
|
+
h('div', { className: 'ops-trend' }, h('span', { className: 'ops-dim' }, T.cpu), h(Spark, { rows: list, field: 'cpu' })),
|
|
2422
|
+
h('div', { className: 'ops-trend' }, h('span', { className: 'ops-dim' }, T.mem), h(Spark, { rows: list, field: 'mem' })),
|
|
2423
|
+
h('div', { className: 'ops-trend' }, h('span', { className: 'ops-dim' }, T.disk), h(Spark, { rows: list, field: 'disk' })))
|
|
2417
2424
|
|
|
2418
2425
|
const conn = conns[host.name]
|
|
2419
2426
|
const meta = h('div', { className: 'ops-dim' },
|
|
@@ -2506,6 +2513,11 @@ window.__ModuleLoader__.load({
|
|
|
2506
2513
|
: null,
|
|
2507
2514
|
h('div', { className: 'ops-modal-row' }, h('b', null, T.simpleService), h('span', null, serviceText)),
|
|
2508
2515
|
h('div', { className: 'ops-modal-row' }, h('b', null, T.simpleUptime), h('span', null, uptime)),
|
|
2516
|
+
state.failing.length && state.machineOk
|
|
2517
|
+
? h('p', { className: 'ops-sub', style: { margin: '6px 0 0', fontSize: '12.5px' } },
|
|
2518
|
+
L(`服务器本身正常(CPU、内存、磁盘都没问题),只是有 ${state.failing.length} 项检查没通过。`,
|
|
2519
|
+
`The server itself is fine (CPU, memory and disk are healthy); ${state.failing.length} check(s) failed.`))
|
|
2520
|
+
: null,
|
|
2509
2521
|
state.failing.length
|
|
2510
2522
|
? h('div', { style: { marginTop: '6px' } }, ...state.failing.slice(0, 3).map(item => {
|
|
2511
2523
|
const tip = suggestionFor(item)
|
|
@@ -2540,19 +2552,33 @@ window.__ModuleLoader__.load({
|
|
|
2540
2552
|
checkedText ? h('div', { className: 'ops-dim', style: { fontSize: '11px', marginTop: '6px' } }, checkedText) : null))
|
|
2541
2553
|
})
|
|
2542
2554
|
|
|
2555
|
+
const alertGroups = []
|
|
2556
|
+
for (const alert of alerts) {
|
|
2557
|
+
const text = plainCheckDetail(alert.message)
|
|
2558
|
+
const last = alertGroups[alertGroups.length - 1]
|
|
2559
|
+
if (last && last.text === text) {
|
|
2560
|
+
last.count += 1
|
|
2561
|
+
last.acked = last.acked && alert.acked
|
|
2562
|
+
last.items.push(alert)
|
|
2563
|
+
} else {
|
|
2564
|
+
alertGroups.push({ text, at: alert.at, level: alert.level, acked: alert.acked, count: 1, items: [alert] })
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2543
2568
|
const simpleAlerts = h('div', { className: 'ops-card' },
|
|
2544
2569
|
h('div', { className: 'ops-card-h' }, h('span', null, T.recentAlerts)),
|
|
2545
2570
|
h('div', { className: 'ops-card-b' },
|
|
2546
2571
|
alerts.length === 0
|
|
2547
2572
|
? h('p', { className: 'ops-empty' }, T.noAlerts)
|
|
2548
|
-
: h('div', null, ...
|
|
2549
|
-
h('span', { style: { display: 'flex', alignItems: 'center', gap: '8px', opacity:
|
|
2550
|
-
h('i', { className: 'ops-dot ' + (
|
|
2551
|
-
h('span', null,
|
|
2552
|
-
h('span', { className: 'ops-
|
|
2553
|
-
|
|
2573
|
+
: h('div', null, ...alertGroups.map((group, index) => h('div', { key: index, className: 'ops-row', style: { gridTemplateColumns: '1fr auto' } },
|
|
2574
|
+
h('span', { style: { display: 'flex', alignItems: 'center', gap: '8px', opacity: group.acked ? 0.5 : 1 } },
|
|
2575
|
+
h('i', { className: 'ops-dot ' + (group.level === 'critical' ? 'bad' : group.level === 'warning' ? 'warn' : '') }),
|
|
2576
|
+
h('span', null, group.text),
|
|
2577
|
+
group.count > 1 ? h('span', { className: 'ops-chip' }, `×${group.count}`) : null,
|
|
2578
|
+
h('span', { className: 'ops-dim', style: { fontSize: '11px' } }, fmt(group.at))),
|
|
2579
|
+
group.acked
|
|
2554
2580
|
? h('span', { className: 'ops-chip' }, T.acked)
|
|
2555
|
-
: h('button', { className: 'ops-btn ops-btn-sm', onClick: () => { void ackAlert(
|
|
2581
|
+
: h('button', { className: 'ops-btn ops-btn-sm', onClick: () => { void Promise.all(group.items.map(item => ackAlert(item))) } }, T.alertAck))))))
|
|
2556
2582
|
|
|
2557
2583
|
const simpleView = h('div', { style: { display: 'flex', flexDirection: 'column', gap: '12px' } },
|
|
2558
2584
|
simpleNotice ? h('div', { className: 'ops-ok', style: { fontSize: '12.5px' } }, simpleNotice) : null,
|
|
@@ -2806,7 +2832,7 @@ window.__ModuleLoader__.load({
|
|
|
2806
2832
|
return hostDetailView
|
|
2807
2833
|
}
|
|
2808
2834
|
|
|
2809
|
-
function Panel({ initialHosts = [], initialDetailHost = null, initialDetailTab = 'summary', initialUiMode = 'pro' } = {}) {
|
|
2835
|
+
function Panel({ initialHosts = [], initialDetailHost = null, initialDetailTab = 'summary', initialUiMode = 'pro', initialSimpleMonitors = {} } = {}) {
|
|
2810
2836
|
const [tab, setTab] = React.useState(0)
|
|
2811
2837
|
const [detailHost, setDetailHost] = React.useState(initialDetailHost)
|
|
2812
2838
|
const [detailTab, setDetailTab] = React.useState(initialDetailTab)
|
|
@@ -2853,7 +2879,7 @@ window.__ModuleLoader__.load({
|
|
|
2853
2879
|
const [alerts, setAlerts] = React.useState([])
|
|
2854
2880
|
const [audit, setAudit] = React.useState([])
|
|
2855
2881
|
const [info, setInfo] = React.useState(null)
|
|
2856
|
-
const [simpleMonitors, setSimpleMonitors] = React.useState(
|
|
2882
|
+
const [simpleMonitors, setSimpleMonitors] = React.useState(initialSimpleMonitors)
|
|
2857
2883
|
const [simpleCtx, setSimpleCtx] = React.useState({})
|
|
2858
2884
|
const [simpleNotice, setSimpleNotice] = React.useState('')
|
|
2859
2885
|
const [maintenanceUntil, setMaintenanceUntil] = React.useState(null)
|
|
@@ -3127,7 +3153,7 @@ window.__ModuleLoader__.load({
|
|
|
3127
3153
|
}, [tab])
|
|
3128
3154
|
|
|
3129
3155
|
React.useEffect(() => {
|
|
3130
|
-
if (
|
|
3156
|
+
if (tab !== 0 || hosts.length === 0) return
|
|
3131
3157
|
void (async () => {
|
|
3132
3158
|
try {
|
|
3133
3159
|
const [alertData, auditData, infoData] = await Promise.all([
|
|
@@ -3838,11 +3864,11 @@ window.__ModuleLoader__.load({
|
|
|
3838
3864
|
const at = new Date(item.last?.at || 0).getTime()
|
|
3839
3865
|
return at > latest ? at : latest
|
|
3840
3866
|
}, 0)
|
|
3867
|
+
const machineOk = !unreachable && disk < 95
|
|
3841
3868
|
let level = 'ok'
|
|
3842
|
-
if (unreachable) level = 'bad'
|
|
3843
|
-
if (failing.length > 0 || disk >=
|
|
3844
|
-
|
|
3845
|
-
return { list, failing, sample, disk, level, unreachable, lastAt }
|
|
3869
|
+
if (unreachable || disk >= 95) level = 'bad'
|
|
3870
|
+
else if (failing.length > 0 || disk >= 85) level = 'warn'
|
|
3871
|
+
return { list, failing, sample, disk, level, unreachable, machineOk, lastAt }
|
|
3846
3872
|
}
|
|
3847
3873
|
|
|
3848
3874
|
const suggestionFor = (item) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ops-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "OPC-运维工作台 (dsh-ops-kit) — Server operations kit for DeepSeek Harness: server cards, health charts, config browser, app manager and plain-language AI diagnosis — over SSH, no agent install.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|