问题描述
我发现调试监视是一个主要的痛苦。 Monit的shell环境基本上没有任何东西(没有路径或其他环境变量)。另外,没有可以找到的日志文件。问题是,如果monit脚本中的start或stop命令失败,很难辨别错了。通常情况下,它不像在shell上运行命令那么简单,因为shell环境与monit shell环境不同。
人们使用的是什么技术调试monit配置?
例如,我将很高兴有一个monit shell,来测试我的脚本,或者一个日志文件,看看出了什么问题。 p>
我有同样的问题。使用monit的详细的命令行选项有助于一些,但是我发现最好的方法是创建一个与monit环境相似的环境,并从那里运行start / stop程序。
#monit以超级用户身份运行
$ sudo su
#-i选项忽略继承的环境
#此PATH是默认用的monit
$ env -i PATH = / bin:/ usr / bin:/ sbin:/ usr / sbin / bin / sh
#尝试运行启动/停止程序这里
$
我发现最常见的问题是环境变量相关(特别是 PATH
)或权限相关。你应该记住,monit通常以root身份运行。
另外,如果您在monit配置中使用作为uid myusername
那么在进行测试之前,您应该更改为用户 myusername
。
我希望有帮助。
I find debugging monit to be a major pain. Monit's shell environment basically has nothing in it (no paths or other environment variables). Also, there are no log file that I can find.
The problem is, if the start or stop command in the monit script fails, it is difficult to discern what is wrong with it. Often times it is not as simple as just running the command on the shell because the shell environment is different from the monit shell environment.
What are some techniques that people use to debug monit configurations?
For example, I would be happy to have a monit shell, to test my scripts in, or a log file to see what went wrong.
I've had the same problem. Using monit's verbose command-line option helps a bit, but I found the best way was to create an environment as similar as possible to the monit environment and run the start/stop program from there.
# monit runs as superuser
$ sudo su
# the -i option ignores the inherited environment
# this PATH is what monit supplies by default
$ env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh
# try running start/stop program here
$
I've found the most common problems are environment variable related (especially PATH
) or permission-related. You should remember that monit usually runs as root.
Also if you use as uid myusername
in your monit config, then you should change to user myusername
before carrying out the test.
I hope that helps.
这篇关于调查监狱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!