Ejemplo n.º 1
0
Archivo: tparse.c Proyecto: LLNL/lmt
int
_parse_ost_v2 (const char *s)
{
    int retval = -1;
    char *ossname = NULL;
    char *ostname = NULL;
    char *recov_status = NULL;
    float pct_cpu, pct_mem;
    uint64_t read_bytes, write_bytes;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    uint64_t iops, num_exports;
    uint64_t lock_count, grant_rate, cancel_rate;
    uint64_t connect, reconnect;
    List ostinfo = NULL;
    ListIterator itr = NULL;
    char *osi;

    if (lmt_ost_decode_v2 (s, &ossname, &pct_cpu, &pct_mem, &ostinfo) < 0)
        goto done;
    if (!(itr = list_iterator_create (ostinfo)))
        goto done;
    while ((osi = list_next (itr))) {
        if (lmt_ost_decode_v2_ostinfo (osi, &ostname, &read_bytes, &write_bytes,
                                       &kbytes_free, &kbytes_total,
                                       &inodes_free, &inodes_total, &iops,
                                       &num_exports, &lock_count, &grant_rate,
                                       &cancel_rate, &connect, &reconnect,
                                       &recov_status) < 0)
            goto done;
        free (ostname);
        free (recov_status);
    }
    retval = 0;
done:
    if (ossname)
        free (ossname);
    if (itr)
        list_iterator_destroy (itr);
    if (ostinfo)
        list_destroy (ostinfo);
    return retval;
}
Ejemplo n.º 2
0
Archivo: lmtdb.c Proyecto: degrand1/lmt
/* Helper for lmt_db_insert_ost_v2 () */
static void
_insert_ostinfo (char *ossname, float pct_cpu, float pct_mem, char *s)
{
    lmt_db_t db;
    char *ostname = NULL;
    uint64_t read_bytes, write_bytes;
    uint64_t kbytes_free, kbytes_total;
    uint64_t inodes_free, inodes_total;
    uint64_t iops, num_exports;
    uint64_t lock_count, grant_rate, cancel_rate;
    uint64_t connect, reconnect;
    uint64_t hits, access;
    char *recov_status = NULL;

    if (lmt_ost_decode_v2_ostinfo (s, &ostname, &read_bytes, 
                                   &hits, &access, &write_bytes,
                                   &kbytes_free, &kbytes_total,
                                   &inodes_free, &inodes_total, &iops,
                                   &num_exports, &lock_count, &grant_rate,
                                   &cancel_rate, &connect, &reconnect,
                                   &recov_status) < 0) {
        goto done;
    }
    if (!(db = _svc_to_db (ostname)))
        goto done;
    if (lmt_db_insert_ost_data (db, ossname, ostname, read_bytes, write_bytes,
                                kbytes_free, kbytes_total - kbytes_free,
                                inodes_free, inodes_total - inodes_free) < 0) {
        _trigger_db_reconnect ();
        goto done;
    }
    if (lmt_db_insert_oss_data (db, 0, ossname, pct_cpu, pct_mem) < 0) {
        _trigger_db_reconnect ();
        goto done;
    }
done:
    if (ostname)
        free (ostname);
    if (recov_status)
        free (recov_status);
}