我可以在 Puppet 仪表板 Web GUI 中查看“当前失败”的节点,甚至可以深入查看哪些策略出了问题。我还可以查看节点是否未报告。
有什么办法可以让我通过电子邮件收到这些失败警报吗?
答案1
Puppet 的“tagmail”报告可能会满足您的要求。请参阅官方 tagmail 文档了解更多信息。
答案2
领班电子邮件可能是获取此类报告的最佳方式。您可以将其与仪表板一起运行。
答案3
我遇到了同样的问题,我没有费力安装 Foreman,而是编写了一个快速而粗糙的 shell/cron 脚本来 curl 和 grep puppet 仪表板,并通过电子邮件发送结果。觉得发布它可能会有所帮助。当然可以清理,但目前对我来说有用。
#!/bin/bash
UNRESPURL="http://puppet/nodes/unresponsive"
ERRORURL="http://puppet/nodes/failed"
[email protected]
NUMUNRESPNODES=`curl ${UNRESPURL} 2> /dev/null | grep -Po '(?<=<a href="/nodes/unresponsive">)([^</a>]*)' | grep -v "Unresponsive"`
NUMERRORNODES=`curl ${ERRORURL} 2> /dev/null | grep -Po '(?<=<a href="/nodes/failed">)([^</\a>]*)' | grep -v "Failed"`
# Check if there are any unresponsive nodes, before emailing
if [ ${NUMUNRESPNODES} -gt 0 ]; then
# Email an alert
echo "There are ${NUMUNRESPNODES} puppet nodes that haven't reported back to the puppetmaster. Please check ${UNRESPURL} for more info." | mail -s "ALERT: ${NUMUNRESPNODES} puppet nodes are unresponsive" ${EMAIL}
fi
# Check if there are any nodes with errors, before emailing
if [ ${NUMERRORNODES} -gt 0 ]; then
# Email an alert
echo "There are ${NUMERRORNODES} puppet nodes that are reporting errors. Please check ${ERRORURL} for more info." | mail -s "ALERT: ${NUMERRORNODES} puppet nodes are reporting errors" ${EMAIL}
fi
exit 0
答案4
我正在寻找 Log>Level>err 消息,它也可以在成功运行时创建错误消息。这是由日志文件生成的,可以在仪表板中看到:
err 无法调用刷新:无法重新启动服务 [haproxy]:执行'/sbin/service haproxy restart' 返回 1: