如何检查网页是否包含文本“连接数据库错误”,如果页面中存在该文本则重新启动数据库?
这是我目前拥有的但它不起作用:
check host website.com with address website.com
group database
start program = "/usr/bin/service mysql start"
stop program = "/usr/bin/service mysql stop"
if url http://website.com content == "Error connecting to database" then restart
答案1
来自文档这里,failed 是必需的关键字(事实上,几乎每个 monit 测试都是这种形式if failed
)。您必须将测试写为失败,这才是正常的:
if failed (url http://www.example.com and content != "Error connecting to database")
因此,失败意味着无法检索页面或页面内容与正则表达式“连接数据库时出错”匹配