代码之家  ›  专栏  ›  技术社区  ›  Anto

数据狗代理检查找不到指定的路径

  •  0
  • Anto  · 技术社区  · 7 年前

    我已经按照本页的说明在Python中编写了一个Datadog代理签入: https://docs.datadoghq.com/developers/agent_checks/ .

    要读取的文件夹在Yaml文件中指定如下:

    init_config:
    taskResultLocation: "Z:/TaskResults"
    

    task_result_location = self.init_config.get('taskResultLocation')
    # Loop through all the XML files in the specified folder
    for file in os.listdir(task_result_location):
    

    如果我在IDE中运行Python脚本,一切都会正常工作。 将检查添加到IDE所在的同一台计算机上的Datadog代理管理器并运行检查时,Datadog代理管理器日志中会抛出一个错误,说明:

    2018-08-14 14:33:26 EEST | ERROR |(runner.go:277 in work)| ERROR running check taskresultorreader:[{“message”:“[ERROR 3]系统找不到指定的路径:'Z:/TaskResults/ “,”traceback“:”traceback(最近一次调用):\n File\”C:“Program Files\Datadog\Datadog Agent\embedded\lib\site packages\Datadog\checks\base.py\”,第294行,运行中的self.check(copy.deepcopy(self.instances[0]))\n File\”C:“programdata\Datadog\checks.d\taskResultOrReader.py\”,第42行,在os.listdir中检查文件(任务结果位置):\nWindows错误:[Error 3]系统找不到指定的路径:“Z:/tasksresults”/ . '\n“}]

    我试过用单引号和双引号、正斜杠和反斜杠以及双斜杠以多种方式指定文件夹位置,但也会抛出同样的错误。

    2 回复  |  直到 7 年前
        1
  •  0
  •   NotSoShabby    7 年前

    即使datadog是从同一台机器上运行的,它也在您的机器上设置一个单独的服务器。因此,听起来datadog代理无法访问z:/驱动程序。

    尝试将“tasksresults”文件夹放在根目录中(从datadog运行时,mycheck.yaml文件在其中),并相应地更改路径。

    documentation

        2
  •  0
  •   Anto    7 年前

    解决方法是在网络驱动器上创建文件共享,并使用该路径而不是完整的网络驱动器路径。

    init_config:
    taskResultLocation: "Z:/TaskResults"
    

    使用

    init_config:
    taskResultLocation: '//FileShareName/d/TaskResults'