Exemplo n.º 1
0
Arquivo: lmtdb.c Projeto: LaHaine/lmt
/* 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);        
}
Exemplo n.º 2
0
Arquivo: lmtdb.c Projeto: 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);
}