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) – Primary key: Id
subid (VarcharField) – Subid
time (DateTimeField) – Time
state (CharField) – State
value (IntegerField) – Value
severity (IntegerField) – Severity
Relationship fields:
- Parameters:
source (
ForeignKey
toSubsystem
) – Source (related name:source_of_events
)target (
ForeignKey
toSubsystem
) – Target (related name:target_of_events
)device (
ForeignKey
toDevice
) – Device (related name:events
)netbox (
ForeignKey
toNetbox
) – Netbox (related name:events
)event_type (
ForeignKey
toEventType
) – Event type (related name:events
)
Reverse relationships:
- Parameters:
variables (Reverse
ForeignKey
fromEventQueueVar
) – All variables of this event queue (related name ofevent_queue
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))
- STATE_END = 'e'
- STATE_START = 's'
- STATE_STATELESS = 'x'
- device
Type:
ForeignKey
toDevice
Device (related name:
events
)
- event_type
Type:
ForeignKey
toEventType
Event type (related name:
events
)
- event_type_id
Internal field, use
event_type
instead.
- get_next_by_time(*, field=<django.db.models.DateTimeField: time>, is_next=True, **kwargs)
Finds next instance based on
time
. Seeget_next_by_FOO()
for more information.
- get_previous_by_time(*, field=<django.db.models.DateTimeField: time>, is_next=False, **kwargs)
Finds previous instance based on
time
. Seeget_previous_by_FOO()
for more information.
- get_state_display(*, field=<django.db.models.CharField: state>)
Shows the label of the
state
. Seeget_FOO_display()
for more information.
- netbox
Type:
ForeignKey
toNetbox
Netbox (related name:
events
)
- objects = <django.db.models.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
Type:
IntegerField
Severity
- source
Type:
ForeignKey
toSubsystem
Source (related name:
source_of_events
)
- subid
Type:
VarcharField
Subid
- target
Type:
ForeignKey
toSubsystem
Target (related name:
target_of_events
)
- time
Type:
DateTimeField
Time
- value
Type:
IntegerField
Value
- variables
Type: Reverse
ForeignKey
fromEventQueueVar
All variables of this event queue (related name of
event_queue
)
- varmap
EventQueueVar
- class nav.models.event.EventQueueVar(*args, **kwargs)
From NAV Wiki: Defines additional (key,value) tuples that follow events.
- Parameters:
Relationship fields:
- Parameters:
event_queue (
ForeignKey
toEventQueue
) – Event queue (related name:variables
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- event_queue
Type:
ForeignKey
toEventQueue
Event queue (related name:
variables
)
- event_queue_id
Internal field, use
event_queue
instead.
- objects = <django.db.models.Manager object>
- variable
Type:
VarcharField
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) – Primary key: Id
subid (VarcharField) – Subid
time (DateTimeField) – Time
state (CharField) – State
value (IntegerField) – Value
severity (IntegerField) – Severity
Relationship fields:
- Parameters:
source (
ForeignKey
toSubsystem
) – Source (related name:alerts
)device (
ForeignKey
toDevice
) – Device (related name:alerts
)netbox (
ForeignKey
toNetbox
) – Netbox (related name:alerts
)event_type (
ForeignKey
toEventType
) – Event type (related name:alerts
)alert_type (
ForeignKey
toAlertType
) – Alert type (related name:alerts
)history (
ForeignKey
toAlertHistory
) – History (related name:alerts
)
Reverse relationships:
- Parameters:
messages (Reverse
ForeignKey
fromAlertQueueMessage
) – All messages of this alert queue (related name ofalert_queue
)variables (Reverse
ForeignKey
fromAlertQueueVariable
) – All variables of this alert queue (related name ofalert_queue
)queued_alerts (Reverse
ForeignKey
fromAccountAlertQueue
) – All queued alerts of this alert queue (related name ofalert
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))
- STATE_END = 'e'
- STATE_START = 's'
- STATE_STATELESS = 'x'
- alert_type
Type:
ForeignKey
toAlertType
Alert type (related name:
alerts
)
- alert_type_id
Internal field, use
alert_type
instead.
- device
Type:
ForeignKey
toDevice
Device (related name:
alerts
)
- event_type
Type:
ForeignKey
toEventType
Event type (related name:
alerts
)
- event_type_id
Internal field, use
event_type
instead.
- get_next_by_time(*, field=<django.db.models.DateTimeField: time>, is_next=True, **kwargs)
Finds next instance based on
time
. Seeget_next_by_FOO()
for more information.
- get_previous_by_time(*, field=<django.db.models.DateTimeField: time>, is_next=False, **kwargs)
Finds previous instance based on
time
. Seeget_previous_by_FOO()
for more information.
- get_state_display(*, field=<django.db.models.CharField: state>)
Shows the label of the
state
. Seeget_FOO_display()
for more information.
- history
Type:
ForeignKey
toAlertHistory
History (related name:
alerts
)
- messages
Type: Reverse
ForeignKey
fromAlertQueueMessage
All messages of this alert queue (related name of
alert_queue
)
- netbox
Type:
ForeignKey
toNetbox
Netbox (related name:
alerts
)
- objects = <django.db.models.Manager object>
- queued_alerts
Type: Reverse
ForeignKey
fromAccountAlertQueue
All queued alerts of this alert queue (related name of
alert
)
- 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
Type:
IntegerField
Severity
- source
Type:
ForeignKey
toSubsystem
Source (related name:
alerts
)
- subid
Type:
VarcharField
Subid
- time
Type:
DateTimeField
Time
- value
Type:
IntegerField
Value
- variables
Type: Reverse
ForeignKey
fromAlertQueueVariable
All variables of this alert queue (related name of
alert_queue
)
- 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:
Relationship fields:
- Parameters:
alert_queue (
ForeignKey
toAlertQueue
) – Alert queue (related name:variables
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- alert_queue
Type:
ForeignKey
toAlertQueue
Alert queue (related name:
variables
)
- alert_queue_id
Internal field, use
alert_queue
instead.
- objects = <django.db.models.Manager object>
- variable
Type:
VarcharField
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) – Primary key: Id
subid (VarcharField) – Subid
start_time (DateTimeField) – Start time
end_time (DateTimeInfinityField) – End time
value (IntegerField) – Value
severity (IntegerField) – Severity
Relationship fields:
- Parameters:
source (
ForeignKey
toSubsystem
) – Source (related name:alert_history_set
)device (
ForeignKey
toDevice
) – Device (related name:alert_history_set
)netbox (
ForeignKey
toNetbox
) – Netbox (related name:alert_history_set
)event_type (
ForeignKey
toEventType
) – Event type (related name:alert_history_set
)alert_type (
ForeignKey
toAlertType
) – Alert type (related name:alert_history_set
)
Reverse relationships:
- Parameters:
alerts (Reverse
ForeignKey
fromAlertQueue
) – All alerts of this alert history (related name ofhistory
)messages (Reverse
ForeignKey
fromAlertHistoryMessage
) – All messages of this alert history (related name ofalert_history
)variables (Reverse
ForeignKey
fromAlertHistoryVariable
) – All variables of this alert history (related name ofalert_history
)acknowledgement (Reverse
OneToOneField
fromAcknowledgement
) – The acknowledgement of this alert history (related name ofalert
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- acknowledge(account, comment)
Acknowledges this alert using a given account and comment.
Any pre-existing acknowledgement will be overwritten.
- acknowledgement
Type: Reverse
OneToOneField
fromAcknowledgement
The acknowledgement of this alert history (related name of
alert
)
- alert_type
Type:
ForeignKey
toAlertType
Alert type (related name:
alert_history_set
)
- alert_type_id
Internal field, use
alert_type
instead.
- alerts
Type: Reverse
ForeignKey
fromAlertQueue
All alerts of this alert history (related name of
history
)
- device
Type:
ForeignKey
toDevice
Device (related name:
alert_history_set
)
- end_time
Type:
DateTimeInfinityField
End time
- event_type
Type:
ForeignKey
toEventType
Event type (related name:
alert_history_set
)
- event_type_id
Internal field, use
event_type
instead.
- 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.DateTimeField: start_time>, is_next=True, **kwargs)
Finds next instance based on
start_time
. Seeget_next_by_FOO()
for more information.
- get_previous_by_start_time(*, field=<django.db.models.DateTimeField: start_time>, is_next=False, **kwargs)
Finds previous instance based on
start_time
. Seeget_previous_by_FOO()
for more information.
- 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
Type: Reverse
ForeignKey
fromAlertHistoryMessage
All messages of this alert history (related name of
alert_history
)
- netbox
Type:
ForeignKey
toNetbox
Netbox (related name:
alert_history_set
)
- 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
Type:
IntegerField
Severity
- source
Type:
ForeignKey
toSubsystem
Source (related name:
alert_history_set
)
- start_time
Type:
DateTimeField
Start time
- subid
Type:
VarcharField
Subid
- value
Type:
IntegerField
Value
- variables
Type: Reverse
ForeignKey
fromAlertHistoryVariable
All variables of this alert history (related name of
alert_history
)
- 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:
Relationship fields:
- Parameters:
alert_history (
ForeignKey
toAlertHistory
) – Alert history (related name:variables
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))
- STATE_END = 'e'
- STATE_START = 's'
- STATE_STATELESS = 'x'
- alert_history
Type:
ForeignKey
toAlertHistory
Alert history (related name:
variables
)
- alert_history_id
Internal field, use
alert_history
instead.
- get_state_display(*, field=<django.db.models.CharField: state>)
Shows the label of the
state
. Seeget_FOO_display()
for more information.
- objects = <django.db.models.Manager object>
- variable
Type:
VarcharField
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:
Relationship fields:
- Parameters:
alert_history (
ForeignKey
toAlertHistory
) – Alert history (related name:messages
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATE_CHOICES = (('x', 'stateless'), ('s', 'start'), ('e', 'end'))
- STATE_END = 'e'
- STATE_START = 's'
- STATE_STATELESS = 'x'
- alert_history
Type:
ForeignKey
toAlertHistory
Alert history (related name:
messages
)
- alert_history_id
Internal field, use
alert_history
instead.
- get_state_display(*, field=<django.db.models.CharField: state>)
Shows the label of the
state
. Seeget_FOO_display()
for more information.
- language
Type:
VarcharField
Language
- objects = <django.db.models.Manager object>
- type
Type:
VarcharField
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:
Reverse relationships:
- Parameters:
events (Reverse
ForeignKey
fromEventQueue
) – All events of this event type (related name ofevent_type
)alerts (Reverse
ForeignKey
fromAlertQueue
) – All alerts of this event type (related name ofevent_type
)alert_types (Reverse
ForeignKey
fromAlertType
) – All alert types of this event type (related name ofevent_type
)alert_history_set (Reverse
ForeignKey
fromAlertHistory
) – All alert history set of this event type (related name ofevent_type
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- STATEFUL_CHOICES = (('y', 'stateful'), ('n', 'stateless'))
- STATEFUL_FALSE = 'n'
- STATEFUL_TRUE = 'y'
- alert_history_set
Type: Reverse
ForeignKey
fromAlertHistory
All alert history set of this event type (related name of
event_type
)
- alert_types
Type: Reverse
ForeignKey
fromAlertType
All alert types of this event type (related name of
event_type
)
- alerts
Type: Reverse
ForeignKey
fromAlertQueue
All alerts of this event type (related name of
event_type
)
- description
Type:
VarcharField
Description
- events
Type: Reverse
ForeignKey
fromEventQueue
All events of this event type (related name of
event_type
)
- get_stateful_display(*, field=<django.db.models.CharField: stateful>)
Shows the label of the
stateful
. Seeget_FOO_display()
for more information.
- objects = <django.db.models.Manager object>
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) – Primary key: Id
name (VarcharField) – Name
description (VarcharField) – Description
Relationship fields:
- Parameters:
event_type (
ForeignKey
toEventType
) – Event type (related name:alert_types
)
Reverse relationships:
- Parameters:
alerts (Reverse
ForeignKey
fromAlertQueue
) – All alerts of this alert type (related name ofalert_type
)alert_history_set (Reverse
ForeignKey
fromAlertHistory
) – All alert history set of this alert type (related name ofalert_type
)
- exception DoesNotExist
- exception MultipleObjectsReturned
- alert_history_set
Type: Reverse
ForeignKey
fromAlertHistory
All alert history set of this alert type (related name of
alert_type
)
- alerts
Type: Reverse
ForeignKey
fromAlertQueue
All alerts of this alert type (related name of
alert_type
)
- description
Type:
VarcharField
Description
- event_type
Type:
ForeignKey
toEventType
Event type (related name:
alert_types
)
- event_type_id
Internal field, use
event_type
instead.
- name
Type:
VarcharField
Name
- objects = <django.db.models.Manager object>