Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

386fix #4076

Closed
wants to merge 9 commits into from
39 changes: 39 additions & 0 deletions plugins/inputs/win_perf_counters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ It is recommended NOT to use this on OSes starting with Vista and newer because
Example for Windows Server 2003, this would be set to true:
`PreVistaSupport=true`

#### UsePerfCounterTime

Bool, if set to `true` will request a timestamp along with the PerfCounter data.

Note: This call may not be supported on all versions of windows. If you receive an error, set this value to false to disable the feature, and searching for this call entirely.

### Object

See Entry below.
Expand All @@ -50,6 +56,16 @@ beneath the main win_perf_counters entry, `[[inputs.win_perf_counters]]`.

Following this is 3 required key/value pairs and the three optional parameters and their usage.

#### Computer
**Optional**

Computer specifies the computer to connect to for querying the performance counters. While "localhost" will work to retrieve data from a local host, it is recommended
to use the actual machine name as the data will be tagged with a "Node" tag with the value of this parameter as the value.

Important: If you are requesting data from a remote node you must do the following:
1. Log into that node and ensure the user telegraf is running under is added to the "Performance Monitor Users" group.
2. Change the user telegraf is running under to be running as that user. You can use the account "NT AUTHORITY\NETWORK_SERVICE

#### ObjectName
**Required**

Expand Down Expand Up @@ -128,6 +144,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# Processor usage, alternative to native, reports on a per core.
Computer = "localhost"
ObjectName = "Processor"
Instances = ["*"]
Counters = ["% Idle Time", "% Interrupt Time", "% Privileged Time", "% User Time", "% Processor Time"]
Expand All @@ -136,13 +153,15 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# Disk times and queues
Computer = "localhost"
ObjectName = "LogicalDisk"
Instances = ["*"]
Counters = ["% Idle Time", "% Disk Time","% Disk Read Time", "% Disk Write Time", "% User Time", "Current Disk Queue Length"]
Measurement = "win_disk"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).

