static void htable_rpc_stats(rpc_t* rpc, void* c) { ht_t *ht; void* th; unsigned int min; unsigned int max; unsigned int all; unsigned int i; ht = ht_get_root(); if(ht==NULL) { rpc->fault(c, 500, "No htables"); return; } while (ht != NULL) { /* add entry node */ if (rpc->add(c, "{", &th) < 0) { rpc->fault(c, 500, "Internal error creating structure rpc"); goto error; } all = 0; max = 0; min = 4294967295U; for(i=0; i<ht->htsize; i++) { ht_slot_lock(ht, i); if(ht->entries[i].esize<min) min = ht->entries[i].esize; if(ht->entries[i].esize>max) max = ht->entries[i].esize; all += ht->entries[i].esize; ht_slot_unlock(ht, i); } if(rpc->struct_add(th, "Sdddd", "name", &ht->name, /* str */ "slots", (int)ht->htsize, /* uint */ "all", (int)all, /* uint */ "min", (int)min, /* uint */ "max", (int)max /* uint */ ) < 0) { rpc->fault(c, 500, "Internal error creating rpc structure"); goto error; } ht = ht->next; } error: return; }
static void htable_rpc_list(rpc_t* rpc, void* c) { ht_t *ht; void* th; char dbname[128]; ht = ht_get_root(); if(ht==NULL) { rpc->fault(c, 500, "No htables"); return; } while (ht != NULL) { int len = 0; /* add entry node */ if (rpc->add(c, "{", &th) < 0) { rpc->fault(c, 500, "Internal error creating structure rpc"); goto error; } if (ht->dbtable.len > 0) { len = ht->dbtable.len > 127 ? 127 : ht->dbtable.len; memcpy(dbname, ht->dbtable.s, len); dbname[len] = '\0'; } else { dbname[0] = '\0'; } if(rpc->struct_add(th, "Ssddddd", "name", &ht->name, /* String */ "dbtable", &dbname , /* Char * */ "dbmode", (int) ht->dbmode, /* u int */ "expire", (int) ht->htexpire, /* u int */ "updateexpire", ht->updateexpire, /* int */ "size", (int) ht->htsize, /* u int */ "dmqreplicate", ht->dmqreplicate /* int */ ) < 0) { rpc->fault(c, 500, "Internal error creating data rpc"); goto error; } ht = ht->next; } error: return; }
static void add_root_to_holder (GRawDataItem item, GHolder * h, GO_UNUSED const GPanel * panel) { GSubList *sub_list; GMetrics *metrics, *nmetrics; char *root = NULL; int root_idx = KEY_NOT_FOUND, idx = 0; if (set_root_metrics (item.key, item.value, h->module, &nmetrics) == 1) return; if (!(root = (ht_get_root (h->module, item.key)))) return; /* add data as a child node into holder */ if (KEY_NOT_FOUND == (root_idx = get_item_idx_in_holder (h, root))) { idx = h->idx; sub_list = new_gsublist (); metrics = new_gmetrics (); h->items[idx].metrics = metrics; h->items[idx].metrics->data = root; h->idx++; } else { sub_list = h->items[root_idx].sub_list; metrics = h->items[root_idx].metrics; idx = root_idx; free (root); } add_sub_item_back (sub_list, h->module, nmetrics); h->items[idx].sub_list = sub_list; h->items[idx].metrics = metrics; h->items[idx].metrics->avgts.nts += nmetrics->avgts.nts; h->items[idx].metrics->cumts.nts += nmetrics->cumts.nts; h->items[idx].metrics->maxts.nts += nmetrics->maxts.nts; h->items[idx].metrics->bw.nbw += nmetrics->bw.nbw; h->items[idx].metrics->hits += nmetrics->hits; h->items[idx].metrics->visitors += nmetrics->visitors; h->sub_items_size++; }