Hi,
I have a PowerShell script that returns an output for Hyper-V cluster shared volumes. It outputs the below in PS from a Hyper-V host.
HypervCSV UsedSpace(GB)=“9,729.60”,FreeSpace(GB)=“6,654.38”,PercentFree=“40.62”,Size(GB)=“16,383.98”
HypervCSV UsedSpace(GB)=“9,858.69”,FreeSpace(GB)=“6,525.29”,PercentFree=“39.83”,Size(GB)=“16,383.98”
HypervCSV UsedSpace(GB)=“12,553.78”,FreeSpace(GB)=“3,830.20”,PercentFree=“23.38”,Size(GB)="16,383.98
I have then setup Inputs Exec to run the script and send to InfluxDB. The issue I am having is I cannot get the details about the space used, free and percent to show in Data explorer.
Any help would be appreciated, below is telegraf setup and the PS script.
[[inputs.exec]]
interval = "120s"
## Commands array
commands = ['powershell "C:\\telegraf\\HVCsv.ps1"']
## Environment variables
## Array of "key=value" pairs to pass as environment variables
## e.g. "KEY=value", "USERNAME=John Doe",
## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs"
# environment = []
## Timeout for each command to complete.
timeout = "2m"
## measurement name suffix (for separating different commands)
#name_suffix = "_mycollector"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
param(
[String[]] $ClusterSharedVolume = [Environment]::SharedVolumeInfo
)
$HypervCSV = Get-ClusterSharedVolume | Select-Object -Expand SharedVolumeInfo | Select-Object -Expand Partition `
$Server = @{label="Server";expression={$_.SystemName}}
$Size = @{ Label = "Size(GB)" ; Expression = { "{0:N2}" -f ($_.Size/1024/1024/1024) } }
$FreeSpace = @{ Label = "FreeSpace(GB)" ; Expression = { "{0:N2}" ` -f ($_.FreeSpace/1024/1024/1024) } }
$UsedSpace = @{ Label= "UsedSpace(GB)" ; Expression = { "{0:N2}" ` -f ($_.UsedSpace/1024/1024/1024) } }
$PercentFree = @{ Label = "PercentFree" ; Expression = { "{0:N2}" -f ($_.PercentFree) } }
$Measurement = "HypervCSV"
$TagList = "Server"
$MetricList = "Size(GB)","UsedSpace(GB)","FreeSpace(GB)","PercentFree"
$HypervCSV | Select-Object $Server,$Size,$UsedSpace,$FreeSpace,$PercentFree | ConvertTo-Metric -Measure $Measurement -MetricProperty $MetricList -TagProperty $TagList | ConvertTo-InfluxLineString -WarningAction SilentlyContinue