Monitoring Server Resources
This document explains how to move data collector set information
in a SharePoint library.
Setting Up the
SharePoint Document Library
A document library needs to be created in SharePoint that’s
email enabled. A scheduled task running a PowerShell script from the sever,
will email the results from the data collector set to this library.
1.
In SharePoint create a document library where
the data collector set information will be stored.
2.
In the settings of the document library, under
communications, select Incoming email settings.
3.
Select the yes radio button for “Allow this
document library to receive email.” Enter an email address the PowerShell
script will use to email the Data collect information. Hit OK when finished.
Creating a Custom Data Collector Set
The first thing that needs to be completed is the creation
of a Custom Data Collector Set. These instructions are going to use a
predefined template that comes with Windows.
1.
In Server Manager, right click on User Defined
and select New, Data Collector Set.
2.
Give the data collector set a name and select
the Create from a template radio button. Then click next.
3.
Choose the System Performance template and
select next.
4.
Choose where you want the Data Collector Set to
be saved. The default location will work, but in the one I did, I change the
final folder in the path to the server name. Click next when you got it.
5.
Click Finish
6.
Under User Defined, right click on the new Data
Collector Set and select properties.
7.
Select the directory tab. In the subdirectory
field, enter a name for the subdirectory. This name should be something simple,
as it will be used in a PowerShell script later. Remove all entries from the
Subdirectory name format field, and uncheck the “Prefix subdirectory with
Computer name” checkbox. When it is complete it should look something
like this.
8.
Select the Schedule tab and add a time to
collect the data. This should be a time that the server is used the most.
9.
On the Stop Condition tab, under Overall
Duration, set how long you want the data collector set to run. The longer it
runs the better the report, and the bigger the file that is created. A 10
minute run it the testing I did created about 1.5mb file.
The PowerShell Script
This PowerShell script emails the data collector set report
to the SharePoint document library and then deletes it from the server. I’m
sure this script can be improved but it does work.
$SMTPServer
= "mailrelay.yourplace.com"
#SMTP Server
$emailto =
"SPPerformance@sharePoint.vbgov.com" #The email address assigned to
the SharePoint list$emailFrom = “yourname@yourplace.com” #Who the email is from. This person should have write #access to the SharePoint list
$subject =
"Server Report"
$body =
"Server Report"$Server = "ServerName"
$datetime = get-date -f MMddyyyy #Gets the date that will be part of the new file name.
$file = ($server + "_" + $Datetime + ".htm") #Creates a variable that will be used for the filename.
$attach = "C:\PerfLogs\Admin\ServerName-SP_WFE1\Report\$file" #Make sure the path matches #what is setup in the data collector set.
CD "C:\PerfLogs\Admin\vbas0120-SP_WFE1\Report"
#Renames the
report.html file to ServerName_Date.html
rename-item
report.html -newname ($server + "_" + $Datetime + ".html")
#Emails the ServerName_Date.html file to the
SharePoint library.
Send-MailMessage
-To $emailto -From $emailfrom -subject $subject -Body $Body -attachments
$attach -smtpserver $smtpserver remove-item report –recurse
Creating the
Scheduled Task
1.
Right click on the Task Scheduler library and
select create task.
2.
Setup the General tab as follows. Make sure the
task runs under an account that has access to server.
3.
Setup a trigger when the task will run. Make
sure it is after the data collector set is created.
4.
Set the actions to run the PowerShell Script
5.
That’s all that is required, now test, test,
test.








No comments:
Post a Comment