def get_many_clients(self, creds, client_count):
     rc = RestClient(creds["QHOST"], 8000)
     rc.login(creds["QUSER"], creds["QPASS"])
     ips = []
     rcs = []
     for d in rc.network.list_network_status_v2(1):
         ips.append(d['network_statuses'][0]['address'])
     for i in range(0, client_count):
         rcc = RestClient(ips[i % len(ips)], 8000)
         rcc.login(creds["QUSER"], creds["QPASS"])
         rcs.append(rcc)
     return rcs
Esempio n. 2
0
def main():
    # Initial setup
    rc1 = RestClient(cluster1, 8000)
    rc1.login(api_user, api_password)
    rc2 = RestClient(cluster2, 8000)
    rc2.login(api_user, api_password)

    relationship_id = get_relationship_id(rc2, "/keyva_demo/")
    rc2.replication.make_target_writable(relationship_id=relationship_id)
    rc1.replication.modify_source_relationship(relationship_id=relationship_id, source_root_read_only=True)
    time.sleep(15)
    rc2.replication.reverse_target_relationship(relationship_id=relationship_id, source_address=cluster1)
    rc1.replication.reconnect_target_relationship(relationship_id=relationship_id)
Esempio n. 3
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Walk levels of a known Qumulo filesystem tree and gather capacity metrics'
    )
    parser.add_argument('-s', help='Qumulo hostname', required=True)
    parser.add_argument('-u', help='Qumulo api user', required=True)
    parser.add_argument('-p', help='Qumulo api passord')
    parser.add_argument('-d', help='Starting directory path', required=True)
    parser.add_argument('-o',
                        help='Output file name',
                        default='qumulo-data-by-directory.csv')
    parser.add_argument('-l', nargs='+', help='Level names', required=True)
    args, other_args = parser.parse_known_args()

    if not args.p:
        args.p = getpass()

    creds = {"QHOST": args.s, "QUSER": args.u, "QPASS": args.p}
    level_names = []

    # initialize the REST client
    rc = RestClient(creds["QHOST"], 8000)
    rc.login(creds["QUSER"], creds["QPASS"])

    get_capacity_aggregates(rc, args.d, args.l, args.o)
    print("Created file: %s" % args.o)
Esempio n. 4
0
 def __init__(self, cluster, username, password, data_dir):
     self.username = username
     self.password = password
     self.api_cli = RestClient(cluster, 8000)
     self.qumulo_api_call(self.api_cli.login, username=username, password=password)
     self.data_dir = data_dir
     self.datestamp = self.timestamp[:10]
Esempio n. 5
0
 def __init__(self, hostname, user, password):
     self.hostname = hostname
     self.user = user
     self.password = password
     self.rc = RestClient(self.hostname, 8000)
     self.rc.login(self.user, self.password)
     self.date = date.today()
Esempio n. 6
0
def process_snap_diff(creds, path, snap_before, snap_after):
    q = multiprocessing.Queue()
    q_len = multiprocessing.Value("i", 0)
    q_lock = multiprocessing.Lock()

    pool = multiprocessing.Pool(MAX_WORKER_COUNT, 
                                 snap_worker,
                                 (creds, q, q_lock, q_len))

    rc = RestClient(creds["QHOST"], 8000)
    rc.login(creds["QUSER"], creds["QPASS"])
    results = rc.snapshot.get_all_snapshot_tree_diff(older_snap=snap_before['id'], newer_snap=snap_after['id'])
    ent_list = []
    for res in results:
        for ent in res['entries']:
            print(ent)
            add_to_q(q, q_lock, q_len, {"type":"diff_item", "value": ent})
    #         ent_list.append(ent)
    #         if len(ent_list) > 1:
    #             add_to_q(q, q_lock, q_len, ent_list)
    #             ent_list = []
    # add_to_q(q, q_lock, q_len, ent_list)
    while True:
        log_it("Queue length: %s" % q_len.value)
        time.sleep(WAIT_SECONDS)
        if q_len.value <= 0:
            break
