Python, rrdtool create - time stamp, timezone
===

Hello everybody in the house!

my python script creates an rrd file. The create_rrd and update function is started with the values "interval" and "starttime" (current epoch). The epoch time is correct when the functions are used. BUT: Doing an rrdtool fetch on the rrd file, the last time stamp is everytime 2 hours ago. My trick of calling subprocess.Popen with the ENV 'TZ' doesn't work.
So all rrd file updates fail.
Does anybody knows why, what I am doing wrong?

Best regards
Stefan



        def create_rrd(self, interval, starttime):
        interval = str(interval)
        interval_mins = float(interval) / 60
        heartbeat = str(int(interval) * 2)
        ds_string = 'DS:test:GAUGE:%s:U:U' % heartbeat
        rra_1 = 'RRA:AVERAGE:0.5:1:' + str(int(4000 / interval_mins))
        rra_2 = 'RRA:AVERAGE:0.5:' +  str(int(30 / interval_mins)) + ':800'
        rra_3 = 'RRA:AVERAGE:0.5:' + str(int(120 / interval_mins)) + ':800'
        rra_4 = 'RRA:AVERAGE:0.5:' + str(int(1440 / interval_mins)) + ':800'
        cmd_create = [
            '/omd/versions/default/bin/rrdtool',
            'create',
            self.rrd_name,
            '-b',
            str(starttime-10),
            '--step',
            interval,
            ds_string,
            rra_1,
            rra_2,
            rra_3 ,
            rra_4,
        ]
        print cmd_create
        cmd = Popen(cmd_create, stdout=PIPE, stderr=PIPE, env={'LANG':'de_DE@euro','TZ':'Europe/Berlin'})
        cmd_output = cmd.communicate()
        self.errorprint(cmd_output)
        #p = Popen(["date"], env={'TZ':'America/New_York'})
        #p.wait()
        #p = Popen(["date"], env={'TZ':'Europe/Berlin'})
        #p.wait()


    def update(self, starttime, *values):
        values_args = ''.join([str(value) + ':' for value in values])[:-1]
        values_final = '%s:%s' % (str(starttime), values_args)
        cmd_update = [
                    '/omd/versions/default/bin/rrdtool',
                    'update',
                    self.rrd_name,
                    values_final,
        ]
        print cmd_update
        cmd = Popen(cmd_update, stdout=PIPE, stderr=PIPE, env={'LANG':'de_DE@euro','TZ':'Europe/Berlin'})
        cmd_output = cmd.communicate()
        self.errorprint(cmd_output

Here is the command list of the Popen for create and update:

    rrd create
    ['/omd/versions/default/bin/rrdtool', 'create', '/tmp/test1/CPU_utilization_util.rrd', '-b', '1342630417', '--step', '300', 'DS:test:GAUGE:600:U:U', 'RRA:AVERAGE:0.5:1:800', 'RRA:AVERAGE:0.5:6:800', 'RRA:AVERAGE:0.5:24:800', 'RRA:AVERAGE:0.5:288:800']
    rrd update
    ['/omd/versions/default/bin/rrdtool', 'update', '/tmp/test1/CPU_utilization_util.rrd', '1342630427:8.37649086759']