Compare commits
No commits in common. "873f00b21bea3902da1193bf2517ec682ea0156a" and "2356040572922cfbaa7384a43eb2b7a2ae17f809" have entirely different histories.
873f00b21b
...
2356040572
@ -1,6 +1,5 @@
|
|||||||
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');
|
||||||
|
|
||||||
@ -39,15 +38,32 @@ 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("worker_connectionTest").tag("hostname", Os.hostname())) // Write point
|
writeApi.writePoint(new Point("test").tag("ConnectionTest", true).intField("value", 0).timestamp(0)) // Write dummy-point
|
||||||
writeApi.close()
|
writeApi.close()
|
||||||
.catch((err) => {
|
.then((res) => {
|
||||||
|
logger.debug("Writing ok");
|
||||||
|
|
||||||
|
// 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())
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
logger.error("Could not get writeApi:");
|
logger.error("Could not get writeApi:");
|
||||||
logger.error(`Error [${err.code}]:`, err.message);
|
logger.error(`Error [${err.code}]:`, err.message);
|
||||||
reject();
|
reject();
|
||||||
}).then((res) => {
|
|
||||||
logger.debug("Writing ok");
|
|
||||||
resolve();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user