Esempio n. 7
0
def walk_tree(QHOST, QUSER, QPASS, start_path):
    global gvars
    if start_path[-1] != "/":
        start_path = start_path + "/"
    log("Tree walk on Qumulo cluster %s starting at path %s" %
        (QHOST, start_path))
    gvars = Gvars(QHOST, QUSER, QPASS)
    the_pool = multiprocessing.Pool(16, worker_main)
    rc = RestClient(gvars.QHOST, 8000)
    rc.login(gvars.QUSER, gvars.QPASS)
    root = rc.fs.read_dir_aggregates(path=start_path, max_depth=0)
    log("Directories to walk: %12s" %
        "{:,}".format(int(root["total_directories"])))
    log("      Files to walk: %12s" % "{:,}".format(int(root["total_files"])))
    add_to_queue({"path": start_path, "max_depth": 5})
    time.sleep(0.1)  # wait a bit for the queue to get build up.
    wait_count = 0
    while gvars.the_queue_len.value > 0:
        wait_count += 1
        if (wait_count % 50) == 0:  # show status every ~5 seconds
            log("Processed %s entries. Queue length: %s" %
                (gvars.done_queue_len.value, gvars.the_queue_len.value))
        time.sleep(0.1)
    the_pool.terminate()
    log("Processed %s entries." % gvars.done_queue_len.value)
    log("Done with tree walk. Combining results")
    fw = open("file-list.txt", "w")
    for f in glob.glob('out-*.txt'):
        fr = open(f, "r")
        fw.write(fr.read())
        fr.close()
        os.remove(f)
    del gvars
    log("Results save to file: file-list.txt")
Esempio n. 8
0
 def rc_get_ips(creds: Creds) -> Sequence[str]:
     rc = RestClient(creds["QHOST"], 8000)
     rc.login(creds["QUSER"], creds["QPASS"])
     ips = []
     for d in rc.network.list_network_status_v2(1):
         ips.append(d["network_statuses"][0]["address"])
     return ips
Esempio n. 9
0
def main():
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('-s', help='Qumulo hostname', required=True)
    parser.add_argument('-u',
                        help='Qumulo API user',
                        default=os.getenv('QUSER') or 'admin')
    parser.add_argument('-p',
                        help='Qumulo API password',
                        default=os.getenv('QPASS') or 'admin')
    parser.add_argument('-d', help='Root Directory', default='/')
    try:
        args, other_args = parser.parse_known_args()
    except:
        print("-" * 80)
        parser.print_help()
        print("-" * 80)
        sys.exit(0)
    if args.d != '/':
        args.d = re.sub('/$', '', args.d) + '/'

    creds = {"QHOST": args.s, "QUSER": args.u, "QPASS": args.p}
    log_it("Log in to: %s" % (args.s))
    rc = RestClient(creds["QHOST"], 8000)
    rc.login(creds["QUSER"], creds["QPASS"])

    res = rc.snapshot.list_snapshot_statuses()
    snap_before = None
    snap_after = None
    for snap in sorted(res['entries'], key=lambda d: int(d['id'])):
        if snap['name'] == SNAP_NAME and snap['source_file_path'] == args.d:
            if snap_before is None:
                snap_before = snap
            elif snap_after is None:
                snap_after = snap

    if snap_before and not snap_after:
        snap_after = rc.snapshot.create_snapshot(path=args.d, name=SNAP_NAME)
        log_it("Created new snapshot %s on %s" % (snap_after['id'], args.d))

    if snap_before and snap_after:
        log_it("Diffing snaps on %s between %s and %s" %
               (args.d, snap_before['timestamp'][0:16],
                snap_after['timestamp'][0:16]))
        process_snap_diff(creds, args.d, snap_before['id'], snap_after['id'])
        rc.snapshot.delete_snapshot(snapshot_id=snap_before['id'])
    else:
        # initial tree walk
        snap_before = rc.snapshot.create_snapshot(path=args.d, name=SNAP_NAME)
        log_it("Initial tree walk for: %s+snap:%s" %
               (args.d, snap_before['id']))
        log_file = "output-qumulo-fs-index-%s-tree.txt" % (re.sub(
            "[^a-z0-9]+", "_", args.d))
        w = QWalkWorker(
            creds,
            Search([
                '--re', '.', '--cols',
                'dir_id,id,type,path,name,size,blocks,owner,change_time,link_target,NEW'
            ]), args.d, str(snap_before['id']), None, log_file, None)
        w.run()
