func buildPoolMonitoringProfile(pool *pool.ResourcePool, hostIDs []string, client *master.Client) error { var totalMemory uint64 = 0 var totalCores int = 0 //calculate total memory and total cores for i := range hostIDs { host, err := client.GetHost(hostIDs[i]) if err != nil { glog.Errorf("Failed to get host for id=%s -> %s", hostIDs[i], err) return err } totalCores += host.Cores totalMemory += host.Memory } tags := map[string][]string{"controlplane_host_id": hostIDs} profile, err := hostPoolProfile.ReBuild("1h-ago", tags) if err != nil { glog.Error("Failed to create pool profile: %s", err) return err } //add graphs to profile profile.GraphConfigs = make([]domain.GraphConfig, 3) profile.GraphConfigs[0] = newCpuConfigGraph(tags, totalCores) profile.GraphConfigs[1] = newRSSConfigGraph(tags, totalMemory) profile.GraphConfigs[2] = newMajorPageFaultGraph(tags) pool.MonitoringProfile = *profile return nil }
func getPoolHostIds(poolID string, client *master.Client) ([]string, error) { hosts, err := client.FindHostsInPool(poolID) if err != nil { glog.Errorf("Could not get hosts: %v", err) return nil, err } hostIDs := make([]string, len(hosts)) for i := range hosts { hostIDs[i] = hosts[i].ID } return hostIDs, nil }