monit」カテゴリーアーカイブ




monitを利用して色々なパターンの外部URLの監視、http監視を設定してみる




投稿日:

monitは基本的にサーバのリソースやプロセス監視で利用されることが多いのですが、外部のURL監視にも利用できます。今回はそのパターンをいくつか忘却録としてメモしておきます。(他にも使い易いパターンが有れば是非教えてください。)


1, シンプルなURL監視
[html]
check host xxx.example.com with address xxx.example.com
if failed url http://xxx.example.com/
then alert
[/html]


2, basic認証のついたURLの監視
[html]
check host xxx.example.com with address xxx.example.com
if failed url http://username:password@xxx.example.com/
then alert
[/html]


3, URLのコンテンツのチェックも実施
[html]
check host xxx.example.com with address xxx.example.com
if failed url http://xxx.example.com/
and content = "contents"
then alert
[/html]


4, headerを利用したURL監視
[html]
check host xxx.example.com with address xxx.example.com
if failed port 80
send "GET / HTTP/1.0\r\nHost: xxx.example.com\r\n\r\n"
expect "HTTP/[0-9\.]{3} 200 .*\r\n"
then alert
[/html]


5, headerを利用したURL監視(ユーザエージェント定義)
[html]
check host xxx.example.com with address xxx.example.com
if failed port 80
send "GET / HTTP/1.0\r\nUser-Agent: iPhone monit/5.5\r\nHost: xxx.example.com\r\n\r\n"
expect "HTTP/[0-9\.]{3} 200 .*\r\n"
then alert
[/html]


6, headerを利用したURL監視(cookie定義)
[html]
check host xxx.example.com with address xxx.example.com
if failed port 80
send "GET / HTTP/1.0\r\nCookie: csrftoken=nj1bI3CnMCaiNv4beqo8ZaCfAQQvpgLH\r\nHost: xxx.example.com\r\n\r\n"
expect "HTTP/[0-9\.]{3} 200 .*\r\n"
then alert
[/html]