Central data models of NAV’s event/alert subsystems¶
EventQueue¶
- class nav.models.event.EventQueue(*args, **kwargs)¶
From NAV Wiki: The event queue. Additional data in eventqvar. Different subsystem (specified in source) post events on the event queue. Normally event engine is the target and will take the event off the event queue and process it. getDeviceData are in some cases the target.
- Parameters
id (AutoField) – Id
source (ForeignKey to
Subsystem
) – Sourcetarget (ForeignKey to
Subsystem
) – Targetdevice (ForeignKey to
Device
) – Devicenetbox (ForeignKey to
Netbox
) – Netboxsubid (VarcharField) – Subid
time (DateTimeField) – Time
event_type (ForeignKey to
EventType
) – Event typestate (CharField) – State
value (IntegerField) – Value
severity (IntegerField) – Severity
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))¶
- STATE_END = 'e'¶
- STATE_START = 's'¶
- STATE_STATELESS = 'x'¶
- device¶
Model field: device, accesses the
Device
model.
- device_id¶
Model field: device
- event_type_id¶
Model field: event type
- get_next_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
time
.
- get_previous_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
time
.
- get_state_display(*, field=<django.db.models.fields.CharField: state>)¶
Autogenerated: Shows the label of the
state
- id¶
Model field: id
- netbox_id¶
Model field: netbox
- objects = <django.db.models.manager.Manager object>¶
- save(*args, **kwargs)¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- severity¶
Model field: severity
- source¶
Model field: source, accesses the
Subsystem
model.
- source_id¶
Model field: source
- state¶
Model field: state
- subid¶
Model field: subid
- target¶
Model field: target, accesses the
Subsystem
model.
- target_id¶
Model field: target
- time¶
Model field: time
- value¶
Model field: value
- variables¶
Model field: event queue, accesses the M2M
EventQueueVar
model.
- varmap¶
EventQueueVar¶
- class nav.models.event.EventQueueVar(*args, **kwargs)¶
From NAV Wiki: Defines additional (key,value) tuples that follow events.
- Parameters
id (AutoField) – Id
event_queue (ForeignKey to
EventQueue
) – Event queuevariable (VarcharField) – Variable
value (TextField) – Value
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- event_queue¶
Model field: event queue, accesses the
EventQueue
model.
- event_queue_id¶
Model field: event queue
- id¶
Model field: ID
- objects = <django.db.models.manager.Manager object>¶
- value¶
Model field: value
- variable¶
Model field: variable
AlertQueue¶
- class nav.models.event.AlertQueue(*args, **kwargs)¶
From NAV Wiki: The alert queue. Additional data in alertqvar and alertmsg. Event engine posts alerts on the alert queue (and in addition on the alerthist table). Alert engine will process the data on the alert queue and send alerts to users based on their alert profiles. When all signed up users have received the alert, alert engine will delete the alert from alertq (but not from alert history).
- Parameters
id (AutoField) – Id
source (ForeignKey to
Subsystem
) – Sourcedevice (ForeignKey to
Device
) – Devicenetbox (ForeignKey to
Netbox
) – Netboxsubid (VarcharField) – Subid
time (DateTimeField) – Time
event_type (ForeignKey to
EventType
) – Event typealert_type (ForeignKey to
AlertType
) – Alert typestate (CharField) – State
value (IntegerField) – Value
severity (IntegerField) – Severity
history (ForeignKey to
AlertHistory
) – History
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))¶
- STATE_END = 'e'¶
- STATE_START = 's'¶
- STATE_STATELESS = 'x'¶
- accountalertqueue_set¶
Model field: alert, accesses the M2M
AccountAlertQueue
model.
- alert_type_id¶
Model field: alert type
- device¶
Model field: device, accesses the
Device
model.
- device_id¶
Model field: device
- event_type_id¶
Model field: event type
- get_next_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
time
.
- get_previous_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
time
.
- get_state_display(*, field=<django.db.models.fields.CharField: state>)¶
Autogenerated: Shows the label of the
state
- history¶
Model field: history, accesses the
AlertHistory
model.
- history_id¶
Model field: history
- id¶
Model field: id
- messages¶
Model field: alert queue, accesses the M2M
AlertQueueMessage
model.
- netbox_id¶
Model field: netbox
- objects = <django.db.models.manager.Manager object>¶
- save(*args, **kwargs)¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- severity¶
Model field: severity
- source¶
Model field: source, accesses the
Subsystem
model.
- source_id¶
Model field: source
- state¶
Model field: state
- subid¶
Model field: subid
- time¶
Model field: time
- value¶
Model field: value
- variables¶
Model field: alert queue, accesses the M2M
AlertQueueVariable
model.
- varmap¶
AlertQueueVariable¶
- class nav.models.event.AlertQueueVariable(*args, **kwargs)¶
From NAV Wiki: Defines additional (key,value) tuples that follow alert. Note: the eventqvar tuples are passed along to the alertqvar table so that the variables may be used in alert profiles.
- Parameters
id (AutoField) – Id
alert_queue (ForeignKey to
AlertQueue
) – Alert queuevariable (VarcharField) – Variable
value (TextField) – Value
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- alert_queue¶
Model field: alert queue, accesses the
AlertQueue
model.
- alert_queue_id¶
Model field: alert queue
- id¶
Model field: id
- objects = <django.db.models.manager.Manager object>¶
- value¶
Model field: value
- variable¶
Model field: variable
AlertHistory¶
- class nav.models.event.AlertHistory(*args, **kwargs)¶
From NAV Wiki: The alert history. Simular to the alert queue with one important distinction; alert history stores stateful events as one row, with the start and end time of the event.
- Parameters
id (AutoField) – Id
source (ForeignKey to
Subsystem
) – Sourcedevice (ForeignKey to
Device
) – Devicenetbox (ForeignKey to
Netbox
) – Netboxsubid (VarcharField) – Subid
start_time (DateTimeField) – Start time
end_time (DateTimeInfinityField) – End time
event_type (ForeignKey to
EventType
) – Event typealert_type (ForeignKey to
AlertType
) – Alert typevalue (IntegerField) – Value
severity (IntegerField) – Severity
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- acknowledge(account, comment)¶
Acknowledges this alert using a given account and comment.
Any pre-existing acknowledgement will be overwritten.
- acknowledgement¶
Model field: alert, accesses the
Acknowledgement
model.
- alert_type_id¶
Model field: alert type
- alertqueue_set¶
Model field: history, accesses the M2M
AlertQueue
model.
- device¶
Model field: device, accesses the
Device
model.
- device_id¶
Model field: device
- end_time¶
Model field: end time
- event_type_id¶
Model field: event type
- get_downtime()¶
Returns the difference between start_time and end_time, the current downtime if the alert is still open, and None if the alert is stateless.
- get_next_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=True, **kwargs)¶
Autogenerated: Finds next instance based on
start_time
.
- get_previous_by_start_time(*, field=<django.db.models.fields.DateTimeField: start_time>, is_next=False, **kwargs)¶
Autogenerated: Finds previous instance based on
start_time
.
- id¶
Model field: id
- is_acknowledged()¶
Returns an Acknowledgement instance if this alert has been acknowledged, otherwise None.
- is_open()¶
Returns true if stateful and open.
- is_stateful()¶
Returns true if the alert is stateful.
- messages¶
Model field: alert history, accesses the M2M
AlertHistoryMessage
model.
- netbox_id¶
Model field: netbox
- objects = <django.db.models.manager.ManagerFromAlertHistoryQuerySet object>¶
- save(*args, **kwargs)¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- severity¶
Model field: severity
- source¶
Model field: source, accesses the
Subsystem
model.
- source_id¶
Model field: source
- start_time¶
Model field: start time
- subid¶
Model field: subid
- value¶
Model field: value
- variables¶
Model field: alert history, accesses the M2M
AlertHistoryVariable
model.
- varmap¶
Descriptor for simplified dict-like access to the AlertHistory stateful variable map.
NOTE: Updating the dictionary will not save it, the attribute must be assigned a dict value for a db update to take place.
AlertHistoryVariable¶
- class nav.models.event.AlertHistoryVariable(*args, **kwargs)¶
From NAV Wiki: Defines additional (key,value) tuples that follow the alerthist record.
- Parameters
id (AutoField) – Id
alert_history (ForeignKey to
AlertHistory
) – Alert historystate (CharField) – State
variable (VarcharField) – Variable
value (TextField) – Value
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))¶
- STATE_END = 'e'¶
- STATE_START = 's'¶
- STATE_STATELESS = 'x'¶
- alert_history¶
Model field: alert history, accesses the
AlertHistory
model.
- alert_history_id¶
Model field: alert history
- get_state_display(*, field=<django.db.models.fields.CharField: state>)¶
Autogenerated: Shows the label of the
state
- id¶
Model field: id
- objects = <django.db.models.manager.Manager object>¶
- state¶
Model field: state
- value¶
Model field: value
- variable¶
Model field: variable
AlertHistoryMessage¶
- class nav.models.event.AlertHistoryMessage(*args, **kwargs)¶
From NAV Wiki: To have a history of the formatted messages too, they are stored in alerthistmsg.
- Parameters
id (AutoField) – Id
alert_history (ForeignKey to
AlertHistory
) – Alert historystate (CharField) – State
type (VarcharField) – Type
language (VarcharField) – Language
message (TextField) – Message
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))¶
- STATE_END = 'e'¶
- STATE_START = 's'¶
- STATE_STATELESS = 'x'¶
- alert_history¶
Model field: alert history, accesses the
AlertHistory
model.
- alert_history_id¶
Model field: alert history
- get_state_display(*, field=<django.db.models.fields.CharField: state>)¶
Autogenerated: Shows the label of the
state
- id¶
Model field: id
- language¶
Model field: language
- message¶
Model field: message
- objects = <django.db.models.manager.Manager object>¶
- state¶
Model field: state
- type¶
Model field: type
EventMixIn¶
- class nav.models.event.EventMixIn¶
MixIn for methods common to multiple event/alert/alerthistory models
- SUBID_MAP = {'aggregateLinkState': 'Interface', 'bgpState': 'GatewayPeerSession', 'chassisState': 'NetboxEntity', 'fanState': 'PowerSupplyOrFan', 'linkState': 'Interface', 'moduleState': 'Module', 'psuState': 'PowerSupplyOrFan', 'serviceState': 'Service'}¶
- get_key()¶
Returns an identifying key for this event.
The key is a tuple of identity attribute values and can be used as a dictionary key to keep track of events that reference the same problem.
- get_subject()¶
Returns the subject of a given event/alert.
Sometimes, the subject is just a Netbox objects. Other times, it may be some physical or logical subcomponents of a Netbox.
EventType¶
- class nav.models.event.EventType(*args, **kwargs)¶
From NAV Wiki: Defines event types.
- Parameters
id (CharField) – Id
description (VarcharField) – Description
stateful (CharField) – Stateful
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- STATEFUL_CHOICES = (('y', 'stateful'), ('n', 'stateless'))¶
- STATEFUL_FALSE = 'n'¶
- STATEFUL_TRUE = 'y'¶
- alerthistory_set¶
Model field: event type, accesses the M2M
AlertHistory
model.
- alertqueue_set¶
Model field: event type, accesses the M2M
AlertQueue
model.
- description¶
Model field: description
- eventqueue_set¶
Model field: event type, accesses the M2M
EventQueue
model.
- get_stateful_display(*, field=<django.db.models.fields.CharField: stateful>)¶
Autogenerated: Shows the label of the
stateful
- id¶
Model field: id
- objects = <django.db.models.manager.Manager object>¶
- stateful¶
Model field: stateful
AlertType¶
- class nav.models.event.AlertType(*args, **kwargs)¶
From NAV Wiki: Defines the alert types. An event type may have many alert types.
- Parameters
id (AutoField) – Id
event_type (ForeignKey to
EventType
) – Event typename (VarcharField) – Name
description (VarcharField) – Description
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- alerthistory_set¶
Model field: alert type, accesses the M2M
AlertHistory
model.
- alertqueue_set¶
Model field: alert type, accesses the M2M
AlertQueue
model.
- description¶
Model field: description
- event_type_id¶
Model field: event type
- id¶
Model field: id
- name¶
Model field: name
- objects = <django.db.models.manager.Manager object>¶