如何通过 Azure linux (ubuntu) DSC 框为 bash 脚本 运行 启用完整的标准输出日志

How to enable full standard output log for bash scripts run by Azure linux (ubuntu) DSC box

我们正在使用 linux 的 DSC 在 linux 个 Azure VM 上部署 Elasticsearch。 目前调试 DSC 配置是一个巨大的挑战,因为 DSC 构建的周转时间很长(几分钟)/运行 并且接近 OMI 服务生成的无用日志:dsc.log 该文件包含大量 "noise" 和非常有限的命令有用输出。 IE。如果脚本配置步骤失败,它只会声明: "A general error occurred, not covered by a more specific error code.. The related ResourceId is [nxScript]/somename/"

另一方面,根据OMI logging and debugging

The logging level for the omiserver.log log file cannot be changed from the default in this version of the Operations Manager Agents for UNIX and Linux.

从 DSC 运行 shell 脚本记录所有标准输出的最佳方式是什么?

到目前为止,我们设法从 OMI 服务器获取完整日志的唯一方法是通过更改 /init.d/omid 文件的守护程序启动命令行,例如:

$CREATE_LINKS && start-stop-daemon --start --quiet --pidfile $PIDFILE --name "omid" --startas $OMI_BIN -- --configfile=/etc/opt/omi/conf/omiserver.conf -d

$CREATE_LINKS && start-stop-daemon --start --quiet --pidfile $PIDFILE --name "omid" --startas /bin/bash --background -- -c "exec $OMI_BIN --configfile=/etc/opt/omi/conf/omiserver.conf > /var/log/omiserver.log 2>&1"

请注意:此解决方法仅作为调试解决方案足够好,不应传播到接近生产的任何地方。 omiserver.log 将包含所有执行的脚本及其 std 和 err 输出。