How to using metric-window-network

Hi all,

I would like to monitor network on client devices. I using samroy92/sensu-plugins-windows with metric-windows-network.ps1 to monitor network. But when I create check it and access portal sensu to check result it can not run and notice
You cannot call a method on a null-valued expression.
At C:\Users\son\Downloads\sensu-plugins-windows_3.0.3_windows_amd64\bin\metric-windows-network.ps1:53 char:7

  • if ($Interfaces.Contains($ObjNet.InstanceName))
  •   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull
      So how can I configure to run it


Windows isn’t my strong suit, but if i’m reading the code for the t powershell script correctly, it requires you to pass an interface name. If no interface is passed the Interfaces string array is empty resulting in the Contains function erroring out.

I tested this a little bit on an AWS EC2 instance, there are some other gotchas as well with the handling of spaces mixed with underscores in the interface names. But the error you are seeing is related to the need to pass an interface.

How you know what WIndows names its interfaces…that I’m not sure how to do off the top of my head, because like I said Windows Powershell isn’t an environment i know well.