WIP
This commit is contained in:
parent
a35e9d2d44
commit
340ad2b518
8 changed files with 129 additions and 38 deletions
|
|
@ -11,10 +11,13 @@ function machinesLastPing () {
|
|||
const sql = `select name, min(extract(epoch from (now() - machine_events.created))) as age
|
||||
from machine_events, devices
|
||||
where machine_events.device_id = devices.device_id
|
||||
and devices.paired
|
||||
group by name`
|
||||
|
||||
return db.any(sql)
|
||||
.then(r => {
|
||||
if (r.length === 0) return 'No paired machines'
|
||||
|
||||
const downRows = r.filter(row => row.age > CONSIDERED_UP_SECS)
|
||||
if (downRows.length === 0) return 'All machines are up'
|
||||
|
||||
|
|
@ -54,6 +57,7 @@ function status () {
|
|||
}]
|
||||
return {up, lastPing, rates, machineStatus}
|
||||
})
|
||||
.catch(() => ({up, lastPing, rates: [], machineStatus}))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue