Package: tdb-io
Project: tdbiomore or less actual at 0.5.12A tool to get info on,data from,insert to - influx database -
local,remoteA tool to do backup to csv, parquet (pandas) or h5LIBRARY for pythonic oneline insertion to Influx databaseEven some plotting remained from the previous versionUse casesYou need~/.influx_userpassdbon Linux orC:\Users\someone\.influx_userpassdbon windows.The content isusername
password
dbnamePython script to insert dataCLI - List databasestdb_io ls inflOr remotetdb_io ls infl -ip 10.10.104.21CLI - List measurements in db and save csvDatabase namedtesttdb_io ls infl testThis will show and save the last 5 points of a measurementstdb_io ls infl test somemeasurementThis will show and save the last 555 points of a measurementstdb_io ls infl test somemeasurement 555This will show and save the last 5 hours of a measurementstdb_io ls infl test somemeasurement 5hThis will show and save the last 1 day of a measurements from remote PCtdb_io ls infl test somemeasurement 1d -ip 10.10.104.21AT THIS CASE:CSVis always savedh5is saved iftablesis installed by pipparquetof pandas saved ifpyarrowis properly installedCLI - Backup all the measurements from the databaseDatabase namedtesttdb_io ls infl test all 1d -ip 10.10.104.21CLI - Insert some data# laterCLI - Insert some data with a faked timestamp# laterUsing system influx clientInsert dataIninfluxafterauthINSERT cpu,host=serverA value=10carefullthe taghostwill make the life difficult to tdbio!Show influx contentIninfluxafterauthshow databases
 use test
 show measuremnts
# select * from meas limit 5 ??Appendices:Setup letsencrypt keysI already have autoupdate keysSetup GrafanaNewly-from repoSeehttps://www.digitalocean.com/community/tutorials/how-to-install-and-secure-grafana-on-ubuntu-22-04wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install grafana
sudo systemctl enable --now grafana-server
sudo systemctl status grafana-serverBasic dockerdocker run -d -p 3000:3000  grafana/grafana[2021-04-14 Wed]When anonymous access neededdocker run --name grafana-gigajm-v2104a -d  -p 3000:3000 -e "GF_AUTH_ANONYMOUS_ENABLED=true" --restart=unless-stopped  grafana-gigajm-v2104What is the password? admin admin - change from webinterface nowBut - once the password is set, and PC restarts, it is nice to have a
more persistent image.docker ps
docker commit  cdcc1c4a1816 grafana-gigajm
docker stop ...
docker rm ...
docker images

docker run -d --restart unless-stopped  grafana-mc2_vacInstall pluginsThen, it is necessary to install a plugin and not to loose the
container.docker ps
docker exec -it c4886ae1f59c bash
# INSIDE DOCKER
grafana-cli plugins install mtanda-histogram-panel
grafana-cli plugins install pr0ps-trackmap-panel

# I did a new commit
docker commit c4886ae1f59c  grafana-gigajm2
# and restarted the container
docker restart c4886ae1f59cWhat is the password? admin admin - change from webinterface nowDEFINE DATASOURCE in grafanahttp://x.x.x.x:8086no change anythingdatabase userpasssaveReset password in grafanato admin adminsudo sqlite3 /var/lib/grafana/grafana.db

sqlite> update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
sqlite> .exitReset certbotgoto /etc/letsencryptsee there are certificates therecheck, where influxdb expects them:less /etc/influxdb/influxdb.confhttps-certificate = "/etc/ssl/fullchain.pem"https-private-key = "/etc/ssl/privkey.pem"cd /etc/sslcd /etc/letsencrypt/archive/www.xxxxxxxx.czchown influxdb:influxdb *was useless in the momentcp `ls -1 privkey*.pem | tail -1` /etc/ssl/privkey.pemcp `ls -1 fullchain*.pem | tail -1` /etc/ssl/fullchain.pemsystemctl restart influxdb.servicereload grafana web and influx is seen.I HAVE PUT IT INTO A CODEupdate_keys.py:#!/usr/bin/env python3

from fire import Fire
from os import listdir
from os.path import isfile, join
import glob
import os
import subprocess as sp


def chk_influx():
    print("D... check influx ssl file's directory")
    with open("/etc/influxdb/influxdb.conf") as f:
        res = f.readlines()
    res = [ x for x in res if x.find("#")<0 ]
    res = [ x.strip() for x in res if x.find("ssl")>0 ]
    res = [ x.split("=")[1].strip().strip('"')  for x in res ]

    print("D... influx needs these two:",res)
    full = [x for x in res if x.find("fullchain.pem")>0]
    pkey = [x for x in res if x.find("privkey.pem")>0]

    return full[0],pkey[0]

def main():
    fullchain,pkey = chk_influx()

    print("D... main update keys for grafana reading influx")
    print(" ... i assume that grafana has own certificate (due to domainname grafana.)  ")
    print(" ... i assume influx is accessed on www. ")
    certpath = "/etc/letsencrypt/archive"
    dirs = glob.glob(certpath+"/*/")
    print("D... dirs seen:",dirs)
    for i in dirs:
        #print("D..>",i[0],i[-1], i[-2])
        #============== WWW.CZ================
        if (i.find("www.")>=0) and (i[-2]=="z"):
            #wdir = certpath+"/"+i
            print(f"D... globbing {i}")

            files = glob.glob( i+"fullchain*" )
            #print( files )
            latest_fullchain = max(files, key=os.path.getctime)
            print(latest_fullchain)

            files = glob.glob( i+"privkey*" )
            #print( files )
            latest_privkey = max(files, key=os.path.getctime)
            print(latest_privkey)

            # execute ========================
            CMD1 = f"cp {latest_fullchain} {fullchain}"
            CMD2 = f"cp {latest_privkey} {pkey}"
            print(CMD1)
            print(CMD2)

            status = sp.call( CMD1 , shell=True)
            status = sp.call( CMD2 , shell=True)

            CMD = "systemctl restart influxdb.service"
            print(CMD)
            status = sp.call( CMD , shell=True)
            print(status)



if __name__=="__main__":
    Fire(main)And grafana.site started to display again on the first attempt.Setup influxdbInstallapt install influxdb
apt install influxdb-clientemacs /etc/influxdb/influxdb.confandauth-enabled = falsesystemctl restart influxdbCREATE USER admin WITH PASSWORD 'asd' WITH ALL PRIVILEGESCreate databasesinflux
> show databases
> create database test
> create database data
> show databases
name: databases
name
----
_internal
test
dataCreate userinflux
> create user xxx with password 'xxxxxx'
> show users
user admin
---- -----
xxx  falseGRANT USER> grant all on  test to  xxx
> grant all on  data to xxx
> quitRESTART with authemacs /etc/influxdb/influxdb.confandauth-enabled = truesystemctl restart influxdb
systemctl status influxdb
influx
show databases
auth
show databasesProblem with ssl, unsafe sslTry to runinflux -ssl -unsafeSslGeo information for track-mapuse test
Using database test
> show measurements
name: measurements
name
----
> insert geotest,host=me longitude=15.134,latitude=49.1234Access from grafanaIf the certifictes are forwww.blabla, useURL:https://www.websitename.cz:8086Module: mongo