Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.

Commit df07e87

Browse files
committed
Added the <MetricCleaning> section to the configuration file. Updated the Import-XMLConfig function to import the new configuration values. Updated Pester Tests to make sure the new values are loaded.
1 parent e67b86f commit df07e87

File tree

3 files changed

+89
-51
lines changed

3 files changed

+89
-51
lines changed

Functions/Internal.Tests.ps1

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Describe "Importing of XML Configuration File" {
1212
$Config | Should Not BeNullOrEmpty
1313
}
1414
It "Should Have 16 Properties" {
15-
$Config.Count | Should Be 16
15+
$Config.Count | Should Be 17
1616
}
1717
It "SendUsingUDP should be Boolean" {
1818
$Config.SendUsingUDP -is [Boolean] | Should Be $true
@@ -35,5 +35,8 @@ Describe "Importing of XML Configuration File" {
3535
It "MSSQLMetricTimeSpan should be TimeSpan" {
3636
$Config.MSSQLMetricTimeSpan -is [TimeSpan] | Should Be $true
3737
}
38+
It "MetricReplace should be HashTable" {
39+
$Config.MetricReplace -is [System.Collections.Specialized.OrderedDictionary] | Should Be $true
40+
}
3841
}
3942
}

Functions/Internal.ps1

+10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ Function Import-XMLConfig
7070
$Config.Counters += $counter.Name
7171
}
7272

73+
# Create the Metric Cleanup Hashtable
74+
$Config.MetricReplace = New-Object System.Collections.Specialized.OrderedDictionary
75+
76+
# Load metric cleanup config
77+
ForEach ($metricreplace in $xmlfile.Configuration.MetricCleaning.MetricReplace)
78+
{
79+
# Load each MetricReplace into an array
80+
$Config.MetricReplace.Add($metricreplace.This,$metricreplace.With)
81+
}
82+
7383
$Config.Filters = [string]::Empty;
7484
# Load each row from the configuration file into the counter array
7585
foreach ($MetricFilter in $xmlfile.Configuration.Filtering.MetricFilter)

StatsToGraphiteConfig.xml

