Skip to content

Commit

Permalink
Upload preferences.json and oref0 version to devicestatus (#1300)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
scottleibrand authored Oct 20, 2019
1 parent 84e6736 commit 8fddb0d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
30 changes: 28 additions & 2 deletions bin/ns-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -51,7 +63,13 @@ function uploaderStatus (status) {
if (!module.parent) {

var argv = require('yargs')
.usage("$0 <clock.json> <iob.json> <suggested.json> <enacted.json> <battery.json> <reservoir.json> <status.json> [--uploader uploader.json] [mmtune.json]")
.usage("$0 <clock.json> <iob.json> <suggested.json> <enacted.json> <battery.json> <reservoir.json> <status.json> [--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,
Expand All @@ -71,13 +89,16 @@ 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) {
argv.showHelp();
process.exit(1);
}

var pjson = require('../package.json');

var cwd = process.cwd() + '/';

var hostname = 'unknown';
Expand Down Expand Up @@ -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),
Expand All @@ -127,6 +149,10 @@ if (!module.parent) {
mmtuneStatus(status);
}

if (preferences_input) {
preferencesStatus(status);
}

if (uploader_input) {
uploaderStatus(status);
}
Expand Down
4 changes: 2 additions & 2 deletions bin/oref0-ns-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion logrotate.openaps
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/var/log/openaps/*.log {
rotate 30
daily
size 10M
size 5M
compress
delaycompress
missingok
Expand Down

0 comments on commit 8fddb0d

Please sign in to comment.