• [^] # Re: en changeant la destination des ecritures

    Posté par . En réponse au message Faire 2 bases de données. Évalué à 1. Dernière modification le 17 avril 2015 à 21:09.

    Non non je suis sur j'ai recréer 2 BD data_DHT22T.rrd et data_DHT22Y.rrd , tous les fichiers Xml dont dans webdata dossier virtuel donc je les ai effacé et au lancement de ReadDht22.py il se recréent.
    Voila avec quoi je crées ma BD

    #!/usr/bin/env python
    ''' this routine will create the rrdtool data base 
     database => data_DHT22Y.rrd
     The data base is used to create chronologic Hygrometrie chart
    '''
    import datetime
    import subprocess
    #let's create the command for rrdtool
    #first the rrdtool itself
    theCMD=['rrdtool','create','data_DHT22Y.rrd']
    #start the table from first day of this year
    theCMD.append("--start")
    theCMD.append("01/01/"+str(datetime.datetime.now().year))
    theCMD.append("--step")
    theCMD.append("5")
    #now let's add all sensors
    theCMD.append("DS:{}:GAUGE:1200:-40:125".format('hm_dht22'))
    #and now the AVERAGE,MIN,MAX
    # last hour 5 seconds 720 points
    theCMD.append("RRA:AVERAGE:0.5:1:721")
    theCMD.append("RRA:MIN:0.5:1:720")
    theCMD.append("RRA:MAX:0.5:1:720")
    #last 3 hours 30 seconds 360 points
    theCMD.append("RRA:AVERAGE:0.5:6:360")
    theCMD.append("RRA:MIN:0.5:6:360")
    theCMD.append("RRA:MAX:0.5:6:360")
    #last 48 hours 5 mins 576 points
    theCMD.append("RRA:AVERAGE:0.5:60:576")
    theCMD.append("RRA:MIN:0.5:60:576")
    theCMD.append("RRA:MAX:0.5:60:576")
    #last week 15 mins 672 points
    theCMD.append("RRA:AVERAGE:0.5:180:672")
    theCMD.append("RRA:MIN:0.5:180:672")
    theCMD.append("RRA:MAX:0.5:180:672")
    #last month 90 mins 496 points
    theCMD.append("RRA:AVERAGE:0.5:5400:496")
    theCMD.append("RRA:MIN:0.5:5400:496")
    theCMD.append("RRA:MAX:0.5:5400:496")
    #last year 24Hours 730 points
    theCMD.append("RRA:AVERAGE:0.5:17280:730")
    theCMD.append("RRA:MIN:0.5:17280:730")
    theCMD.append("RRA:MAX:0.5:17280:730")
    subprocess.call(theCMD)
    #transfer rrdtool to /webdata
    theCMD = ['cp', 'data_DHT22Y.rrd', '/webdata/data_DHT22Y.rrd'] 
    subprocess.call(theCMD)