use machine name if available in alerts

This commit is contained in:
Josh Harvey 2016-04-23 23:09:02 +03:00
parent 3720c2eca9
commit 0d4ce51467
2 changed files with 7 additions and 4 deletions

View file

@ -95,7 +95,7 @@ function devicesAndEvents () {
}
function checkStatus () {
var alerts = {devices: {}}
var alerts = {devices: {}, deviceNames: {}}
alerts.general = checkBalances()
return devicesAndEvents()
@ -105,6 +105,7 @@ function checkStatus () {
devices.rows.forEach(function (deviceRow) {
var deviceFingerprint = deviceRow.fingerprint
var deviceName = deviceRow.name || deviceFingerprint
var deviceEvents = events.rows.filter(function (eventRow) {
return eventRow.device_fingerprint === deviceFingerprint
})
@ -113,7 +114,8 @@ function checkStatus () {
deviceAlerts = R.concat(deviceAlerts, checkStuckScreen(deviceEvents))
deviceAlerts = R.concat(deviceAlerts, checkPing(deviceEvents))
alerts.devices[deviceRow.fingerprint] = deviceAlerts
alerts.devices[deviceFingerprint] = deviceAlerts
alerts.deviceNames[deviceFingerprint] = deviceName
})
return alerts
@ -155,7 +157,8 @@ function printEmailAlerts (alertRec) {
}
R.keys(alertRec.devices).forEach(function (device) {
body = body + '\nErrors for ' + device + ':\n'
var deviceName = alertRec.deviceNames[device]
body = body + '\nErrors for ' + deviceName + ':\n'
body = body + emailAlerts(alertRec.devices[device])
})

View file

@ -1 +1 @@
- configure LOW_BALANCE_THRESHOLD, STALE_STATE, NETWORK_DOWN_TIME
- fix tests