[[inputs.win_perf_counters.object]]
Computer = "localhost"
ObjectName = "System"
Counters = ["Context Switches/sec","System Calls/sec", "Processor Queue Length"]
Instances = ["------"]
Expand All @@ -151,6 +170,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# Example query where the Instance portion must be removed to get data back, such as from the Memory object.
Computer = "localhost"
ObjectName = "Memory"
Counters = ["Available Bytes","Cache Faults/sec","Demand Zero Faults/sec","Page Faults/sec","Pages/sec","Transition Faults/sec","Pool Nonpaged Bytes","Pool Paged Bytes"]
Instances = ["------"] # Use 6 x - to remove the Instance bit from the query.
Expand All @@ -160,6 +180,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
[[inputs.win_perf_counters.object]]
# more counters for the Network Interface Object can be found at
# https://msdn.microsoft.com/en-us/library/ms803962.aspx
Computer = "localhost"
ObjectName = "Network Interface"
Counters = ["Bytes Received/sec","Bytes Sent/sec","Packets Received/sec","Packets Sent/sec"]
Instances = ["*"] # Use 6 x - to remove the Instance bit from the query.
Expand All @@ -170,6 +191,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
### Active Directory Domain Controller
```
[[inputs.win_perf_counters.object]]
Computer = "localhost"
ObjectName = "DirectoryServices"
Instances = ["*"]
Counters = ["Base Searches/sec","Database adds/sec","Database deletes/sec","Database modifys/sec","Database recycles/sec","LDAP Client Sessions","LDAP Searches/sec","LDAP Writes/sec"]
Expand All @@ -178,13 +200,15 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).

[[inputs.win_perf_counters.object]]
Computer = "localhost"
ObjectName = "Security System-Wide Statistics"
Instances = ["*"]
Counters = ["NTLM Authentications","Kerberos Authentications","Digest Authentications"]
Measurement = "win_ad"
#IncludeTotal=false #Set to true to include _Total instance when querying for all (*).

[[inputs.win_perf_counters.object]]
Computer = "localhost"
ObjectName = "Database"
Instances = ["*"]
Counters = ["Database Cache % Hit","Database Cache Page Fault Stalls/sec","Database Cache Page Faults/sec","Database Cache Size"]
Expand All @@ -196,6 +220,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
```
[[inputs.win_perf_counters.object]]
# AD, DFS N, Useful if the server hosts a DFS Namespace or is a Domain Controller
Computer = "localhost"
ObjectName = "DFS Namespace Service Referrals"
Instances = ["*"]
Counters = ["Requests Processed","Requests Failed","Avg. Response Time"]
Expand All @@ -209,6 +234,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
```
[[inputs.win_perf_counters.object]]
# AD, DFS R, Useful if the server hosts a DFS Replication folder or is a Domain Controller
Computer = "localhost"
ObjectName = "DFS Replication Service Volumes"
Instances = ["*"]
Counters = ["Data Lookups","Database Commits"]
Expand All @@ -221,6 +247,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
### DNS Server + Domain Controllers
```
[[inputs.win_perf_counters.object]]
Computer = "localhost"
ObjectName = "DNS"
Counters = ["Dynamic Update Received","Dynamic Update Rejected","Recursive Queries","Recursive Queries Failure","Secure Update Failure","Secure Update Received","TCP Query Received","TCP Response Sent","UDP Query Received","UDP Response Sent","Total Query Received","Total Response Sent"]
Instances = ["------"]
Expand All @@ -232,6 +259,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
```
[[inputs.win_perf_counters.object]]
# HTTP Service request queues in the Kernel before being handed over to User Mode.
Computer = "localhost"
ObjectName = "HTTP Service Request Queues"
Instances = ["*"]
Counters = ["CurrentQueueSize","RejectedRequests"]
Expand All @@ -240,6 +268,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# IIS, ASP.NET Applications
Computer = "localhost"
ObjectName = "ASP.NET Applications"
Counters = ["Cache Total Entries","Cache Total Hit Ratio","Cache Total Turnover Rate","Output Cache Entries","Output Cache Hits","Output Cache Hit Ratio","Output Cache Turnover Rate","Compilations Total","Errors Total/Sec","Pipeline Instance Count","Requests Executing","Requests in Application Queue","Requests/Sec"]
Instances = ["*"]
Expand All @@ -248,6 +277,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# IIS, ASP.NET
Computer = "localhost"
ObjectName = "ASP.NET"
Counters = ["Application Restarts","Request Wait Time","Requests Current","Requests Queued","Requests Rejected"]
Instances = ["*"]
Expand All @@ -256,6 +286,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# IIS, Web Service
Computer = "localhost"
ObjectName = "Web Service"
Counters = ["Get Requests/sec","Post Requests/sec","Connection Attempts/sec","Current Connections","ISAPI Extension Requests/sec"]
Instances = ["*"]
Expand All @@ -264,6 +295,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# Web Service Cache / IIS
Computer = "localhost"
ObjectName = "Web Service Cache"
Counters = ["URI Cache Hits %","Kernel: URI Cache Hits %","File Cache Hits %"]
Instances = ["*"]
Expand All @@ -276,6 +308,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
```
[[inputs.win_perf_counters.object]]
# Process metrics, in this case for IIS only
Computer = "localhost"
ObjectName = "Process"
Counters = ["% Processor Time","Handle Count","Private Bytes","Thread Count","Virtual Bytes","Working Set"]
Instances = ["w3wp"]
Expand All @@ -288,6 +321,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.
```
[[inputs.win_perf_counters.object]]
# .NET CLR Exceptions, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR Exceptions"
Counters = ["# of Exceps Thrown / sec"]
Instances = ["w3wp"]
Expand All @@ -296,6 +330,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# .NET CLR Jit, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR Jit"
Counters = ["% Time in Jit","IL Bytes Jitted / sec"]
Instances = ["w3wp"]
Expand All @@ -304,6 +339,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# .NET CLR Loading, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR Loading"
Counters = ["% Time Loading"]
Instances = ["w3wp"]
Expand All @@ -312,6 +348,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# .NET CLR LocksAndThreads, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR LocksAndThreads"
Counters = ["# of current logical Threads","# of current physical Threads","# of current recognized threads","# of total recognized threads","Queue Length / sec","Total # of Contentions","Current Queue Length"]
Instances = ["w3wp"]
Expand All @@ -320,6 +357,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# .NET CLR Memory, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR Memory"
Counters = ["% Time in GC","# Bytes in all Heaps","# Gen 0 Collections","# Gen 1 Collections","# Gen 2 Collections","# Induced GC","Allocated Bytes/sec","Finalization Survivors","Gen 0 heap size","Gen 1 heap size","Gen 2 heap size","Large Object Heap size","# of Pinned Objects"]
Instances = ["w3wp"]
Expand All @@ -328,6 +366,7 @@ if any of the combinations of ObjectName/Instances/Counters are invalid.

[[inputs.win_perf_counters.object]]
# .NET CLR Security, in this case for IIS only
Computer = "localhost"
ObjectName = ".NET CLR Security"
Counters = ["% Time in RT checks","Stack Walk Depth","Total Runtime Checks"]
Instances = ["w3wp"]
Expand Down
73 changes: 73 additions & 0 deletions plugins/inputs/win_perf_counters/kernel32.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2010 The win Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// This is the official list of 'win' authors for copyright purposes.
//
// Alexander Neumann <an2048@googlemail.com>
// Joseph Watson <jtwatson@linux-consulting.us>
// Kevin Pors <krpors@gmail.com>

// +build windows

package win_perf_counters

import (
"syscall"
)

type SYSTEMTIME struct {
wYear uint16
wMonth uint16
wDayOfWeek uint16
wDay uint16
wHour uint16
wMinute uint16
wSecond uint16
wMilliseconds uint16
}

type FILETIME struct {
dwLowDateTime uint32
dwHighDateTime uint32
}

var (
// Library
libkrnDll *syscall.DLL

// Functions
krn_FileTimeToSystemTime *syscall.Proc
krn_FileTimeToLocalFileTime *syscall.Proc
krn_LocalFileTimeToFileTime *syscall.Proc
krn_WideCharToMultiByte *syscall.Proc
)

func init() {
libkrnDll = syscall.MustLoadDLL("Kernel32.dll")

krn_FileTimeToSystemTime = libkrnDll.MustFindProc("FileTimeToSystemTime")
krn_FileTimeToLocalFileTime = libkrnDll.MustFindProc("FileTimeToLocalFileTime")
krn_LocalFileTimeToFileTime = libkrnDll.MustFindProc("LocalFileTimeToFileTime")
krn_WideCharToMultiByte = libkrnDll.MustFindProc("WideCharToMultiByte")
}
Loading