The database size can be obtained with system stored procedure sp_helpdb that is included in SQL 2008 and 2005 (not sure about 2000). We cannot use this stored procedure directly with PRTG as it returns to many rows and fields, so here is what we have to do:
Step 1
Create a new stored procedure using the following code
CREATE PROCEDURE [dbo].[spSpaceUsed]
@name nvarchar(24)
AS
BEGIN
SET NOCOUNT ON
-- Create a tempory table
DECLARE @SpaceUsed TABLE
(
name nvarchar(24),
db_size nvarchar(13),
owner nvarchar(24),
dbid smallint,
created char(11),
status varchar(340),
compatibility_level tinyint
)
--Populate the table
INSERT INTO @SpaceUsed EXEC sp_helpdb
--Select the size of the specified table
SELECT
CONVERT (DECIMAL, REPLACE (db_size, 'MB', ''))
AS [size]
FROM @SpaceUsed
WHERE name = @name
END
Step 2
Add a new MSQL sensor
On your PRTG server, add a new MSQL sensor. Fill in the required fields and in the "SQL Expression" field enter
exec dbo.spSpaceUsed YOUR_DATABASE_NAME
In the channels tab select the value channel and enter MB as unit.
Add comment