Ejemplo n.º 1
0
Archivo: lmtdb.c Proyecto: LaHaine/lmt
/* lmt_mds_v2: single mds + single mdt */
void
lmt_db_insert_mds_v2 (char *s)
{
    ListIterator itr;
    lmt_db_t db;
    char *op, *mdtname = NULL, *mdsname = NULL;
    float pct_cpu, pct_mem;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    List mdops = NULL;

    if (_init_db_ifneeded () < 0)
        goto done;
    if (lmt_mds_decode_v2 (s, &mdsname, &mdtname, &pct_cpu, &pct_mem,
                           &inodes_free, &inodes_total,
                           &kbytes_free, &kbytes_total, &mdops) < 0)
        goto done;
    if (!(db = _svc_to_db (mdtname)))
        goto done;
    if (lmt_db_insert_mds_data (db, mdsname, mdtname, pct_cpu,
                                kbytes_free, kbytes_total - kbytes_free,
                                inodes_free, inodes_total - inodes_free) < 0) {
        _trigger_db_reconnect ();
        goto done;
    }
    itr = list_iterator_create (mdops);
    while ((op = list_next (itr)))
        _insert_mds_ops (db, mdtname, op);
    list_iterator_destroy (itr);        
done:
    if (mdtname)
        free (mdtname);    
    if (mdsname)
        free (mdsname);    
    if (mdops)
        list_destroy (mdops);
}
Ejemplo n.º 2
0
Archivo: tparse.c Proyecto: LLNL/lmt
int
_parse_mds_v2 (const char *s)
{
    int retval = -1;
    char *mdsname = NULL;
    char *name = NULL;
    float pct_cpu, pct_mem;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    List mdops = NULL;
    ListIterator itr = NULL;
    char *opname, *op;
    uint64_t samples, sum, sumsq;

    if (lmt_mds_decode_v2 (s, &mdsname, &name, &pct_cpu, &pct_mem,
          &inodes_free, &inodes_total, &kbytes_free, &kbytes_total, &mdops) < 0)
        goto done;
    if (!(itr = list_iterator_create (mdops)))
        goto done;
    while ((op = list_next (itr))) {
        if (lmt_mds_decode_v2_mdops (op, &opname, &samples, &sum, &sumsq) < 0)
            goto done;
        free (opname);
    }
    retval = 0;
done:
    if (itr)
        list_iterator_destroy (itr);
    if (name)
        free (name); 
    if (mdsname)
        free (mdsname); 
    if (mdops)
        list_destroy (mdops);
    return retval;
}