【发布时间】:2018-05-08 21:09:32
【问题描述】:
我正在使用Monit 来监控一个 ubuntu 服务器,并希望对 git repo 中的更改进行测试。
我读过 (here) 说“git ls-files”是最好的方法,但我不确定如何在 monit 中运行 exec 命令作为测试。他们的文档显示了在测试通过后运行 exec 命令的示例,但没有显示如何在 exec 上进行测试。
最好的方法是什么?
===========
PS - 我根据下面的@TheCodeKiller 答案找到了解决方案。这是现在运行良好的最终代码。答案实际上在文档中,但我不认为它是我的解决方案。是here。
内部监控配置(/etc/monit/monitrc):
check program changed_files with path "/path/to/git/directory/monit_alert_changed_files.sh"
if status != 0 for 3 cycles then alert
然后在那个文件里面:
#!/bin/bash
# Script to check if there are changes in the current git directory
if [[ `git --git-dir "/path/to/git/directory/.git" --work-tree "/path/to/git/directory/" ls-files -m -o --exclude-standard` ]]; then
# Changes
exit 1
else
# No changes
exit 0
fi
【问题讨论】:
标签: git monitoring monit