Esempio n. 10
0
def process_dirs(work_queue, i):
    print("Thread{0}: starting".format(i))
    rc1 = RestClient(cluster1, 8000)
    rc1.login(api_user, api_password)
    rc2 = RestClient(cluster2, 8000)
    rc2.login(api_user, api_password)
    while not work_queue.empty():
        directory = work_queue.get()
        if int(directory[-5:]) % 100 == 0:
            print("Thread{0:02d}: removing SMB share {1}".format(i, directory))
        delete_smb_share(rc1,
                         share_name="test_{0}".format(directory),
                         fs_path="/keyva_demo/{0}".format(directory))
        delete_smb_share(rc2,
                         share_name="test_{0}".format(directory),
                         fs_path="/keyva_demo/{0}".format(directory))
        work_queue.task_done()
def login(configdict):
    '''Obtain credentials from the REST server'''
    try:
        rc = RestClient(configdict['host'], configdict['port'])
        rc.login(configdict['user'], configdict['password'])
    except Exception, excpt:
        print "Error connecting to the REST server: %s" % excpt
        print __doc__
        sys.exit(1)
def worker_main():
    global gvars
    rc = RestClient(gvars.QHOST, 8000)
    rc.login(gvars.QUSER, gvars.QPASS)
    while True:
        item = gvars.the_queue.get(True)
        list_dir(rc, item)
        with gvars.the_queue_len.get_lock():
            gvars.the_queue_len.value -= 1
Esempio n. 13
0
def read_time_series_from_cluster(host: str, user: str, password: str,
                                  port: int) -> List[Mapping[str, Any]]:
    """
    Communicates with the cluster to grab the analytics in time series format
    """
    rest_client = RestClient(host, port)
    rest_client.login(user, password)
    return rest_client.analytics.time_series_get(
        begin_time=calculate_begin_time(CSV_FILENAME))
def api_perf_counters():
    rc = get_rc()
    pc_data = {}
    for n in rc.network.list_network_status_v2(1):
        rc = RestClient(n['network_statuses'][0]['address'], 8000)
        rc.login('admin', app.config['API_PASSWORD'])
        resp = rc.request("GET", "/v1/metrics/")
        pc_data[n['node_id']] = resp
    return json.dumps(pc_data)
Esempio n. 15
0
def qumulo_connect_api(qumulo_cluster_ips, qumulo_api_user,
                       qumulo_api_password):
    ip = random.choice(qumulo_cluster_ips)
    rc = RestClient(ip, 8000)
    creds = rc.login(qumulo_api_user, qumulo_api_password)
    ses = requests.Session()
    headers = {"Authorization": "Bearer %s" % str(creds.bearer_token)}
    ses.headers.update(headers)
    return ip, ses
Esempio n. 16
0
def qumulo_connect_api(qumulo_cluster_ips, qumulo_api_user, qumulo_api_password):
    ip = random.choice(qumulo_cluster_ips)
    rc = RestClient(ip, 8000)
    creds = rc.login(qumulo_api_user, qumulo_api_password)
    ses = requests.Session()
    adapter = requests.adapters.HTTPAdapter(pool_maxsize=100)
    ses.mount('https://', adapter)
    headers = {"Authorization": "Bearer %s" % str(creds.bearer_token)}
    ses.headers.update(headers)
    return ip, ses
Esempio n. 17
0
def get_qumulo_cluster_ips(qumulo_cluster, qumulo_api_user, qumulo_api_password):
    qumulo_cluster_ips = []
    rc = RestClient(qumulo_cluster, 8000)
    creds = rc.login(qumulo_api_user, qumulo_api_password)
    for d in rc.cluster.list_nodes():
        c = rc.network.get_network_status_v2(1, d['id'])
        if len(c['network_statuses'][0]['floating_addresses']) > 0:
            qumulo_cluster_ips.append(c['network_statuses'][0]['floating_addresses'][0])
        else:
            qumulo_cluster_ips.append(c['network_statuses'][0]['address'])
    return qumulo_cluster_ips
