예제 #1
0
func InitializeSystemSummary() {
	var system models.System

	reqId, err := uuid.New()
	if err != nil {
		logger.Get().Error("Error Creating the RequestId. error: %v", err)
		return
	}

	ctxt := fmt.Sprintf("%v:%v", models.ENGINE_NAME, reqId.String())

	system.Name = monitoring.SYSTEM

	_, clusterFetchError := GetClusters(nil)
	if clusterFetchError != nil {
		if clusterFetchError == mgo.ErrNotFound {
			return
		}
		logger.Get().Error("%s - Failed to fetch clusters.Err %v", ctxt, clusterFetchError)
	}

	sluStatusWiseCounts, err := ComputeSluStatusWiseCount(nil, bson.M{"utilizationtype": monitoring.SLU_UTILIZATION, "thresholdseverity": models.CRITICAL})
	system.SLUCount = sluStatusWiseCounts

	storageCount, err := GetStorageCount(nil)
	system.StorageCount = storageCount

	clustersCount, err := ComputeClustersStatusWiseCounts()
	system.ClustersCount = clustersCount
	systemthresholds := monitoring.GetSystemDefaultThresholdValues()

	net_storage_profile_utilization, err := ComputeStorageProfileUtilization(nil, systemthresholds[monitoring.STORAGE_PROFILE_UTILIZATION].Configs)
	system.StorageProfileUsage = net_storage_profile_utilization

	system.UpdatedAt = time.Now().String()

	mostUsedStorages, err := GetTopStorageUsage(nil)
	system.MostUsedStorages = mostUsedStorages

	sessionCopy := db.GetDatastore().Copy()
	defer sessionCopy.Close()

	coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_SKYRING_UTILIZATION)
	if _, err := coll.Upsert(bson.M{"name": monitoring.SYSTEM}, system); err != nil {
		logger.Get().Error("%s - Error persisting the system.Error %v", ctxt, err)
	}
}
예제 #2
0
func UpdateStorageProfileUtilizationToSummaries(ctxt string, cluster models.Cluster) {
	pluginIndex := monitoring.GetPluginIndex(monitoring.STORAGE_PROFILE_UTILIZATION, cluster.Monitoring.Plugins)
	if pluginIndex != -1 {
		if storageProfileUtilization, err := ComputeStorageProfileUtilization(
			bson.M{"clusterid": cluster.ClusterId},
			cluster.Monitoring.Plugins[pluginIndex].Configs); err != nil {
			logger.Get().Error("%s - Failed to fetch storage profile utilization of cluster %v.Error %v", ctxt, cluster.Name, err)
		} else {
			UpdateDb(bson.M{"clusterid": cluster.ClusterId}, bson.M{"storageprofileusage": storageProfileUtilization}, models.COLL_NAME_CLUSTER_SUMMARY, ctxt)
		}
	}

	systemthresholds := monitoring.GetSystemDefaultThresholdValues()
	utilization, err := ComputeStorageProfileUtilization(nil, systemthresholds[monitoring.STORAGE_PROFILE_UTILIZATION].Configs)
	if err != nil {
		logger.Get().Error("%s - Error updating the storage profile utilization to system summary. Error %v", ctxt, err)
	} else {
		UpdateDb(bson.M{"name": monitoring.SYSTEM}, bson.M{"storageprofileusage": utilization}, models.COLL_NAME_SKYRING_UTILIZATION, ctxt)
	}
}