|
|
@ -1,5 +1,6 @@
|
|
|
|
const logger = require.main.require("./helper/logger.js")("influx-checks");
|
|
|
|
const logger = require.main.require("./helper/logger.js")("influx-checks");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Os = require("os");
|
|
|
|
const { InfluxDB, Point } = require('@influxdata/influxdb-client')
|
|
|
|
const { InfluxDB, Point } = require('@influxdata/influxdb-client')
|
|
|
|
const Influx = require('@influxdata/influxdb-client-apis');
|
|
|
|
const Influx = require('@influxdata/influxdb-client-apis');
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +39,7 @@ function checkBucket(influxDb, options){
|
|
|
|
function checkWriteApi(influxDb, options){
|
|
|
|
function checkWriteApi(influxDb, options){
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const writeApi = influxDb.getWriteApi(options.org, options.bucket); // Get WriteAPI
|
|
|
|
const writeApi = influxDb.getWriteApi(options.org, options.bucket); // Get WriteAPI
|
|
|
|
writeApi.writePoint(new Point("test").tag("ConnectionTest", true).intField("value", 0).timestamp(0)) // Write dummy-point
|
|
|
|
writeApi.writePoint(new Point("worker_connectionTest").tag("hostname", Os.hostname())) // Write point
|
|
|
|
writeApi.close()
|
|
|
|
writeApi.close()
|
|
|
|
.catch((err) => {
|
|
|
|
.catch((err) => {
|
|
|
|
logger.error("Could not get writeApi:");
|
|
|
|
logger.error("Could not get writeApi:");
|
|
|
@ -46,23 +47,7 @@ function checkWriteApi(influxDb, options){
|
|
|
|
reject();
|
|
|
|
reject();
|
|
|
|
}).then((res) => {
|
|
|
|
}).then((res) => {
|
|
|
|
logger.debug("Writing ok");
|
|
|
|
logger.debug("Writing ok");
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
// Delete the connection-text-point
|
|
|
|
|
|
|
|
new Influx.DeleteAPI(influxDb).postDelete({
|
|
|
|
|
|
|
|
"body": {
|
|
|
|
|
|
|
|
"start": 0,
|
|
|
|
|
|
|
|
"end": 1,
|
|
|
|
|
|
|
|
"predicate": "ConnectionTest==true"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"org": options.org,
|
|
|
|
|
|
|
|
"bucket": options.bucket
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
|
|
|
logger.error("Could not delete ConnectionTest-Point:");
|
|
|
|
|
|
|
|
logger.error(`Error [${err.code}]:`, err.message);
|
|
|
|
|
|
|
|
reject();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(resolve())
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|