Esempio n. 18
0
def main():

    parser = argparse.ArgumentParser(description='Example command usage usage:\npython timeseries-to-csv.py --host product --user admin --pass admin'
                                    , epilog='.'
                                    , formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("--host", required=True, help="Required: Specify host (Qumulo cluster)")
    parser.add_argument("--user", required=True, help="Specify api user")
    parser.add_argument("--pass", required=True, dest="passwd", help="Specify api password ")
    args = parser.parse_args()

    rc = RestClient(args.host, 8000)
    rc.login(args.user, args.passwd);

    last_line = None
    columns = ["iops.read.rate", "iops.write.rate", 
               "throughput.read.rate", "throughput.write.rate",
               "reclaim.deferred.rate", "reclaim.snapshot.rate"]

    csv_file_name = "qumulo-timeseries-data.csv"

    if os.path.exists(csv_file_name):
        # read to the last line in the file
        with open(csv_file_name, "rb") as csvfile:
            reader = csv.reader(csvfile)
            for row in reader:
                last_line = row

    # at most we'll have 1 day of data
    begin_time = int(time.time()) - 60 * 60 * 24
    # otherwise, pull only the latest data, if we already have a file
    if last_line is not None: 
        begin_time = int(last_line[0]) + 5
    results = rc.analytics.time_series_get(begin_time = begin_time)
    print("Appending %s results to '%s'." % (len(results[0]['values']), csv_file_name))
    data = {}
    for i in range(0,len(results[0]['times'])-1):
        ts = results[0]['times'][i]
        data[ts] = [None] * len(columns)

    for series in results:
        if series['id'] not in columns:
            continue
        for i in range(0,len(series['values'])):
            ts = series['times'][i]
            data[ts][columns.index(series['id'])] = series['values'][i]

    fw = open(csv_file_name, "a")
    if last_line is None:
        fw.write("unix.timestamp,gmtime," + ",".join(columns) + "\r\n")
    for ts in sorted(data):
        gmt = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(ts))
        fw.write("%s,%s," % (ts, gmt) + ",".join([str(d) for d in data[ts]]) + "\r\n")
    fw.close()
Esempio n. 19
0
 def run(self) -> None:
     if not os.path.exists("old-queue.txt"):
         self.run_task.work_start(self)
         rc = RestClient(self.creds["QHOST"], 8000)
         rc.login(self.creds["QUSER"], self.creds["QPASS"])
         if self.snap:
             d_attr = rc.fs.read_dir_aggregates(path=self.start_path,
                                                snapshot=self.snap,
                                                max_entries=0)
         else:
             d_attr = rc.fs.read_dir_aggregates(path=self.start_path,
                                                max_entries=0)
         d_attr["total_directories"] = 1 + int(d_attr["total_directories"])
         d_attr["total_inodes"] = d_attr["total_directories"] + int(
             d_attr["total_files"])
         log_it(
             "Walking - %(total_directories)9s dir|%(total_inodes)10s inod"
             % d_attr)
         self.add_to_queue({
             "type": "list_dir",
             "path_id": d_attr["id"],
             "snapshot": self.snap
         })
         self.wait_for_complete()
     else:
         with open("old-queue.txt", "r") as fr:
             last_time = time.time()
             for line in fr:
                 # back off because we have a lot of directories now
                 while self.queue_len.value > MAX_QUEUE_LENGTH:
                     if time.time() - last_time >= WAIT_SECONDS:
                         self.print_status()
                         last_time = time.time()
                     time.sleep(1)
                 self.add_to_queue({
                     "type": "list_dir",
                     "path_id": line.strip(),
                     "snapshot": self.snap,
                 })
                 if time.time() - last_time >= WAIT_SECONDS:
                     self.print_status()
                     last_time = time.time()
         os.remove("old-queue.txt")
         self.wait_for_complete()
     self.pool.close()
     self.pool.join()
     self.queue.close()
     self.queue.join_thread()
     if self.rc:
         rc.close()
         del rc
     del self.pool
     del self.queue
Esempio n. 20
0
def worker_main():
    global gvars
    proc = multiprocessing.current_process()
    rc = RestClient(gvars.QHOST, 8000)
    rc.login(gvars.QUSER, gvars.QPASS)
    out_file = open("out-%s.txt" % proc.pid, "w")
    while True:
        item = gvars.the_queue.get(True)
        list_dir(rc, item, out_file)
        out_file.flush()
        with gvars.the_queue_len.get_lock():
            gvars.the_queue_len.value -= 1
