Example #1
0
    def get_intervals(self):
        fh = gzip.GzipFile(self.fs_path, 'rb')
        try:
            info = whisper.__readHeader(fh) # evil, but necessary.
        finally:
            fh.close()

        start = time.time() - info['maxRetention']
        end = max( os.stat(self.fs_path).st_mtime, start )
        return IntervalSet( [Interval(start, end)] )
Example #2
0
  def get_intervals(self):
    fh = gzip.GzipFile(self.fs_path, 'rb')
    try:
      info = whisper.__readHeader(fh) # evil, but necessary.
    finally:
      fh.close()

    start = time.time() - info['maxRetention']
    end = max( os.stat(self.fs_path).st_mtime, start )
    return IntervalSet( [Interval(start, end)] )
Example #3
0
def do_scale(fname):
    with open(fname, 'r+b') as fh:
        header = __readHeader(fh)
        for archive in header['archives']:
            assert pointSize * archive['points'] == archive['size']
            fh.seek(archive['offset'])
            for n in range(archive['points']):
                time, value = unpack(pointFormat, fh.read(pointSize))
                fh.seek(-pointSize, 1)
                fh.write(pack(pointFormat, time, value * 1024))
Example #4
0
    def getIntervals(self):
        if not gzip:
            return []

        fh = gzip.GzipFile(self.fs_path, 'rb')
        try:
            start = time.time() - whisper.__readHeader(fh)['maxRetention']
            end = max(os.stat(self.fs_path).st_mtime, start)
        finally:
            fh.close()
        return [(start, end)]
Example #5
0
  def getIntervals(self):
    if not gzip:
      return []

    fh = gzip.GzipFile(self.fs_path, 'rb')
    try:
      start = time.time() - whisper.__readHeader(fh)['maxRetention']
      end = max( os.stat(self.fs_path).st_mtime, start )
    finally:
      fh.close()
    return [ (start, end) ]
Example #6
0
def set_xff(path, xff):
    with open(path) as f:
        header = whisper.__readHeader(f)
        agg_method = header['aggregationMethod']
        old_xff = header['xFilesFactor']

    try:
        whisper.setAggregationMethod(path, agg_method, xff)
    except IOError as e:
        sys.stderr.write("[ERROR] file '%s' not exist!\n" % path)
        option_parser.print_help()
        sys.exit(1)
    except whisper.WhisperException as e:
        raise SystemExit("[ERROR] %s" % e)

    print 'update xff: %s (%s -> %s)' % (path, old_xff, xff)
Example #7
0
def run(args):
  with open(args.filename, 'rb') as fh:
    info = whisper.__readHeader(fh)

    print '%s: period=%s, aggregation=%s, propagation=%s, archives=%s' % \
      (args.filename, info['maxRetention'], info['aggregationMethod'],
      info['xFilesFactor'], len(info['archives']))

    for i, archive in enumerate(info['archives']):
      print '  period=%s, points=%s, seconds=%s, size=%s, offset=%s' % \
        (archive['retention'], archive['points'], archive['secondsPerPoint'],
        archive['size'], archive['offset'])

    if not args.header:
      # Request all points until now. toInterval will be equal to now + step.
      (fromInterval, toInterval, step), points = whisper.file_fetch(fh, 0, None)
      print 'from=%s, to=%s, step=%s' % (fromInterval, toInterval, step)
      if any(points):
        for point in points:
          print point