如何解决当 SSH/RDP 服务未在 GCE VM 中运行时如何通知/警报
GCP Operation 的套件没有预先构建的指标来监控 GCE 虚拟机中运行的 SSH (Linux) / RDP (Windows) 服务。我也试图在 GCP Logging 中找到它,但找不到关于在操作系统中运行的服务的任何日志。
有没有其他方法可以监控 GCE 虚拟机中 SSH/RDP 服务的运行状况?并在未处于运行状态时转发警报。
解决方法
我更新了我的答案:
您可以使用 Cloud Logging 来监控 SSH 守护程序的状态及其在您的虚拟机实例上的连接:
- 安装将日志发送到 Cloud Logging(以前称为 Stackdriver)的 logging agent:
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
sudo bash add-logging-agent-repo.sh
sudo apt-get update
sudo apt-get install google-fluentd
sudo apt-get install -y google-fluentd-catch-all-config
-
edit logging agent configuration 位于
/etc/google-fluentd/config.d/syslog.conf
,通过添加以下内容从auth.log
收集条目:
<source>
type tail
# Parse the timestamp,but still collect the entire line as 'message'
format /^(?<message>(?<time>[^ ]*\s*[^ ]* [^ ]*) .*)$/
path /var/log/auth.log
pos_file /var/lib/google-fluentd/pos/auth.log.pos
read_from_head false
tag auth
</source>
- 重启
google-fluentd
以应用更新的配置:
sudo service google-fluentd restart
- 转到
Cloud Console
->Logging
->Logs Explorer
并查找与 SSH 守护程序相关的事件:
- configure alerts;此外,看看第 3 方示例 here 和 here。
您可以使用相同的方法在 Windows 上检查和监控 RDP:
-
edit logging agent configuration 位于
C:\Program Files (x86)\Stackdriver\LoggingAgent\fluent.conf
-
重启日志代理
-
转到
Cloud Console
->Logging
->Logs Explorer
并查找与 RDP 服务相关的事件。
编辑
为了使事件不自动关闭,您可以创建两个指标:
第一个记录终止信号,第二个记录 SSH 启动。
然后,您应该创建一个警报,当第一个高于零且第二个低于 1 时触发该警报。
这样,事件会一直持续到 sshd 再次启动。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。