Esempio n. 21
0
 def ids_to_attrs(cluster, id_attr_list):
     inode_types = {}
     qumulo_client = RestClient(cluster['host'], 8000)
     qumulo_client.login(cluster['user'], cluster['password'])
     for inode_id in id_attr_list:
         try:
             attrs = qumulo_client.fs.get_attr(id_=inode_id)
             if inode_id not in inode_types:
                 inode_types[inode_id] = attrs["type"]
         except:
             pass
     return inode_types
Esempio n. 22
0
def process_dirs(work_queue1, work_queue2, i):
    global replication_sync
    print("Thread{0}: starting".format(i))
    rc1 = RestClient(cluster1, 8000)
    rc1.login(api_user, api_password)
    rc2 = RestClient(cluster2, 8000)
    rc2.login(api_user, api_password)
    while not work_queue1.empty():
        try:
            directory = work_queue1.get(timeout=30)
        except queue.Empty:
            break
        # if int(directory[-5:]) % 100 == 0:
        #     print("Thread{0:02d}: making dir {1}".format(i, directory))
        create_dir(rc1, name=directory, dir_path='/keyva_demo')
        work_queue1.task_done()
    counter = 0
    while replication_sync != "success":
        if counter == 600:
            raise RuntimeError("Timed out waiting on replication sync.")
        time.sleep(1)
        counter += 1
    while not work_queue2.empty():
        try:
            directory = work_queue2.get(timeout=30)
        except queue.Empty:
            break
        # if int(directory[-5:]) % 100 == 0:
        #     print("Thread{0:02d}: making smb share test_{1}".format(i, directory))
        create_smb_share(rc1,
                         share_name="test_{0}".format(directory),
                         fs_path="/keyva_demo/{0}".format(directory))
        create_smb_share(rc2,
                         share_name="test_{0}".format(directory),
                         fs_path="/keyva_demo/{0}".format(directory))
        create_test_file(rc1,
                         filename="testfile",
                         dir_path="/keyva_demo/{0}".format(directory))
        work_queue2.task_done()
    print("Thread{0}: complete".format(i))
def get_file_attrs(x):
    credentials, paths = x
    client = RestClient(credentials["cluster"], credentials["port"])
    client.login(credentials["user"], credentials["password"])
    result = []
    for path in paths:
        if seen.has_key(path):
            result += [seen[path]]
            continue
        str_owner = enumerate_owner(client, path)
        seen[path] = str_owner
        result.append(str_owner)
    return result
Esempio n. 24
0
    def __init__(self, cluster, conf):
        self.DIRECTORY_DEPTH_LIMIT = conf['DIRECTORY_DEPTH_LIMIT']
        self.IOPS_THRESHOLD = conf['IOPS_THRESHOLD']
        self.THROUGHPUT_THRESHOLD = conf['THROUGHPUT_THRESHOLD']
        self.DIRECTORIES_ONLY = conf['DIRECTORIES_ONLY']

        # initial fields in the data dict
        # "qumulo_host"
        # "client_ip"
        # "client_host_name"
        # "path"
        # "path_levels"
        # "timestamp"

        # default dict for the metrics
        self.EMPTY_DATA = OrderedDict([
            ('file-throughput-write', 0.0),
            ('file-throughput-read', 0.0),
            ('file-iops-write', 0.0),
            ('file-iops-read', 0.0),
            ('metadata-iops-write', 0.0),
            ('metadata-iops-read', 0.0),
            ('iops-total', 0.0),
            ('throughput-total', 0.0),
        ])

        self.ids_to_paths = {}
        self.ips_to_hostnames = {}
        self.combined_data = {}
        self.new_db_entries = []

        self.pool = Pool(6)
        self.cluster = cluster

        log("Connect to Qumulo API for cluster: %s" % self.cluster['host'])
        self.qumulo_client = RestClient(self.cluster['host'], 8000)
        self.qumulo_client.login(self.cluster['user'],
                                 self.cluster['password'])

        log("Get current activity data from Qumulo API for %s" %
            self.cluster['host'])
        activity_data = self.qumulo_client.analytics.current_activity_get()
        self.current_timestamp = datetime.datetime.utcnow()
        self.current_epoch = int(time.time())
        # Filter out client IPs based on regex in per-cluster config
        self.entries = list()
        client_ip_regex = self.cluster.get('client_ip_regex', '.*')
        for entry in activity_data['entries']:
            if re.match(client_ip_regex, entry['ip']):
                self.entries.append(entry)
        log("Successfully recieved %s activity entries." % len(self.entries))
