auf aktuelle esprimo-Version updated

This commit is contained in:
rxf
2023-12-18 17:23:59 +01:00
parent 4f19f9973a
commit 6d1d60a9c1
16 changed files with 102 additions and 964 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,4 +6,5 @@ docker-compose.yml
Dockerfile* Dockerfile*
INFLUXSERVER INFLUXSERVER
TRANSFERE TRANSFERE
data

2
.gitignore vendored
View File

@@ -3,5 +3,7 @@ node_modules
.idea .idea
.env .env
log log
docs/Readme.md_x
docs/Readme_tmp.html

27
Dockerfile_readin Normal file
View File

@@ -0,0 +1,27 @@
FROM node:18-alpine
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /tmp/package.json /opt/app/
WORKDIR /opt/app
ADD . /opt/app
ADD crontab.tmp /opt/app
RUN mkdir -p data
#RUN apk add busybox-initscripts
#RUN apk add --no-cache tzdata
#ENV TZ Europe/Berlin
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN crontab crontab.tmp
RUN deluser --remove-home node
RUN touch cmds.sh \
&& echo 'crond -f' >>cmds.sh
CMD sh ./cmds.sh

View File

@@ -14,8 +14,8 @@
set -x set -x
port="" port=""
orgName=timeseries orgName=readin
name=timeseries name=readin
usage() usage()
{ {

View File

@@ -1,2 +1,2 @@
1-59/5 * * * * cd /opt/app && npm start 3-59/5 * * * * cd /opt/app && npm start

19
deploy.sh Executable file
View File

@@ -0,0 +1,19 @@
# Deploy Sensor-Files via esprimo und docker.citysensor.de
# 2023-12-17 rxf
#
# set -x
LINUX='esprimo'
path="/home/rxf/Projekte/Sensors"
name=readin
rsync -avn --exclude=node_modules --exclude=.git --exclude=deploy.sh --exclude=TRANSFERE --exclude=INFLUXSERVER --exclude=data --exclude=log --exclude=.idea --exclude=.vscode --exclude=docs ./ $LINUX:$path/$name
exit 0
ssh $LINUX "cd $path/$name;
./build_and_copy.sh localhost;
docker tag $name docker.citysensor.de/$name;
docker push docker.citysensor.de/$name;"
exit 0

View File

@@ -1,45 +1,54 @@
version: '3.9' version: '3.9'
volumes: volumes:
mongo_data_1: mongo_vol:
influx_vol:
services: services:
node: timeseries:
image: timeseries image: timeseries
environment: environment:
DEVELOP: "true" DEVELOP: "true"
MONGOHOST: mongodb MONGOHOST: mongodb
MONGOUSRP: "rexfue:noise4mongo"
MONGOAUTH: "true"
INFLUXHOST: influxdb INFLUXHOST: influxdb
INFLUXTOKEN: "q35XUBaElzcy8dDd9HF2_mpeHvYCampZg_9mJNP5jeBQRopq3EWIzNTZ555QLSIXhZC05RXCoFgjiaT7VzyNkQ=="
TYP: "[\"noise\", \"thp\"]" TYP: "[\"noise\", \"thp\"]"
volumes: volumes:
- ${PWD}/log:/var/log - ${PWD}/log:/var/log
container_name: timeseries container_name: timeseries
restart: unless-stopped restart: unless-stopped
influx: mongodb:
image: influxdb:latest image: mongo:6
container_name: influxdb
volumes: volumes:
- ${PWD}/INFLUXSERVER/data:/var/lib/influxdb2 - ${PWD}/entries:/docker-entrypoint-initdb.d
- ${PWD}/INFLUXSERVER/config:/etc/influxdb2 - mongo_vol:/data/db
ports:
- "27017:27017"
container_name: mongodb
environment:
- MONGO_INITDB_DATABASE=sensor_data
- MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
restart: unless-stopped
influxdb:
image: influxdb:2.0
ports: ports:
- '8086:8086' - '8086:8086'
volumes:
- influx_vol:/var/lib/influxdb2
environment: environment:
DOCKER_INFLUXDB_INIT_MODE: ${DOCKER_INFLUXDB_INIT_MODE} DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: ${DOCKER_INFLUXDB_INIT_USERNAME} DOCKER_INFLUXDB_INIT_USERNAME: ${DOCKER_INFLUXDB_INIT_USERNAME}
DOCKER_INFLUXDB_INIT_PASSWORD: ${DOCKER_INFLUXDB_INIT_PASSWORD} DOCKER_INFLUXDB_INIT_PASSWORD: ${DOCKER_INFLUXDB_INIT_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: ${DOCKER_INFLUXDB_INIT_ORG} DOCKER_INFLUXDB_INIT_ORG: citysensor
DOCKER_INFLUXDB_INIT_BUCKET: ${DOCKER_INFLUXDB_INIT_BUCKET} DOCKER_INFLUXDB_INIT_BUCKET: sensor_data
restart: unless-stopped DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${DOCKER_INFLUXTOKEN}
restart:
unless-stopped
container_name: influxdb
mongodb:
image: mongo
volumes:
- mongo_data_1:/data/db
- ${PWD}/TRANSFERE:/TRANSFERE
ports:
- "27098:27017"
container_name: mongodb
# command: '--auth'
restart: unless-stopped

BIN
docs/.DS_Store vendored Normal file

Binary file not shown.

BIN
docs/Laerm_API.pdf Normal file

Binary file not shown.

View File

@@ -11,7 +11,7 @@ let MONGOHOST = process.env.MONGOHOST || 'localhost'
let MONGOPORT = process.env.MONGOPORT || 27017 let MONGOPORT = process.env.MONGOPORT || 27017
let MONGOAUTH = process.env.MONGOAUTH || 'false' let MONGOAUTH = process.env.MONGOAUTH || 'false'
let MONGOUSRP = process.env.MONGOUSRP || '' let MONGOUSRP = process.env.MONGOUSRP || ''
let MONGOBASE = process.env.MONGOBASE || 'allsensors' let MONGOBASE = process.env.MONGOBASE || 'sensor_data'
let MONGO_URL = 'mongodb://' + MONGOHOST + ':' + MONGOPORT; // URL to mongo database let MONGO_URL = 'mongodb://' + MONGOHOST + ':' + MONGOPORT; // URL to mongo database

939
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "node fetchnewdata.js -m >>/var/log/timeseries.log 2>&1" "start": "node fetchnewdata.js -m >>/var/log/readin.log 2>&1"
}, },
"type": "module", "type": "module",
"keywords": [], "keywords": [],

View File

@@ -146,7 +146,7 @@ const buildNewEntry = (item, typ, dt, now) => {
const types = { const types = {
P1: 'pm', P2: 'pm', P0: 'pm', P1: 'pm', P2: 'pm', P0: 'pm',
temperature: 'thp', humidity: 'thp', pressure: 'thp', temperature: 'thp', humidity: 'thp', pressure: 'thp',
noise_LAeq: 'noise', noise_LA_max: 'noise', noise_LAeq: 'noise', noise_LA_max: 'noise', noise_LA_min: 'noise',
counts_per_minute: 'radioactivity', counts_per_minute: 'radioactivity',
lat: 'gps' lat: 'gps'
}; };
@@ -182,6 +182,9 @@ export const constructDBaseEntries = async (client, body, args) => {
if (typ === 'unknown') { // extract measurement type if (typ === 'unknown') { // extract measurement type
typ = getType(vtyp) typ = getType(vtyp)
} }
if(typ === 'noise') {
vtyp = vtyp.slice(6)
}
let val = v.value; // and value let val = v.value; // and value
let x let x
try { try {
@@ -196,7 +199,7 @@ export const constructDBaseEntries = async (client, body, args) => {
values[vtyp] = x values[vtyp] = x
ival += `${vtyp}=${x},` ival += `${vtyp}=${x},`
// if noise sensor precalculate pow10 // if noise sensor precalculate pow10
if (vtyp == 'noise_LAeq') { if (vtyp == 'LAeq') {
let e10 = Math.pow(10, x / 10) let e10 = Math.pow(10, x / 10)
values.E10tel_eq = e10 values.E10tel_eq = e10
ival += `E10tel_eq=${e10},` ival += `E10tel_eq=${e10},`

View File

@@ -49,4 +49,3 @@ function saveDatatoFile(fn, data) {
function readDatafromFile(fn) { function readDatafromFile(fn) {
return JSON.parse(fs.readFileSync(fn)) return JSON.parse(fs.readFileSync(fn))
} }

9
ts_rotate Normal file
View File

@@ -0,0 +1,9 @@
/var/log/timeseries.log {
daily
rotate 7
delaycompress
compress
notifempty
missingok
}