From 8fddb0d4d293eee00c1d5562af86ef45df83e54b Mon Sep 17 00:00:00 2001 From: Scott Leibrand Date: Sun, 20 Oct 2019 15:19:19 -0700 Subject: [PATCH] Upload preferences.json and oref0 version to devicestatus (#1300) * per #1288, only use minZTUAMPredBG if enableUAM, and use minGuardBG otherwise * upload preferences.json to devicestatus * use --preferences instead of positional arguments * yargs entry for --preferences * upload oref0 package.json version string * redact sensitive fields in preferences.json * reduce size of large logfiles like new -date ones --- bin/ns-status.js | 30 ++++++++++++++++++++++++++++-- bin/oref0-ns-loop.sh | 4 ++-- logrotate.openaps | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/bin/ns-status.js b/bin/ns-status.js index 64564e51c..4b86c80a7 100755 --- a/bin/ns-status.js +++ b/bin/ns-status.js @@ -35,6 +35,18 @@ function mmtuneStatus (status) { } } +function preferencesStatus (status) { + var preferences = requireWithTimestamp(cwd + preferences_input); + if (preferences) { + status.preferences = preferences; + if (preferences.nightscout_host) { status.preferences.nightscout_host = "redacted"; } + if (preferences.bt_mac) { status.preferences.bt_mac = "redacted"; } + if (preferences.pushover_token) { status.preferences.pushover_token = "redacted"; } + if (preferences.pushover_user) { status.preferences.pushover_user = "redacted"; } + if (preferences.pump_serial) { status.preferences.pump_serial = "redacted"; } + } +} + function uploaderStatus (status) { var uploader = require(cwd + uploader_input); if (uploader) { @@ -51,7 +63,13 @@ function uploaderStatus (status) { if (!module.parent) { var argv = require('yargs') - .usage("$0 [--uploader uploader.json] [mmtune.json]") + .usage("$0 [--uploader uploader.json] [mmtune.json] [--preferences preferences.json]") + .option('preferences', { + alias: 'p', + nargs: 1, + describe: "OpenAPS preferences file", + default: false + }) .option('uploader', { alias: 'u', nargs: 1, @@ -71,6 +89,7 @@ if (!module.parent) { var reservoir_input = inputs[5]; var status_input = inputs[6]; var mmtune_input = inputs[7]; + var preferences_input = params.preferences; var uploader_input = params.uploader; if (inputs.length < 7 || inputs.length > 8) { @@ -78,6 +97,8 @@ if (!module.parent) { process.exit(1); } + var pjson = require('../package.json'); + var cwd = process.cwd() + '/'; var hostname = 'unknown'; @@ -113,7 +134,8 @@ if (!module.parent) { openaps: { iob: iob, suggested: suggested, - enacted: enacted + enacted: enacted, + version: pjson.version }, pump: { clock: safeRequire(cwd + clock_input), @@ -127,6 +149,10 @@ if (!module.parent) { mmtuneStatus(status); } + if (preferences_input) { + preferencesStatus(status); + } + if (uploader_input) { uploaderStatus(status); } diff --git a/bin/oref0-ns-loop.sh b/bin/oref0-ns-loop.sh index a191f1a32..27ce62e3b 100755 --- a/bin/oref0-ns-loop.sh +++ b/bin/oref0-ns-loop.sh @@ -184,9 +184,9 @@ function upload_ns_status { # ns-status monitor/clock-zoned.json monitor/iob.json enact/suggested.json enact/enacted.json monitor/battery.json monitor/reservoir.json monitor/status.json --uploader monitor/edison-battery.json > upload/ns-status.json function format_ns_status { if [ -s monitor/edison-battery.json ]; then - ns-status monitor/clock-zoned.json monitor/iob.json enact/suggested.json enact/enacted.json monitor/battery.json monitor/reservoir.json monitor/status.json --uploader monitor/edison-battery.json > upload/ns-status.json + ns-status monitor/clock-zoned.json monitor/iob.json enact/suggested.json enact/enacted.json monitor/battery.json monitor/reservoir.json monitor/status.json --preferences preferences.json --uploader monitor/edison-battery.json > upload/ns-status.json else - ns-status monitor/clock-zoned.json monitor/iob.json enact/suggested.json enact/enacted.json monitor/battery.json monitor/reservoir.json monitor/status.json > upload/ns-status.json + ns-status monitor/clock-zoned.json monitor/iob.json enact/suggested.json enact/enacted.json monitor/battery.json monitor/reservoir.json monitor/status.json --preferences preferences.json > upload/ns-status.json fi } diff --git a/logrotate.openaps b/logrotate.openaps index a83fd8041..24e7808d3 100644 --- a/logrotate.openaps +++ b/logrotate.openaps @@ -17,7 +17,7 @@ /var/log/openaps/*.log { rotate 30 daily - size 10M + size 5M compress delaycompress missingok