Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Server System Report


SQL Server System Report

Author
Message
Joe Zonum
Joe Zonum
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 438
To Sean Smith,
Reg: usp_SQL_Server_System_Report

First off, Thank you for this script. It has made my life a lot easier.

I was woundering if you would be able to modify the script to use mounting points for the disk drive info? I am not the greatest tSql developer and I have had the hardest time trying to modify your script. I have tried to modify it using the following code as a starting point.


declare @svrName varchar(255)
declare @sql varchar(400)
--by default it will take the current server name, we can the set the server name as well
set @svrName = @@SERVERNAME
set @sql = 'powershell.exe -c "Get-WmiObject -ComputerName ' + QUOTENAME(@svrName,'''') + ' -Class Win32_Volume -Filter ''DriveType = 3'' | select name,capacity,freespace | foreach{$_.name+''|''+$_.capacity/1048576+''%''+$_.freespace/1048576+''*''}"'
--creating a temporary table
CREATE TABLE #output
(line varchar(255))
--inserting disk name, total space and free space value in to temporary table
insert #output
EXEC xp_cmdshell @sql
--script to retrieve the values in MB from PS Script output
select rtrim(ltrim(SUBSTRING(line,1,CHARINDEX('|',line) -1))) as drivename
,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1,
(CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float),0) as 'capacity(MB)'
,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1,
(CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float),0) as 'freespace(MB)'
from #output
where line like '[A-Z][:]%'
order by drivename
--script to retrieve the values in GB from PS Script output
select rtrim(ltrim(SUBSTRING(line,1,CHARINDEX('|',line) -1))) as drivename
,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('|',line)+1,
(CHARINDEX('%',line) -1)-CHARINDEX('|',line)) )) as Float)/1024,0) as 'capacity(GB)'
,round(cast(rtrim(ltrim(SUBSTRING(line,CHARINDEX('%',line)+1,
(CHARINDEX('*',line) -1)-CHARINDEX('%',line)) )) as Float) /1024 ,0)as 'freespace(GB)'
from #output
where line like '[A-Z][:]%'
order by drivename
--script to drop the temporary table
drop table #output


Please let me if this is something you can work on.

JM
Sean Smith-776614
Sean Smith-776614
SSC-Addicted
SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)

Group: General Forum Members
Points: 431 Visits: 943
Hi there.

I am glad that the script has helped you out (I actually have plans for expanding it soon-ish).

Unfortunately, I know nothing about PowerShell, so I won't be able to help you out. Sad Have you tried posting this question on other forums to see if an expert can assist you?
Joe Zonum
Joe Zonum
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 438
No, I have not asked. I am new to powershell as well. I am in no rush.
Sean Smith-776614
Sean Smith-776614
SSC-Addicted
SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)

Group: General Forum Members
Points: 431 Visits: 943
Okay. Best suggestion then is to try some PowerShell user groups / sites. If you find the answer feel free to share it. Smile
rob.patterson-1085747
rob.patterson-1085747
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 78
This is a great script, thanks for sharing it. I made a few little tweaks that others might find useful.

---I made @vRecipients a parameter that can be passed at the time of execution:

CREATE PROCEDURE [dbo].[usp_SQL_Server_System_Report]

@v_Output_Mode CHAR (1) = NULL
,@vUnused_Index_Days INT = 7
,@vRecipients AS NVARCHAR(128) = NULL

AS

.....

---and then commented out the declaration for it
DECLARE @vOnline_Since AS NVARCHAR (19)
-- DECLARE @vRecipients AS VARCHAR (MAX)
DECLARE @vSQL_String AS NVARCHAR (MAX)

.....

---also, I modified the part where the email is sent, so if there are multiple email profiles and/or no default mail profile, it will still work.
IF @v_Output_Mode = 'E'
BEGIN
DECLARE @profname sysname

SELECT @profname = name
FROM msdb.dbo.sysmail_profile
WHERE profile_id in (SELECT min(profile_id) FROM msdb.dbo.sysmail_profile)

EXECUTE [msdb].[dbo].[sp_send_dbmail]

@profile_name = @profname
,@recipients = @vRecipients
,@copy_recipients = @vCopy_Recipients
,@subject = @vSubject
,@body = @vBody
,@body_format = 'HTML'

END



The changes I made allow the report to be sent to anyone on the dba team.

Hope these mods are helpful to others.
Joe Zonum
Joe Zonum
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 438
Can you post the entire code vs. bit and pieces?

Thank you
rob.patterson-1085747
rob.patterson-1085747
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 78
Sure Juan, please see attached.
Attachments
SQL_Server_Report.txt (16 views, 36.00 KB)
Sean Smith-776614
Sean Smith-776614
SSC-Addicted
SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)

Group: General Forum Members
Points: 431 Visits: 943
This is fantastic! Thanks for sharing. I am actually in the process of updating / adding to the code. Would you mind if I integrate your additions (officially) to it?
Joe Zonum
Joe Zonum
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 438
If you could update the Drive space code with the MP code listed in an earlier post.
That would be great.

JM
SQL_Padre
SQL_Padre
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 562
I would actually like to see the option to have this information saved to a AdminDB table.

SQL Padre
aka Robert M Bishop

"Do or do not, there is no try" -- Yoda
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search