Documentation ¶
Index ¶
- Constants
- Variables
- func AlarmID(connector, connectorName, entityID string) string
- func AsInteger(value interface{}) (int64, bool)
- func GenDisplayName() string
- func InterfaceToString(v interface{}) (string, error)
- func RandString(n int) string
- type ActionParameterPBehavior
- type Alarm
- func (a *Alarm) Ack(event Event) AlarmStep
- func (a Alarm) AlarmComponentID() string
- func (a Alarm) AlarmID() string
- func (a *Alarm) AssocTicket(event Event) AlarmStep
- func (a Alarm) CacheID() string
- func (a *Alarm) Cancel(event Event) AlarmStep
- func (a *Alarm) ChangeState(event Event) AlarmStep
- func (a *Alarm) ChangeStateFromAction(timestamp CpsTime, msg, author string, state CpsNumber) AlarmStep
- func (a Alarm) Closable(baggotTime time.Duration) bool
- func (a *Alarm) Comment(event Event) AlarmStep
- func (a *Alarm) ComputeStatus() CpsNumber
- func (a *Alarm) CropSteps() bool
- func (a *Alarm) CurrentState() CpsNumber
- func (a *Alarm) CurrentStatus() CpsNumber
- func (a *Alarm) DeclareTicket(event Event) AlarmStep
- func (a *Alarm) Done(event Event) AlarmStep
- func (a Alarm) HasSingleAck() bool
- func (a Alarm) IsAck() bool
- func (a Alarm) IsCanceled() bool
- func (a Alarm) IsFlapping() bool
- func (a Alarm) IsMalfunctioning() bool
- func (a Alarm) IsMatched(regex string, fields []string) bool
- func (a Alarm) IsMetaAlarm() bool
- func (a Alarm) IsMetaChildren() bool
- func (a *Alarm) IsResolved() bool
- func (a Alarm) IsSnoozed() bool
- func (a *Alarm) IsStateLocked() bool
- func (a Alarm) IsStealthy() bool
- func (a *Alarm) PbhEnter(event Event) AlarmStep
- func (a *Alarm) PbhLeave(event Event) AlarmStep
- func (a *Alarm) Resolve(timestamp *CpsTime)
- func (a *Alarm) ResolveCancel(timestamp *CpsTime)
- func (a *Alarm) Snooze(timestamp CpsTime, duration CpsNumber, author string, output string, ...) (AlarmStep, error)
- func (a *Alarm) SnoozeFromEvent(event Event) (AlarmStep, error)
- func (a *Alarm) Ticket(stepType string, timestamp CpsTime, author string, ticketNumber string, ...) AlarmStep
- func (a *Alarm) UnSnooze()
- func (a *Alarm) Unack(event Event) AlarmStep
- func (a *Alarm) Uncancel(event Event) AlarmStep
- func (a *Alarm) Update(e Event) bool
- func (a *Alarm) UpdateLongOutput(newOutput string)
- func (a *Alarm) UpdateOutput(newOutput string)
- func (a *Alarm) UpdateState(stateValue CpsNumber, ts CpsTime)
- func (a *Alarm) UpdateStatus(timestamp CpsTime, author, message string) bool
- type AlarmChange
- type AlarmChangeType
- type AlarmStep
- type AlarmSteps
- type AlarmTicket
- type AlarmValue
- type AlarmWithEntity
- type ContextInformation
- type CpsDuration
- type CpsNumber
- type CpsTime
- type CropCounter
- type DedupList
- func (i *DedupList) Add(items ...string)
- func (i *DedupList) Del(items ...string)
- func (i *DedupList) EnsureInitialized()
- func (i DedupList) Exists(item string) bool
- func (i DedupList) GetBSON() (interface{}, error)
- func (i DedupList) List() []string
- func (i DedupList) Map() map[string]bool
- func (i DedupList) MarshalBinary() ([]byte, error)
- func (i DedupList) MarshalJSON() ([]byte, error)
- func (i *DedupList) SetBSON(raw bson.Raw) error
- func (i *DedupList) UnmarshalBinary(in []byte) error
- func (i *DedupList) UnmarshalJSON(in []byte) error
- type Entity
- type Event
- func (e *Event) Format()
- func (e *Event) GenerateContextInformations() []ContextInformation
- func (e *Event) GetCompatRK() string
- func (e *Event) GetEID() string
- func (e *Event) GetLockID() string
- func (e *Event) GetRequiredKeys() []string
- func (e *Event) InjectExtraInfos(source []byte) error
- func (e Event) IsContextable() bool
- func (e Event) IsMatched(regex string, fields []string) bool
- func (e Event) IsValid() error
- func (e *Event) SetField(name string, value interface{}) (err error)
- type GenericEvent
- type Info
- type PBehavior
- type PBehaviorComment
- type PBehaviorComments
- type PerfData
Constants ¶
const ( AlarmStepCropMinStates = 20 AlarmStepsHardLimit = 2000 )
Alarm consts
const ( RandomWithoutPrefixNamingScheme = iota RandomWithTimePrefixNamingScheme RandomWithResourcePrefix RandomWithConnectorPrefix )
const ( SourceTypeResource = "resource" SourceTypeComponent = "component" SourceTypeWatcher = "watcher" SourceTypeMetaAlarm = "metaalarm" )
Source types
const ( EventTypeAck = "ack" EventTypeAckremove = "ackremove" EventTypeAssocTicket = "assocticket" EventTypeCalendar = "calendar" EventTypeCancel = "cancel" EventTypeCheck = "check" EventTypeComment = "comment" EventTypeConsolidation = "consolidation" EventTypeDeclareTicket = "declareticket" EventTypeDeclareTicketWebhook = "declareticketwebhook" EventTypeDone = "done" EventTypeDowntime = "downtime" EventTypeEue = "eue" EventTypeLog = "log" EventTypeChangestate = "changestate" EventTypeKeepstate = "keepstate" EventTypePBehavior = "pbehavior" EventTypePerf = "perf" EventTypeSelector = "selector" EventTypeSLA = "sla" EventTypeSnooze = "snooze" EventTypeUnsnooze = "unsnooze" EventTypeTrap = "trap" EventTypeStatCounterInc = "statcounterinc" EventTypeStatDuration = "statduration" EventTypeStatStateInterval = "statstateinterval" EventTypeUncancel = "uncancel" EventTypeUser = "user" EventTypeWatcher = "watcher" EventTypeUpdateWatcher = "updatewatcher" EventTypeMetaAlarm = "metaalarm" EventTypePbhEnter = "pbhenter" EventTypePbhLeave = "pbhleave" EventTypeResolveDone = "resolve_done" EventTypeResolveCancel = "resolve_cancel" EventTypeResolveClose = "resolve_close" EventTypeUpdateStatus = "updatestatus" )
Event types
const ( AlarmStateOK = iota AlarmStateMinor AlarmStateMajor AlarmStateCritical AlarmStateUnknown )
Alarm states
const ( AlarmStatusOff = iota AlarmStatusOngoing AlarmStatusStealthy AlarmStatusFlapping AlarmStatusCancelled )
Alarm statuses
const ( AlarmStepStateIncrease = "stateinc" AlarmStepStateDecrease = "statedec" AlarmStepStatusIncrease = "statusinc" AlarmStepStatusDecrease = "statusdec" AlarmStepAck = "ack" AlarmStepAckRemove = "ackremove" AlarmStepCancel = "cancel" AlarmStepUncancel = "uncancel" AlarmStepComment = "comment" AlarmStepDone = "done" AlarmStepDeclareTicket = "declareticket" AlarmStepAssocTicket = "assocticket" AlarmStepSnooze = "snooze" AlarmStepPbehavior = "pbehavior" AlarmStepStateCounter = "statecounter" AlarmStepChangeState = "changestate" AlarmStepPbhEnter = "pbhenter" AlarmStepPbhLeave = "pbhleave" )
Alarm steps
const ( EntityTypeConnector = "connector" EntityTypeComponent = "component" EntityTypeResource = "resource" EntityTypeWatcher = "watcher" EntityTypeMetaAlarm = "metaalarm" )
Entity types
const DefaultNameSchemeTemplate = "{{ rand_string 2 }}-{{ rand_string 2 }}-{{ rand_string 2 }}"
const NamingCharacterSet = "abcdefghijklmnopqrstuvwxyz1234567890"
Variables ¶
var NumberOfCharacter = int64(len(NamingCharacterSet))
Functions ¶
func AsInteger ¶
AsInteger tries to convert an interface{} into an int64, and returns its value and an integer indicating whether it succeeded or not.
It works with int, uint, int64, uint64, CpsNumber and CpsTime (in this case, a unix timestamp is returned).
func GenDisplayName ¶
func GenDisplayName() string
func InterfaceToString ¶
InterfaceToString tries to convert v to it's string value. Supported types: * float64 * string * bool * int|int64|uint|uint64 * []interface{} : join elements with "," * nil: will return empty string
Any other type will return empty string and an error, like lists or maps...
Types ¶
type ActionParameterPBehavior ¶
type ActionParameterPBehavior struct { Author string `bson:"author" json:"author"` Name string `bson:"name" json:"name"` Reason string `bson:"reason" json:"reason"` Type string `bson:"type" json:"type"` RRule string `bson:"rrule" json:"rrule"` Tstart int64 `bson:"tstart" json:"tstart"` Tstop int64 `bson:"tstop" json:"tstop"` }
ActionParameterPBehavior is a possible parameter value for Action
type Alarm ¶
type Alarm struct { ID string `bson:"_id" json:"_id"` Time CpsTime `bson:"t" json:"t"` EntityID string `bson:"d" json:"d"` Value AlarmValue `bson:"v" json:"v"` }
Alarm represents an alarm document.
func (Alarm) AlarmComponentID ¶
AlarmComponentID is like Alarm.AlarmID() but uses Alarm.Value.Component instead of Alarm.EntityID
func (*Alarm) AssocTicket ¶
AssocTicket associate a ticket number to an alarm
func (*Alarm) ChangeState ¶
ChangeState force the state of an alarm
func (*Alarm) ChangeStateFromAction ¶
func (a *Alarm) ChangeStateFromAction(timestamp CpsTime, msg, author string, state CpsNumber) AlarmStep
ChangeStateFromAction force the state of an alarm by action
func (Alarm) Closable ¶
Closable checks the last step for it's state to be OK for at least baggotTime. Reference time is time.Now() when this function is called.
func (*Alarm) ComputeStatus ¶
ComputeStatus of an Alarm from an Event
func (*Alarm) CropSteps ¶
CropSteps calls Crop() on Alarm.Value.Steps with alarm parameters. returns true if the alarm was modified.
func (*Alarm) CurrentState ¶
CurrentState returns the Current State of the Alarm
func (*Alarm) CurrentStatus ¶
CurrentStatus returns the Current status of the alarm
func (*Alarm) DeclareTicket ¶
DeclareTicket ask for a creation
func (Alarm) HasSingleAck ¶
HasSingleAck returns true if the alarm has been acknowledged exactly once. Note that this method will return false if the alarm has received a first ack, an ackremove, and a second ack. It should be used to run actions on the first acknowledgement only.
func (Alarm) IsFlapping ¶
IsFlapping check if an Alarm is currently flapping
func (Alarm) IsMetaAlarm ¶
func (Alarm) IsMetaChildren ¶
func (*Alarm) IsResolved ¶
IsResolved tell if an alarm has been resolved
func (*Alarm) IsStateLocked ¶
IsStateLocked checks that the Alarm is not Locked (by manual intervention for example)
func (Alarm) IsStealthy ¶
IsStealthy checks if an Alarm is currently stealthy
func (*Alarm) ResolveCancel ¶
ResolveCancel forces alarm resolution on cancel
func (*Alarm) Snooze ¶
func (a *Alarm) Snooze(timestamp CpsTime, duration CpsNumber, author string, output string, role string) (AlarmStep, error)
Snooze apply a snooze step to an Alarm
func (*Alarm) SnoozeFromEvent ¶
SnoozeFromEvent apply a snooze step to an Alarm
func (*Alarm) Ticket ¶
func (a *Alarm) Ticket(stepType string, timestamp CpsTime, author string, ticketNumber string, role string, data map[string]string) AlarmStep
Ticket add a ticket on an alarm
func (*Alarm) UpdateLongOutput ¶
UpdateLongOutput updates an alarm output field
func (*Alarm) UpdateOutput ¶
UpdateOutput updates an alarm output field
func (*Alarm) UpdateState ¶
UpdateState updates alarm's state to stateValue if it worst
type AlarmChange ¶
type AlarmChange struct { Type AlarmChangeType PreviousState CpsNumber PreviousStateChange CpsTime PreviousStatus CpsNumber PreviousStatusChange CpsTime }
AlarmChange is a struct containing the type of change that occured on an alarm, as well as its previous state.
func NewAlarmChange ¶
func NewAlarmChange() AlarmChange
func (*AlarmChange) Triggers ¶
func (ac *AlarmChange) Triggers(triggerName string) bool
type AlarmChangeType ¶
type AlarmChangeType string
AlarmChangeType is a type representing a change that can occur on an alarm.
const ( AlarmChangeTypeNone AlarmChangeType = "" AlarmChangeTypeStateIncrease AlarmChangeType = "stateinc" AlarmChangeTypeStateDecrease AlarmChangeType = "statedec" AlarmChangeTypeCreate AlarmChangeType = "create" AlarmChangeTypeAck AlarmChangeType = "ack" AlarmChangeTypeAckremove AlarmChangeType = "ackremove" AlarmChangeTypeCancel AlarmChangeType = "cancel" AlarmChangeTypeUncancel AlarmChangeType = "uncancel" AlarmChangeTypeDeclareTicket AlarmChangeType = "declareticket" AlarmChangeTypeDeclareTicketWebhook AlarmChangeType = "declareticketwebhook" AlarmChangeTypeAssocTicket AlarmChangeType = "assocticket" AlarmChangeTypeSnooze AlarmChangeType = "snooze" AlarmChangeTypeUnsnooze AlarmChangeType = "unsnooze" AlarmChangeTypeResolve AlarmChangeType = "resolve" AlarmChangeTypeDone AlarmChangeType = "done" AlarmChangeTypeComment AlarmChangeType = "comment" AlarmChangeTypeChangeState AlarmChangeType = "changestate" AlarmChangeTypePbhEnter AlarmChangeType = "pbhenter" AlarmChangeTypePbhLeave AlarmChangeType = "pbhleave" AlarmChangeTypeUpdateStatus AlarmChangeType = "changestatus" )
An AlarmChangeType can have the following values:
type AlarmStep ¶
type AlarmStep struct { Type string `bson:"_t" json:"_t"` Timestamp CpsTime `bson:"t" json:"t"` Author string `bson:"a" json:"a"` Message string `bson:"m" json:"m"` Role string `bson:"role,omitempty" json:"role,omitempty"` Value CpsNumber `bson:"val" json:"val"` StateCounter CropCounter `bson:"statecounter,omitempty" json:"statecounter,omitempty"` }
AlarmStep represents a generic step used in an alarm.
func NewAlarmStep ¶
func NewAlarmStep(stepType string, timestamp CpsTime, author string, msg string, role string) AlarmStep
NewAlarmStep returns an AlarmStep. If the timestamp or author are empty, default values will be used to create an AlarmStep.
func NewAlarmStepFromAction ¶
func NewAlarmStepFromEvent ¶
NewAlarmStepFromEvent returns an AlarmStep.
type AlarmSteps ¶
type AlarmSteps []AlarmStep
AlarmSteps is a sortable implementation of []*AlarmStep. Used for sorting steps in some functions. Implements sort.Interface
func (*AlarmSteps) Add ¶
func (s *AlarmSteps) Add(step AlarmStep) error
Add handle adding a step to the list
func (AlarmSteps) Crop ¶
func (s AlarmSteps) Crop(currentStatus *AlarmStep, cropNum int) (AlarmSteps, bool)
Crop steps by replacing stateinc and statedec steps after the current status with a statecounter step Returns :
- the updated alarm steps
- True if it was updated, false else
param currentStatus: the current status of the alarm. The steps will be cropped from this status param cropNum: crop only if we have at least cropNum steps with type AlarmStepStateIncrease or AlarmStepStateDecrease
func (AlarmSteps) Last ¶
func (s AlarmSteps) Last() (AlarmStep, error)
Last returns the last step, if any, or returns an error.
func (AlarmSteps) UpdateStateCounter ¶
func (s AlarmSteps) UpdateStateCounter(currentStatus *AlarmStep, currentStatusIdx int, counter CropCounter) AlarmSteps
UpdateStateCounter updates the alarm steps with the statecounter step Returns the updated AlarmSteps and the updated (or newly created) statecounter step. param currentStatus: the current status of the alarm. The statecounter step infos will come from it. param currentStatusIdx: the alarm current status' index. It is used to insert or update the statecounter step right after it. param counter: the crop counter to update or create the statecounter step from.
type AlarmTicket ¶
type AlarmTicket struct { Type string `bson:"_t" json:"_t"` Timestamp CpsTime `bson:"t" json:"t"` Author string `bson:"a" json:"a"` Message string `bson:"m" json:"m"` Role string `bson:"role,omitempty" json:"role,omitempty"` Value string `bson:"val" json:"val"` Data map[string]string }
AlarmTicket step is distinct from generic alarm step because value is a string TODO: move string value to message (and in py and js too)
type AlarmValue ¶
type AlarmValue struct { ACK *AlarmStep `bson:"ack,omitempty" json:"ack,omitempty"` Canceled *AlarmStep `bson:"canceled,omitempty" json:"canceled,omitempty"` Done *AlarmStep `bson:"done,omitempty" json:"done,omitempty"` Snooze *AlarmStep `bson:"snooze,omitempty" json:"snooze,omitempty"` State *AlarmStep `bson:"state,omitempty" json:"state,omitempty"` Status *AlarmStep `bson:"status,omitempty" json:"status,omitempty"` Ticket *AlarmTicket `bson:"ticket,omitempty" json:"ticket,omitempty"` Steps AlarmSteps `bson:"steps" json:"steps"` Component string `bson:"component" json:"component"` Connector string `bson:"connector" json:"connector"` ConnectorName string `bson:"connector_name" json:"connector_name"` CreationDate CpsTime `bson:"creation_date" json:"creation_date"` DisplayName string `bson:"display_name" json:"display_name"` HardLimit *CpsNumber `bson:"hard_limit,omitempty" json:"hard_limit,omitempty"` InitialOutput string `bson:"initial_output" json:"initial_output"` Output string `bson:"output" json:"output"` InitialLongOutput string `bson:"initial_long_output" json:"initial_long_output"` LongOutput string `bson:"long_output" json:"long_output"` LongOutputHistory []string `bson:"long_output_history" json:"long_output_history"` LastUpdateDate CpsTime `bson:"last_update_date" json:"last_update_date"` LastEventDate CpsTime `bson:"last_event_date" json:"last_event_date"` Resource string `bson:"resource,omitempty" json:"resource,omitempty"` Resolved *CpsTime `bson:"resolved,omitempty" json:"resolved,omitempty"` Tags []string `bson:"tags" json:"tags"` Meta string `bson:"meta,omitempty" json:"meta,omitempty"` Parents []string `bson:"parents" json:"parents"` Children []string `bson:"children" json:"children"` StateChangesSinceStatusUpdate CpsNumber `bson:"state_changes_since_status_update,omitempty" json:"state_changes_since_status_update,omitempty"` TotalStateChanges CpsNumber `bson:"total_state_changes,omitempty" json:"total_state_changes,omitempty"` Extra map[string]interface{} `bson:"extra" json:"extra"` Infos map[string]map[string]string `bson:"infos" json:"infos"` // store version of dynamic-infos rule RuleVersion map[string]string `bson:"infos_rule_version"` }
AlarmValue represents a full description of an alarm.
func (*AlarmValue) Transform ¶
func (v *AlarmValue) Transform()
type AlarmWithEntity ¶
type AlarmWithEntity struct { Alarm Alarm `bson:"alarm" json:"alarm"` Entity Entity `bson:"entity" json:"entity"` }
AlarmWithEntity is an encapsulated type, mostly to facilitate the alarm manipulation for the post-processors
type ContextInformation ¶
type ContextInformation struct { ID string // Entity ID Name string Type string Impacts []string Depends []string }
ContextInformation regroup context values necessary for creating a new entity
func (*ContextInformation) NewEntity ¶
func (ci *ContextInformation) NewEntity() Entity
NewEntity create an entity from ContextInformation struct
type CpsDuration ¶
CpsDuration allow conversions from/to time.Duration to/from string
func (CpsDuration) Duration ¶
func (t CpsDuration) Duration() time.Duration
Duration return the CpsDuration casted to time.Duration
func (CpsDuration) GetBSON ¶
func (t CpsDuration) GetBSON() (interface{}, error)
GetBSON implements the bson.Getter interface
func (CpsDuration) MarshalJSON ¶
func (t CpsDuration) MarshalJSON() ([]byte, error)
MarshalJSON converts a CpsDuration to string
func (*CpsDuration) SetBSON ¶
func (t *CpsDuration) SetBSON(raw bson.Raw) error
SetBSON implements the bson.Setter interface
func (*CpsDuration) UnmarshalJSON ¶
func (t *CpsDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON converts a string to CpsDuration
type CpsNumber ¶
type CpsNumber int64
CpsNumber is here for compatibility with old python engines. It will force an int64 from a float64.
func (CpsNumber) CpsTimestamp ¶
CpsTimestamp convert a number to a timestamp
func (CpsNumber) MarshalJSON ¶
MarshalJSON implements json.Encoder interface
func (*CpsNumber) UnmarshalJSON ¶
UnmarshalJSON implements json.Decoder interface
type CpsTime ¶
CpsTime allows conversion from time.Time to time.Time.Unix()
func NewCpsTime ¶
NewCpsTime create a CpsTime from a timestamp
func (CpsTime) MarshalJSON ¶
MarshalJSON converts from CpsTime to timestamp as bytes
func (*CpsTime) UnmarshalJSON ¶
UnmarshalJSON converts from string to CpsTime
type CropCounter ¶
type CropCounter struct { StateChanges int `bson:"statechanges" json:"statechanges"` Stateinc int `bson:"stateinc" json:"stateinc"` Statedec int `bson:"statedec" json:"statedec"` StateInfo int `bson:"state:0,omitempty" json:"state:0,omitempty"` StateMinor int `bson:"state:1,omitempty" json:"state:1,omitempty"` StateMajor int `bson:"state:2,omitempty" json:"state:2,omitempty"` StateCritical int `bson:"state:3,omitempty" json:"state:3,omitempty"` }
CropCounter provides an explicit way of counting the steps that were cropped.
func (*CropCounter) MergeCounter ¶
func (counter *CropCounter) MergeCounter(secondCounter CropCounter)
MergeCounter merges the current counter with the provided counter and returns the merged counter.
func (*CropCounter) UpdateWithStep ¶
func (counter *CropCounter) UpdateWithStep(step AlarmStep)
UpdateWithStep updates the CropCounter with the provided step informations.
type DedupList ¶
type DedupList struct {
// contains filtered or unexported fields
}
DedupList is not to be used directly, use NewDedupList instead.
func NewDedupList ¶
NewDedupList creates a new DedupList struct.
func (*DedupList) Del ¶
Del some items from the list. This function is VERY slow, avoid making multiple calls since for each call if the DedupList has to be modified, the internal cached list is recomputed. Prefer call Del(items...) where items is a []string
func (*DedupList) EnsureInitialized ¶
func (i *DedupList) EnsureInitialized()
EnsureInitialized ensure internal states to be initialized
func (DedupList) Map ¶
Map returns a copy of the underlying map[string]bool The bool value has no meaning, it's only here so we can deduplicate using a standard map.
func (DedupList) MarshalBinary ¶
MarshalBinary ...
func (DedupList) MarshalJSON ¶
MarshalJSON implements json.Encoder
func (*DedupList) UnmarshalBinary ¶
UnmarshalBinary ...
func (*DedupList) UnmarshalJSON ¶
UnmarshalJSON implements json.Decoder
type Entity ¶
type Entity struct { ID string `bson:"_id" json:"_id"` Name string `bson:"name" json:"name"` Impacts []string `bson:"impact" json:"impact"` Depends []string `bson:"depends" json:"depends"` EnableHistory []CpsTime `bson:"enable_history" json:"enable_history"` //Measurements *[]Measurement `bson:"measurements" json:"measurements"` Measurements interface{} `bson:"measurements" json:"measurements"` // unused collection ids Enabled bool `bson:"enabled" json:"enabled"` Infos map[string]Info `bson:"infos" json:"infos"` Type string `bson:"type" json:"type"` Component string `bson:"component,omitempty" json:"component,omitempty"` }
Entity ...
func NewEntity ¶
func NewEntity(id string, name string, entityType string, infos map[string]Info, impacts, depends []string) Entity
NewEntity instanciate a new entity struct [sic]
func (*Entity) EnsureInitialized ¶
func (e *Entity) EnsureInitialized()
EnsureInitialized verifies that all complex structs are well initialized
type Event ¶
type Event struct { ID *string `bson:"_id" json:"_id"` Connector string `bson:"connector" json:"connector"` ConnectorName string `bson:"connector_name" json:"connector_name"` EventType string `bson:"event_type" json:"event_type"` Component string `bson:"component" json:"component"` Resource string `bson:"resource" json:"resource"` PerfData *string `bson:"perf_data" json:"perf_data"` PerfDataArray []PerfData `bson:"perf_data_array" json:"perf_data_array"` Status *CpsNumber `bson:"status" json:"status"` Timestamp CpsTime `bson:"timestamp" json:"timestamp"` StateType *CpsNumber `bson:"state_type" json:"state_type"` SourceType string `bson:"source_type" json:"source_type"` LongOutput string `bson:"long_output" json:"long_output"` State CpsNumber `bson:"state" json:"state"` Output string `bson:"output" json:"output"` Alarm *Alarm `bson:"current_alarm" json:"current_alarm"` Entity *Entity `bson:"current_entity" json:"current_entity"` Author string `bson:"author" json:"author"` RK string `bson:"routing_key" json:"routing_key"` AckResources bool `json:"ack_resources"` Duration *CpsNumber `json:"duration"` Ticket string `bson:"ticket" json:"ticket"` StatName string `bson:"stat_name" json:"stat_name"` Debug bool `bson:"debug" json:"debug"` Role string `bson:"role,omitempty" json:"role,omitempty"` ExtraInfos map[string]interface{} `json:"extra"` AlarmChange *AlarmChange `bson:"alarm_change" json:"alarm_change"` MetaAlarmRuleID string `bson:"metaalarm_rule_id" json:"metaalarm_rule_id"` MetaAlarmParents *[]string `bson:"ma_parents" json:"ma_parents"` MetaAlarmChildren *[]string `bson:"ma_children" json:"ma_children"` }
Event represents a canopsis event.
func NewEventFromAlarm ¶
func NewEventFromJSON ¶
NewEventFromJSON create an Event from a raw json
func (*Event) Format ¶
func (e *Event) Format()
Format an event
"timestamp" is fill with time.Now() "event_type" is fill with EventTypeCheck if "entity" is not null, "impacts" and "depends" are ensured to be initialized
func (*Event) GenerateContextInformations ¶
func (e *Event) GenerateContextInformations() []ContextInformation
GenerateContextInformations generate connector, component and resource entity informations. First element is always connector Second element is always component Third element doesnt exists if event is not SourceTypeResource, otherwise it is resource
func (*Event) GetCompatRK ¶
GetCompatRK returns the event routing key. For compatibility only with old engines.
func (*Event) GetRequiredKeys ¶
GetRequiredKeys read all declared json tags in the struct
func (*Event) InjectExtraInfos ¶
InjectExtraInfos takes the raw JSON event document and puts any unknown field into Event.ExtraInfos
func (Event) IsContextable ¶
IsContextable tells you if the given event can lead to context enrichment.
type GenericEvent ¶
type GenericEvent struct {
Content interface{}
}
GenericEvent contains an interface so you can do this: body := `<a json document>` var gevent GenericEvent json.Unmarshal(body, &gevent.Content) gevent.PartialID(<rules>)
func (*GenericEvent) JSONUnmarshal ¶
func (e *GenericEvent) JSONUnmarshal(body []byte) error
JSONUnmarshal is a shortcut for this: var event GenericEvent json.Unmarshal(body, &event.Content)
func (*GenericEvent) PartialID ¶
func (e *GenericEvent) PartialID(heartBeatItem heartbeat.Item) (string, error)
PartialID builds the event ID, as a string, from the heartBeatItem configuration. Given this event:
{ "connector": "zabbix", "connector_name": "instance1", "component": "localhost", ... }
And the given heartBeatItem:
li := NewHeartBeatItem(time.Minute*5) li.AddMapping("connector", "zabbix") li.AddMapping("connector_name", "instance1")
PartialID will return "connector:zabbix.connector_name:instance1" as ID. Keys will alphabetically sorted!
type Info ¶
type Info struct { Name string `bson:"name,omitempty" json:"name"` Description string `bson:"description,omitempty" json:"description"` Value string `bson:"-" json:"value"` RealValue interface{} `bson:"value,omitempty"` }
Info contain extra values for the entity
type PBehavior ¶
type PBehavior struct { ID string `bson:"_id,omitempty" json:"_id,omitempty"` Author string `bson:"author" json:"author"` Comments PBehaviorComments `bson:"comments,omitempty" json:"comments,omitempty"` Connector string `bson:"connector" json:"connector"` ConnectorName string `bson:"connector_name" json:"connector_name"` Eids []string `bson:"eids,omitempty" json:"eids,omitempty"` Enabled bool `bson:"enabled" json:"enabled"` Filter string `bson:"filter" json:"filter"` Name string `bson:"name" json:"name"` Reason string `bson:"reason" json:"reason"` RRule string `bson:"rrule" json:"rrule"` Start *CpsTime `bson:"tstart" json:"tstart"` Stop *CpsTime `bson:"tstop" json:"tstop"` Type string `bson:"type_" json:"type_"` Timezone string `bson:"timezone,omitempty" json:"timezone"` Exdate []CpsTime `bson:"exdate" json:"exdate"` }
PBehavior represents a canopsis periodical behavior.
func NewPBehavior ¶
func NewPBehavior(author, filter, name, reason, type_, rrule string, start, stop *CpsTime, timezone string, exdate []CpsTime) PBehavior
NewPBehavior instanciate a new pbehavior
func (PBehavior) IsImpacted ¶
IsImpacted checks if an entity id is impacted by a pbehavior
type PBehaviorComment ¶
type PBehaviorComment struct { ID string `bson:"_id" json:"_id"` Author string `bson:"author" json:"author"` Timestamp *CpsTime `bson:"ts" json:"ts"` Message string `bson:"message" json:"message"` }
PBehavior represents a comment in a PBehavior.
type PBehaviorComments ¶
type PBehaviorComments []*PBehaviorComment