add ping check
This commit is contained in:
parent
056d035805
commit
12a1dcbf9a
1 changed files with 18 additions and 0 deletions
|
|
@ -18,6 +18,23 @@ function sameState (a, b) {
|
|||
return a.note.sessionId === b.note.sessionId && a.note.state === b.note.state
|
||||
}
|
||||
|
||||
function checkPing (deviceEvents) {
|
||||
var sortedEvents = R.sortBy(R.compose(toInt10, R.prop('device_time')), R.map(jsonParse, deviceEvents))
|
||||
var lastEvent = R.last(sortedEvents)
|
||||
var NETWORK_DOWN_TIME = 2 * 60 * 1000
|
||||
|
||||
if (!lastEvent) {
|
||||
console.log('No data for device')
|
||||
return
|
||||
}
|
||||
|
||||
if (lastEvent.age > NETWORK_DOWN_TIME) {
|
||||
return console.log('Device not reachable [ALERT]')
|
||||
}
|
||||
|
||||
console.log('Device reachable [OK]')
|
||||
}
|
||||
|
||||
function checkStuckScreen (deviceEvents) {
|
||||
var sortedEvents = R.sortBy(R.compose(toInt10, R.prop('device_time')), R.map(jsonParse, deviceEvents))
|
||||
var noRepeatEvents = R.dropRepeatsWith(sameState, sortedEvents)
|
||||
|
|
@ -72,6 +89,7 @@ function checkStatus () {
|
|||
|
||||
console.log('DEVICE: ' + deviceRow.fingerprint)
|
||||
checkStuckScreen(deviceEvents)
|
||||
checkPing(deviceEvents)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue