From 0d4ce5146742ef66692ce34995d0e61c2a2e92fd Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Sat, 23 Apr 2016 23:09:02 +0300 Subject: [PATCH] use machine name if available in alerts --- lib/notifier.js | 9 ++++++--- todo.txt | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/notifier.js b/lib/notifier.js index 7857054a..12da5eea 100644 --- a/lib/notifier.js +++ b/lib/notifier.js @@ -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]) }) diff --git a/todo.txt b/todo.txt index 9676b2f9..b93b3ca5 100644 --- a/todo.txt +++ b/todo.txt @@ -1 +1 @@ -- configure LOW_BALANCE_THRESHOLD, STALE_STATE, NETWORK_DOWN_TIME +- fix tests