# 使用 Node-Red 和 Telegram 监控 Discourse 状态

**URL:** https://meta.discourse.org/t/use-node-red-and-telegram-to-monitor-discourse-status/157229
**Category:** Developers
**Tags:** how-to
**Created:** [2020年七月9日 07:17 UTC](https://meta.discourse.org/t/use-node-red-and-telegram-to-monitor-discourse-status/157229 "2020-07-09T07:17:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [2020年七月9日 07:17 UTC](https://meta.discourse.org/t/use-node-red-and-telegram-to-monitor-discourse-status/157229/1 "2020-07-09T07:17:02Z")

</div>

> _请注意，这与使用 Discourse Telegram 通知插件发送 Discourse 应用通知是不同的应用程序。此 Node-Red 应用程序用于监控服务器、Docker 以及 Discourse 应用本身。_

像许多忙碌的系统管理员一样，我们在外出时觉得从手机监控生产应用非常有用。

我们使用 Telegram 和 Node-Red（NR）来完成这项任务。例如，我们目前的一些 Discourse NR 任务包括：

1. Node-Red 每分钟对为此目的创建的类别发起 HTTPS GET 请求，并在检测到 Discourse 宕机（以及重新上线且无震荡）时向我们的 Telegram 机器人发送警报。

2. 我们的基础 Telegram 机器人 `UNIXForumBot` 提供多项检查功能，包括：

- 手动检查 Discourse 是否正在运行。
- 快速显示反向代理正在使用哪个 Discourse 容器。
- 检查服务器运行时间。
- 检查磁盘使用率。
- Ping 同一服务器上的其他 LAMP 应用。

> Telegram 截图示例：

 ![IMG_9631](https://global.discourse-cdn.com/meta/original/3X/3/b/3b0c191e3b5b32d85ef6003e733f00eda047ebb9.png) ![IMG_9630](https://global.discourse-cdn.com/meta/original/3X/5/4/545ae38d2bb3c25d7a2731d4fcab34c3d5239765.png) ![IMG_9629](https://global.discourse-cdn.com/meta/original/3X/b/4/b4d0e9211383d2001fa81d4bb95a405999145a28.png) ![IMG_9628](https://global.discourse-cdn.com/meta/original/3X/f/8/f8e6a52170c498eefc94e44959fab776676b37b0.png)

> **我们的设置与背景信息**
>
> > 背景信息
> 
> 我们检查哪个 Discourse 容器正在运行的原因是：如果出现问题，或者我仅仅想要升级或进行修改，我们总希望在登录服务器之前快速了解哪个容器正在运行 Discourse。
> 
> 我们始终在反向代理后面运行 Discourse。由于同一服务器上运行着许多其他 Web 应用（与 Discourse Docker 应用一起运行的 LAMP 应用），我们按以下方式运行 Discourse：
> 
> - 将 Discourse 数据容器与应用容器分离。
> - Discourse 应用容器仅向主机（即反向代理）暴露一个 Unix 域套接字。
> 
> 这意味着，对于不熟悉此设置的用户来说，当新版本发布时，我们可以构建 Discourse，并通过在反向代理配置中指定不同的 Unix 域套接字，实现零停机时间切换到该新版本。
> 
> 如果最新的测试版出现问题，也没关系，我们可以快速轻松地回退到运行早期 Discourse 版本的另一个容器。效果完美。

> 我们用于监控 Discourse 的 Telegram 机器人的 Node-Red 流程图

 ![Screen Shot 2020-07-09 at 1.22.34 PM](https://global.discourse-cdn.com/meta/original/3X/0/0/007763e6cafad95b0d62e6a819930f988ec17dc2.jpeg)

对于任何希望使用 Telegram 和 NR 监控其 Discourse 应用的用户，我已将此应用的 Node-Red 节点公开。您可以根据需要进行自定义：

> **[UnixForumBot Node-Red Diagram and Nodes](https://community.unix.com/t/unixforumbot-node-red-diagram-and-nodes/379154)**
>
> UnixForumBot Version 0.5 Diagram Node-Red Nodes \[ { "id": "5dddf6dd.c8bf48", "type": "tab", "label": "ForumBot", "disabled": false, "info": "" }, { "id": "286f517c.4abebe", "type": "telegram receiver", ...

未来，我们计划在 Telegram 应用中扩展 Docker 和 Discourse 的监控功能。

另请参阅：

> **[Checking Our Discourse Community Status with Telegram Bot via Node-Red](https://community.unix.com/t/checking-our-discourse-community-status-with-telegram-bot-via-node-red/379153)**
>
> Dear Everyone, I have updated our Telegram bot to check the status of this Discourse community. You can subscribe to this Telegram bot: UnixForumBot So far, I have added two Discourse related functions: /comm #checks the status of our...

希望其他对监控生产服务器和 Discourse 应用感兴趣的管理员觉得这个简短的主题有用。
