Exemple #1
0
/* lmt_ost_v1: single ost (no oss info) */
void
lmt_db_insert_ost_v1 (char *s)
{
    lmt_db_t db;
    char *ossname = NULL, *ostname = NULL;
    uint64_t read_bytes, write_bytes;
    uint64_t kbytes_free, kbytes_total;
    uint64_t inodes_free, inodes_total;

    if (_init_db_ifneeded () < 0)
        goto done;
    if (lmt_ost_decode_v1 (s, &ossname, &ostname, &read_bytes, &write_bytes,
                           &kbytes_free, &kbytes_total,
                           &inodes_free, &inodes_total) < 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;
    }
done:
    if (ostname)
        free (ostname);    
    if (ossname)
        free (ossname);    
}
Exemple #2
0
/* lmt_oss_v1: single oss (no ost info) */
void
lmt_db_insert_oss_v1 (char *s)
{
    ListIterator itr = NULL;
    lmt_db_t db;
    char *ossname = NULL;
    float pct_cpu, pct_mem;

    if (_init_db_ifneeded () < 0)
        goto done;
    if (lmt_oss_decode_v1 (s, &ossname, &pct_cpu, &pct_mem) < 0)
        goto done;
    itr = list_iterator_create (dbs);
    while ((db = list_next (itr))) {
        /* N.B. defeat automatic insertion of new OSS_INFO for legacy,
         * as there is no way to tie OSS to a particular file system.
         */
        if (lmt_db_lookup (db, "oss", ossname) < 0)
            continue; 
        if (lmt_db_insert_oss_data (db, 1, ossname, pct_cpu, pct_mem) < 0) {
            _trigger_db_reconnect ();
            goto done;
        }
    }
done:
    if (ossname)
        free (ossname);    
    if (itr)
        list_iterator_destroy (itr);        
}
Exemple #3
0
/* lmt_router_v1: router */
void
lmt_db_insert_router_v1 (char *s)
{
    ListIterator itr;
    lmt_db_t db;
    char *rtrname = NULL;
    float pct_cpu, pct_mem;
    uint64_t bytes;

    if (_init_db_ifneeded () < 0)
        goto done;
    if (lmt_router_decode_v1 (s, &rtrname, &pct_cpu, &pct_mem, &bytes) < 0)
        goto done;
    itr = list_iterator_create (dbs);
    while ((db = list_next (itr))) {
        if (lmt_db_insert_router_data (db, rtrname, bytes, pct_cpu) < 0) {
            _trigger_db_reconnect ();
            break;
        }
    }
    list_iterator_destroy (itr);        
done:
    if (rtrname)
        free (rtrname);
}
Exemple #4
0
/* helper for lmt_db_insert_mdt_v1 () */
static void
_insert_mds (char *mdsname, float pct_cpu, float pct_mem, char *s)
{
    ListIterator itr;
    lmt_db_t db;
    char *op, *mdtname = NULL;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    List mdops = NULL;

    if (lmt_mdt_decode_v1_mdtinfo (s, &mdtname, &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 (mdops)
        list_destroy (mdops);
}
Exemple #5
0
/* 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);
}
Exemple #6
0
/* helper for _insert_mds () */
static void
_insert_mds_ops (lmt_db_t db, char *mdtname, char *s)
{
    char *opname = NULL;
    uint64_t samples, sum, sumsquares;

    if (lmt_mdt_decode_v1_mdops (s, &opname, &samples, &sum, &sumsquares) < 0)
        goto done;
    if (lmt_db_insert_mds_ops_data (db, mdtname, opname,
                                    samples, sum, sumsquares) < 0) {
        _trigger_db_reconnect ();
        goto done;
    }
done:
    if (opname)
        free (opname);    
}