本文整理汇总了Golang中github.com/skyrings/skyring-common/models.AppEvent.Description方法的典型用法代码示例。如果您正苦于以下问题:Golang AppEvent.Description方法的具体用法?Golang AppEvent.Description怎么用?Golang AppEvent.Description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skyrings/skyring-common/models.AppEvent
的用法示例。
在下文中一共展示了AppEvent.Description方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: collectd_status_handler
func collectd_status_handler(event models.AppEvent, ctxt string) (models.AppEvent, error) {
// adding the details for event
if strings.HasSuffix(event.Message, "inactive") {
util.AppendServiceToNode(bson.M{"nodeid": event.NodeId}, models.SkyringServices[0], models.STATUS_DOWN, ctxt)
event.Name = skyring.EventTypes["COLLECTD_STATE_CHANGED"]
event.Message = fmt.Sprintf("Collectd process stopped on Host: %s", event.NodeName)
event.Description = fmt.Sprintf("Collectd process is stopped on Host: %s. This might affect the monitoring functionality of skyring", event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_MAJOR
} else if strings.HasSuffix(event.Message, "active") {
util.AppendServiceToNode(bson.M{"nodeid": event.NodeId}, models.SkyringServices[0], models.STATUS_UP, ctxt)
event.Name = skyring.EventTypes["COLLECTD_STATE_CHANGED"]
event.Message = fmt.Sprintf("Collectd process started on Host: %s", event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_CLEARED
} else {
return event, nil
}
event.NotificationEntity = models.NOTIFICATION_ENTITY_HOST
event.Notify = true
if err := update_alarm_count(event, ctxt); err != nil {
logger.Get().Error("%s-could not update alarm"+
" count for event: %s", ctxt, event.EventId.String())
return event, err
}
return event, nil
}
示例2: resource_threshold_crossed
func resource_threshold_crossed(event models.AppEvent, ctxt string) (models.AppEvent, error) {
event.Name = skyring.EventTypes[strings.ToUpper(event.Tags["Plugin"])]
currentValue, currentValueErr := util.GetReadableFloat(event.Tags["CurrentValue"], ctxt)
if currentValueErr != nil {
logger.Get().Error("%s-Could not parse the CurrentValue: %s", ctxt, (event.Tags["Plugin"]))
return event, currentValueErr
}
thresholdValue, thresholdValueErr := util.GetReadableFloat(event.Tags["FailureMax"], ctxt)
if thresholdValueErr != nil {
logger.Get().Error("%s-Could not parse the Failure max value: %s", ctxt, (event.Tags["FailureMax"]))
return event, thresholdValueErr
}
if event.Tags["Plugin"] == "df" {
event.Name = fmt.Sprintf("%s-%s", event.Name, event.Tags["PluginInstance"])
event.Tags["Plugin"] = fmt.Sprintf("%s MountPoint", event.Tags["PluginInstance"])
}
if event.Tags["Severity"] == "WARNING" {
event.Description = fmt.Sprintf("%s utilization on the node: %s has crossed the threshold value of %s%%. Current utilization: %s%%", event.Tags["Plugin"], event.NodeName, thresholdValue, currentValue)
event.Message = fmt.Sprintf("%s utilization crossed threshold on: %s", event.Tags["Plugin"], event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_WARNING
} else if event.Tags["Severity"] == "FAILURE" {
event.Description = fmt.Sprintf("%s utilization on the node: %s has crossed the threshold value of %s%%. Current utilization: %s%%", event.Tags["Plugin"], event.NodeName, thresholdValue, currentValue)
event.Message = fmt.Sprintf("%s utilization crossed threshold on: %s", event.Tags["Plugin"], event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_CRITICAL
} else if event.Tags["Severity"] == "OKAY" {
event.Description = fmt.Sprintf("%s utilization on the node: %s is back to normal. Threshold value: %s%%. Current utilization: %s%%", event.Tags["Plugin"], event.NodeName, thresholdValue, currentValue)
event.Message = fmt.Sprintf("%s utilization back to normal on: %s", event.Tags["Plugin"], event.NodeName)
event.EntityId = event.NodeId
event.Severity = models.ALARM_STATUS_CLEARED
}
event.Tags = map[string]string{
"Current Utilization": currentValue,
"Threshold value": thresholdValue,
}
event.NotificationEntity = models.NOTIFICATION_ENTITY_HOST
event.Notify = true
if err := update_alarm_count(event, ctxt); err != nil {
logger.Get().Error("%s-could not update alarm"+
" count for event: %s", ctxt, event.EventId.String())
return event, err
}
return event, nil
}
示例3: logAuditEvent
func logAuditEvent(
eventtype string,
message string,
description string,
entityId *uuid.UUID,
clusterId *uuid.UUID,
notificationEntity models.NotificationEntity,
taskId *uuid.UUID,
deletionAudit bool,
ctxt string) error {
var event models.AppEvent
eventId, err := uuid.New()
if err != nil {
logger.Get().Error("%s-Uuid generation for the event failed for event: %s. error: %v", ctxt, event.Name, err)
return err
}
event.EventId = *eventId
if entityId != nil {
event.EntityId = *entityId
}
if clusterId != nil {
event.ClusterId = *clusterId
}
event.NotificationEntity = notificationEntity
event.Timestamp = time.Now()
event.Notify = false
event.Name = eventtype
event.Message = message
event.Description = description
event.Severity = models.ALARM_STATUS_CLEARED
if taskId != nil {
event.Tags = map[string]string{
"Task Id": (*taskId).String(),
}
}
if err := common_event.AuditLog(ctxt, event, GetDbProvider()); err != nil {
logger.Get().Error("%s- Error logging the event: %s. Error:%v", ctxt, event.Name, err)
return err
}
if deletionAudit {
if err := common_event.DismissAllEventsForEntity(event.EntityId, event, ctxt); err != nil {
logger.Get().Error("%s-Error while dismissing events for entity: %v. Error: %v", ctxt, event.EntityId, err)
}
}
return nil
}