External Parameter Help

Started by Rabid, April 11, 2013, 10:18:01 PM

Previous topic - Next topic

Rabid

I am trying to get a powershell script to run but I am receiving a communication error.  I have a folder on my test host called c:\scripts with two .ps1 files.  I have the following on the test host's config:

ExternalParameter = Testing:"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" "C:\Scripts\testing.ps1"
ExternalParameter = Testing2:"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" "C:\Scripts\testing2.ps1"


Testing returns a value but Testing2 produces a communication error.  I have ran testing2.ps1 on the local machine and it returns a value.  I have also ran the testing2.ps1 off of the machine hosting the netxms console.



testing2.ps1

$a = Get-Counter -Computername valandil -Counter "\Network Interface(my adapter goes here)\Bytes Total/sec" -sampleinterval 1 | ForEach-Object{$_.CounterSamples[0].CookedValue}
$b = Get-Counter -Computername valandil -Counter "\Network Interface(my second adapter goes here)\Bytes Total/sec" -sampleinterval 1 | ForEach-Object{$_.CounterSamples[0].CookedValue}

$ab = $a+$b
$ab = "{0:F0}" -f $ab
$ab



I have a need to take two perfmon counters and add them for a single value.  How can I fix the communication issue OR is there a way two add two counters together a different way?


Victor Kirhenshtein

Hi!

Most likely timeout for agent command is too small (by default it's two seconds, so reading two perf counters with 1 second interval between samples for each will not fit). There was few discussions about agent timeout intervals on the forum. In short summary, two timeouts should be set correctly:

a) ExecTimeout on agent - timeout for executing external program
b) AgentCommandTimeout on server - timeout for any command sent from server to client

In general AgentCommandTimeout must be greater or equal to ExecTimeout.

Best regards,
Victor

Rabid

Thanks, this worked perfectly.