_ops_state.mjs 746 B

123456789101112131415161718
  1. // P92-5:打印 /ops/api/state 全文,看重算任务状态(job/status/rc/progress)
  2. const GW = 'http://106.120.102.238:28084'
  3. const r = await fetch(GW + '/ops/api/state')
  4. const txt = await r.text()
  5. console.log('STATE ' + r.status + ' ' + txt.length + ' B')
  6. let j = null
  7. try { j = JSON.parse(txt) } catch { /* ignore */ }
  8. if (j) {
  9. console.log('TOP_KEYS ' + JSON.stringify(Object.keys(j)))
  10. for (const k of Object.keys(j)) {
  11. const v = JSON.stringify(j[k])
  12. if (!/services/.test(k)) console.log(' ' + k + ' = ' + String(v).slice(0, 320))
  13. }
  14. const s = j.services || {}
  15. console.log('SERVICES ' + JSON.stringify(Object.fromEntries(Object.entries(s).map(([k, v]) => [k, v.up ?? v]))))
  16. } else {
  17. console.log(txt.slice(0, 400))
  18. }