KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Create import file of PerfMon counters

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Library
View previous topic :: View next topic  
Author Message
andrew_dc



Joined: 19 Aug 2010
Posts: 1

PostPosted: Thu Aug 19, 2010 1:39 pm    Post subject: Create import file of PerfMon counters Reply with quote

Have you ever created multiple perfmon counters for multiple servers?

While there are several ways to attack this problem, I put together this PowerShell script to create an import file.



Code:

# Create WMI Import.ps1
# Created by Andrew Rodriguez
# Email: andrew.mywork :at: gmail :dot: com
# Version: 0.1
# Created: 08/19/2010
# Last modification: 08/19/2010

# Notes:
#
# You'll want to do the following before using:
#  1. Modify $path where you save your script
#  2. Modify $destFolder as needed
#  3. Create the "raw_counters.txt" file
#  4. Modify $counters where you saved the previously mentioned file.
# Optionally:
#  5. You may want to modify "Interval =" and "Alerts ="

# Setup default variables
# -----------------------
$path = "C:\Dev\HostMonitor\"
$destFolder = "Root\"
$crlf = "`r`n"


$server = Read-Host "Enter a server name:"
$folder = Read-Host "Enter folder name (folder must exist!):"
$file = "$path$server$(get-date -f yyyy-MM-dd-hh-mm-ss).txt"


$counters = Get-Content "C:\Dev\HostMonitor\raw_counters.txt"
foreach ($counter in $counters)
    {
    $counter
    "Method      = PerfCounter" + $crlf | Out-File $file -Append -encoding UTF8
    ";--" + $server + " - " + $counter  + $crlf | Out-File $file -Append -encoding UTF8
    "DestFolder = " +$destFolder + $folder + "\"  + $crlf | Out-File $file -Append -encoding UTF8
    "Title       = PerfCounter: " + $counter.split("\")[-2,-1]  + $crlf | Out-File $file -Append -encoding UTF8
    "Comment     = PerfCounter: " + $counter  + $crlf | Out-File $file -Append -encoding UTF8
    "RelatedURL  = "  + $crlf | Out-File $file -Append -encoding UTF8
    "NamePattern = PerfCounter: %object%"  + $crlf | Out-File $file -Append -encoding UTF8
    "CmntPattern = PerfCounter: %path%"  + $crlf | Out-File $file -Append -encoding UTF8
    "ScheduleMode= Regular"  + $crlf | Out-File $file -Append -encoding UTF8
    "Schedule    = 7 Days, 24 Hours"  + $crlf | Out-File $file -Append -encoding UTF8
    "Interval    = 60"  + $crlf | Out-File $file -Append -encoding UTF8
    "Alerts      = Testing Alert"  + $crlf | Out-File $file -Append -encoding UTF8
    "ReverseAlert= No"  + $crlf | Out-File $file -Append -encoding UTF8
    "UnknownIsBad= Yes"  + $crlf | Out-File $file -Append -encoding UTF8
    "WarningIsBad= Yes"  + $crlf | Out-File $file -Append -encoding UTF8
    "UseCommonLog= Yes"  + $crlf | Out-File $file -Append -encoding UTF8
    "PrivLogMode = Default"  + $crlf | Out-File $file -Append -encoding UTF8
    "CommLogMode = Default"  + $crlf | Out-File $file -Append -encoding UTF8
    ";--- Test specific properties ---"  + $crlf | Out-File $file -Append -encoding UTF8
    "PerfCounter = \\" + $server + $counter  + $crlf | Out-File $file -Append -encoding UTF8
    "Condition   = "  + $crlf | Out-File $file -Append -encoding UTF8
    "Value       = "  + $crlf | Out-File $file -Append -encoding UTF8
    "DisplayMode = AsIs"  + $crlf | Out-File $file -Append -encoding UTF8
    ""  + $crlf | Out-File $file -Append -encoding UTF8
    ""  + $crlf | Out-File $file -Append -encoding UTF8
    }
   



Sample file for raw_counters.txt
Code:

\Cache\MDL Read Hits %
\Memory\% Committed Bytes In Use
\Memory\Available MBytes
\Memory\Page Reads/sec
\Memory\Pages/sec
\Memory\Pool Nonpaged Bytes
\Network Interface(*)\Bytes Received/sec
\Network Interface(*)\Bytes Sent/sec
\Network Interface(*)\Packets Outbound Discarded
\Network Interface(*)\Packets Received Discarded
\PhysicalDisk(*)\Avg. Disk Queue Length
\PhysicalDisk(*)\Avg. Disk sec/Transfer
\PhysicalDisk(*)\% Disk Time
\Processor(_Total)\% Interrupt Time
\Processor(_Total)\% Privileged Time
\Processor(_Total)\% Processor Time
\Processor(_Total)\% User Time
\System\Context Switches/sec
\System\Processor Queue Length
\System\System Up Time
\System\Threads
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Thu Aug 19, 2010 3:08 pm    Post subject: Reply with quote

Thank you

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index