xe

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2021 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned for a non-existent session
	ErrNotFound = errors.New("session not found")
	// ErrNotRunning is return for autostart sessions that aren't running
	ErrNotRunning = errors.New("session not running")
	// ErrNoFileTarget is for running sessions that have no file target
	ErrNoFileTarget = errors.New("no file target")
)

Functions

func ValidateSession

func ValidateSession(db *sql.DB, session string) error

ValidateSession confirms that a session is valid and has a file target

Types

type Database

type Database struct {
	Name       string
	CreateDate time.Time
}

Database holds some basic information about a database on the server

type Event

type Event map[string]interface{}

Event is a key value of entries for the XE event

func Parse

func Parse(i *SQLInfo, eventData string) (Event, error)

Parse converts event data into an Event

func (*Event) Copy

func (e *Event) Copy(srckey, newkey string)

Copy value from srckey to newkey

func (*Event) GetInt64

func (e *Event) GetInt64(key string) (int64, bool)

GetInt64 returns an integer value

func (*Event) GetResourceUsageDesc

func (e *Event) GetResourceUsageDesc() string

GetResourceUsageDesc returns a compressed CPU, Reads, Writes, Duration field

func (*Event) GetString

func (e *Event) GetString(key string) string

GetString returns a value as a string

func (*Event) GetTime

func (e *Event) GetTime(key string) time.Time

GetTime returns a time.Time if the value is time.Time Otherwise is returns a zero value time

func (*Event) Name

func (e *Event) Name() string

Name returns the "name" attribute from the event It returns an empty string if not found or not a string

func (*Event) Rename

func (e *Event) Rename(oldkey, newkey string)

Rename old key to new key

func (*Event) Set

func (e *Event) Set(key string, value interface{})

Set assigns a string value to a key in the event

func (*Event) SetAppSource

func (e *Event) SetAppSource()

SetAppSource creates the xecap_login_app_client event which is server_principal_name - client_app_name (client_hostname) and xecap_login_app

func (*Event) SetIfEmpty

func (e *Event) SetIfEmpty(key string, value interface{})

SetIfEmpty assigns a value at the key if it doesn't already exist

func (*Event) Timestamp

func (e *Event) Timestamp() time.Time

Timestamp returns the "timestamp" attribute from the event It returns the zero value if it doesn't exist

func (*Event) ToJSON

func (e *Event) ToJSON() (string, error)

ToJSON marshalls to a byte array

type FieldTypeKey

type FieldTypeKey struct {
	Object string
	Name   string
}

FieldTypeKey is the key for fields structure

type MapValueKey

type MapValueKey struct {
	Name   string
	MapKey int
}

MapValueKey is the lookup to the XE map value

type SQLInfo

type SQLInfo struct {
	Server   string
	Domain   string
	Computer string

	// ProductLevel holds "SP1"
	ProductLevel string
	// ProductRelease holds "13.0"
	ProductRelease string
	// Version holds "SQL Server 2013"
	Version string
	// ProductVersion holds "13.0.5101.9"
	ProductVersion string

	Fields      map[FieldTypeKey]string
	Actions     map[string]string
	MapValues   map[MapValueKey]string
	Databases   map[int64]*Database
	LoginErrors map[int64]bool

	DB *sql.DB
}

SQLInfo stores cached info about the server we connected to

func GetSQLInfo

func GetSQLInfo(driver, cxnstring, serverOverride, domainOverride string) (info SQLInfo, err error)

GetSQLInfo gets basic SQL Server info and lookup values

func (*SQLInfo) CacheSize

func (i *SQLInfo) CacheSize() int

CacheSize returns the number of items in the cache

type Session

type Session struct {
	Name     string
	Filename string
	WildCard string
}

Session holds the XE session from SQL Server. Mainly the file name and the wildcard

func GetSession

func GetSession(db *sql.DB, session string) (s Session, err error)

GetSession returns an XE session from the database

type XMLEventData

type XMLEventData struct {
	Name         string      `xml:"name,attr"`
	TimeStamp    time.Time   `xml:"timestamp,attr"`
	DataValues   []xmlData   `xml:"data"`
	ActionValues []xmlAction `xml:"action"`
}

XMLEventData holds the root for XE XML data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL