Exemple #1
0
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;
}
Exemple #2
0
/* lmt_ost_v2: oss + multiple ost's */
void
lmt_db_insert_ost_v2 (char *s)
{
    ListIterator itr = NULL;
    char *ostr, *ossname = NULL;
    float pct_cpu, pct_mem;
    List ostinfo = NULL;

    if (_init_db_ifneeded () < 0)
        goto done;
    if (lmt_ost_decode_v2 (s, &ossname, &pct_cpu, &pct_mem, &ostinfo) < 0)
        goto done;
    itr = list_iterator_create (ostinfo);
    while ((ostr = list_next (itr)))
        _insert_ostinfo (ossname, pct_cpu, pct_mem, ostr);
    list_iterator_destroy (itr);        
done:
    if (ossname)
        free (ossname);    
    if (ostinfo)
        list_destroy (ostinfo);
}