def counter(self, key, value, timestamp=None):
        _min, _max, count, _sum = self.stats.get(key, (None, None, 0, 0))
        count += 1
        _sum += value
        if _min is None or value < _min:
            _min = value
        if _max is None or value > _max:
            _max = value
        self.stats[key] = (_min, _max, count, _sum)
        if self.statsd_enabled and self.statsd_sock:
            packet = '%s.%s.%s:%d|c' % (self.statsd_prefix, self.name, key, value)
            packet = packet.encode('utf-8')
            try:
                self.statsd_sock.sendto(packet, self.statsd_addr)
            except (socket.error, socket.gaierror):
                pass
        if self.statsd_enabled and self.carbon:
            self.send_to_graphite(key, value, timestamp=timestamp)
        if self.statsd_enabled and self.file_d:
            if timestamp is None:
                timestamp = int(time.time())
            packet = self.line_fmt
            if not self.date_fmt:
                date = "%s" % timestamp
            else:
                date = datetime.datetime.fromtimestamp(timestamp).strftime(self.date_fmt)
            packet = packet.replace("
            packet = packet.replace("
            packet = packet.replace("
            packet = packet.replace("
            try:
                self.file_d.write(packet)
            except IOError:
                logger.warning("Could not write to the file: %s", packet)
        if self.broks_enabled:
            logger.debug("alignak stat brok: %s = %s", key, value)
            if timestamp is None:
                timestamp = int(time.time())
            return Brok({'type': 'alignak_stat',
                         'data': {
                             'ts': timestamp,
                             'type': 'counter',
                             'metric': '%s.%s.%s' % (self.statsd_prefix, self.name, key),
                             'value': value,
                             'uom': 'c'
                         }})
        return None