/usr/bin/convert-wsp-to-ceres is in python-ceres 0.10.0~git20130913-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #! /usr/bin/python
import sys
import os
import time
from os.path import exists, dirname, basename, isfile, isdir, join
from optparse import OptionParser
import whisper
import ceres
parser = OptionParser(usage='''%prog [options] <path/to/somefile.wsp>''')
parser.add_option('--verbose', action='store_true')
parser.add_option('--delete', action='store_true')
options, args = parser.parse_args()
if not args:
print "You must specify a wsp file"
parser.print_usage()
sys.exit(1)
wsp_file = args[0]
wsp_dir = dirname(wsp_file)
metric_name = basename(wsp_file)[:-4] #strip .wsp
ceres_node_dir = join(wsp_dir, metric_name)
if isdir(ceres_node_dir):
print "error: ceres node directory already exists (%s)" % ceres_node_dir
sys.exit(1)
tree = ceres.getTree(ceres_node_dir)
if not tree:
print "error: the specified path is not in a ceres tree"
sys.exit(1)
nodePath = tree.getNodePath(ceres_node_dir)
if options.verbose:
print "extracting datapoints from wsp file"
timeInfo, values = whisper.fetch(wsp_file, fromTime=0, untilTime=time.time())
datapoints = zip( xrange(*timeInfo), values )
datapoints = [ (t,v) for (t,v) in datapoints if v is not None ]
if options.verbose:
print "creating ceres node %s" % nodePath
node = tree.createNode(nodePath)
if options.verbose:
print "importing %d datapoints" % len(datapoints)
node.write(datapoints)
if options.delete:
if options.verbose:
print "deleting original wsp file: %s" % wsp_file
os.unlink(wsp_file)
if options.verbose:
print "conversion successful"
|