Esempio n. 1
0
File: mdt.c Progetto: LaHaine/lmt
static int
_get_mdtop (hash_t stats, const char *key, char *s, int len)
{
    uint64_t count = 0, sum = 0, sumsq = 0;
    int retval = -1;
    int n;

    (void)proc_lustre_parsestat (stats, key, &count, NULL, NULL, &sum, &sumsq);
    n = snprintf (s, len, "%"PRIu64";%"PRIu64";%"PRIu64";", count, sum, sumsq);
    if (n >= len) {
        if (lmt_conf_get_proto_debug ())
            msg ("string overflow");
        goto done;
    }
    retval = 0;
done:
    return retval;
}
Esempio n. 2
0
int
lmt_client_string (pctx_t ctx, char *s, int len)
{
    static uint64_t cpuused = 0, cputot = 0;
    struct utsname uts;
    double cpupct, mempct;
    int n, retval = -1, lustre_mounted = 0;
    hash_t stats_hash = NULL;
    uint64_t read_bytes = 0, write_bytes = 0;
    uint64_t read_count = 0, write_count = 0;
    uint64_t open_count = 0, close_count = 0;
    uint64_t getattr_count = 0, setattr_count = 0;
    uint64_t seek_count = 0, fsync_count = 0;
    uint64_t dhits_count = 0, dmisses_count = 0;
    char *path_base = "/proc/fs/lustre/llite", stats_file[256], name[256];
    DIR  *d = NULL;
    struct dirent *dir;

    d = opendir(path_base);
    if (d != NULL) {
        lustre_mounted = 1;
        while ((dir = readdir(d)) != NULL) {
            if (!strncmp(dir->d_name, ".", 1)) continue;
            strcpy(name, dir->d_name);
        }
    }
    closedir(d);

    if (uname (&uts) < 0) {
        err ("uname");
        goto done;
    }
    if (proc_stat2 (ctx, &cpuused, &cputot, &cpupct) < 0) {
        err ("error reading cpu usage from proc");
        goto done;
    }
    if (_get_mem_usage (ctx, &mempct) < 0)
        goto done;

    sprintf(stats_file, "%s/%s/stats", path_base, name);
    if (lustre_mounted && !access(stats_file, R_OK)) {
        if (proc_lustre_hashstats (ctx, name, &stats_hash) < 0) {
            err ("error reading lustre %s stats from proc", name);
            goto done;
        }
        proc_lustre_parsestat (stats_hash, "read_bytes", NULL, NULL, NULL,
                               &read_bytes, NULL);
        proc_lustre_parsestat (stats_hash, "read_bytes", &read_count, NULL, NULL,
                               NULL, NULL);
        proc_lustre_parsestat (stats_hash, "write_bytes", NULL, NULL, NULL,
                               &write_bytes, NULL);
        proc_lustre_parsestat (stats_hash, "write_bytes", &write_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "open", &open_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "close", &close_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "getattr", &getattr_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "setattr", &setattr_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "seek", &seek_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "fsync", &fsync_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "dirty_pages_hits", &dhits_count, NULL, NULL,
                              NULL, NULL);
        proc_lustre_parsestat (stats_hash, "dirty_pages_misses", &dmisses_count, NULL, NULL,
                              NULL, NULL);
    }
    n = snprintf (s, len, "%f;%f"
                  ";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64
                  ";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64
                  ";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64,
		  cpupct, mempct,
                  read_bytes, read_count, write_bytes, write_count,
                  open_count, close_count, getattr_count, setattr_count,
                  seek_count, fsync_count, dhits_count, dmisses_count);
    if (n >= len) {
        msg ("string overflow");
        goto done;
    }
    retval = 0;
done:
    return retval;
}
Esempio n. 3
0
File: ost.c Progetto: haasken/lmt
static int
_get_oststring_v2 (pctx_t ctx, char *name, char *s, int len)
{
    char *uuid = NULL;
    uint64_t filesfree, filestotal;
    uint64_t kbytesfree, kbytestotal;
    uint64_t read_bytes, write_bytes;
    uint64_t iops, num_exports;
    uint64_t lock_count, grant_rate, cancel_rate;
    uint64_t connect, reconnect;
    hash_t stats_hash = NULL;
    int n, retval = -1;
    char recov_str[64];

    if (proc_lustre_uuid (ctx, name, &uuid) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s uuid from proc", name);
        goto done;
    }
    if (proc_lustre_hashstats (ctx, name, &stats_hash) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s stats from proc", name);
        goto done;
    }
    proc_lustre_parsestat (stats_hash, "read_bytes", NULL, NULL, NULL,
                           &read_bytes, NULL);
    proc_lustre_parsestat (stats_hash, "write_bytes", NULL, NULL, NULL,
                           &write_bytes, NULL);
    proc_lustre_parsestat (stats_hash, "connect", &connect, NULL, NULL,
                           NULL, NULL);
    proc_lustre_parsestat (stats_hash, "reconnect", &reconnect, NULL, NULL,
                           NULL, NULL);
    //proc_lustre_parsestat (stats_hash, "commitrw", &iops, NULL, NULL,
    //                       NULL, NULL);
    if (_get_iops (ctx, name, &iops) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s brw_stats", name);
        /* As of 2.4 (if not earlier), osd-zfs and osd-liskfs lack
         * the brw_stats file in proc like obdfilter used to have.
         * But this should be a non-fatal event. */
    }
    if (proc_lustre_files (ctx, name, &filesfree, &filestotal) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s file stats from proc", name);
        goto done;
    }
    if (proc_lustre_kbytes (ctx, name, &kbytesfree, &kbytestotal) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s kbytes stats from proc", name);
        goto done;
    }
    if (proc_lustre_num_exports (ctx, name, &num_exports) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s num_exports stats from proc", name);
        goto done;
    }
    if (proc_lustre_ldlm_lock_count (ctx, name, &lock_count) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s ldlm lock_count from proc", name);
        goto done;
    }
    if (proc_lustre_ldlm_grant_rate (ctx, name, &grant_rate) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s ldlm grant_rate from proc", name);
        goto done;
    }
    if (proc_lustre_ldlm_cancel_rate (ctx, name, &cancel_rate) < 0) {
        if (lmt_conf_get_proto_debug ())
            err ("error reading lustre %s ldlm cancel_rate from proc", name);
        goto done;
    }
    if (_get_recovstr (ctx, name, recov_str, sizeof (recov_str)) < 0)
        goto done;
    n = snprintf (s, len, "%s;%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64
                  ";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64
                  ";%"PRIu64";%"PRIu64";%"PRIu64";%"PRIu64";%s;",
                  uuid, filesfree, filestotal, kbytesfree, kbytestotal,
                  read_bytes, write_bytes, iops, num_exports,
                  lock_count, grant_rate, cancel_rate,
                  connect, reconnect, recov_str);
    if (n >= len) {
        if (lmt_conf_get_proto_debug ())
            msg ("string overflow");
        return -1;
    }
    retval = 0;
done:
    if (uuid)
        free (uuid);
    if (stats_hash)
        hash_destroy (stats_hash);
    return retval;
}