print "It is no longer necessary to run this script to install the Monitoring Tables."
print "Monitoring Tables are now installed by the installmaster script."
print ""
print "This installmontables script is provided as a sample that can be copied and"
print "modified to support remote access of Monitoring Tables. To do so you need to:"
print "1) Replace all instances of @SERVER@ with the name of the remote ASE from which"
print "   monitoring data is to be obtained. Note that each remote ASE to be monitored"
print "   must be added to the local ASE's sysservers table using sp_addserver."
print "2) Create a database with the same name as the remote ASE. This database need "
print "   only be of the minimum size as these tables do not store any data."
print "3) Remove this header (i.e. these first 21 lines)."
print "4) Run the script against the local ASE using the isql utility as follows:"
print "   isql -Usa -P<password> -S<server name> -i<script name>"
print "5) Retrieve remote monitoring data. E.g. to obtain monEngine information for an"
print "   ASE named REMASE you would execute the following SQL:"
print "        use REMASE"
print "        go"
print "        select * from monEngine"
print "        go"
go
quit
/*
Monitoring Tables/15.5/17340/P/x86_64/Enterprise Linux/ase155/2391/64-bit/OPT/Mon Nov 09 13:55:05 2009

Confidential property of Sybase, Inc.
Copyright 2001, 2007
Sybase, Inc.  All rights reserved.
Unpublished rights reserved under U.S. copyright laws.

This software contains confidential and trade secret information of Sybase,
Inc.   Use,  duplication or disclosure of the software and documentation by
the  U.S.  Government  is  subject  to  restrictions set forth in a license
agreement  between  the  Government  and  Sybase,  Inc.  or  other  written
agreement  specifying  the  Government's rights to use the software and any
applicable FAR provisions, for example, FAR 52.227-19.
Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
*/

/* Use a different database to obtain monitoring information for each ASE */
use @SERVER@
go

/*
** monTables definition
*/
if (exists (select * from sysobjects 
	where name = 'monTables' 
	  and type = 'U')) 
	drop table monTables
go
print "Creating monTables"
go
create existing table monTables ( 
	TableID                         int,
	Columns                         tinyint,
	Parameters                      tinyint,
	Indicators                      int,
	Size                            int,
	TableName                       varchar(30) NULL,
	Description                     varchar(368) NULL,
) 
external procedure
at "@SERVER@...$monTables"
go
grant select on monTables to mon_role
go

/*
** monTableParameters definition
*/
if (exists (select * from sysobjects 
	where name = 'monTableParameters' 
	  and type = 'U')) 
	drop table monTableParameters
go
print "Creating monTableParameters"
go
create existing table monTableParameters ( 
	TableID                         int,
	ParameterID                     int,
	TypeID                          int,
	Precision                       tinyint,
	Scale                           tinyint,
	Length                          smallint,
	TableName                       varchar(30) NULL,
	ParameterName                   varchar(30) NULL,
	TypeName                        varchar(20) NULL,
	Description                     varchar(255) NULL,
) 
external procedure
at "@SERVER@...$monTableParameters"
go
grant select on monTableParameters to mon_role
go

/*
** monTableColumns definition
*/
if (exists (select * from sysobjects 
	where name = 'monTableColumns' 
	  and type = 'U')) 
	drop table monTableColumns
go
print "Creating monTableColumns"
go
create existing table monTableColumns ( 
	TableID                         int,
	ColumnID                        int,
	TypeID                          int,
	Precision                       tinyint,
	Scale                           tinyint,
	Length                          smallint,
	Indicators                      int,
	TableName                       varchar(30) NULL,
	ColumnName                      varchar(30) NULL,
	TypeName                        varchar(20) NULL,
	Description                     varchar(255) NULL,
) 
external procedure
at "@SERVER@...$monTableColumns"
go
grant select on monTableColumns to mon_role
go

/*
** monState definition
*/
if (exists (select * from sysobjects 
	where name = 'monState' 
	  and type = 'U')) 
	drop table monState
go
print "Creating monState"
go
create existing table monState ( 
	InstanceID                      tinyint,
	LockWaitThreshold               int,
	LockWaits                       int,
	DaysRunning                     int,
	CheckPoints                     int,
	NumDeadlocks                    int,
	DiagnosticDumps                 int,
	Connections                     int,
	MaxRecovery                     int,
	Transactions                    int,
	StartDate                       datetime NULL,
	CountersCleared                 datetime NULL,
) 
external procedure
at "@SERVER@...$monState"
go
grant select on monState to mon_role
go

/*
** monEngine definition
*/
if (exists (select * from sysobjects 
	where name = 'monEngine' 
	  and type = 'U')) 
	drop table monEngine
go
print "Creating monEngine"
go
create existing table monEngine ( 
	EngineNumber                    smallint,
	InstanceID                      tinyint,
	CurrentKPID                     int,
	PreviousKPID                    int,
	CPUTime                         int,
	SystemCPUTime                   int,
	UserCPUTime                     int,
	IOCPUTime                       int,
	IdleCPUTime                     int,
	Yields                          int,
	Connections                     int,
	DiskIOChecks                    int,
	DiskIOPolled                    int,
	DiskIOCompleted                 int,
	MaxOutstandingIOs               int,
	ProcessesAffinitied             int,
	ContextSwitches                 int,
	HkgcMaxQSize                    int,
	HkgcPendingItems                int,
	HkgcHWMItems                    int,
	HkgcOverflows                   int,
	Status                          varchar(20) NULL,
	StartTime                       datetime NULL,
	StopTime                        datetime NULL,
	AffinitiedToCPU                 int NULL,
	OSPID                           int NULL,
) 
external procedure
at "@SERVER@...$monEngine"
go
grant select on monEngine to mon_role
go

/*
** monDataCache definition
*/
if (exists (select * from sysobjects 
	where name = 'monDataCache' 
	  and type = 'U')) 
	drop table monDataCache
