示例#1
0
    def __init__(self, section, options={}):
        """Initialise the cache thread

        Manage a cache for the rrd.

        A timer in a separated thread will pickle the cache to disk every 30 seconds.

        An other thread will update the rrd every hours

        :param options: The options used to start the worker.
        :type clientid: str
        """
        self.section = section
        BaseThread.__init__(self, options=options)
        self.config_timeout_delay = 1
        self.loop_sleep = 0.01
        self._lock = threading.Lock()
        #~ self._cache_rrd_ttl = 60*60
        self._cache_rrd_ttl = 60*60
        self._cache_pickle_ttl = 240
        self._cache_pickle_timer = None
        self._cache_dead_ttl = 60*60*24
        self._cache_dead_timer = None
        self._thread_delay = 0.01
        self._rrd_rotate_next_run = None
        self._rrd_rotate_ttl = 1
        self._dirmask = None
        self._filemask = None
        self._cache = {}
        """
        whe have a datasource with a unique_name haddnode but at component start, we don't have it.
        whe receive data from mqtt with params : haddvalue, value_uuid, value_index at etime

        whe should update the rrd with : rtime:val1:val2:val3 ...

        Whe should be abble to flush a rrd file for graphing

        cache { 'rrd_0001' : { 'step':300, 'values' : {'epoch_time' : { 0 : 'U', ...}}, 'labels':{0:...}}

        When updating a data, we can find the latest serie values filtering on epoch_time

        We should look at the cache to find rrd_files that need a new serie of values (now - last_epoch) > step.
        In this case, we add a new serie of with 'U' as values.

                hadd
                    value_uuid
                        value_index
        """
        self.epoch = datetime.datetime(1970,1,1)
        self._mqttc = None
        """
        """
        self.params = {}
示例#2
0
    def __init__(self, section, options={}):
        """Initialise the cache thread

        Manage a cache for the rrd.

        A timer in a separated thread will pickle the cache to disk every 30 seconds.

        An other thread will update the rrd every hours

        :param options: The options used to start the worker.
        :type clientid: str
        """
        self.section = section
        BaseThread.__init__(self, options=options)
        self.config_timeout_delay = 1.5
        self.loop_sleep = 0.005
        self.host = "localhost"
        self.port = 8081
        self._server = None