def do_it(opts, args):
    credentials = {
        "user": opts.user,
        "password": opts.password,
        "cluster": opts.cluster
    }

    # Qumulo API login
    client = RestClient(opts.cluster, opts.port)
    client.login(opts.user, opts.password)

    total_capacity_used = int(
        client.fs.read_dir_aggregates(args[0])['total_capacity'])

    pool = Pool(opts.concurrency)

    # First build a vector of all samples...
    samples = get_samples(pool, args[0], credentials, opts)

    # Then get a corresponding vector of owner strings
    owner_vec = get_owner_vec(pool, credentials, samples, opts)

    owners = {}
    directories = {}

    # Create a mapping of user to tree...
    for s, owner in zip(samples, owner_vec):
        owners.setdefault(owner, SampleTreeNode(""))
        owners[owner].insert(s["name"], 1)

    def format_capacity(samples):
        bytes_per_terabyte = 1000.**4
        if opts.dollars_per_terabyte != None:
            return "$%0.02f/month" % (samples * total_capacity_used /
                                      opts.samples / bytes_per_terabyte *
                                      opts.dollars_per_terabyte)
        else:
            return pretty_print_capacity(samples * total_capacity_used /
                                         opts.samples)

    print "Total: %s" % (format_capacity(opts.samples))
    sorted_owners = sorted(
        owners.items(), lambda x, y: cmp(y[1].sum_samples, x[1].sum_samples))
    # For each owner, print total used, then refine the tree and dump it.
    for name, tree in sorted_owners:
        print "Owner %s (~%0.1f%%/%s)" % (name, tree.sum_samples / float(
            opts.samples) * 100, format_capacity(tree.sum_samples))
        tree.prune_until(max_leaves=opts.max_leaves,
                         min_samples=opts.min_samples)

        print tree.__str__("    ", lambda x: format_capacity(x))
 def __init__(self, cluster, username, password, data_dir):
     self.username = username
     self.password = password
     self.data_dir = data_dir
     self.timestamp = time.strftime('%Y-%m-%d %H:%M:%S')
     self.datestamp = self.timestamp[:10]
     self.searched_paths = {}
     self.files_added = {}
     self.api_call_times = {}
     # Initialize rest client
     self.api_cli = RestClient(cluster, 8000)
     self.qumulo_api_call(self.api_cli.login,
                          username=username,
                          password=password)
def get_file_attrs(x):
    credentials, paths = x
    client = RestClient(credentials["cluster"], 8000)
    client.login(credentials["user"], credentials["password"])
    result = []
    for path in paths:
        if seen.has_key(path):
            result += [seen[path]]
            continue
        owner_id = client.fs.get_attr(path)["owner"]
        str_owner = translate_owner_to_owner_string(client, owner_id)
        seen[path] = str_owner
        result.append(str_owner)
    return result
Esempio n. 28
0
def timestamps():
    '''
    Get Qumulo Timestamps
    '''

    # Get user informaation
    creds = Creds.objects.first()
    user = creds.user
    password = creds.password
    ipaddress = creds.ipaddress

    columns = [
        "iops.read.rate", "iops.write.rate", "throughput.read.rate",
        "throughput.write.rate", "reclaim.deferred.rate",
        "reclaim.snapshot.rate"
    ]

    #
    feed = []
    rc = RestClient(ipaddress, 8000)
    rc.login(user, password)
    #
    begin_time = int(time.time()) - 60 * 60 * 24
    results = rc.analytics.time_series_get(begin_time=begin_time)
    data = {}
    #
    for i in range(0, len(results[0]['times']) - 1):
        ts = results[0]['times'][i]
        data[ts] = [None] * len(columns)

    for series in results:
        if series['id'] not in columns:
            continue
        for i in range(0, len(series['values'])):
            ts = series['times'][i]
            data[ts][columns.index(series['id'])] = series['values'][i]

    for key in data.items():
        tmp = [
            key[0], key[1][0], key[1][1], key[1][2], key[1][3], key[1][4],
            key[1][5]
        ]
        if key[1][0] == 0.0 and key[1][1] == 0.0 and key[1][2] == 0.0 and key[
                1][3] == 0.0 and key[1][4] == 0.0 and key[1][5] == 0.0:
            continue
        feed.append(tmp)

    return render_template('main/index.sm.html', feed=feed)
