セッション数を監視します。シェルスクリプトで実装します。
バージョンの確認
> select version();
+-----------------+
| version() |
+-----------------+
| 10.1.40-MariaDB |
+-----------------+
セッション数の上限を確認
> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
現在利用しているセッション数確認
> select count(*) from information_schema.processlist;
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
監視用のシェル作成
test.sh
# ! /usr/bin/bash
RESULT=`mysql -uroot -pkusakari -s -N < test.sql`
if [ $RESULT -ge $1 ]; then
echo "FATAL"
else
echo "NORMAL"
fi
インプット用ファイル
test.sql
select count(*) from information_schema.processlist;
実行するコマンド
$ ./test.sh 1
FATAL
$ ./test.sh 0
FATAL
$ ./test.sh 2
NORMAL
以上、よろしくお願いいたします