需要有关用于电子邮件警报的 bash 脚本的想法

问题描述 投票:0回答:0

我是新的 bash 脚本。 我已经配置了 aurora mysql 服务器的 proxysql 服务器。如果任何服务器状态更改为 shunned,我需要通过 cron 作业使用 bash 脚本设置电子邮件警报。如何实现这一点?

SELECT * FROM mysql_servers;
+--------------+----------------------------------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+
| hostgroup_id | hostname                               | port | gtid_port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment     |
+--------------+----------------------------------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+
| 100          | globaldbeast01-instance-1.adelphic.net | 3306 | 0         | ONLINE | 1000   | 0           | 1500            | 0                   | 0       | 0              | ReadWrite01 |
| 200          | globaldbeast02-instance-2.adelphic.net | 3306 | 0         | ONLINE | 300    | 0           | 1000            | 0                   | 0       | 0              | ReadOnly02  |
| 200          | globaldbeast03-instance-3.adelphic.net | 3306 | 0         | ONLINE | 3000   | 0           | 1000            | 0                   | 0       | 0              | ReadOnly01  |
| 300          | globaldbeast01-instance-1.adelphic.net | 3306 | 0         | ONLINE | 1000   | 0           | 1000            | 0                   | 0       | 0              | ReadWrite01 |
| 400          | globaldbeast02-instance-2.adelphic.net | 3306 | 0         | ONLINE | 1000   | 0           | 1000            | 1500                | 0       | 0              | ReadOnly02  |
| 400          | globaldbeast03-instance-3.adelphic.net | 3306 | 0         | ONLINE | 1000   | 0           | 1000            | 1500                | 0       | 0              | ReadOnly01  |
+--------------+----------------------------------------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+
6 rows in set (0.00 sec)

如果任何服务器状态更改为已回避而不是在线,则需要将警报发送到电子邮件并包含详细信息。 是否可以使用脚本通过 cron 作业? 感谢您的帮助。

bash database-administration amazon-aurora proxy-server mysql-cluster
© www.soinside.com 2019 - 2024. All rights reserved.