influxdb数据库简单导出导入

导出语句(这样导出的数据是line protocol格式的)

influx_inspect export -datadir "/var/lib/influxdb/data" -waldir "/var/lib/influxdb/wal" -out "export" -database mydb -retention autogen

导入语句

influx -import -path=export -precision=ns

 

纯line protocol格式数据写入语句

$ curl -i -XPOST "http://localhost:8086/write?db=mydb" --data-binary @bridges.txt

20190330导出导入数据

查lsf作业调度数据

 influx -database 'paradata_dev' -execute 'select * from lsfCluster'  -format='csv' >lsfCluster.txt

再格式化之后再写入

#!/opt/miniconda3/bin/python


f = open("lsfCluster.txt", 'r')

for line in f.read().split("\n"):
    name = str(line.split(',')[0])
    t =  str(line.split(',')[1])
    avg_que_time =  str(line.split(',')[2])
    avg_run_time =  str(line.split(',')[3])
    configName =  str(line.split(',')[4])
    exit_jobs =  str(line.split(',')[5])
    finish_jobs =  str(line.split(',')[6])
    fs_iused =  str(line.split(',')[7])
    fs_used =  str(line.split(',')[8])
    hosts_num =  str(line.split(',')[9])
    hosts_unavail =  str(line.split(',')[10])
    hosts_unavail_list =  str(line.split(',')[11])
    lsfName =  str(line.split(',')[12])
    master =  str(line.split(',')[13])
    pending =  str(line.split(',')[14])
    running =  str(line.split(',')[15])
    slot =  str(line.split(',')[16])
    slot_used =  str(line.split(',')[17])
    statu =  str(line.split(',')[18])
    status_value =  str(line.split(',')[19])
    newLine = ("%s,lsfName=%s avg_que_time=%s,avg_run_time=%s,configName=\"%s\",exit_jobs=%s,finish_jobs=%s,fs_iused=%s,fs_used=%s,hosts_num=%s,hosts_unavail=%s,hosts_unavail_list=\"%s\",master=\"%s\",pending=%s,running=%s,slot=%s,slot_used=%s,status=\"%s\",status_value=%s %s") % (name, lsfName, avg_que_time,avg_run_time,configName,exit_jobs,finish_jobs,fs_iused,fs_used,hosts_num,hosts_unavail,hosts_unavail_list,master,pending,running,slot,slot_used,statu,status_value,t)
    print(newLine)

 

你可能感兴趣的:(influxdb)