go
print "Creating monDataCache"
go
create existing table monDataCache ( 
	CacheID                         int,
	InstanceID                      tinyint,
	RelaxedReplacement              int,
	BufferPools                     int,
	CacheSearches                   int,
	PhysicalReads                   int,
	LogicalReads                    int,
	PhysicalWrites                  int,
	Stalls                          int,
	CachePartitions                 smallint,
	CacheName                       varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monDataCache"
go
grant select on monDataCache to mon_role
go

/*
** monProcedureCache definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcedureCache' 
	  and type = 'U')) 
	drop table monProcedureCache
go
print "Creating monProcedureCache"
go
create existing table monProcedureCache ( 
	Requests                        int,
	Loads                           int,
	Writes                          int,
	Stalls                          int,
	InstanceID                      tinyint,
) 
external procedure
at "@SERVER@...$monProcedureCache"
go
grant select on monProcedureCache to mon_role
go

/*
** monProcedureCacheMemoryUsage definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcedureCacheMemoryUsage' 
	  and type = 'U')) 
	drop table monProcedureCacheMemoryUsage
go
print "Creating monProcedureCacheMemoryUsage"
go
create existing table monProcedureCacheMemoryUsage ( 
	InstanceID                      tinyint,
	AllocatorID                     int,
	ModuleID                        int,
	Active                          int,
	HWM                             int,
	ChunkHWM                        int,
	NumReuseCaused                  int,
	AllocatorName                   varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monProcedureCacheMemoryUsage"
go
grant select on monProcedureCacheMemoryUsage to mon_role
go

/*
** monProcedureCacheModuleUsage definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcedureCacheModuleUsage' 
	  and type = 'U')) 
	drop table monProcedureCacheModuleUsage
go
print "Creating monProcedureCacheModuleUsage"
go
create existing table monProcedureCacheModuleUsage ( 
	InstanceID                      tinyint,
	ModuleID                        int,
	Active                          int,
	HWM                             int,
	NumPagesReused                  int,
	ModuleName                      varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monProcedureCacheModuleUsage"
go
grant select on monProcedureCacheModuleUsage to mon_role
go

/*
** monOpenDatabases definition
*/
if (exists (select * from sysobjects 
	where name = 'monOpenDatabases' 
	  and type = 'U')) 
	drop table monOpenDatabases
go
print "Creating monOpenDatabases"
go
create existing table monOpenDatabases ( 
	DBID                            int,
	InstanceID                      tinyint,
	BackupInProgress                int,
	LastBackupFailed                int,
	TransactionLogFull              int,
	SuspendedProcesses              int,
	AppendLogRequests               int,
	AppendLogWaits                  int,
	DBName                          varchar(30) NULL,
	BackupStartTime                 datetime NULL,
	LastCheckpointTime              datetime NULL,
	LastTranLogDumpTime             datetime NULL,
	QuiesceTag                      varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monOpenDatabases"
go
grant select on monOpenDatabases to mon_role
go

/*
** monSysWorkerThread definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysWorkerThread' 
	  and type = 'U')) 
	drop table monSysWorkerThread
go
print "Creating monSysWorkerThread"
go
create existing table monSysWorkerThread ( 
	InstanceID                      tinyint,
	ThreadsActive                   int,
	TotalWorkerThreads              int,
	HighWater                       int,
	ParallelQueries                 int,
	PlansAltered                    int,
	WorkerMemory                    int,
	TotalWorkerMemory               int,
	WorkerMemoryHWM                 int,
	MaxParallelDegree               int,
	MaxScanParallelDegree           int,
) 
external procedure
at "@SERVER@...$monSysWorkerThread"
go
grant select on monSysWorkerThread to mon_role
go

/*
** monNetworkIO definition
*/
if (exists (select * from sysobjects 
	where name = 'monNetworkIO' 
	  and type = 'U')) 
	drop table monNetworkIO
go
print "Creating monNetworkIO"
go
create existing table monNetworkIO ( 
	InstanceID                      tinyint,
	PacketsSent                     int,
	PacketsReceived                 int,
	BytesSent                       int,
	BytesReceived                   int,
) 
external procedure
at "@SERVER@...$monNetworkIO"
go
grant select on monNetworkIO to mon_role
go

/*
** monErrorLog definition
*/
if (exists (select * from sysobjects 
	where name = 'monErrorLog' 
	  and type = 'U')) 
	drop table monErrorLog
go
print "Creating monErrorLog"
go
create existing table monErrorLog ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	FamilyID                        int,
	EngineNumber                    smallint,
	ErrorNumber                     int,
	Severity                        int,
	State                           int,
	Time                            datetime,
	ErrorMessage                    varchar(512) NULL,
) 
external procedure
at "@SERVER@...$monErrorLog"
go
grant select on monErrorLog to mon_role
go

/*
** monLocks definition
*/
if (exists (select * from sysobjects 
	where name = 'monLocks' 
	  and type = 'U')) 
	drop table monLocks
go
print "Creating monLocks"
go
create existing table monLocks ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	DBID                            int,
	ParentSPID                      int,
	LockID                          int,
	Context                         int,
	DBName                          varchar(30) NULL,
	ObjectID                        int NULL,
	LockState                       varchar(20) NULL,
	LockType                        varchar(20) NULL,
	LockLevel                       varchar(30) NULL,
	WaitTime                        int NULL,
	PageNumber                      int NULL,
	RowNumber                       int NULL,
	BlockedState                    varchar(64) NULL,
	BlockedBy                       int NULL,
	SourceCodeID                    varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monLocks"
go
grant select on monLocks to mon_role
go

/*
** monDeadLock definition
*/
if (exists (select * from sysobjects 
	where name = 'monDeadLock' 
	  and type = 'U')) 
	drop table monDeadLock
go
print "Creating monDeadLock"
go
create existing table monDeadLock ( 
	DeadlockID                      int,
	VictimKPID                      int,
	InstanceID                      tinyint,
	ResolveTime                     datetime,
	ObjectDBID                      int,
	PageNumber                      int,
	RowNumber                       int,
	HeldFamilyID                    int,
	HeldSPID                        int,
	HeldKPID                        int,
	HeldProcDBID                    int,
	HeldProcedureID                 int,
	HeldBatchID                     int,
	HeldContextID                   int,
	HeldLineNumber                  int,
	WaitFamilyID                    int,
	WaitSPID                        int,
	WaitKPID                        int,
	WaitTime                        int,
	ObjectName                      varchar(30) NULL,
	HeldUserName                    varchar(30) NULL,
	HeldApplName                    varchar(30) NULL,
	HeldTranName                    varchar(255) NULL,
	HeldLockType                    varchar(20) NULL,
	HeldCommand                     varchar(30) NULL,
	WaitUserName                    varchar(30) NULL,
	WaitLockType                    varchar(20) NULL,
	HeldSourceCodeID                varchar(30) NULL,
	WaitSourceCodeID                varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monDeadLock"
go
grant select on monDeadLock to mon_role
go

/*
** monWaitClassInfo definition
*/
if (exists (select * from sysobjects 
	where name = 'monWaitClassInfo' 
	  and type = 'U')) 
	drop table monWaitClassInfo
go
print "Creating monWaitClassInfo"
go
create existing table monWaitClassInfo ( 
	WaitClassID                     smallint,
	Description                     varchar(55) NULL,
) 
external procedure
at "@SERVER@...$monWaitClassInfo"
go
grant select on monWaitClassInfo to mon_role
go

/*
** monWaitEventInfo definition
*/
if (exists (select * from sysobjects 
	where name = 'monWaitEventInfo' 
	  and type = 'U')) 
	drop table monWaitEventInfo
go
print "Creating monWaitEventInfo"
go
create existing table monWaitEventInfo ( 
	WaitEventID                     smallint,
	WaitClassID                     smallint,
	Description                     varchar(55) NULL,
) 
external procedure
at "@SERVER@...$monWaitEventInfo"
go
grant select on monWaitEventInfo to mon_role
go

/*
** monCachedObject definition
*/
if (exists (select * from sysobjects 
	where name = 'monCachedObject' 
	  and type = 'U')) 
	drop table monCachedObject
go
print "Creating monCachedObject"
go
create existing table monCachedObject ( 
	CacheID                         int,
	InstanceID                      tinyint,
	DBID                            int,
	IndexID                         int,
	PartitionID                     int,
	CachedKB                        int,
	CacheName                       varchar(30) NULL,
	ObjectID                        int NULL,
	DBName                          varchar(30) NULL,
	OwnerUserID                     int NULL,
	OwnerName                       varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	PartitionName                   varchar(30) NULL,
	ObjectType                      varchar(30) NULL,
	TotalSizeKB                     int NULL,
	ProcessesAccessing              int NULL,
) 
external procedure
at "@SERVER@...$monCachedObject"
go
grant select on monCachedObject to mon_role
go

/*
** monCachePool definition
*/
if (exists (select * from sysobjects 
	where name = 'monCachePool' 
	  and type = 'U')) 
	drop table monCachePool
go
print "Creating monCachePool"
go
create existing table monCachePool ( 
	CacheID                         int,
	InstanceID                      tinyint,
	IOBufferSize                    int,
	AllocatedKB                     int,
	PhysicalReads                   int,
	Stalls                          int,
	PagesTouched                    int,
	PagesRead                       int,
	BuffersToMRU                    int,
	BuffersToLRU                    int,
	CacheName                       varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monCachePool"
go
grant select on monCachePool to mon_role
go

/*
** monDBRecovery definition
*/
if (exists (select * from sysobjects 
	where name = 'monDBRecovery' 
	  and type = 'U')) 
	drop table monDBRecovery
go
print "Creating monDBRecovery"
go
create existing table monDBRecovery ( 
	DBID                            int,
	InstanceID                      tinyint,
	MaxOpenXacts                    int,
	MaxPFTSEntries                  int,
	Buckets                         int,
	LogBTotPages                    int,
	LogBTotAPFWaited                int,
	LogBTotIO                       int,
	AnlTotRec                       int,
	AnlPhase1Recs                   int,
	AnlPhase1RedoRecs               int,
	AnlPhase2Recs                   int,
	AnlPhase2RedoRecs               int,
	AnlTotPages                     int,
	AnlTotAPFWaited                 int,
	AnlTotIO                        int,
	RedoOps                         int,
	RedoOpsNotRedonePFTS            int,
	RedoOpsRedonePFTS               int,
	RedoOpsRedoneTS                 int,
	RedoOpsNotRedoneTS              int,
	RedoLogTotPages                 int,
	RedoLogTotAPFWaited             int,
	RedoLogTotIO                    int,
	RedoRecTotPages                 int,
	RedoRecTotAPFWaited             int,
	RedoRecTotIO                    int,
	UndoRecsUndone                  int,
	UndoLogTotPages                 int,
	UndoLogTotAPFWaited             int,
	UndoLogTotIO                    int,
	UndoRecTotPages                 int,
	UndoRecTotAPFWaited             int,
	UndoRecTotIO                    int,
	DBName                          varchar(30) NULL,
	FailedInstances                 varchar(96) NULL,
	Command                         varchar(30) NULL,
	RecType                         varchar(30) NULL,
	LogBStartTime                   datetime NULL,
	LogBEndTime                     datetime NULL,
	AnlStartTime                    datetime NULL,
	AnlEndTime                      datetime NULL,
	RedoStartTime                   datetime NULL,
	RedoEndTime                     datetime NULL,
	UndoStartTime                   datetime NULL,
	UndoEndTime                     datetime NULL,
) 
external procedure
at "@SERVER@...$monDBRecovery"
go
grant select on monDBRecovery to mon_role
go

/*
** monDBRecoveryLRTypes definition
*/
if (exists (select * from sysobjects 
	where name = 'monDBRecoveryLRTypes' 
	  and type = 'U')) 
	drop table monDBRecoveryLRTypes
go
print "Creating monDBRecoveryLRTypes"
go
create existing table monDBRecoveryLRTypes ( 
	DBID                            int,
	InstanceID                      tinyint,
	NumRecs                         int,
	LogrecType                      varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monDBRecoveryLRTypes"
go
grant select on monDBRecoveryLRTypes to mon_role
go

/*
** monFailoverRecovery definition
*/
if (exists (select * from sysobjects 
	where name = 'monFailoverRecovery' 
	  and type = 'U')) 
	drop table monFailoverRecovery
go
print "Creating monFailoverRecovery"
go
create existing table monFailoverRecovery ( 
	InstanceID                      tinyint,
	ModuleName                      varchar(30) NULL,
	FailedInstances                 varchar(96) NULL,
	StartTime                       datetime NULL,
	EndTime                         datetime NULL,
) 
external procedure
at "@SERVER@...$monFailoverRecovery"
go
grant select on monFailoverRecovery to mon_role
go

/*
** monOpenObjectActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monOpenObjectActivity' 
	  and type = 'U')) 
	drop table monOpenObjectActivity
go
print "Creating monOpenObjectActivity"
go
create existing table monOpenObjectActivity ( 
	DBID                            int,
	ObjectID                        int,
	IndexID                         int,
	InstanceID                      tinyint,
	DBName                          varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	LogicalReads                    int NULL,
	PhysicalReads                   int NULL,
	APFReads                        int NULL,
	PagesRead                       int NULL,
	PhysicalWrites                  int NULL,
	PagesWritten                    int NULL,
	RowsInserted                    int NULL,
	RowsDeleted                     int NULL,
	RowsUpdated                     int NULL,
	Operations                      int NULL,
	LockRequests                    int NULL,
	LockWaits                       int NULL,
	OptSelectCount                  int NULL,
	LastOptSelectDate               datetime NULL,
	UsedCount                       int NULL,
	LastUsedDate                    datetime NULL,
	HkgcRequests                    int NULL,
	HkgcPending                     int NULL,
	HkgcOverflows                   int NULL,
	PhysicalLocks                   int NULL,
	PhysicalLocksRetained           int NULL,
	PhysicalLocksRetainWaited       int NULL,
	PhysicalLocksDeadlocks          int NULL,
	PhysicalLocksWaited             int NULL,
	PhysicalLocksPageTransfer       int NULL,
	TransferReqWaited               int NULL,
	AvgPhysicalLockWaitTime         real NULL,
	AvgTransferReqWaitTime          real NULL,
	TotalServiceRequests            int NULL,
	PhysicalLocksDowngraded         int NULL,
	PagesTransferred                int NULL,
	ClusterPageWrites               int NULL,
	AvgServiceTime                  real NULL,
	AvgTimeWaitedOnLocalUsers       real NULL,
	AvgTransferSendWaitTime         real NULL,
	AvgIOServiceTime                real NULL,
	AvgDowngradeServiceTime         real NULL,
) 
external procedure
at "@SERVER@...$monOpenObjectActivity"
go
grant select on monOpenObjectActivity to mon_role
go

/*
** monIOQueue definition
*/
if (exists (select * from sysobjects 
	where name = 'monIOQueue' 
	  and type = 'U')) 
	drop table monIOQueue
go
print "Creating monIOQueue"
go
create existing table monIOQueue ( 
	InstanceID                      tinyint,
	IOs                             int,
	IOTime                          int,
	LogicalName                     varchar(30) NULL,
	IOType                          varchar(12) NULL,
) 
external procedure
at "@SERVER@...$monIOQueue"
go
grant select on monIOQueue to mon_role
go

/*
** monDeviceIO definition
*/
if (exists (select * from sysobjects 
	where name = 'monDeviceIO' 
	  and type = 'U')) 
	drop table monDeviceIO
go
print "Creating monDeviceIO"
go
create existing table monDeviceIO ( 
	InstanceID                      tinyint,
	Reads                           int,
	APFReads                        int,
	Writes                          int,
	DevSemaphoreRequests            int,
	DevSemaphoreWaits               int,
	IOTime                          int,
	LogicalName                     varchar(30) NULL,
	PhysicalName                    varchar(128) NULL,
) 
external procedure
at "@SERVER@...$monDeviceIO"
go
grant select on monDeviceIO to mon_role
go

/*
** monSysWaits definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysWaits' 
	  and type = 'U')) 
	drop table monSysWaits
go
print "Creating monSysWaits"
go
create existing table monSysWaits ( 
	InstanceID                      tinyint,
	WaitEventID                     smallint,
	WaitTime                        int,
	Waits                           int,
) 
external procedure
at "@SERVER@...$monSysWaits"
go
grant select on monSysWaits to mon_role
go

/*
** monProcess definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcess' 
	  and type = 'U')) 
	drop table monProcess
go
print "Creating monProcess"
go
create existing table monProcess ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ServerUserID                    int,
	BatchID                         int,
	ContextID                       int,
	LineNumber                      int,
	SecondsConnected                int,
	DBID                            int,
	EngineNumber                    smallint,
	Priority                        int,
	FamilyID                        int NULL,
	Login                           varchar(30) NULL,
	Application                     varchar(30) NULL,
	Command                         varchar(30) NULL,
	NumChildren                     int NULL,
	SecondsWaiting                  int NULL,
	WaitEventID                     smallint NULL,
	BlockingSPID                    int NULL,
	BlockingXLOID                   int NULL,
	DBName                          varchar(30) NULL,
	EngineGroupName                 varchar(30) NULL,
	ExecutionClass                  varchar(30) NULL,
	MasterTransactionID             varchar(255) NULL,
) 
external procedure
at "@SERVER@...$monProcess"
go
grant select on monProcess to mon_role
go

/*
** monProcessLookup definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessLookup' 
	  and type = 'U')) 
	drop table monProcessLookup
go
print "Creating monProcessLookup"
go
create existing table monProcessLookup ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	Login                           varchar(30) NULL,
	Application                     varchar(30) NULL,
	ClientHost                      varchar(30) NULL,
	ClientIP                        varchar(64) NULL,
	ClientOSPID                     varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monProcessLookup"
go
grant select on monProcessLookup to mon_role
go

/*
** monProcessActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessActivity' 
	  and type = 'U')) 
	drop table monProcessActivity
go
print "Creating monProcessActivity"
go
create existing table monProcessActivity ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ServerUserID                    int,
	CPUTime                         int,
	WaitTime                        int,
	PhysicalReads                   int,
	LogicalReads                    int,
	PagesRead                       int,
	PhysicalWrites                  int,
	PagesWritten                    int,
	MemUsageKB                      int,
	LocksHeld                       int,
	TableAccesses                   int,
	IndexAccesses                   int,
	TempDbObjects                   int,
	WorkTables                      int,
	ULCBytesWritten                 int,
	ULCFlushes                      int,
	ULCFlushFull                    int,
	ULCMaxUsage                     int,
	ULCCurrentUsage                 int,
	Transactions                    int,
	Commits                         int,
	Rollbacks                       int,
) 
external procedure
at "@SERVER@...$monProcessActivity"
go
grant select on monProcessActivity to mon_role
go

/*
** monProcessWorkerThread definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessWorkerThread' 
	  and type = 'U')) 
	drop table monProcessWorkerThread
go
print "Creating monProcessWorkerThread"
go
create existing table monProcessWorkerThread ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ThreadsActive                   int,
	MaxParallelDegree               smallint,
	MaxScanParallelDegree           smallint,
	ParallelQueries                 int,
	PlansAltered                    int,
	FamilyID                        int NULL,
) 
external procedure
at "@SERVER@...$monProcessWorkerThread"
go
grant select on monProcessWorkerThread to mon_role
go

/*
** monProcessNetIO definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessNetIO' 
	  and type = 'U')) 
	drop table monProcessNetIO
go
print "Creating monProcessNetIO"
go
create existing table monProcessNetIO ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	NetworkPacketSize               int,
	PacketsSent                     int,
	PacketsReceived                 int,
	BytesSent                       int,
	BytesReceived                   int,
	NetworkEngineNumber             smallint NULL,
) 
external procedure
at "@SERVER@...$monProcessNetIO"
go
grant select on monProcessNetIO to mon_role
go

/*
** monProcessObject definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessObject' 
	  and type = 'U')) 
	drop table monProcessObject
go
print "Creating monProcessObject"
go
create existing table monProcessObject ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	DBID                            int,
	ObjectID                        int,
	PartitionID                     int,
	IndexID                         int,
	OwnerUserID                     int,
	LogicalReads                    int,
	PhysicalReads                   int,
	PhysicalAPFReads                int,
	DBName                          varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	PartitionName                   varchar(30) NULL,
	ObjectType                      varchar(30) NULL,
	PartitionSize                   int NULL,
) 
external procedure
at "@SERVER@...$monProcessObject"
go
grant select on monProcessObject to mon_role
go

/*
** monProcessWaits definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessWaits' 
	  and type = 'U')) 
	drop table monProcessWaits
go
print "Creating monProcessWaits"
go
create existing table monProcessWaits ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ServerUserID                    int,
	WaitEventID                     smallint,
	Waits                           int,
	WaitTime                        int,
) 
external procedure
at "@SERVER@...$monProcessWaits"
go
grant select on monProcessWaits to mon_role
go

/*
** monProcessStatement definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessStatement' 
	  and type = 'U')) 
	drop table monProcessStatement
go
print "Creating monProcessStatement"
go
create existing table monProcessStatement ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	DBID                            int,
	ProcedureID                     int,
	PlanID                          int,
	BatchID                         int,
	ContextID                       int,
	LineNumber                      int,
	CpuTime                         int,
	WaitTime                        int,
	MemUsageKB                      int,
	PhysicalReads                   int,
	LogicalReads                    int,
	PagesModified                   int,
	PacketsSent                     int,
	PacketsReceived                 int,
	NetworkPacketSize               int,
	PlansAltered                    int,
	RowsAffected                    int,
	DBName                          varchar(30) NULL,
	StartTime                       datetime NULL,
) 
external procedure
at "@SERVER@...$monProcessStatement"
go
grant select on monProcessStatement to mon_role
go

/*
** monSysStatement definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysStatement' 
	  and type = 'U')) 
	drop table monSysStatement
go
print "Creating monSysStatement"
go
create existing table monSysStatement ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	DBID                            int,
	ProcedureID                     int,
	PlanID                          int,
	BatchID                         int,
	ContextID                       int,
	LineNumber                      int,
	CpuTime                         int,
	WaitTime                        int,
	MemUsageKB                      int,
	PhysicalReads                   int,
	LogicalReads                    int,
	PagesModified                   int,
	PacketsSent                     int,
	PacketsReceived                 int,
	NetworkPacketSize               int,
	PlansAltered                    int,
	RowsAffected                    int,
	ErrorStatus                     int,
	HashKey                         int,
	SsqlId                          int,
	ProcNestLevel                   int,
	StatementNumber                 int,
	DBName                          varchar(30) NULL,
	StartTime                       datetime NULL,
	EndTime                         datetime NULL,
) 
external procedure
at "@SERVER@...$monSysStatement"
go
grant select on monSysStatement to mon_role
go

/*
** monProcessSQLText definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessSQLText' 
	  and type = 'U')) 
	drop table monProcessSQLText
go
print "Creating monProcessSQLText"
go
create existing table monProcessSQLText ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ServerUserID                    int,
	BatchID                         int,
	LineNumber                      int,
	SequenceInLine                  int,
	SQLText                         varchar(255) NULL,
) 
external procedure
at "@SERVER@...$monProcessSQLText"
go
grant select on monProcessSQLText to mon_role
go

/*
** monSysSQLText definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysSQLText' 
	  and type = 'U')) 
	drop table monSysSQLText
go
print "Creating monSysSQLText"
go
create existing table monSysSQLText ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	ServerUserID                    int,
	BatchID                         int,
	SequenceInBatch                 int,
	SQLText                         varchar(255) NULL,
) 
external procedure
at "@SERVER@...$monSysSQLText"
go
grant select on monSysSQLText to mon_role
go

/*
** monCachedProcedures definition
*/
if (exists (select * from sysobjects 
	where name = 'monCachedProcedures' 
	  and type = 'U')) 
	drop table monCachedProcedures
go
print "Creating monCachedProcedures"
go
create existing table monCachedProcedures ( 
	ObjectID                        int,
	InstanceID                      tinyint,
	OwnerUID                        int,
	DBID                            int,
	PlanID                          int,
	MemUsageKB                      int,
	CompileDate                     datetime,
	ObjectName                      varchar(30) NULL,
	ObjectType                      varchar(32) NULL,
	OwnerName                       varchar(30) NULL,
	DBName                          varchar(30) NULL,
	RequestCnt                      int NULL,
	TempdbRemapCnt                  int NULL,
	AvgTempdbRemapTime              int NULL,
) 
external procedure
at "@SERVER@...$monCachedProcedures"
go
grant select on monCachedProcedures to mon_role
go

/*
** monProcessProcedures definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessProcedures' 
	  and type = 'U')) 
	drop table monProcessProcedures
go
print "Creating monProcessProcedures"
go
create existing table monProcessProcedures ( 
	SPID                            int,
	InstanceID                      tinyint,
	KPID                            int,
	DBID                            int,
	OwnerUID                        int,
	ObjectID                        int,
	PlanID                          int,
	MemUsageKB                      int,
	CompileDate                     datetime,
	ContextID                       int,
	LineNumber                      int,
	StatementNumber                 int,
	DBName                          varchar(30) NULL,
	OwnerName                       varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	ObjectType                      varchar(32) NULL,
) 
external procedure
at "@SERVER@...$monProcessProcedures"
go
grant select on monProcessProcedures to mon_role
go

/*
** monSysPlanText definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysPlanText' 
	  and type = 'U')) 
	drop table monSysPlanText
go
print "Creating monSysPlanText"
go
create existing table monSysPlanText ( 
	PlanID                          int,
	InstanceID                      tinyint,
	SPID                            int,
	KPID                            int,
	BatchID                         int,
	ContextID                       int,
	SequenceNumber                  int,
	DBID                            int,
	ProcedureID                     int,
	DBName                          varchar(30) NULL,
	PlanText                        varchar(160) NULL,
) 
external procedure
at "@SERVER@...$monSysPlanText"
go
grant select on monSysPlanText to mon_role
go

/*
** monOpenPartitionActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monOpenPartitionActivity' 
	  and type = 'U')) 
	drop table monOpenPartitionActivity
go
print "Creating monOpenPartitionActivity"
go
create existing table monOpenPartitionActivity ( 
	DBID                            int,
	ObjectID                        int,
	IndexID                         int,
	PartitionID                     int,
	InstanceID                      tinyint,
	DBName                          varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	PartitionName                   varchar(30) NULL,
	LogicalReads                    int NULL,
	PhysicalReads                   int NULL,
	APFReads                        int NULL,
	PagesRead                       int NULL,
	PhysicalWrites                  int NULL,
	PagesWritten                    int NULL,
	RowsInserted                    int NULL,
	RowsDeleted                     int NULL,
	RowsUpdated                     int NULL,
	OptSelectCount                  int NULL,
	LastOptSelectDate               datetime NULL,
	UsedCount                       int NULL,
	LastUsedDate                    datetime NULL,
	HkgcRequests                    int NULL,
	HkgcPending                     int NULL,
	HkgcOverflows                   int NULL,
	PhysicalLocks                   int NULL,
	PhysicalLocksRetained           int NULL,
	PhysicalLocksRetainWaited       int NULL,
	PhysicalLocksDeadlocks          int NULL,
	PhysicalLocksWaited             int NULL,
	PhysicalLocksPageTransfer       int NULL,
	TransferReqWaited               int NULL,
	AvgPhysicalLockWaitTime         real NULL,
	AvgTransferReqWaitTime          real NULL,
	TotalServiceRequests            int NULL,
	PhysicalLocksDowngraded         int NULL,
	PagesTransferred                int NULL,
	ClusterPageWrites               int NULL,
	AvgServiceTime                  real NULL,
	AvgTimeWaitedOnLocalUsers       real NULL,
	AvgTransferSendWaitTime         real NULL,
	AvgIOServiceTime                real NULL,
	AvgDowngradeServiceTime         real NULL,
) 
external procedure
at "@SERVER@...$monOpenPartitionActivity"
go
grant select on monOpenPartitionActivity to mon_role
go

/*
** monLicense definition
*/
if (exists (select * from sysobjects 
	where name = 'monLicense' 
	  and type = 'U')) 
	drop table monLicense
go
print "Creating monLicense"
go
create existing table monLicense ( 
	InstanceID                      tinyint,
	Quantity                        int,
	Name                            varchar(30) NULL,
	Edition                         varchar(30) NULL,
	Type                            varchar(64) NULL,
	Version                         varchar(16) NULL,
	Status                          varchar(30) NULL,
	LicenseExpiry                   datetime NULL,
	GraceExpiry                     datetime NULL,
	LicenseID                       varchar(150) NULL,
	Filter                          varchar(14) NULL,
	Attributes                      varchar(64) NULL,
) 
external procedure
at "@SERVER@...$monLicense"
go
grant select on monLicense to public
go

/*
** monLogicalCluster definition
*/
if (exists (select * from sysobjects 
	where name = 'monLogicalCluster' 
	  and type = 'U')) 
	drop table monLogicalCluster
go
print "Creating monLogicalCluster"
go
create existing table monLogicalCluster ( 
	LCID                            int,
	Attributes                      int,
	ActiveConnections               int,
	BaseInstances                   tinyint,
	ActiveBaseInstances             tinyint,
	FailoverInstances               tinyint,
	ActiveFailoverInstances         tinyint,
	Name                            varchar(30) NULL,
	State                           varchar(20) NULL,
	DownRoutingMode                 varchar(20) NULL,
	FailoverMode                    varchar(30) NULL,
	FailoverRecovery                varchar(30) NULL,
	StartupMode                     varchar(20) NULL,
	SystemView                      varchar(20) NULL,
	Roles                           varchar(30) NULL,
	LoadProfile                     varchar(30) NULL,
	ActionRelease                   varchar(20) NULL,
	Gather                          varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monLogicalCluster"
go
grant select on monLogicalCluster to public
go

/*
** monLogicalClusterAction definition
*/
if (exists (select * from sysobjects 
	where name = 'monLogicalClusterAction' 
	  and type = 'U')) 
	drop table monLogicalClusterAction
go
print "Creating monLogicalClusterAction"
go
create existing table monLogicalClusterAction ( 
	Handle                          int,
	LCID                            int,
	InstancesWaiting                int,
	StartTime                       datetime,
	ConnectionsRemaining            int,
	NonMigConnections               int,
	NonHAConnections                int,
	State                           varchar(20) NULL,
	LogicalClusterName              varchar(30) NULL,
	Action                          varchar(30) NULL,
	FromInstances                   varchar(96) NULL,
	ToInstances                     varchar(96) NULL,
	WaitType                        varchar(20) NULL,
	Deadline                        datetime NULL,
	CompleteTime                    datetime NULL,
) 
external procedure
at "@SERVER@...$monLogicalClusterAction"
go
grant select on monLogicalClusterAction to public
go

/*
** monLogicalClusterInstance definition
*/
if (exists (select * from sysobjects 
	where name = 'monLogicalClusterInstance' 
	  and type = 'U')) 
	drop table monLogicalClusterInstance
go
print "Creating monLogicalClusterInstance"
go
create existing table monLogicalClusterInstance ( 
	LCID                            int,
	InstanceID                      tinyint,
	ActiveConnections               int,
	NonMigConnections               int,
	NonHAConnections                int,
	LoadScore                       real,
	LogicalClusterName              varchar(30) NULL,
	InstanceName                    varchar(30) NULL,
	Type                            varchar(20) NULL,
	FailoverGroup                   tinyint NULL,
	State                           varchar(20) NULL,
) 
external procedure
at "@SERVER@...$monLogicalClusterInstance"
go
grant select on monLogicalClusterInstance to public
go

/*
** monLogicalClusterRoute definition
*/
if (exists (select * from sysobjects 
	where name = 'monLogicalClusterRoute' 
	  and type = 'U')) 
	drop table monLogicalClusterRoute
go
print "Creating monLogicalClusterRoute"
go
create existing table monLogicalClusterRoute ( 
	LCID                            int,
	LogicalClusterName              varchar(30) NULL,
	RouteType                       varchar(20) NULL,
	RouteKey                        varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monLogicalClusterRoute"
go
grant select on monLogicalClusterRoute to public
go

/*
** monWorkload definition
*/
if (exists (select * from sysobjects 
	where name = 'monWorkload' 
	  and type = 'U')) 
	drop table monWorkload
go
print "Creating monWorkload"
go
create existing table monWorkload ( 
	LCID                            int,
	InstanceID                      tinyint,
	LoadProfileID                   tinyint,
	LoadScore                       real,
	ConnectionsScore                real,
	CpuScore                        real,
	RunQueueScore                   real,
	IoLoadScore                     real,
	EngineScore                     real,
	UserScore                       real,
	LogicalClusterName              varchar(30) NULL,
	InstanceName                    varchar(30) NULL,
	LoadProfileName                 varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monWorkload"
go
grant select on monWorkload to public
go

/*
** monWorkloadPreview definition
*/
if (exists (select * from sysobjects 
	where name = 'monWorkloadPreview' 
	  and type = 'U')) 
	drop table monWorkloadPreview
go
print "Creating monWorkloadPreview"
go
create existing table monWorkloadPreview ( 
	InstanceID                      tinyint,
	LoadProfileID                   tinyint,
	LoadScore                       real,
	ConnectionsScore                real,
	CpuScore                        real,
	RunQueueScore                   real,
	IoLoadScore                     real,
	EngineScore                     real,
	UserScore                       real,
	InstanceName                    varchar(30) NULL,
	LoadProfileName                 varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monWorkloadPreview"
go
grant select on monWorkloadPreview to public
go

/*
** monWorkloadProfile definition
*/
if (exists (select * from sysobjects 
	where name = 'monWorkloadProfile' 
	  and type = 'U')) 
	drop table monWorkloadProfile
go
print "Creating monWorkloadProfile"
go
create existing table monWorkloadProfile ( 
	ProfileID                       int,
	ConnectionsWeight               tinyint,
	CpuWeight                       tinyint,
	RunQueueWeight                  tinyint,
	IoLoadWeight                    tinyint,
	EngineWeight                    tinyint,
	UserWeight                      tinyint,
	LoginThreshold                  tinyint,
	DynamicThreshold                tinyint,
	Hysteresis                      tinyint,
	Name                            varchar(30) NULL,
	Type                            varchar(20) NULL,
) 
external procedure
at "@SERVER@...$monWorkloadProfile"
go
grant select on monWorkloadProfile to public
go

/*
** monWorkloadRaw definition
*/
if (exists (select * from sysobjects 
	where name = 'monWorkloadRaw' 
	  and type = 'U')) 
	drop table monWorkloadRaw
go
print "Creating monWorkloadRaw"
go
create existing table monWorkloadRaw ( 
	InstanceID                      tinyint,
	ConnectionsRaw                  real,
	CpuRaw                          real,
	RunQueueRaw                     real,
	IoLoadRaw                       real,
	EngineRaw                       real,
	UserRaw                         real,
	InstanceName                    varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monWorkloadRaw"
go
grant select on monWorkloadRaw to public
go

/*
** monSysLoad definition
*/
if (exists (select * from sysobjects 
	where name = 'monSysLoad' 
	  and type = 'U')) 
	drop table monSysLoad
go
print "Creating monSysLoad"
go
create existing table monSysLoad ( 
	StatisticID                     smallint,
	InstanceID                      tinyint,
	EngineNumber                    smallint,
	Sample                          real,
	SteadyState                     real,
	Avg_1min                        real,
	Avg_5min                        real,
	Avg_15min                       real,
	Peak                            real,
	Max_1min                        real,
	Max_5min                        real,
	Max_15min                       real,
	Peak_Time                       datetime,
	Max_1min_Time                   datetime,
	Max_5min_Time                   datetime,
	Max_15min_Time                  datetime,
	Statistic                       varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monSysLoad"
go
grant select on monSysLoad to public
go

/*
** monCIPC definition
*/
if (exists (select * from sysobjects 
	where name = 'monCIPC' 
	  and type = 'U')) 
	drop table monCIPC
go
print "Creating monCIPC"
go
create existing table monCIPC ( 
	InstanceID                      tinyint,
	ReceiveCount                    int,
	TransmitCount                   int,
	Multicast                       int,
	Synchronous                     int,
	ReceiveSoftError                int,
	ReceiveHardError                int,
	TransmitSoftError               int,
	TransmitHardError               int,
	Retransmits                     int,
	Switches                        int,
	FailedSwitches                  int,
	RegularBuffersInUse             int,
	FreeRegularBuffers              int,
	MaxRegularBuffersInUse          int,
	LargeBuffersInUse               int,
	FreeLargeBuffers                int,
	MaxLargeBuffersInUse            int,
) 
external procedure
at "@SERVER@...$monCIPC"
go
grant select on monCIPC to mon_role
go

/*
** monCIPCEndpoints definition
*/
if (exists (select * from sysobjects 
	where name = 'monCIPCEndpoints' 
	  and type = 'U')) 
	drop table monCIPCEndpoints
go
print "Creating monCIPCEndpoints"
go
create existing table monCIPCEndpoints ( 
	InstanceID                      tinyint,
	ReceiveCount                    int,
	TransmitCount                   int,
	ReceiveBytes                    int,
	TransmitBytes                   int,
	ReceiveQ                        int,
	MaxReceiveQ                     int,
	DoneQ                           int,
	MaxDoneQ                        int,
	MaxRecvQTime                    real,
	AvgRecvQTime                    real,
	EndPoint                        varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monCIPCEndpoints"
go
grant select on monCIPCEndpoints to mon_role
go

/*
** monCIPCMesh definition
*/
if (exists (select * from sysobjects 
	where name = 'monCIPCMesh' 
	  and type = 'U')) 
	drop table monCIPCMesh
go
print "Creating monCIPCMesh"
go
create existing table monCIPCMesh ( 
	InstanceID                      tinyint,
	FarInstanceID                   tinyint,
	Received                        int,
	Dropped                         int,
	Transmitted                     int,
	Resent                          int,
	Retry                           int,
	ControlRx                       int,
	ControlTx                       int,
	SendQ                           int,
	MaxSendQ                        int,
	SentQ                           int,
	MaxSentQ                        int,
	MaxSendQTime                    real,
	AvgSendQTime                    real,
	Mesh                            varchar(30) NULL,
	MinRTT                          int NULL,
	MaxRTT                          int NULL,
	AverageRTT                      int NULL,
) 
external procedure
at "@SERVER@...$monCIPCMesh"
go
grant select on monCIPCMesh to mon_role
go

/*
** monClusterCacheManager definition
*/
if (exists (select * from sysobjects 
	where name = 'monClusterCacheManager' 
	  and type = 'U')) 
	drop table monClusterCacheManager
go
print "Creating monClusterCacheManager"
go
create existing table monClusterCacheManager ( 
	InstanceID                      tinyint,
	RequestsQueued                  int,
	RequestsRequeued                int,
	RequestsServiced                int,
	DiskWrites                      int,
	SleepCount                      int,
	DaemonName                      varchar(30) NULL,
	TransfersInitiated              int NULL,
	Downgrades                      int NULL,
	Releases                        int NULL,
	AvgServiceTime                  real NULL,
	MaxQSize                        int NULL,
) 
external procedure
at "@SERVER@...$monClusterCacheManager"
go
grant select on monClusterCacheManager to mon_role
go

/*
** monCMSFailover definition
*/
if (exists (select * from sysobjects 
	where name = 'monCMSFailover' 
	  and type = 'U')) 
	drop table monCMSFailover
go
print "Creating monCMSFailover"
go
create existing table monCMSFailover ( 
	InstanceID                      tinyint,
	FailedInstanceID                varchar(96) NULL,
	FailDetectTime                  datetime NULL,
	InitViewTime                    datetime NULL,
	FinalViewTime                   datetime NULL,
	ResyncHBTime                    datetime NULL,
	NotifyFailTime                  datetime NULL,
	EventdoneTime                   datetime NULL,
) 
external procedure
at "@SERVER@...$monCMSFailover"
go
grant select on monCMSFailover to mon_role
go

/*
** monTempdbActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monTempdbActivity' 
	  and type = 'U')) 
	drop table monTempdbActivity
go
print "Creating monTempdbActivity"
go
create existing table monTempdbActivity ( 
	DBID                            int,
	InstanceID                      tinyint,
	AppendLogRequests               int,
	AppendLogWaits                  int,
	DBName                          varchar(30) NULL,
	LogicalReads                    int NULL,
	PhysicalReads                   int NULL,
	APFReads                        int NULL,
	PagesRead                       int NULL,
	PhysicalWrites                  int NULL,
	PagesWritten                    int NULL,
	LockRequests                    int NULL,
	LockWaits                       int NULL,
	CatLockRequests                 int NULL,
	CatLockWaits                    int NULL,
	AssignedCnt                     int NULL,
	SharableTabCnt                  int NULL,
) 
external procedure
at "@SERVER@...$monTempdbActivity"
go
grant select on monTempdbActivity to mon_role
go

/*
** monCIPCLinks definition
*/
if (exists (select * from sysobjects 
	where name = 'monCIPCLinks' 
	  and type = 'U')) 
	drop table monCIPCLinks
go
print "Creating monCIPCLinks"
go
create existing table monCIPCLinks ( 
	InstanceID                      tinyint,
	LocalInterface                  varchar(30),
	RemoteInterface                 varchar(30),
	PassiveState                    varchar(10),
	PassiveStateAge                 int,
	ActiveState                     varchar(10),
	ActiveStateAge                  int,
) 
external procedure
at "@SERVER@...$monCIPCLinks"
go
grant select on monCIPCLinks to mon_role
go

/*
** monProcessMigration definition
*/
if (exists (select * from sysobjects 
	where name = 'monProcessMigration' 
	  and type = 'U')) 
	drop table monProcessMigration
go
print "Creating monProcessMigration"
go
create existing table monProcessMigration ( 
	SPID                            int,
	KPID                            int,
	LogicalCluster                  varchar(30) NULL,
	Instance                        varchar(30) NULL,
	MigrationLogicalCluster         varchar(30) NULL,
	MigrationInstance               varchar(30) NULL,
	Command                         varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monProcessMigration"
go
grant select on monProcessMigration to public
go

/*
** monStatementCache definition
*/
if (exists (select * from sysobjects 
	where name = 'monStatementCache' 
	  and type = 'U')) 
	drop table monStatementCache
go
print "Creating monStatementCache"
go
create existing table monStatementCache ( 
	InstanceID                      tinyint,
	TotalSizeKB                     int,
	UsedSizeKB                      int,
	NumStatements                   int,
	NumSearches                     int,
	HitCount                        int,
	NumInserts                      int,
	NumRemovals                     int,
	NumRecompilesSchemaChanges      int,
	NumRecompilesPlanFlushes        int,
) 
external procedure
at "@SERVER@...$monStatementCache"
go
grant select on monStatementCache to mon_role
go

/*
** monCachedStatement definition
*/
if (exists (select * from sysobjects 
	where name = 'monCachedStatement' 
	  and type = 'U')) 
	drop table monCachedStatement
go
print "Creating monCachedStatement"
go
create existing table monCachedStatement ( 
	InstanceID                      tinyint,
	SSQLID                          int,
	Hashkey                         int,
	UserID                          int,
	SUserID                         int,
	DBID                            smallint,
	UseCount                        int,
	StatementSize                   int,
	MinPlanSizeKB                   int,
	MaxPlanSizeKB                   int,
	CurrentUsageCount               int,
	MaxUsageCount                   int,
	NumRecompilesSchemaChanges      int,
	NumRecompilesPlanFlushes        int,
	HasAutoParams                   tinyint,
	ParallelDegree                  tinyint,
	QuotedIdentifier                tinyint,
	TransactionIsolationLevel       tinyint,
	TransactionMode                 tinyint,
	SAAuthorization                 tinyint,
	SystemCatalogUpdate             tinyint,
	MetricsCount                    int,
	MinPIO                          int,
	MaxPIO                          int,
	AvgPIO                          int,
	MinLIO                          int,
	MaxLIO                          int,
	AvgLIO                          int,
	MinCpuTime                      int,
	MaxCpuTime                      int,
	AvgCpuTime                      int,
	MinElapsedTime                  int,
	MaxElapsedTime                  int,
	AvgElapsedTime                  int,
	DBName                          varchar(30) NULL,
	CachedDate                      datetime NULL,
	LastUsedDate                    datetime NULL,
	LastRecompiledDate              datetime NULL,
) 
external procedure
at "@SERVER@...$monCachedStatement"
go
grant select on monCachedStatement to mon_role
go

/*
** monPCIBridge definition
*/
if (exists (select * from sysobjects 
	where name = 'monPCIBridge' 
	  and type = 'U')) 
	drop table monPCIBridge
go
print "Creating monPCIBridge"
go
create existing table monPCIBridge ( 
	InstanceID                      tinyint,
	Status                          char(10),
	ConfiguredSlots                 int,
	ActiveSlots                     int,
	ConfiguredPCIMemoryKB           int,
	UsedPCIMemoryKB                 int,
) 
external procedure
at "@SERVER@...$monPCIBridge"
go
grant select on monPCIBridge to mon_role
go

/*
** monPCISlots definition
*/
if (exists (select * from sysobjects 
	where name = 'monPCISlots' 
	  and type = 'U')) 
	drop table monPCISlots
go
print "Creating monPCISlots"
go
create existing table monPCISlots ( 
	InstanceID                      tinyint,
	Slot                            int,
	Status                          char(10),
	Modulename                      varchar(30),
	engine                          int,
) 
external procedure
at "@SERVER@...$monPCISlots"
go
grant select on monPCISlots to mon_role
go

/*
** monPCIEngine definition
*/
if (exists (select * from sysobjects 
	where name = 'monPCIEngine' 
	  and type = 'U')) 
	drop table monPCIEngine
go
print "Creating monPCIEngine"
go
create existing table monPCIEngine ( 
	InstanceID                      tinyint,
	engine                          int,
	Status                          char(10),
	PLBStatus                       char(10),
	NumberofActiveThreads           int,
	PLBRequests                     int,
	PLBwakeupRequests               int,
) 
external procedure
at "@SERVER@...$monPCIEngine"
go
grant select on monPCIEngine to mon_role
go

/*
** monSQLRepActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monSQLRepActivity' 
	  and type = 'U')) 
	drop table monSQLRepActivity
go
print "Creating monSQLRepActivity"
go
create existing table monSQLRepActivity ( 
	DBID                            int,
	ObjectID                        int,
	InstanceID                      tinyint,
	DBName                          varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	UpdateStmts                     int NULL,
	InsertSelectStmts               int NULL,
	DeleteStmts                     int NULL,
	SelectIntoStmts                 int NULL,
	RowsThreshold                   int NULL,
) 
external procedure
at "@SERVER@...$monSQLRepActivity"
go
grant select on monSQLRepActivity to mon_role
go

/*
** monSQLRepMisses definition
*/
if (exists (select * from sysobjects 
	where name = 'monSQLRepMisses' 
	  and type = 'U')) 
	drop table monSQLRepMisses
go
print "Creating monSQLRepMisses"
go
create existing table monSQLRepMisses ( 
	DBID                            int,
	ObjectID                        int,
	InstanceID                      tinyint,
	DBName                          varchar(30) NULL,
	ObjectName                      varchar(30) NULL,
	Threshold                       int NULL,
	QueryLimitation                 int NULL,
	Configuration                   int NULL,
) 
external procedure
at "@SERVER@...$monSQLRepMisses"
go
grant select on monSQLRepMisses to mon_role
go

/*
** monPCM definition
*/
if (exists (select * from sysobjects 
	where name = 'monPCM' 
	  and type = 'U')) 
	drop table monPCM
go
print "Creating monPCM"
go
create existing table monPCM ( 
	InstanceId                      tinyint,
	Sent                            int,
	Fragments_sent                  int,
	Fragments_received              int,
	Received                        int,
	Reply                           int,
	Unicast                         int,
	Multicast                       int,
	Sync                            int,
	Async                           int,
	MinBytes                        int,
	AvgBytes                        int,
	MaxBytes                        int,
	MinDialog                       int,
	AvgDialog                       int,
	MaxDialog                       int,
	Dialog                          int,
	MinTimeSyncApi                  real,
	AvgTimeSyncApi                  real,
	MaxTimeSyncApi                  real,
	MinTimeAsyncApi                 real,
	AvgTimeAsyncApi                 real,
	MaxTimeAsyncApi                 real,
	MinTimeCIPCMsgAlloc             real,
	AvgTimeCIPCMsgAlloc             real,
	MaxTimeCIPCMsgAlloc             real,
	MinTimeCIPCSendCB               real,
	AvgTimeCIPCSendCB               real,
	MaxTimeCIPCSendCB               real,
	MinTimeCIPCUnicastsmsg          real,
	AvgTimeCIPCUnicastsmsg          real,
	MaxTimeCIPCUnicastsmsg          real,
	MinTimeCIPCMulticastsmsg        real,
	AvgTimeCIPCMulticastsmsg        real,
	MaxTimeCIPCMulticastsmsg        real,
	MinTimeClientRecvCB             real,
	AvgTimeClientRecvCB             real,
	MaxTimeClientRecvCB             real,
	ModuleName                      varchar(32) NULL,
) 
external procedure
at "@SERVER@...$monPCM"
go
grant select on monPCM to mon_role
go

/*
** monCLMObjectActivity definition
*/
if (exists (select * from sysobjects 
	where name = 'monCLMObjectActivity' 
	  and type = 'U')) 
	drop table monCLMObjectActivity
go
print "Creating monCLMObjectActivity"
go
create existing table monCLMObjectActivity ( 
	InstanceID                      tinyint,
	DBID                            int,
	Object_PartitionID              int,
	LockRequests                    int,
	LocalMaster                     int,
	Waited                          int,
	Granted                         int,
	RWConflictWaited                int,
	AvgRWConflictWaitTime           real,
	MaxRWConflictWaitTime           real,
	WWConflictWaited                int,
	AvgWWConflictWaitTime           real,
	MaxWWConflictWaitTime           real,
	ClusterMsgWaits                 int,
	AvgClusterMsgWaitTime           real,
	MaxClusterMsgWaitTime           real,
	DowngradeReqRecv                int,
	DowngradeReqRecvWithNoBlocker   int,
	ClusterDeadlock                 int,
	LockType                        varchar(20) NULL,
) 
external procedure
at "@SERVER@...$monCLMObjectActivity"
go
grant select on monCLMObjectActivity to mon_role
go

/*
** monTableTransfer definition
*/
if (exists (select * from sysobjects 
	where name = 'monTableTransfer' 
	  and type = 'U')) 
	drop table monTableTransfer
go
print "Creating monTableTransfer"
go
create existing table monTableTransfer ( 
	InstanceID                      tinyint,
	DBID                            smallint,
	TableID                         int,
	SequenceID                      int,
	PercentDone                     smallint,
	BeginTime                       datetime,
	TransferFloor                   bigint,
	TransferCeiling                 bigint,
	RowsSent                        bigint,
	BytesSent                       bigint,
	TableName                       varchar(255) NULL,
	TrackingID                      int NULL,
	EndTime                         datetime NULL,
	EndCode                         smallint NULL,
	Format                          varchar(8) NULL,
) 
external procedure
at "@SERVER@...$monTableTransfer"
go
grant select on monTableTransfer to public
go

/*
** monInmemoryStorage definition
*/
if (exists (select * from sysobjects 
	where name = 'monInmemoryStorage' 
	  and type = 'U')) 
	drop table monInmemoryStorage
go
print "Creating monInmemoryStorage"
go
create existing table monInmemoryStorage ( 
	InstanceID                      tinyint,
	ID                              int,
	DeviceNum                       int,
	StartPage                       int,
	NumPages                        int,
	SizeKB                          int,
	Name                            varchar(30) NULL,
	DeviceName                      varchar(30) NULL,
	Type                            varchar(30) NULL,
	Status                          varchar(30) NULL,
) 
external procedure
at "@SERVER@...$monInmemoryStorage"
go
grant select on monInmemoryStorage to public
go
