Skip to content

Instantly share code, notes, and snippets.

@rudibroekhuizen
Created February 13, 2015 09:22
Show Gist options
  • Save rudibroekhuizen/fea8b99fb689903b1d36 to your computer and use it in GitHub Desktop.
Save rudibroekhuizen/fea8b99fb689903b1d36 to your computer and use it in GitHub Desktop.
Logstash WMI input
# Author: rudi.broekhuizen@naturalis.nl
#
# C:/Temp/metrics.ps1:
# Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DeviceID -eq "C:" } | Select-Object SystemName, Caption, FreeSpace | convertto-json -Compress | Out-File -Append -NoClobber "C:/Temp/metrics.json" -encoding utf8
# Get-WmiObject Win32_OperatingSystem | convertto-json -Depth 1 -Compress | Out-File -Append -NoClobber "C:/Temp/metrics.json" -encoding utf8
# Get-WmiObject Win32_PerfFormattedData_PerfOS_System | convertto-json -Depth 1 -Compress | Out-File -Append -NoClobber "C:/Temp/metrics.json" -encoding utf8
#
input {
exec {
command => "@powershell -NoProfile -ExecutionPolicy unrestricted -File C:/Temp/metrics.ps1"
interval => 60
}
file {
path => "C:/Temp/metrics.json"
codec => json
tags => [ "logstash-win-base-20" ]
}
}
output {
elasticsearch {
cluster => "cluster-02"
}
}
@rudibroekhuizen
Copy link
Author

You need PowerShell version 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment