【问题标题】:How to execute metricbeat while using subprocess.Popen()如何在使用 subprocess.Popen() 时执行 metricbeat
【发布时间】:2019-02-01 12:21:14
【问题描述】:

我正在尝试执行 metricebeat,其方式与从 Windows 命令行执行的方式相同,但在 python 脚本中使用 subprocess.Popen。

   subprocess.Popen(["C:\metricbeat\metricbeat.exe"])

尽管我执行具有相同实现的其他进程并且它们工作并且不会终止,但该进程会立即启动和终止。

    self.process.poll()
        if self.process.returncode is not None:
            self.Shutdown()

这是我的终止条件,它总是正确的,这就是它终止的原因。

有没有办法将metricebeat作为后台进程执行?或者我可以尝试什么想法

【问题讨论】:

    标签: python elastic-stack elastic-beats


    【解决方案1】:

    你应该使用:

    os.popen("Powershell.exe", 'C:\metricbeat\metricbeat -e -c C:\metricbeat\metricbeat.yml', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-15
      • 2011-10-13
      • 2019-11-08
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 1970-01-01
      • 2011-03-09
      相关资源
      最近更新 更多