+75-50
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,78 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Configuration>
3-
<Graphite>
4-
<CarbonServer>yourCarbonServerNameOrIP</CarbonServer>
5-
<CarbonServerPort>2003</CarbonServerPort>
6-
<MetricPath>datacenter1.servers</MetricPath>
7-
<NodeHostName>$env:COMPUTERNAME</NodeHostName>
8-
<MetricSendIntervalSeconds>5</MetricSendIntervalSeconds>
9-
<SendUsingUDP>False</SendUsingUDP>
10-
</Graphite>
11-
<PerformanceCounters>
12-
<Counter Name="\Network Interface(*)\Bytes Received/sec"/>
13-
<Counter Name="\Network Interface(*)\Bytes Sent/sec"/>
14-
<Counter Name="\Network Interface(*)\Packets Received Unicast/sec"/>
15-
<Counter Name="\Network Interface(*)\Packets Sent Unicast/sec"/>
16-
<Counter Name="\Network Interface(*)\Packets Received Non-Unicast/sec"/>
17-
<Counter Name="\Network Interface(*)\Packets Sent Non-Unicast/sec"/>
18-
<Counter Name="\Processor(_Total)\% Processor Time"/>
19-
<Counter Name="\Memory\Available MBytes"/>
20-
<Counter Name="\Memory\Pages/sec"/>
21-
<Counter Name="\Memory\Pages Input/sec"/>
22-
<Counter Name="\System\Processor Queue Length"/>
23-
<Counter Name="\System\Threads"/>
24-
<Counter Name="\PhysicalDisk(*)\Avg. Disk Write Queue Length"/>
25-
<Counter Name="\PhysicalDisk(*)\Avg. Disk Read Queue Length"/>
26-
</PerformanceCounters>
27-
<Filtering>
28-
<MetricFilter Name="isatap"/>
29-
<MetricFilter Name="teredo tunneling"/>
30-
</Filtering>
31-
<MSSQLMetics>
32-
<MetricPath>datacenter1.sqlmetrics</MetricPath>
33-
<MetricSendIntervalSeconds>60</MetricSendIntervalSeconds>
34-
<SQLConnectionTimeoutSeconds>5</SQLConnectionTimeoutSeconds>
35-
<SQLQueryTimeoutSeconds>5</SQLQueryTimeoutSeconds>
36-
<SQLServers>
37-
<!-- A SQL Server Connection Using SQL Authentication -->
38-
<SQLServer ServerInstance="(localdb)\v11.0" Username="sa" Password="PASSWORD1!">
39-
<Query Database="mydb" MetricName="mydb.userlist.rowcount" TSQL="select count(userListID) From [dbo].[userList]"/>
40-
<Query Database="mydb" MetricName="mydb.userlist.ukemails" TSQL="select count(userListID) From [dbo].[userList] Where Emails like '%.uk%'"/>
41-
</SQLServer>
42-
<!-- A SQL Server Connection Using Windows Authentication. The credentials from the running PowerShell session will be used. -->
43-
<SQLServer ServerInstance="MSSQLServer" Username="" Password="">
44-
<Query Database="citydb" MetricName="citydb.cities.navadwipkota" TSQL="Select COUNT (city) from [dbo].[cities] Where City = 'Navadwip' OR City = 'Kota'"/>
45-
<!-- An example query SQL query using a greater-than symbol. The symbol must be replaced with an XML Entity References. List here - http://msdn.microsoft.com/en-us/library/windows/desktop/dd892769%28v=vs.85%29.aspx -->
46-
<Query Database="addressbook" MetricName="people.ages.over30" TSQL="Select COUNT (personid) from [dbo].[tblAddressBook] Where Age &gt; 30"/>
47-
</SQLServer>
48-
</SQLServers>
49-
</MSSQLMetics>
50-
<Logging>
51-
<VerboseOutput>True</VerboseOutput>
52-
</Logging>
3+
<Graphite>
4+
<CarbonServer>yourCarbonServerNameOrIP</CarbonServer>
5+
<CarbonServerPort>2003</CarbonServerPort>
6+
<MetricPath>datacenter1.servers</MetricPath>
7+
<NodeHostName>$env:COMPUTERNAME</NodeHostName>
8+
<MetricSendIntervalSeconds>5</MetricSendIntervalSeconds>
9+
<SendUsingUDP>False</SendUsingUDP>
10+
</Graphite>
11+
<PerformanceCounters>
12+
<Counter Name="\Network Interface(*)\Bytes Received/sec"/>
13+
<Counter Name="\Network Interface(*)\Bytes Sent/sec"/>
14+
<Counter Name="\Network Interface(*)\Packets Received Unicast/sec"/>
15+
<Counter Name="\Network Interface(*)\Packets Sent Unicast/sec"/>
16+
<Counter Name="\Network Interface(*)\Packets Received Non-Unicast/sec"/>
17+
<Counter Name="\Network Interface(*)\Packets Sent Non-Unicast/sec"/>
18+
<Counter Name="\Processor(_Total)\% Processor Time"/>
19+
<Counter Name="\Memory\Available MBytes"/>
20+
<Counter Name="\Memory\Pages/sec"/>
21+
<Counter Name="\Memory\Pages Input/sec"/>
22+
<Counter Name="\System\Processor Queue Length"/>
23+
<Counter Name="\System\Threads"/>
24+
<Counter Name="\PhysicalDisk(*)\Avg. Disk Write Queue Length"/>
25+
<Counter Name="\PhysicalDisk(*)\Avg. Disk Read Queue Length"/>
26+
</PerformanceCounters>
27+
<MetricCleaning>
28+
<!-- These will be found and replaced in the order they appear here -->
29+
<MetricReplace This="physicaldisk\(.* (.*)\:\)" With="physicaldisk.#{CAPTUREGROUP}-drive"/>
30+
<MetricReplace This="^\\\\" With=""/>
31+
<MetricReplace This="\\\\" With=""/>
32+
<MetricReplace This="\/" With="-"/>
33+
<MetricReplace This=":" With="."/>
34+
<MetricReplace This="\\" With="."/>
35+
<MetricReplace This="\(" With="."/>
36+
<MetricReplace This="\)" With=""/>
37+
<MetricReplace This="\]" With=""/>
38+
<MetricReplace This="\[" With=""/>
39+
<MetricReplace This="\%" With=""/>
40+
<MetricReplace This="\s+" With=""/>
41+
<MetricReplace This="\.\." With="."/>
42+
<MetricReplace This="_" With=""/>
43+
<MetricReplace This="\#" With="num"/>
44+
<MetricReplace This="\.processor\." With=".cpu."/>
45+
<MetricReplace This="\.cpu\.total\.processortime" With=".cpu.usage"/>
46+
<MetricReplace This="\.networkinterface\." With=".nic."/>
47+
<MetricReplace This="\.physicaldisk\." With=".hdd."/>
48+
<MetricReplace This="\.intel[a-zA-Z0-9]+\." With=".intel."/>
49+
<MetricReplace This="\.realtek[a-zA-Z0-9]+\." With=".realtek."/>
50+
<MetricReplace This="\.memory\." With=".mem."/>
51+
</MetricCleaning>
52+
<Filtering>
53+
<MetricFilter Name="isatap"/>
54+
<MetricFilter Name="teredo tunneling"/>
55+
</Filtering>
56+
<MSSQLMetics>
57+
<MetricPath>datacenter1.sqlmetrics</MetricPath>
58+
<MetricSendIntervalSeconds>60</MetricSendIntervalSeconds>
59+
<SQLConnectionTimeoutSeconds>5</SQLConnectionTimeoutSeconds>
60+
<SQLQueryTimeoutSeconds>5</SQLQueryTimeoutSeconds>
61+
<SQLServers>
62+
<!-- A SQL Server Connection Using SQL Authentication -->
63+
<SQLServer ServerInstance="(localdb)\v11.0" Username="sa" Password="PASSWORD1!">
64+
<Query Database="mydb" MetricName="mydb.userlist.rowcount" TSQL="select count(userListID) From [dbo].[userList]"/>
65+
<Query Database="mydb" MetricName="mydb.userlist.ukemails" TSQL="select count(userListID) From [dbo].[userList] Where Emails like '%.uk%'"/>
66+
</SQLServer>
67+
<!-- A SQL Server Connection Using Windows Authentication. The credentials from the running PowerShell session will be used. -->
68+
<SQLServer ServerInstance="MSSQLServer" Username="" Password="">
69+
<Query Database="citydb" MetricName="citydb.cities.navadwipkota" TSQL="Select COUNT (city) from [dbo].[cities] Where City = 'Navadwip' OR City = 'Kota'"/>
70+
<!-- An example query SQL query using a greater-than symbol. The symbol must be replaced with an XML Entity References. List here - http://msdn.microsoft.com/en-us/library/windows/desktop/dd892769%28v=vs.85%29.aspx -->
71+
<Query Database="addressbook" MetricName="people.ages.over30" TSQL="Select COUNT (personid) from [dbo].[tblAddressBook] Where Age &gt; 30"/>
72+
</SQLServer>
73+
</SQLServers>
74+
</MSSQLMetics>
75+
<Logging>
76+
<VerboseOutput>True</VerboseOutput>
77+
</Logging>
5378
</Configuration>

0 commit comments

Comments
 (0)