/* 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); }
/* 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); }
/* 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); }