Esempio n. 29
0
    def __init__(self, cluster):
        # default dictionary for activity data
        self.EMPTY_DATA = OrderedDict([
            ('file-throughput-write', 0.0),
            ('file-throughput-read', 0.0),
            ('file-iops-write', 0.0),
            ('file-iops-read', 0.0),
            ('metadata-iops-write', 0.0),
            ('metadata-iops-read', 0.0),
            ('iops-total', 0.0),
            ('throughput-total', 0.0),
        ])

        PG_SETUP_SQL = """CREATE TABLE qumulo_activity(
                        qumulo_host VARCHAR(128),
                        client_ip VARCHAR(20),
                        client_hostname VARCHAR(256),
                        path VARCHAR(2048),
                        ts TIMESTAMP,
                        file_throughput_write FLOAT,
                        file_throughput_read FLOAT,
                        file_iops_write FLOAT,
                        file_iops_read FLOAT,
                        metadata_iops_write FLOAT,
                        metadata_iops_read FLOAT,
                        iops_total FLOAT,
                        throughput_total FLOAT
                        );"""
        self.ids_to_paths = {}
        self.ips_to_hostnames = {}
        self.combined_data = {}
        self.new_db_entries = []

        self.pool = Pool(6)
        self.cluster = cluster

        log("Connect to Qumulo API for cluster: %s" % self.cluster['host'])
        self.qumulo_client = RestClient(self.cluster['host'], 8000)
        self.qumulo_client.login(self.cluster['user'],
                                 self.cluster['password'])

        log("Get current activity data from Qumulo API for %s" %
            self.cluster['host'])
        activity_data = self.qumulo_client.analytics.current_activity_get()
        self.current_timestamp = datetime.datetime.utcnow()
        self.current_epoch = int(time.time())
        self.entries = activity_data['entries']
        log("Successfully recieved %s activity entries." % len(self.entries))
Esempio n. 30
0
def main():
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('-s', help='Qumulo hostname', required=True)
    parser.add_argument('-u', help='Qumulo API user', 
                              default=os.getenv('QUSER') or 'admin')
    parser.add_argument('-p', help='Qumulo API password',
                              default=os.getenv('QPASS') or 'admin')
    parser.add_argument('-d', help='Root Directory', default='/')
    try:
        args, other_args = parser.parse_known_args()
    except:
        print("-"*80)
        parser.print_help()
        print("-"*80)
        sys.exit(0)
    if args.d != '/':
        args.d = re.sub('/$', '', args.d) + '/'

    creds = {"QHOST": args.s, "QUSER": args.u, "QPASS": args.p}
    log_it("Log in to: %s" % (args.s))
    rc = RestClient(creds["QHOST"], 8000)
    rc.login(creds["QUSER"], creds["QPASS"])

    res = rc.snapshot.list_snapshot_statuses()
    existing_snap = None
    for snap in res['entries']:
        if snap['name'] == SNAP_NAME and snap['source_file_path'] == args.d:
            existing_snap = snap
            break
    # snap = rcs[len(rcs)-1].snapshot.create_snapshot(path=path, name=SNAP_NAME)

    snap_before = rc.snapshot.get_snapshot(746219)
    snap_after = rc.snapshot.get_snapshot(748466)

    if snap_before:
        process_snap_diff(creds, 
                          args.d,
                          snap_before,
                          snap_after
                          )
    else:
        w = QWalkWorker(creds, 
                    Search(['--re', '.', 
                            '--cols', 'dir_id,id,type,name,size,blocks,owner,change_time']), 
                    args.d,
                    None, "qumulo-fs-index.txt", None)