Getting timed out and flush interval error

For vmware metrics, using 9 powershell scripts with powercli modules to pull metrics.
powershell scripts to read vmware status for (host, cluster, datastore, switch, network ports, storage adaptor ) percentage for ( mem overcommit, network usage) and events counts for reconfigure cluster events.

If i execute one by one in telegraf using exec plugin, i can get the outputs from command prompt and from services.
But i execute all KPI’s in telegraf, getting below errors. Please some one take a look and provide the solution for these. Thanks in advance.

telegraf conf:

interval = “300s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
logtarget = “file”
logfile = “C:/temp/output.txt”
logfile_rotation_max_size = “10MB”
logfile_rotation_max_archives = 2
hostname =“xxx”

To get Host Status:
commands = [ 'powershell -command “Connect-VIServer -Server “xxx” -User “xxx” -Password “xxx” | Out-Null; foreach ($vmh in Get-VMHost) { $hostname=$($vmh.Name); $state=$($vmh.ConnectionState); Write-Host vmhost_name=”$hostname" host_state="$state" } ; Disconnect-VIServer -Confirm:$false " ']
timeout = “60s”
data_format = “logfmt”
name_override = “vcenter_host”
namepass = [“vcenter_host”]
tag = [“vmhost_name”]

C:\Program Files\Telegraf\bin>telegraf.exe --test --config …\conf\123.conf
2022-01-21T09:27:01Z I! Starting Telegraf 1.18.0

ame=xxx host_state=“Connected” 1642757231000

Major error:
2022-01-21T08:16:12Z E! [inputs.exec] Error in plugin: exec: command timed out for command 'powershell -command "

also received other 2 errors:
2022-01-21T07:16:02Z E! [agent] Error killing process: TerminateProcess: Access is denied.
2022-01-21T07:30:38Z W! [agent] [“outputs.kafka”] did not complete within its flush interval

Please check and let me know how to fix this issues.

E! [inputs.exec] Error in plugin: exec: command timed out for command 'powershell -command "

This means that the command got no answer after timeout = “60s”, for how it’s logged there might be some other problems, I’d try to remove the first and last " (the ones wrapping the command)

E! [agent] Error killing process: TerminateProcess: Access is denied

I think it has been raised by the exec plugin, and therefore it has to be the cmd/PowerShell process, as the error states Access is denied it’s permission-related and depends on the user that’s running Telegraf. (it should be easy enough to replicate it)

W! [agent] [“outputs.kafka”] did not complete within its flush interval

The data were not written to the destination in time, meaning before another “interval” triggered interval = “300s”. it means that after gathering ALL the input data, it was unable to write them to the output system… as a sample, with an interval = “30s”, if it takes 10s to fetch all the data, then the remaining 20s are the available time for writing to the output.
The data will remain in the buffer and will be sent in the next cycle

if you want to test the whole pipeline run:
C:\Program Files\Telegraf\bin>telegraf.exe --once --config …\conf\123.conf
the --test flag omits the output section

Hello Giovanni_Luisotto,
Thanks for update and clarifications.
I changed the below values and got the outputs from telegraf without any errors.
timeout = “120s”
flush_interval = “30s”.