sensu-plugins / sensu-plugins-windows

Sensu Windows Plugins
http://sensu-plugins.io
MIT License
22 stars 46 forks source link

metric-windows-network.ps1 - You cannot call a method on a null-valued expression #72

Closed csoleimani closed 4 years ago

csoleimani commented 5 years ago

Getting this error when running metric-windows-network.ps1:

You cannot call a method on a null-valued expression.At C:\opt\sensu\embedded\lib\ruby\gems\2.4.0\gems\sensu-plugins-windows-2.9.0\bin\powershell\metric-windows-network.ps1:53 char:7
csabo commented 5 years ago

@csoleimani it looks like you closed your PR, did you get your issue resolved?

samroy92 commented 5 years ago

I have the same issue as described above.

csoleimani commented 5 years ago

Whoops, I forgot to respond to this. I have not seen this issue for a while, but I'm not sure how we resolved it in our environment.

eike-spiller commented 4 years ago

Hi, still an issue over here.

c:\opt\sensu\embedded\bin\ruby C:\opt\sensu\embedded\bin\powershell_helper.rb windows-metric-network.ps1

does produce this.

c:\opt\sensu\embedded\bin\ruby C:\opt\sensu\embedded\bin\metric-windows-network.rb

does work. So ruby OK, powershell NOT. directly using powershell, like "powershell.exe -ExecutionPolicy ByPass -C metric-windows-network.ps1" has the same issue btw.

Other checks are ok. Would be nice if this will be resolved.

eike-spiller commented 4 years ago

Oh, got it. You have to submit the first param to that function.

In case you just want all network adapters and FQDN names, you can use my stripped down version:

This is working for me now. See attached file b.txt

maxadamo commented 4 years ago

@eike-spiller you have a line wrapped which doesn't seem to make a correct escape. Apart from this small issue, it works properly. Thanks