I am planning to use InfluxDB/Grafana/telegraf to monitor some metrics of multiple win10 hosts and have managed to set everything up with default settings. I have downloaded a premade dashboard to grafana that shows alot of info from one of the hosts running a telegraf-service.
But now I need to add some info from that host using a powershell-script.
I have three questions:
1: How I should format and post the data
2: How do I associate the data with the current hostname?
3: How do I then access the data from grafana so that I can add it to a graph
This is what I have:
I add this to the telegraf config:
[[inputs.exec]]
interval = "60s"
commands = [
'powershell -File "C:\Program Files\Telegraf\getNetworkadapterInfo.ps1"'
timeout = "2m"
data_format = "influx"
This is the powershell-script I need to run, the write-hosts command shows the info I need but I don’t know how I should add this to the body of the post:
$interfaces = Get-NetAdapter | Select-Object "InterfaceDescription", "Status", "LinkSpeed"
foreach ($interface in $interfaces)
{
write-host "interface=$($interface.InterfaceDescription), status=$($interface.Status), linkspeed=$($interface.LinkSpeed)"
Invoke-RestMethod -Uri "http://<InfluxDb>:8086/write?db=database&u=username&p=passwrd" -body $body -Method POST
}