send/expectでheaderを指定する
Authorization headerで送信する文字列。
$ echo -n user:pass | nkf -MB dXNlcjpwYXNzmk
monitのapacheの設定
check process apache with pidfile /var/run/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host localhost port 80
send "GET /path/to/auth/ HTTP/1.0\r\nAuthorization: Basic dXNlcjpwYXNzmk\r\n\r\n"
expect "HTTP/[0-9\.]{3} 200 .*\r\n" then restart
if 5 restarts within 5 cycles then timeout
URLに埋めこむ
書いてから気づいたけど、userとpassはURLに埋め込めるのだった。こっちのほうが楽だな。
check process apache with pidfile /var/run/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed url
http://user:pass@localhost/path/to/auth/ then restart
if 5 restarts within 5 cycles then timeout