Freitag, 15. August 2014

SQL Database file size script

 
SQL Administratoren benötigen oft detaillierte Informationen zu verschiedenen Datenbanken, wie Z.B. Used Space einer Datenbank oder einer Log Datei. 
Um mit geringem Aufwand diese Informationen zu sammeln sollte man dieses SQL Script ausführen. (Kompatibel ab SQL Server 2005)


Als Output erhält man folgende Tabelle:

[image%255B10%255D.png]

DatabaseName, LogicalFileName, RecoveryMode, FileSizeMB, UsedSpaceMB, FreeSpaceMB, FreeSpacePct, PhysicalFileName, Status
SQL-Script:
DECLARE @DBInfo TABLE 
( ServerName VARCHAR(100),
DatabaseName VARCHAR(100),
FileSizeMB INT,
LogicalFileName sysname,
PhysicalFileName NVARCHAR(520),
Status sysname,
Updateability sysname,
RecoveryMode sysname,
FreeSpaceMB INT,
UsedSpaceMB INT,
FreeSpacePct VARCHAR(7),
FreeSpacePages INT,
PollDate datetime)

DECLARE @command VARCHAR(5000)

SELECT @command = 'Use [' + '?' + '] SELECT
@@servername as ServerName,
' + '''' + '?' + '''' + ' AS DatabaseName,
CAST(sysfiles.size/128.0 AS int) AS FileSize,
sysfiles.name AS LogicalFileName, sysfiles.filename AS PhysicalFileName,
CONVERT(sysname,DatabasePropertyEx(''?'',''Status'')) AS Status,
CONVERT(sysname,DatabasePropertyEx(''?'',''Updateability'')) AS Updateability,
CONVERT(sysname,DatabasePropertyEx(''?'',''Recovery'')) AS RecoveryMode,
CAST(sysfiles.size/128.0 - CAST(FILEPROPERTY(sysfiles.name, ' + '''' +
'SpaceUsed' + '''' + ' ) AS int)/128.0 AS int) AS FreeSpaceMB,
CAST(FILEPROPERTY(sysfiles.name, ' + '''' +
'SpaceUsed' + '''' + ' )/128.0 AS int) AS UsedSpaceMB,
CAST(100 * (CAST (((sysfiles.size/128.0 -CAST(FILEPROPERTY(sysfiles.name,
' + '''' + 'SpaceUsed' + '''' + ' ) AS int)/128.0)/(sysfiles.size/128.0))
AS decimal(4,2))) AS varchar(8)) + ' + '''' + '%' + '''' + ' AS FreeSpacePct,
GETDATE() as PollDate FROM dbo.sysfiles'
INSERT INTO @DBInfo
(ServerName,
DatabaseName,
FileSizeMB,
LogicalFileName,
PhysicalFileName,
Status,
Updateability,
RecoveryMode,
FreeSpaceMB,
UsedSpaceMB,
FreeSpacePct,
PollDate)
EXEC sp_MSForEachDB @command

SELECT
--ServerName,
DatabaseName,
LogicalFileName,
RecoveryMode,
FileSizeMB,
UsedSpaceMB,
FreeSpaceMB,
FreeSpacePct,
PhysicalFileName,
Status
--Updateability,
--PollDate
FROM @DBInfo
--WHERE LogicalFileName NOT LIKE '%_log'
ORDER BY
ServerName,
DatabaseName

PRTG: DataCore Monitoring

DataCore stellt eine MIB Datei zur Verfügung, die man mittels dem Paessler MIB Importer V3 in PRTG implementieren kann. Den Download-Link und weitere Informationen findet man hier: http://www.datacore.com/SSV-Webhelp/SNMP_Support.htm
Nach dem MIB Import findet man den Sensor unter der SNMP-Bibliothek image_thumb[4]
  image_thumb[2]

image_thumb[7]
Je nach Anzahl der Volumes /CSV’s können sehr viele Sensoren implementiert werden.
Hierfür sollte der Abtastintervall erhöht werden um den PRTG Server nicht zu überlasten

Anschließend kann man folgendes überwachen:
  • ClientMachineStateMonitor (Monitors the state of hosts)
  • DiskPoolStateMonitor (Monitors the state of disk pools)
  • FallingThresholdPerfMonitor (Monitors the disk pools available space percentage)
  • LogicalDiskAccessRightsMonitor (Monitors the access rights of virtual disk sources)
  • LogicalDiskDataStatusMonitor (Monitors the data status of virtual disk sources)
  • LogicalDiskFailureMonitor (Monitors the failure status of virtual disk sources)
  • LogicalDiskStateMonitor (Monitors the state of virtual disk sources)
  • PhysicalDiskStateMonitor (Monitors the state of physical disks)
  • PoolMemberStateMonitor (Monitors the state of the relation between a pair of mirrored physical disks in a pool)
  • ReplicationNexusStateMonitor (Monitors the replication state of virtual disks)
  • RisingThresholdPerfMonitor (Monitors the disk pools latency)
  • ScsiPortConnectionStateMonitor (Monitors the connection state of SCSI ports)
  • ServerMachineLicenseMonitor (Monitors the license expiration date of DataCore Servers)
  • ServerMachinePowerStateMonitor (Monitors the battery power state for DataCore Servers)
  • ServerMSiScsiInitiatorStateMonitor (Monitors the state of MS iSCSI Initiator ports)
  • StreamLogicalDiskStateMonitor (Monitors the state of the data protection of virtual disk sources)
  • VirtualDiskAccessRightsMonitor (Monitors the access rights of virtual disks)
  • VirtualDiskDataStatusMonitor (Monitors the status of virtual disks)

Hinweiss:
Leider ist das auslesen des Füllstandes eines Volumes aktuell leider nicht möglich.

Microsoft Visio 2013: Neue Stencils

Die Standard Visio Shapes wurden von MS an das Modern UI Konzept angepasst:

DOWNLOAD

3TierConfig_New

Das Stencil muss einfach in den Ordner MyDocuments\My Shapes hinein kopieren. In Vision einfach auf More Shapes und dann My Shapes. Mit einen Klick auf FLEX_Stencil_121412 seht ihr die neuen Shapes.